Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index 1bace44..9426f1f 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 _0x63f1=['nolimit','order','sort','where','pick','filter','merge','includeAll','include','findAll','rows','catch','params','options','find','create','body','update','eml-format','rimraf','fast-json-patch','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','index','map','DeskField','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length'];(function(_0x64b210,_0x301877){var _0x232a2b=function(_0x1056fd){while(--_0x1056fd){_0x64b210['push'](_0x64b210['shift']());}};_0x232a2b(++_0x301877);}(_0x63f1,0x1da));var _0x163f=function(_0x599f41,_0x4db732){_0x599f41=_0x599f41-0x0;var _0x2e4d58=_0x63f1[_0x599f41];return _0x2e4d58;};'use strict';var emlformat=require(_0x163f('0x0'));var rimraf=require(_0x163f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x163f('0x2'));var rp=require('request-promise');var moment=require(_0x163f('0x3'));var BPromise=require(_0x163f('0x4'));var Mustache=require('mustache');var util=require(_0x163f('0x5'));var path=require(_0x163f('0x6'));var sox=require(_0x163f('0x7'));var csv=require(_0x163f('0x8'));var ejs=require(_0x163f('0x9'));var fs=require('fs');var fs_extra=require(_0x163f('0xa'));var _=require(_0x163f('0xb'));var squel=require(_0x163f('0xc'));var crypto=require('crypto');var jsforce=require(_0x163f('0xd'));var deskjs=require(_0x163f('0xe'));var toCsv=require(_0x163f('0x8'));var querystring=require(_0x163f('0xf'));var Papa=require('papaparse');var Redis=require(_0x163f('0x10'));var authService=require(_0x163f('0x11'));var qs=require(_0x163f('0x12'));var as=require(_0x163f('0x13'));var hardwareService=require(_0x163f('0x14'));var logger=require('../../config/logger')(_0x163f('0x15'));var utils=require(_0x163f('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x163f('0x17'));var db=require(_0x163f('0x18'))['db'];function respondWithStatusCode(_0x331cde,_0xe8fc1c){_0xe8fc1c=_0xe8fc1c||0xcc;return function(_0x4bd756){if(_0x4bd756){return _0x331cde[_0x163f('0x19')](_0xe8fc1c);}return _0x331cde[_0x163f('0x1a')](_0xe8fc1c)[_0x163f('0x1b')]();};}function respondWithResult(_0x26635d,_0x151fa8){_0x151fa8=_0x151fa8||0xc8;return function(_0x42a2e0){if(_0x42a2e0){return _0x26635d[_0x163f('0x1a')](_0x151fa8)[_0x163f('0x1c')](_0x42a2e0);}};}function respondWithFilteredResult(_0x1603af,_0x57da99){return function(_0x2a9811){if(_0x2a9811){var _0x261d7b=typeof _0x57da99[_0x163f('0x1d')]===_0x163f('0x1e')&&typeof _0x57da99[_0x163f('0x1f')]==='undefined';var _0x37dacc=_0x2a9811[_0x163f('0x20')];var _0x558191=_0x261d7b?0x0:_0x57da99[_0x163f('0x1d')];var _0x44e0e3=_0x261d7b?_0x2a9811[_0x163f('0x20')]:_0x57da99[_0x163f('0x1d')]+_0x57da99[_0x163f('0x1f')];var _0x352b6b;if(_0x44e0e3>=_0x37dacc){_0x44e0e3=_0x37dacc;_0x352b6b=0xc8;}else{_0x352b6b=0xce;}_0x1603af['status'](_0x352b6b);return _0x1603af[_0x163f('0x21')](_0x163f('0x22'),_0x558191+'-'+_0x44e0e3+'/'+_0x37dacc)['json'](_0x2a9811);}return null;};}function patchUpdates(_0x1d8a9d){return function(_0x4b54a2){try{jsonpatch[_0x163f('0x23')](_0x4b54a2,_0x1d8a9d,!![]);}catch(_0x16fece){return BPromise[_0x163f('0x24')](_0x16fece);}return _0x4b54a2[_0x163f('0x25')]();};}function saveUpdates(_0x18f1a2,_0x169d66){return function(_0x30da66){if(_0x30da66){return _0x30da66['update'](_0x18f1a2)[_0x163f('0x26')](function(_0x55a1ff){return _0x55a1ff;});}return null;};}function removeEntity(_0x49b838,_0x371c22){return function(_0x4becf8){if(_0x4becf8){return _0x4becf8[_0x163f('0x27')]()[_0x163f('0x26')](function(){_0x49b838[_0x163f('0x1a')](0xcc)[_0x163f('0x1b')]();});}};}function handleEntityNotFound(_0x380124,_0x3b479d){return function(_0x9f17a0){if(!_0x9f17a0){_0x380124[_0x163f('0x19')](0x194);}return _0x9f17a0;};}function handleError(_0x4512a2,_0x498b5c){_0x498b5c=_0x498b5c||0x1f4;return function(_0xf03f21){logger[_0x163f('0x28')](_0xf03f21[_0x163f('0x29')]);if(_0xf03f21['name']){delete _0xf03f21[_0x163f('0x2a')];}_0x4512a2[_0x163f('0x1a')](_0x498b5c)[_0x163f('0x2b')](_0xf03f21);};}exports[_0x163f('0x2c')]=function(_0x1f723d,_0x24268d){var _0x16b3e2={},_0x45e7f9={},_0x58b932={'count':0x0,'rows':[]};var _0x5b11d5=_[_0x163f('0x2d')](db[_0x163f('0x2e')][_0x163f('0x2f')],function(_0xe89ef7){return{'name':_0xe89ef7['fieldName'],'type':_0xe89ef7[_0x163f('0x30')][_0x163f('0x31')]};});_0x45e7f9[_0x163f('0x32')]=_[_0x163f('0x2d')](_0x5b11d5,_0x163f('0x2a'));_0x45e7f9[_0x163f('0x33')]=_[_0x163f('0x34')](_0x1f723d['query']);_0x45e7f9[_0x163f('0x35')]=_[_0x163f('0x36')](_0x45e7f9['model'],_0x45e7f9['query']);_0x16b3e2[_0x163f('0x37')]=_[_0x163f('0x36')](_0x45e7f9[_0x163f('0x32')],qs[_0x163f('0x38')](_0x1f723d['query'][_0x163f('0x38')]));_0x16b3e2[_0x163f('0x37')]=_0x16b3e2[_0x163f('0x37')][_0x163f('0x39')]?_0x16b3e2[_0x163f('0x37')]:_0x45e7f9['model'];if(!_0x1f723d[_0x163f('0x33')]['hasOwnProperty'](_0x163f('0x3a'))){_0x16b3e2[_0x163f('0x1f')]=qs['limit'](_0x1f723d[_0x163f('0x33')][_0x163f('0x1f')]);_0x16b3e2['offset']=qs[_0x163f('0x1d')](_0x1f723d['query']['offset']);}_0x16b3e2[_0x163f('0x3b')]=qs[_0x163f('0x3c')](_0x1f723d[_0x163f('0x33')][_0x163f('0x3c')]);_0x16b3e2[_0x163f('0x3d')]=qs[_0x163f('0x35')](_[_0x163f('0x3e')](_0x1f723d[_0x163f('0x33')],_0x45e7f9[_0x163f('0x35')]),_0x5b11d5);if(_0x1f723d[_0x163f('0x33')][_0x163f('0x3f')]){_0x16b3e2['where']=_[_0x163f('0x40')](_0x16b3e2['where'],{'$or':_[_0x163f('0x2d')](_0x5b11d5,function(_0x39c923){if(_0x39c923['type']!=='VIRTUAL'){var _0x46db8a={};_0x46db8a[_0x39c923['name']]={'$like':'%'+_0x1f723d['query'][_0x163f('0x3f')]+'%'};return _0x46db8a;}})});}_0x16b3e2=_[_0x163f('0x40')]({},_0x16b3e2,_0x1f723d['options']);var _0x234416={'where':_0x16b3e2[_0x163f('0x3d')]};return db['DeskField']['count'](_0x234416)[_0x163f('0x26')](function(_0x34bbd8){_0x58b932['count']=_0x34bbd8;if(_0x1f723d['query'][_0x163f('0x41')]){_0x16b3e2[_0x163f('0x42')]=[{'all':!![]}];}return db[_0x163f('0x2e')][_0x163f('0x43')](_0x16b3e2);})[_0x163f('0x26')](function(_0x1a44bd){_0x58b932[_0x163f('0x44')]=_0x1a44bd;return _0x58b932;})[_0x163f('0x26')](respondWithFilteredResult(_0x24268d,_0x16b3e2))[_0x163f('0x45')](handleError(_0x24268d,null));};exports['show']=function(_0x5b6125,_0x2777d6){var _0xe8c203={'raw':!![],'where':{'id':_0x5b6125[_0x163f('0x46')]['id']}},_0x51337e={};_0x51337e[_0x163f('0x32')]=_[_0x163f('0x34')](db[_0x163f('0x2e')]['rawAttributes']);_0x51337e[_0x163f('0x33')]=_[_0x163f('0x34')](_0x5b6125[_0x163f('0x33')]);_0x51337e[_0x163f('0x35')]=_[_0x163f('0x36')](_0x51337e['model'],_0x51337e[_0x163f('0x33')]);_0xe8c203[_0x163f('0x37')]=_['intersection'](_0x51337e[_0x163f('0x32')],qs[_0x163f('0x38')](_0x5b6125[_0x163f('0x33')][_0x163f('0x38')]));_0xe8c203[_0x163f('0x37')]=_0xe8c203[_0x163f('0x37')][_0x163f('0x39')]?_0xe8c203['attributes']:_0x51337e[_0x163f('0x32')];if(_0x5b6125[_0x163f('0x33')][_0x163f('0x41')]){_0xe8c203['include']=[{'all':!![]}];}_0xe8c203=_['merge']({},_0xe8c203,_0x5b6125[_0x163f('0x47')]);return db[_0x163f('0x2e')][_0x163f('0x48')](_0xe8c203)[_0x163f('0x26')](handleEntityNotFound(_0x2777d6,null))[_0x163f('0x26')](respondWithResult(_0x2777d6,null))[_0x163f('0x45')](handleError(_0x2777d6,null));};exports[_0x163f('0x49')]=function(_0x727841,_0x56b9ee){return db[_0x163f('0x2e')][_0x163f('0x49')](_0x727841[_0x163f('0x4a')],{})[_0x163f('0x26')](respondWithResult(_0x56b9ee,0xc9))['catch'](handleError(_0x56b9ee,null));};exports[_0x163f('0x4b')]=function(_0x291aad,_0x5db7fe){if(_0x291aad[_0x163f('0x4a')]['id']){delete _0x291aad['body']['id'];}return db[_0x163f('0x2e')]['find']({'where':{'id':_0x291aad['params']['id']}})['then'](handleEntityNotFound(_0x5db7fe,null))[_0x163f('0x26')](saveUpdates(_0x291aad[_0x163f('0x4a')],null))['then'](respondWithResult(_0x5db7fe,null))[_0x163f('0x45')](handleError(_0x5db7fe,null));};exports[_0x163f('0x27')]=function(_0x3b0db7,_0x251c78){return db['DeskField'][_0x163f('0x48')]({'where':{'id':_0x3b0db7[_0x163f('0x46')]['id']}})['then'](handleEntityNotFound(_0x251c78,null))[_0x163f('0x26')](removeEntity(_0x251c78,null))[_0x163f('0x45')](handleError(_0x251c78,null));};
\ No newline at end of file