Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index 1bace44..6ed1ebf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa142=['include','rows','show','catch','create','body','find','params','html-pdf','eml-format','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','count','offset','limit','set','Content-Range','save','then','destroy','error','stack','name','index','map','DeskField','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','options','includeAll'];(function(_0x7b301,_0x2276d9){var _0x143f22=function(_0x14f9c4){while(--_0x14f9c4){_0x7b301['push'](_0x7b301['shift']());}};_0x143f22(++_0x2276d9);}(_0xa142,0x11c));var _0x2a14=function(_0x1d1918,_0x9b060b){_0x1d1918=_0x1d1918-0x0;var _0x40242b=_0xa142[_0x1d1918];return _0x40242b;};'use strict';var pdf=require(_0x2a14('0x0'));var emlformat=require(_0x2a14('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x2a14('0x2'));var BPromise=require(_0x2a14('0x3'));var Mustache=require(_0x2a14('0x4'));var util=require(_0x2a14('0x5'));var path=require(_0x2a14('0x6'));var sox=require(_0x2a14('0x7'));var csv=require(_0x2a14('0x8'));var ejs=require(_0x2a14('0x9'));var fs=require('fs');var _=require(_0x2a14('0xa'));var squel=require(_0x2a14('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x2a14('0xc'));var toCsv=require('to-csv');var querystring=require(_0x2a14('0xd'));var Papa=require(_0x2a14('0xe'));var Redis=require(_0x2a14('0xf'));var authService=require(_0x2a14('0x10'));var qs=require(_0x2a14('0x11'));var as=require(_0x2a14('0x12'));var hardwareService=require(_0x2a14('0x13'));var logger=require('../../config/logger')(_0x2a14('0x14'));var utils=require(_0x2a14('0x15'));var config=require(_0x2a14('0x16'));var licenseUtil=require(_0x2a14('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xca5c26,_0x4716b3){_0x4716b3=_0x4716b3||0xcc;return function(_0x5d1a29){if(_0x5d1a29){return _0xca5c26[_0x2a14('0x18')](_0x4716b3);}return _0xca5c26['status'](_0x4716b3)[_0x2a14('0x19')]();};}function respondWithResult(_0x416850,_0x36080f){_0x36080f=_0x36080f||0xc8;return function(_0x4e985d){if(_0x4e985d){return _0x416850[_0x2a14('0x1a')](_0x36080f)[_0x2a14('0x1b')](_0x4e985d);}};}function respondWithFilteredResult(_0x170bb5,_0x36e10b){return function(_0x262e3a){if(_0x262e3a){var _0x200409=_0x262e3a[_0x2a14('0x1c')],_0x34eca6=_0x36e10b[_0x2a14('0x1d')],_0x2be69e=_0x36e10b[_0x2a14('0x1d')]+_0x36e10b[_0x2a14('0x1e')],_0x13f101;if(_0x2be69e>=_0x200409){_0x2be69e=_0x200409;_0x13f101=0xc8;}else{_0x13f101=0xce;}_0x170bb5['status'](_0x13f101);return _0x170bb5[_0x2a14('0x1f')](_0x2a14('0x20'),_0x34eca6+'-'+_0x2be69e+'/'+_0x200409)[_0x2a14('0x1b')](_0x262e3a);}return null;};}function patchUpdates(_0x48ae87){return function(_0x364614){try{jsonpatch['apply'](_0x364614,_0x48ae87,!![]);}catch(_0x1cf4ea){return BPromise['reject'](_0x1cf4ea);}return _0x364614[_0x2a14('0x21')]();};}function saveUpdates(_0x547f65,_0x1ef7e7){return function(_0x268a27){if(_0x268a27){return _0x268a27['update'](_0x547f65)[_0x2a14('0x22')](function(_0x49bca1){return _0x49bca1;});}return null;};}function removeEntity(_0x135563,_0x1b54e3){return function(_0x166cf8){if(_0x166cf8){return _0x166cf8[_0x2a14('0x23')]()[_0x2a14('0x22')](function(){_0x135563[_0x2a14('0x1a')](0xcc)[_0x2a14('0x19')]();});}};}function handleEntityNotFound(_0xbc289e,_0x128e15){return function(_0x51efb5){if(!_0x51efb5){_0xbc289e['sendStatus'](0x194);}return _0x51efb5;};}function handleError(_0x13da6b,_0x1a332b){_0x1a332b=_0x1a332b||0x1f4;return function(_0x1fc334){logger[_0x2a14('0x24')](_0x1fc334[_0x2a14('0x25')]);if(_0x1fc334['name']){delete _0x1fc334[_0x2a14('0x26')];}_0x13da6b[_0x2a14('0x1a')](_0x1a332b)['send'](_0x1fc334);};}exports[_0x2a14('0x27')]=function(_0x542f8c,_0x29623d){var _0x1b47d6={},_0x4ccc95={},_0x596af5={'count':0x0,'rows':[]};var _0x4a2018=_[_0x2a14('0x28')](db[_0x2a14('0x29')]['rawAttributes'],function(_0x3f7623){return{'name':_0x3f7623[_0x2a14('0x2a')],'type':_0x3f7623[_0x2a14('0x2b')]['key']};});_0x4ccc95[_0x2a14('0x2c')]=_[_0x2a14('0x28')](_0x4a2018,_0x2a14('0x26'));_0x4ccc95[_0x2a14('0x2d')]=_[_0x2a14('0x2e')](_0x542f8c[_0x2a14('0x2d')]);_0x4ccc95[_0x2a14('0x2f')]=_[_0x2a14('0x30')](_0x4ccc95[_0x2a14('0x2c')],_0x4ccc95[_0x2a14('0x2d')]);_0x1b47d6[_0x2a14('0x31')]=_[_0x2a14('0x30')](_0x4ccc95[_0x2a14('0x2c')],qs[_0x2a14('0x32')](_0x542f8c[_0x2a14('0x2d')][_0x2a14('0x32')]));_0x1b47d6[_0x2a14('0x31')]=_0x1b47d6[_0x2a14('0x31')][_0x2a14('0x33')]?_0x1b47d6[_0x2a14('0x31')]:_0x4ccc95[_0x2a14('0x2c')];if(!_0x542f8c['query'][_0x2a14('0x34')](_0x2a14('0x35'))){_0x1b47d6[_0x2a14('0x1e')]=qs[_0x2a14('0x1e')](_0x542f8c[_0x2a14('0x2d')][_0x2a14('0x1e')]);_0x1b47d6['offset']=qs[_0x2a14('0x1d')](_0x542f8c['query']['offset']);}_0x1b47d6[_0x2a14('0x36')]=qs['sort'](_0x542f8c[_0x2a14('0x2d')]['sort']);_0x1b47d6[_0x2a14('0x37')]=qs[_0x2a14('0x2f')](_[_0x2a14('0x38')](_0x542f8c[_0x2a14('0x2d')],_0x4ccc95[_0x2a14('0x2f')]),_0x4a2018);if(_0x542f8c[_0x2a14('0x2d')][_0x2a14('0x39')]){_0x1b47d6[_0x2a14('0x37')]=_[_0x2a14('0x3a')](_0x1b47d6[_0x2a14('0x37')],{'$or':_[_0x2a14('0x28')](_0x4a2018,function(_0x5393c7){if(_0x5393c7[_0x2a14('0x2b')]!=='VIRTUAL'){var _0x1ce261={};_0x1ce261[_0x5393c7['name']]={'$like':'%'+_0x542f8c['query'][_0x2a14('0x39')]+'%'};return _0x1ce261;}})});}_0x1b47d6=_[_0x2a14('0x3a')]({},_0x1b47d6,_0x542f8c[_0x2a14('0x3b')]);var _0x5480a6={'where':_0x1b47d6[_0x2a14('0x37')]};return db[_0x2a14('0x29')][_0x2a14('0x1c')](_0x5480a6)[_0x2a14('0x22')](function(_0x505fed){_0x596af5[_0x2a14('0x1c')]=_0x505fed;if(_0x542f8c[_0x2a14('0x2d')][_0x2a14('0x3c')]){_0x1b47d6[_0x2a14('0x3d')]=[{'all':!![]}];}return db['DeskField']['findAll'](_0x1b47d6);})['then'](function(_0x2f2aa8){_0x596af5[_0x2a14('0x3e')]=_0x2f2aa8;return _0x596af5;})[_0x2a14('0x22')](respondWithFilteredResult(_0x29623d,_0x1b47d6))['catch'](handleError(_0x29623d,null));};exports[_0x2a14('0x3f')]=function(_0x137331,_0x3211a8){var _0x1fdfab={'raw':!![],'where':{'id':_0x137331['params']['id']}},_0x271560={};_0x271560[_0x2a14('0x2c')]=_[_0x2a14('0x2e')](db['DeskField']['rawAttributes']);_0x271560['query']=_[_0x2a14('0x2e')](_0x137331['query']);_0x271560[_0x2a14('0x2f')]=_['intersection'](_0x271560[_0x2a14('0x2c')],_0x271560[_0x2a14('0x2d')]);_0x1fdfab[_0x2a14('0x31')]=_['intersection'](_0x271560['model'],qs['fields'](_0x137331['query'][_0x2a14('0x32')]));_0x1fdfab[_0x2a14('0x31')]=_0x1fdfab[_0x2a14('0x31')][_0x2a14('0x33')]?_0x1fdfab[_0x2a14('0x31')]:_0x271560[_0x2a14('0x2c')];if(_0x137331['query'][_0x2a14('0x3c')]){_0x1fdfab[_0x2a14('0x3d')]=[{'all':!![]}];}_0x1fdfab=_[_0x2a14('0x3a')]({},_0x1fdfab,_0x137331[_0x2a14('0x3b')]);return db[_0x2a14('0x29')]['find'](_0x1fdfab)[_0x2a14('0x22')](handleEntityNotFound(_0x3211a8,null))['then'](respondWithResult(_0x3211a8,null))[_0x2a14('0x40')](handleError(_0x3211a8,null));};exports[_0x2a14('0x41')]=function(_0x22fc39,_0x3088aa){return db['DeskField'][_0x2a14('0x41')](_0x22fc39[_0x2a14('0x42')],{})[_0x2a14('0x22')](respondWithResult(_0x3088aa,0xc9))['catch'](handleError(_0x3088aa,null));};exports['update']=function(_0xd4c33,_0x7d1c65){if(_0xd4c33[_0x2a14('0x42')]['id']){delete _0xd4c33[_0x2a14('0x42')]['id'];}return db[_0x2a14('0x29')][_0x2a14('0x43')]({'where':{'id':_0xd4c33['params']['id']}})['then'](handleEntityNotFound(_0x7d1c65,null))[_0x2a14('0x22')](saveUpdates(_0xd4c33['body'],null))[_0x2a14('0x22')](respondWithResult(_0x7d1c65,null))['catch'](handleError(_0x7d1c65,null));};exports['destroy']=function(_0x1cea1c,_0xc2b34b){return db[_0x2a14('0x29')][_0x2a14('0x43')]({'where':{'id':_0x1cea1c[_0x2a14('0x44')]['id']}})['then'](handleEntityNotFound(_0xc2b34b,null))[_0x2a14('0x22')](removeEntity(_0xc2b34b,null))[_0x2a14('0x40')](handleError(_0xc2b34b,null));};
\ No newline at end of file
+var _0xf130=['name','index','DeskField','rawAttributes','type','key','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','map','VIRTUAL','options','includeAll','include','findAll','catch','show','params','create','body','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','end','stack'];(function(_0x2a6b84,_0xadf951){var _0x9ce60=function(_0x5c31f9){while(--_0x5c31f9){_0x2a6b84['push'](_0x2a6b84['shift']());}};_0x9ce60(++_0xadf951);}(_0xf130,0x149));var _0x0f13=function(_0x3cd330,_0x5ca015){_0x3cd330=_0x3cd330-0x0;var _0x6ec1b3=_0xf130[_0x3cd330];return _0x6ec1b3;};'use strict';var emlformat=require(_0x0f13('0x0'));var rimraf=require(_0x0f13('0x1'));var zipdir=require(_0x0f13('0x2'));var jsonpatch=require(_0x0f13('0x3'));var rp=require(_0x0f13('0x4'));var moment=require(_0x0f13('0x5'));var BPromise=require(_0x0f13('0x6'));var Mustache=require(_0x0f13('0x7'));var util=require('util');var path=require(_0x0f13('0x8'));var sox=require(_0x0f13('0x9'));var csv=require(_0x0f13('0xa'));var ejs=require(_0x0f13('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0f13('0xc'));var squel=require(_0x0f13('0xd'));var crypto=require(_0x0f13('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x0f13('0xf'));var toCsv=require(_0x0f13('0xa'));var querystring=require(_0x0f13('0x10'));var Papa=require(_0x0f13('0x11'));var Redis=require(_0x0f13('0x12'));var authService=require(_0x0f13('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0f13('0x14'));var logger=require('../../config/logger')(_0x0f13('0x15'));var utils=require(_0x0f13('0x16'));var config=require(_0x0f13('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x0f13('0x18'))['db'];function respondWithStatusCode(_0x216bb7,_0x3e7de8){_0x3e7de8=_0x3e7de8||0xcc;return function(_0x2ad79e){if(_0x2ad79e){return _0x216bb7[_0x0f13('0x19')](_0x3e7de8);}return _0x216bb7[_0x0f13('0x1a')](_0x3e7de8)['end']();};}function respondWithResult(_0x273e5f,_0x404631){_0x404631=_0x404631||0xc8;return function(_0x50f626){if(_0x50f626){return _0x273e5f[_0x0f13('0x1a')](_0x404631)[_0x0f13('0x1b')](_0x50f626);}};}function respondWithFilteredResult(_0x36c09e,_0xe171cd){return function(_0x187568){if(_0x187568){var _0x308893=typeof _0xe171cd[_0x0f13('0x1c')]===_0x0f13('0x1d')&&typeof _0xe171cd['limit']===_0x0f13('0x1d');var _0x2b4f43=_0x187568['count'];var _0x467e84=_0x308893?0x0:_0xe171cd['offset'];var _0xb8cb0f=_0x308893?_0x187568[_0x0f13('0x1e')]:_0xe171cd[_0x0f13('0x1c')]+_0xe171cd[_0x0f13('0x1f')];var _0x4c544e;if(_0xb8cb0f>=_0x2b4f43){_0xb8cb0f=_0x2b4f43;_0x4c544e=0xc8;}else{_0x4c544e=0xce;}_0x36c09e['status'](_0x4c544e);return _0x36c09e[_0x0f13('0x20')](_0x0f13('0x21'),_0x467e84+'-'+_0xb8cb0f+'/'+_0x2b4f43)[_0x0f13('0x1b')](_0x187568);}return null;};}function patchUpdates(_0x1ad99a){return function(_0x446ad4){try{jsonpatch[_0x0f13('0x22')](_0x446ad4,_0x1ad99a,!![]);}catch(_0x14f657){return BPromise[_0x0f13('0x23')](_0x14f657);}return _0x446ad4[_0x0f13('0x24')]();};}function saveUpdates(_0x728b17,_0x5994d0){return function(_0x58dc78){if(_0x58dc78){return _0x58dc78[_0x0f13('0x25')](_0x728b17)[_0x0f13('0x26')](function(_0x860f0c){return _0x860f0c;});}return null;};}function removeEntity(_0x2e71b4,_0x36b170){return function(_0x393f0e){if(_0x393f0e){return _0x393f0e['destroy']()[_0x0f13('0x26')](function(){_0x2e71b4[_0x0f13('0x1a')](0xcc)[_0x0f13('0x27')]();});}};}function handleEntityNotFound(_0x68dffc,_0x5a6aba){return function(_0x1e71b3){if(!_0x1e71b3){_0x68dffc['sendStatus'](0x194);}return _0x1e71b3;};}function handleError(_0x1509d5,_0x4426fa){_0x4426fa=_0x4426fa||0x1f4;return function(_0x1f5c7e){logger['error'](_0x1f5c7e[_0x0f13('0x28')]);if(_0x1f5c7e[_0x0f13('0x29')]){delete _0x1f5c7e[_0x0f13('0x29')];}_0x1509d5[_0x0f13('0x1a')](_0x4426fa)['send'](_0x1f5c7e);};}exports[_0x0f13('0x2a')]=function(_0x57195c,_0x57b9ed){var _0x513eed={},_0x3dfe41={},_0x155a00={'count':0x0,'rows':[]};var _0x2592b0=_['map'](db[_0x0f13('0x2b')][_0x0f13('0x2c')],function(_0x51a83d){return{'name':_0x51a83d['fieldName'],'type':_0x51a83d[_0x0f13('0x2d')][_0x0f13('0x2e')]};});_0x3dfe41['model']=_['map'](_0x2592b0,_0x0f13('0x29'));_0x3dfe41[_0x0f13('0x2f')]=_[_0x0f13('0x30')](_0x57195c[_0x0f13('0x2f')]);_0x3dfe41['filters']=_[_0x0f13('0x31')](_0x3dfe41[_0x0f13('0x32')],_0x3dfe41['query']);_0x513eed[_0x0f13('0x33')]=_[_0x0f13('0x31')](_0x3dfe41[_0x0f13('0x32')],qs[_0x0f13('0x34')](_0x57195c[_0x0f13('0x2f')]['fields']));_0x513eed['attributes']=_0x513eed['attributes'][_0x0f13('0x35')]?_0x513eed['attributes']:_0x3dfe41[_0x0f13('0x32')];if(!_0x57195c[_0x0f13('0x2f')][_0x0f13('0x36')](_0x0f13('0x37'))){_0x513eed['limit']=qs[_0x0f13('0x1f')](_0x57195c[_0x0f13('0x2f')][_0x0f13('0x1f')]);_0x513eed['offset']=qs[_0x0f13('0x1c')](_0x57195c[_0x0f13('0x2f')][_0x0f13('0x1c')]);}_0x513eed[_0x0f13('0x38')]=qs[_0x0f13('0x39')](_0x57195c['query'][_0x0f13('0x39')]);_0x513eed[_0x0f13('0x3a')]=qs['filters'](_['pick'](_0x57195c[_0x0f13('0x2f')],_0x3dfe41[_0x0f13('0x3b')]),_0x2592b0);if(_0x57195c[_0x0f13('0x2f')][_0x0f13('0x3c')]){_0x513eed['where']=_[_0x0f13('0x3d')](_0x513eed['where'],{'$or':_[_0x0f13('0x3e')](_0x2592b0,function(_0x7e19bd){if(_0x7e19bd[_0x0f13('0x2d')]!==_0x0f13('0x3f')){var _0x3eb593={};_0x3eb593[_0x7e19bd[_0x0f13('0x29')]]={'$like':'%'+_0x57195c[_0x0f13('0x2f')]['filter']+'%'};return _0x3eb593;}})});}_0x513eed=_['merge']({},_0x513eed,_0x57195c[_0x0f13('0x40')]);var _0x54b225={'where':_0x513eed[_0x0f13('0x3a')]};return db['DeskField'][_0x0f13('0x1e')](_0x54b225)[_0x0f13('0x26')](function(_0x1f7b0d){_0x155a00[_0x0f13('0x1e')]=_0x1f7b0d;if(_0x57195c['query'][_0x0f13('0x41')]){_0x513eed[_0x0f13('0x42')]=[{'all':!![]}];}return db['DeskField'][_0x0f13('0x43')](_0x513eed);})[_0x0f13('0x26')](function(_0x5d41d6){_0x155a00['rows']=_0x5d41d6;return _0x155a00;})[_0x0f13('0x26')](respondWithFilteredResult(_0x57b9ed,_0x513eed))[_0x0f13('0x44')](handleError(_0x57b9ed,null));};exports[_0x0f13('0x45')]=function(_0x33edc6,_0x31b5ec){var _0x4a9ecf={'raw':!![],'where':{'id':_0x33edc6[_0x0f13('0x46')]['id']}},_0x2d33da={};_0x2d33da['model']=_[_0x0f13('0x30')](db[_0x0f13('0x2b')][_0x0f13('0x2c')]);_0x2d33da[_0x0f13('0x2f')]=_[_0x0f13('0x30')](_0x33edc6['query']);_0x2d33da[_0x0f13('0x3b')]=_[_0x0f13('0x31')](_0x2d33da[_0x0f13('0x32')],_0x2d33da[_0x0f13('0x2f')]);_0x4a9ecf[_0x0f13('0x33')]=_[_0x0f13('0x31')](_0x2d33da[_0x0f13('0x32')],qs[_0x0f13('0x34')](_0x33edc6[_0x0f13('0x2f')][_0x0f13('0x34')]));_0x4a9ecf[_0x0f13('0x33')]=_0x4a9ecf['attributes'][_0x0f13('0x35')]?_0x4a9ecf[_0x0f13('0x33')]:_0x2d33da[_0x0f13('0x32')];if(_0x33edc6[_0x0f13('0x2f')]['includeAll']){_0x4a9ecf[_0x0f13('0x42')]=[{'all':!![]}];}_0x4a9ecf=_[_0x0f13('0x3d')]({},_0x4a9ecf,_0x33edc6[_0x0f13('0x40')]);return db[_0x0f13('0x2b')]['find'](_0x4a9ecf)[_0x0f13('0x26')](handleEntityNotFound(_0x31b5ec,null))[_0x0f13('0x26')](respondWithResult(_0x31b5ec,null))[_0x0f13('0x44')](handleError(_0x31b5ec,null));};exports[_0x0f13('0x47')]=function(_0x54ac44,_0x3d2199){return db[_0x0f13('0x2b')]['create'](_0x54ac44['body'],{})[_0x0f13('0x26')](respondWithResult(_0x3d2199,0xc9))[_0x0f13('0x44')](handleError(_0x3d2199,null));};exports[_0x0f13('0x25')]=function(_0x1f896d,_0x317691){if(_0x1f896d[_0x0f13('0x48')]['id']){delete _0x1f896d[_0x0f13('0x48')]['id'];}return db['DeskField'][_0x0f13('0x49')]({'where':{'id':_0x1f896d[_0x0f13('0x46')]['id']}})[_0x0f13('0x26')](handleEntityNotFound(_0x317691,null))[_0x0f13('0x26')](saveUpdates(_0x1f896d[_0x0f13('0x48')],null))['then'](respondWithResult(_0x317691,null))[_0x0f13('0x44')](handleError(_0x317691,null));};exports['destroy']=function(_0x1b07c6,_0x13d020){return db[_0x0f13('0x2b')][_0x0f13('0x49')]({'where':{'id':_0x1b07c6[_0x0f13('0x46')]['id']}})[_0x0f13('0x26')](handleEntityNotFound(_0x13d020,null))[_0x0f13('0x26')](removeEntity(_0x13d020,null))['catch'](handleError(_0x13d020,null));};
\ No newline at end of file