Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index 726c9c3..4070fbb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8ec7=['bluebird','util','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','count','limit','set','apply','reject','save','update','then','destroy','stack','name','send','map','DeskField','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','pick','filter','merge','where','VIRTUAL','options','includeAll','include','findAll','show','params','rawAttributes','catch','create','body','find','rimraf','fast-json-patch','request-promise','moment'];(function(_0x532589,_0x3c90dc){var _0x33b8c2=function(_0x3f1f81){while(--_0x3f1f81){_0x532589['push'](_0x532589['shift']());}};_0x33b8c2(++_0x3c90dc);}(_0x8ec7,0x15f));var _0x78ec=function(_0x3bef2c,_0x5a86fd){_0x3bef2c=_0x3bef2c-0x0;var _0x331503=_0x8ec7[_0x3bef2c];return _0x331503;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x78ec('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x78ec('0x1'));var rp=require(_0x78ec('0x2'));var moment=require(_0x78ec('0x3'));var BPromise=require(_0x78ec('0x4'));var Mustache=require('mustache');var util=require(_0x78ec('0x5'));var path=require('path');var sox=require('sox');var csv=require(_0x78ec('0x6'));var ejs=require(_0x78ec('0x7'));var fs=require('fs');var fs_extra=require(_0x78ec('0x8'));var _=require(_0x78ec('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x78ec('0xa'));var deskjs=require(_0x78ec('0xb'));var toCsv=require('to-csv');var querystring=require(_0x78ec('0xc'));var Papa=require(_0x78ec('0xd'));var Redis=require(_0x78ec('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x78ec('0xf'));var as=require(_0x78ec('0x10'));var hardwareService=require(_0x78ec('0x11'));var logger=require(_0x78ec('0x12'))(_0x78ec('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x78ec('0x14'));var db=require(_0x78ec('0x15'))['db'];function respondWithStatusCode(_0x404e19,_0x54f6d3){_0x54f6d3=_0x54f6d3||0xcc;return function(_0x4cb8aa){if(_0x4cb8aa){return _0x404e19['sendStatus'](_0x54f6d3);}return _0x404e19[_0x78ec('0x16')](_0x54f6d3)[_0x78ec('0x17')]();};}function respondWithResult(_0x448bc7,_0x3bba29){_0x3bba29=_0x3bba29||0xc8;return function(_0x4dc7f3){if(_0x4dc7f3){return _0x448bc7[_0x78ec('0x16')](_0x3bba29)[_0x78ec('0x18')](_0x4dc7f3);}};}function respondWithFilteredResult(_0x1ff839,_0x1bd7dd){return function(_0x38dc58){if(_0x38dc58){var _0x3e02fc=typeof _0x1bd7dd[_0x78ec('0x19')]==='undefined'&&typeof _0x1bd7dd['limit']===_0x78ec('0x1a');var _0x27c2d1=_0x38dc58[_0x78ec('0x1b')];var _0x295b11=_0x3e02fc?0x0:_0x1bd7dd['offset'];var _0x29439c=_0x3e02fc?_0x38dc58[_0x78ec('0x1b')]:_0x1bd7dd[_0x78ec('0x19')]+_0x1bd7dd[_0x78ec('0x1c')];var _0x1c6cb4;if(_0x29439c>=_0x27c2d1){_0x29439c=_0x27c2d1;_0x1c6cb4=0xc8;}else{_0x1c6cb4=0xce;}_0x1ff839['status'](_0x1c6cb4);return _0x1ff839[_0x78ec('0x1d')]('Content-Range',_0x295b11+'-'+_0x29439c+'/'+_0x27c2d1)[_0x78ec('0x18')](_0x38dc58);}return null;};}function patchUpdates(_0x483dcf){return function(_0x222d46){try{jsonpatch[_0x78ec('0x1e')](_0x222d46,_0x483dcf,!![]);}catch(_0x1c811){return BPromise[_0x78ec('0x1f')](_0x1c811);}return _0x222d46[_0x78ec('0x20')]();};}function saveUpdates(_0x1be54c,_0x1cfec2){return function(_0x28a2e6){if(_0x28a2e6){return _0x28a2e6[_0x78ec('0x21')](_0x1be54c)[_0x78ec('0x22')](function(_0x3ea823){return _0x3ea823;});}return null;};}function removeEntity(_0x4213a4,_0x21f655){return function(_0x20150f){if(_0x20150f){return _0x20150f[_0x78ec('0x23')]()['then'](function(){_0x4213a4[_0x78ec('0x16')](0xcc)[_0x78ec('0x17')]();});}};}function handleEntityNotFound(_0x46918d,_0x52fad3){return function(_0xdc3cad){if(!_0xdc3cad){_0x46918d['sendStatus'](0x194);}return _0xdc3cad;};}function handleError(_0x1b4e80,_0x39eab5){_0x39eab5=_0x39eab5||0x1f4;return function(_0x49c302){logger['error'](_0x49c302[_0x78ec('0x24')]);if(_0x49c302[_0x78ec('0x25')]){delete _0x49c302[_0x78ec('0x25')];}_0x1b4e80['status'](_0x39eab5)[_0x78ec('0x26')](_0x49c302);};}exports['index']=function(_0xe56fab,_0x2fd57b){var _0x1c688c={},_0x57eabb={},_0x409c3c={'count':0x0,'rows':[]};var _0x4182d1=_[_0x78ec('0x27')](db[_0x78ec('0x28')]['rawAttributes'],function(_0x4fdfdb){return{'name':_0x4fdfdb[_0x78ec('0x29')],'type':_0x4fdfdb[_0x78ec('0x2a')][_0x78ec('0x2b')]};});_0x57eabb[_0x78ec('0x2c')]=_[_0x78ec('0x27')](_0x4182d1,'name');_0x57eabb[_0x78ec('0x2d')]=_[_0x78ec('0x2e')](_0xe56fab['query']);_0x57eabb[_0x78ec('0x2f')]=_[_0x78ec('0x30')](_0x57eabb[_0x78ec('0x2c')],_0x57eabb[_0x78ec('0x2d')]);_0x1c688c[_0x78ec('0x31')]=_['intersection'](_0x57eabb['model'],qs['fields'](_0xe56fab['query'][_0x78ec('0x32')]));_0x1c688c[_0x78ec('0x31')]=_0x1c688c[_0x78ec('0x31')][_0x78ec('0x33')]?_0x1c688c[_0x78ec('0x31')]:_0x57eabb['model'];if(!_0xe56fab[_0x78ec('0x2d')][_0x78ec('0x34')](_0x78ec('0x35'))){_0x1c688c['limit']=qs[_0x78ec('0x1c')](_0xe56fab[_0x78ec('0x2d')][_0x78ec('0x1c')]);_0x1c688c[_0x78ec('0x19')]=qs[_0x78ec('0x19')](_0xe56fab[_0x78ec('0x2d')][_0x78ec('0x19')]);}_0x1c688c[_0x78ec('0x36')]=qs['sort'](_0xe56fab['query']['sort']);_0x1c688c['where']=qs[_0x78ec('0x2f')](_[_0x78ec('0x37')](_0xe56fab[_0x78ec('0x2d')],_0x57eabb[_0x78ec('0x2f')]),_0x4182d1);if(_0xe56fab[_0x78ec('0x2d')][_0x78ec('0x38')]){_0x1c688c['where']=_[_0x78ec('0x39')](_0x1c688c[_0x78ec('0x3a')],{'$or':_['map'](_0x4182d1,function(_0x496f9c){if(_0x496f9c[_0x78ec('0x2a')]!==_0x78ec('0x3b')){var _0x14abe7={};_0x14abe7[_0x496f9c[_0x78ec('0x25')]]={'$like':'%'+_0xe56fab[_0x78ec('0x2d')][_0x78ec('0x38')]+'%'};return _0x14abe7;}})});}_0x1c688c=_[_0x78ec('0x39')]({},_0x1c688c,_0xe56fab[_0x78ec('0x3c')]);var _0x356d23={'where':_0x1c688c[_0x78ec('0x3a')]};return db[_0x78ec('0x28')][_0x78ec('0x1b')](_0x356d23)[_0x78ec('0x22')](function(_0x54650e){_0x409c3c[_0x78ec('0x1b')]=_0x54650e;if(_0xe56fab['query'][_0x78ec('0x3d')]){_0x1c688c[_0x78ec('0x3e')]=[{'all':!![]}];}return db[_0x78ec('0x28')][_0x78ec('0x3f')](_0x1c688c);})[_0x78ec('0x22')](function(_0x222f5c){_0x409c3c['rows']=_0x222f5c;return _0x409c3c;})[_0x78ec('0x22')](respondWithFilteredResult(_0x2fd57b,_0x1c688c))['catch'](handleError(_0x2fd57b,null));};exports[_0x78ec('0x40')]=function(_0xd10a3e,_0x28d0b7){var _0x1e0343={'raw':!![],'where':{'id':_0xd10a3e[_0x78ec('0x41')]['id']}},_0x3bafc2={};_0x3bafc2['model']=_['keys'](db[_0x78ec('0x28')][_0x78ec('0x42')]);_0x3bafc2[_0x78ec('0x2d')]=_[_0x78ec('0x2e')](_0xd10a3e[_0x78ec('0x2d')]);_0x3bafc2[_0x78ec('0x2f')]=_[_0x78ec('0x30')](_0x3bafc2[_0x78ec('0x2c')],_0x3bafc2[_0x78ec('0x2d')]);_0x1e0343[_0x78ec('0x31')]=_[_0x78ec('0x30')](_0x3bafc2[_0x78ec('0x2c')],qs[_0x78ec('0x32')](_0xd10a3e['query']['fields']));_0x1e0343[_0x78ec('0x31')]=_0x1e0343[_0x78ec('0x31')][_0x78ec('0x33')]?_0x1e0343[_0x78ec('0x31')]:_0x3bafc2[_0x78ec('0x2c')];if(_0xd10a3e[_0x78ec('0x2d')][_0x78ec('0x3d')]){_0x1e0343[_0x78ec('0x3e')]=[{'all':!![]}];}_0x1e0343=_[_0x78ec('0x39')]({},_0x1e0343,_0xd10a3e['options']);return db[_0x78ec('0x28')]['find'](_0x1e0343)['then'](handleEntityNotFound(_0x28d0b7,null))[_0x78ec('0x22')](respondWithResult(_0x28d0b7,null))[_0x78ec('0x43')](handleError(_0x28d0b7,null));};exports[_0x78ec('0x44')]=function(_0x4d2992,_0x244438){return db[_0x78ec('0x28')]['create'](_0x4d2992[_0x78ec('0x45')],{})['then'](respondWithResult(_0x244438,0xc9))[_0x78ec('0x43')](handleError(_0x244438,null));};exports[_0x78ec('0x21')]=function(_0x137cd7,_0x53f034){if(_0x137cd7[_0x78ec('0x45')]['id']){delete _0x137cd7[_0x78ec('0x45')]['id'];}return db['DeskField'][_0x78ec('0x46')]({'where':{'id':_0x137cd7['params']['id']}})[_0x78ec('0x22')](handleEntityNotFound(_0x53f034,null))[_0x78ec('0x22')](saveUpdates(_0x137cd7[_0x78ec('0x45')],null))[_0x78ec('0x22')](respondWithResult(_0x53f034,null))[_0x78ec('0x43')](handleError(_0x53f034,null));};exports['destroy']=function(_0x2fc234,_0x44d0d9){return db['DeskField']['find']({'where':{'id':_0x2fc234['params']['id']}})[_0x78ec('0x22')](handleEntityNotFound(_0x44d0d9,null))[_0x78ec('0x22')](removeEntity(_0x44d0d9,null))['catch'](handleError(_0x44d0d9,null));};
\ No newline at end of file
+var _0x553f=['create','body','update','find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','count','set','apply','reject','save','then','destroy','error','stack','name','send','map','DeskField','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','include'];(function(_0x575d3b,_0x5a65ce){var _0x5905ea=function(_0x3f631c){while(--_0x3f631c){_0x575d3b['push'](_0x575d3b['shift']());}};_0x5905ea(++_0x5a65ce);}(_0x553f,0x1c0));var _0xf553=function(_0x455d91,_0x22b41a){_0x455d91=_0x455d91-0x0;var _0x41eedb=_0x553f[_0x455d91];return _0x41eedb;};'use strict';var emlformat=require(_0xf553('0x0'));var rimraf=require(_0xf553('0x1'));var zipdir=require(_0xf553('0x2'));var jsonpatch=require(_0xf553('0x3'));var rp=require(_0xf553('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xf553('0x5'));var util=require('util');var path=require(_0xf553('0x6'));var sox=require(_0xf553('0x7'));var csv=require(_0xf553('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf553('0x9'));var _=require(_0xf553('0xa'));var squel=require(_0xf553('0xb'));var crypto=require('crypto');var jsforce=require(_0xf553('0xc'));var deskjs=require(_0xf553('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xf553('0xe'));var authService=require(_0xf553('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xf553('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf553('0x11'))(_0xf553('0x12'));var utils=require('../../config/utils');var config=require(_0xf553('0x13'));var licenseUtil=require(_0xf553('0x14'));var db=require(_0xf553('0x15'))['db'];function respondWithStatusCode(_0x3a296c,_0x16be09){_0x16be09=_0x16be09||0xcc;return function(_0x15231e){if(_0x15231e){return _0x3a296c[_0xf553('0x16')](_0x16be09);}return _0x3a296c[_0xf553('0x17')](_0x16be09)[_0xf553('0x18')]();};}function respondWithResult(_0x154752,_0x49dc14){_0x49dc14=_0x49dc14||0xc8;return function(_0x275d32){if(_0x275d32){return _0x154752[_0xf553('0x17')](_0x49dc14)['json'](_0x275d32);}};}function respondWithFilteredResult(_0x32a01b,_0x12968c){return function(_0x2cef54){if(_0x2cef54){var _0x3197ea=typeof _0x12968c[_0xf553('0x19')]===_0xf553('0x1a')&&typeof _0x12968c['limit']===_0xf553('0x1a');var _0x264bc1=_0x2cef54[_0xf553('0x1b')];var _0x14ae9c=_0x3197ea?0x0:_0x12968c[_0xf553('0x19')];var _0x53aae0=_0x3197ea?_0x2cef54[_0xf553('0x1b')]:_0x12968c[_0xf553('0x19')]+_0x12968c['limit'];var _0x58bd9d;if(_0x53aae0>=_0x264bc1){_0x53aae0=_0x264bc1;_0x58bd9d=0xc8;}else{_0x58bd9d=0xce;}_0x32a01b[_0xf553('0x17')](_0x58bd9d);return _0x32a01b[_0xf553('0x1c')]('Content-Range',_0x14ae9c+'-'+_0x53aae0+'/'+_0x264bc1)['json'](_0x2cef54);}return null;};}function patchUpdates(_0x21c395){return function(_0x560033){try{jsonpatch[_0xf553('0x1d')](_0x560033,_0x21c395,!![]);}catch(_0x2b6f93){return BPromise[_0xf553('0x1e')](_0x2b6f93);}return _0x560033[_0xf553('0x1f')]();};}function saveUpdates(_0x2ad893,_0x242b60){return function(_0x487cdb){if(_0x487cdb){return _0x487cdb['update'](_0x2ad893)[_0xf553('0x20')](function(_0x12e0d1){return _0x12e0d1;});}return null;};}function removeEntity(_0x5d967c,_0x1921cf){return function(_0x585dfa){if(_0x585dfa){return _0x585dfa[_0xf553('0x21')]()[_0xf553('0x20')](function(){_0x5d967c[_0xf553('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1b9a57,_0x501be2){return function(_0x3a58b3){if(!_0x3a58b3){_0x1b9a57[_0xf553('0x16')](0x194);}return _0x3a58b3;};}function handleError(_0x5c4dd2,_0x466be4){_0x466be4=_0x466be4||0x1f4;return function(_0x532fa5){logger[_0xf553('0x22')](_0x532fa5[_0xf553('0x23')]);if(_0x532fa5['name']){delete _0x532fa5[_0xf553('0x24')];}_0x5c4dd2[_0xf553('0x17')](_0x466be4)[_0xf553('0x25')](_0x532fa5);};}exports['index']=function(_0x4749d0,_0x3e06e0){var _0x13b084={},_0x12075e={},_0x53145b={'count':0x0,'rows':[]};var _0x268e0e=_[_0xf553('0x26')](db[_0xf553('0x27')][_0xf553('0x28')],function(_0x31cafc){return{'name':_0x31cafc[_0xf553('0x29')],'type':_0x31cafc[_0xf553('0x2a')][_0xf553('0x2b')]};});_0x12075e['model']=_[_0xf553('0x26')](_0x268e0e,_0xf553('0x24'));_0x12075e['query']=_[_0xf553('0x2c')](_0x4749d0[_0xf553('0x2d')]);_0x12075e[_0xf553('0x2e')]=_[_0xf553('0x2f')](_0x12075e[_0xf553('0x30')],_0x12075e['query']);_0x13b084[_0xf553('0x31')]=_[_0xf553('0x2f')](_0x12075e[_0xf553('0x30')],qs[_0xf553('0x32')](_0x4749d0[_0xf553('0x2d')][_0xf553('0x32')]));_0x13b084[_0xf553('0x31')]=_0x13b084[_0xf553('0x31')][_0xf553('0x33')]?_0x13b084[_0xf553('0x31')]:_0x12075e[_0xf553('0x30')];if(!_0x4749d0['query'][_0xf553('0x34')](_0xf553('0x35'))){_0x13b084[_0xf553('0x36')]=qs[_0xf553('0x36')](_0x4749d0[_0xf553('0x2d')][_0xf553('0x36')]);_0x13b084[_0xf553('0x19')]=qs[_0xf553('0x19')](_0x4749d0[_0xf553('0x2d')]['offset']);}_0x13b084[_0xf553('0x37')]=qs[_0xf553('0x38')](_0x4749d0[_0xf553('0x2d')][_0xf553('0x38')]);_0x13b084['where']=qs[_0xf553('0x2e')](_[_0xf553('0x39')](_0x4749d0[_0xf553('0x2d')],_0x12075e[_0xf553('0x2e')]),_0x268e0e);if(_0x4749d0[_0xf553('0x2d')][_0xf553('0x3a')]){_0x13b084[_0xf553('0x3b')]=_[_0xf553('0x3c')](_0x13b084[_0xf553('0x3b')],{'$or':_[_0xf553('0x26')](_0x268e0e,function(_0x5a721c){if(_0x5a721c[_0xf553('0x2a')]!==_0xf553('0x3d')){var _0x266b9d={};_0x266b9d[_0x5a721c['name']]={'$like':'%'+_0x4749d0[_0xf553('0x2d')]['filter']+'%'};return _0x266b9d;}})});}_0x13b084=_[_0xf553('0x3c')]({},_0x13b084,_0x4749d0[_0xf553('0x3e')]);var _0x582931={'where':_0x13b084[_0xf553('0x3b')]};return db['DeskField'][_0xf553('0x1b')](_0x582931)[_0xf553('0x20')](function(_0x3ecc5d){_0x53145b[_0xf553('0x1b')]=_0x3ecc5d;if(_0x4749d0[_0xf553('0x2d')][_0xf553('0x3f')]){_0x13b084['include']=[{'all':!![]}];}return db[_0xf553('0x27')][_0xf553('0x40')](_0x13b084);})[_0xf553('0x20')](function(_0x294a60){_0x53145b[_0xf553('0x41')]=_0x294a60;return _0x53145b;})[_0xf553('0x20')](respondWithFilteredResult(_0x3e06e0,_0x13b084))[_0xf553('0x42')](handleError(_0x3e06e0,null));};exports[_0xf553('0x43')]=function(_0x5ab801,_0x222666){var _0x37480d={'raw':!![],'where':{'id':_0x5ab801[_0xf553('0x44')]['id']}},_0x28aaa4={};_0x28aaa4[_0xf553('0x30')]=_[_0xf553('0x2c')](db[_0xf553('0x27')]['rawAttributes']);_0x28aaa4[_0xf553('0x2d')]=_[_0xf553('0x2c')](_0x5ab801['query']);_0x28aaa4[_0xf553('0x2e')]=_['intersection'](_0x28aaa4[_0xf553('0x30')],_0x28aaa4[_0xf553('0x2d')]);_0x37480d[_0xf553('0x31')]=_[_0xf553('0x2f')](_0x28aaa4[_0xf553('0x30')],qs[_0xf553('0x32')](_0x5ab801[_0xf553('0x2d')][_0xf553('0x32')]));_0x37480d[_0xf553('0x31')]=_0x37480d[_0xf553('0x31')][_0xf553('0x33')]?_0x37480d[_0xf553('0x31')]:_0x28aaa4['model'];if(_0x5ab801[_0xf553('0x2d')][_0xf553('0x3f')]){_0x37480d[_0xf553('0x45')]=[{'all':!![]}];}_0x37480d=_[_0xf553('0x3c')]({},_0x37480d,_0x5ab801['options']);return db[_0xf553('0x27')]['find'](_0x37480d)[_0xf553('0x20')](handleEntityNotFound(_0x222666,null))[_0xf553('0x20')](respondWithResult(_0x222666,null))['catch'](handleError(_0x222666,null));};exports[_0xf553('0x46')]=function(_0x4d2e2e,_0x556d4e){return db[_0xf553('0x27')][_0xf553('0x46')](_0x4d2e2e[_0xf553('0x47')],{})[_0xf553('0x20')](respondWithResult(_0x556d4e,0xc9))['catch'](handleError(_0x556d4e,null));};exports[_0xf553('0x48')]=function(_0x2adae9,_0x41bbc5){if(_0x2adae9[_0xf553('0x47')]['id']){delete _0x2adae9['body']['id'];}return db[_0xf553('0x27')]['find']({'where':{'id':_0x2adae9[_0xf553('0x44')]['id']}})[_0xf553('0x20')](handleEntityNotFound(_0x41bbc5,null))['then'](saveUpdates(_0x2adae9['body'],null))['then'](respondWithResult(_0x41bbc5,null))[_0xf553('0x42')](handleError(_0x41bbc5,null));};exports[_0xf553('0x21')]=function(_0x1f04a5,_0x17a7e3){return db[_0xf553('0x27')][_0xf553('0x49')]({'where':{'id':_0x1f04a5['params']['id']}})[_0xf553('0x20')](handleEntityNotFound(_0x17a7e3,null))[_0xf553('0x20')](removeEntity(_0x17a7e3,null))['catch'](handleError(_0x17a7e3,null));};
\ No newline at end of file