Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index e347403..6ed1ebf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9763=['querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','status','json','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','stack','name','send','index','map','DeskField','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','pick','filter','where','VIRTUAL','merge','options','count','includeAll','include','findAll','rows','catch','params','find','create','body','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js'];(function(_0x11391f,_0x59511f){var _0x54ce36=function(_0x11c8f4){while(--_0x11c8f4){_0x11391f['push'](_0x11391f['shift']());}};_0x54ce36(++_0x59511f);}(_0x9763,0x86));var _0x3976=function(_0x29ced0,_0x152d0b){_0x29ced0=_0x29ced0-0x0;var _0x1b068e=_0x9763[_0x29ced0];return _0x1b068e;};'use strict';var pdf=require(_0x3976('0x0'));var emlformat=require(_0x3976('0x1'));var rimraf=require(_0x3976('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3976('0x3'));var rp=require(_0x3976('0x4'));var moment=require(_0x3976('0x5'));var BPromise=require(_0x3976('0x6'));var Mustache=require(_0x3976('0x7'));var util=require('util');var path=require('path');var sox=require(_0x3976('0x8'));var csv=require(_0x3976('0x9'));var ejs=require(_0x3976('0xa'));var fs=require('fs');var _=require(_0x3976('0xb'));var squel=require(_0x3976('0xc'));var crypto=require(_0x3976('0xd'));var jsforce=require(_0x3976('0xe'));var deskjs=require(_0x3976('0xf'));var toCsv=require(_0x3976('0x9'));var querystring=require(_0x3976('0x10'));var Papa=require(_0x3976('0x11'));var Redis=require(_0x3976('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x3976('0x13'));var hardwareService=require(_0x3976('0x14'));var logger=require('../../config/logger')(_0x3976('0x15'));var utils=require(_0x3976('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x3976('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3cc672,_0x4e9d94){_0x4e9d94=_0x4e9d94||0xcc;return function(_0x5440bb){if(_0x5440bb){return _0x3cc672['sendStatus'](_0x4e9d94);}return _0x3cc672[_0x3976('0x18')](_0x4e9d94)['end']();};}function respondWithResult(_0xbaadf6,_0x2c2710){_0x2c2710=_0x2c2710||0xc8;return function(_0x24b83d){if(_0x24b83d){return _0xbaadf6[_0x3976('0x18')](_0x2c2710)[_0x3976('0x19')](_0x24b83d);}};}function respondWithFilteredResult(_0xe9d129,_0x49edc7){return function(_0x314e9f){if(_0x314e9f){var _0x18e445=_0x314e9f['count'],_0x2cb70a=_0x49edc7[_0x3976('0x1a')],_0x4ac2a3=_0x49edc7[_0x3976('0x1a')]+_0x49edc7[_0x3976('0x1b')],_0xf3bbd8;if(_0x4ac2a3>=_0x18e445){_0x4ac2a3=_0x18e445;_0xf3bbd8=0xc8;}else{_0xf3bbd8=0xce;}_0xe9d129[_0x3976('0x18')](_0xf3bbd8);return _0xe9d129[_0x3976('0x1c')](_0x3976('0x1d'),_0x2cb70a+'-'+_0x4ac2a3+'/'+_0x18e445)[_0x3976('0x19')](_0x314e9f);}return null;};}function patchUpdates(_0x17b6ff){return function(_0x3f1822){try{jsonpatch[_0x3976('0x1e')](_0x3f1822,_0x17b6ff,!![]);}catch(_0x272834){return BPromise[_0x3976('0x1f')](_0x272834);}return _0x3f1822[_0x3976('0x20')]();};}function saveUpdates(_0x538e16,_0x38c1a8){return function(_0x257b31){if(_0x257b31){return _0x257b31[_0x3976('0x21')](_0x538e16)[_0x3976('0x22')](function(_0x2b8a61){return _0x2b8a61;});}return null;};}function removeEntity(_0x29b2b6,_0x5d0c9e){return function(_0x1616cb){if(_0x1616cb){return _0x1616cb[_0x3976('0x23')]()[_0x3976('0x22')](function(){_0x29b2b6[_0x3976('0x18')](0xcc)[_0x3976('0x24')]();});}};}function handleEntityNotFound(_0x3da64d,_0x5a9257){return function(_0x24f12d){if(!_0x24f12d){_0x3da64d[_0x3976('0x25')](0x194);}return _0x24f12d;};}function handleError(_0x401c42,_0xb00761){_0xb00761=_0xb00761||0x1f4;return function(_0x3dde01){logger['error'](_0x3dde01[_0x3976('0x26')]);if(_0x3dde01[_0x3976('0x27')]){delete _0x3dde01[_0x3976('0x27')];}_0x401c42[_0x3976('0x18')](_0xb00761)[_0x3976('0x28')](_0x3dde01);};}exports[_0x3976('0x29')]=function(_0x1dff20,_0x347eec){var _0x33ead1={},_0x25d08f={},_0x5dc5d5={'count':0x0,'rows':[]};var _0xc0accd=_[_0x3976('0x2a')](db[_0x3976('0x2b')][_0x3976('0x2c')],function(_0x19423f){return{'name':_0x19423f[_0x3976('0x2d')],'type':_0x19423f[_0x3976('0x2e')][_0x3976('0x2f')]};});_0x25d08f[_0x3976('0x30')]=_['map'](_0xc0accd,'name');_0x25d08f[_0x3976('0x31')]=_[_0x3976('0x32')](_0x1dff20[_0x3976('0x31')]);_0x25d08f[_0x3976('0x33')]=_['intersection'](_0x25d08f[_0x3976('0x30')],_0x25d08f['query']);_0x33ead1[_0x3976('0x34')]=_[_0x3976('0x35')](_0x25d08f['model'],qs[_0x3976('0x36')](_0x1dff20[_0x3976('0x31')][_0x3976('0x36')]));_0x33ead1[_0x3976('0x34')]=_0x33ead1[_0x3976('0x34')][_0x3976('0x37')]?_0x33ead1['attributes']:_0x25d08f[_0x3976('0x30')];if(!_0x1dff20[_0x3976('0x31')][_0x3976('0x38')](_0x3976('0x39'))){_0x33ead1[_0x3976('0x1b')]=qs[_0x3976('0x1b')](_0x1dff20[_0x3976('0x31')][_0x3976('0x1b')]);_0x33ead1[_0x3976('0x1a')]=qs[_0x3976('0x1a')](_0x1dff20[_0x3976('0x31')][_0x3976('0x1a')]);}_0x33ead1[_0x3976('0x3a')]=qs['sort'](_0x1dff20[_0x3976('0x31')]['sort']);_0x33ead1['where']=qs[_0x3976('0x33')](_[_0x3976('0x3b')](_0x1dff20[_0x3976('0x31')],_0x25d08f[_0x3976('0x33')]),_0xc0accd);if(_0x1dff20['query'][_0x3976('0x3c')]){_0x33ead1[_0x3976('0x3d')]=_['merge'](_0x33ead1[_0x3976('0x3d')],{'$or':_['map'](_0xc0accd,function(_0x46167c){if(_0x46167c[_0x3976('0x2e')]!==_0x3976('0x3e')){var _0x443182={};_0x443182[_0x46167c[_0x3976('0x27')]]={'$like':'%'+_0x1dff20[_0x3976('0x31')][_0x3976('0x3c')]+'%'};return _0x443182;}})});}_0x33ead1=_[_0x3976('0x3f')]({},_0x33ead1,_0x1dff20[_0x3976('0x40')]);var _0x309e80={'where':_0x33ead1[_0x3976('0x3d')]};return db['DeskField'][_0x3976('0x41')](_0x309e80)['then'](function(_0x5cbd0f){_0x5dc5d5['count']=_0x5cbd0f;if(_0x1dff20[_0x3976('0x31')][_0x3976('0x42')]){_0x33ead1[_0x3976('0x43')]=[{'all':!![]}];}return db['DeskField'][_0x3976('0x44')](_0x33ead1);})[_0x3976('0x22')](function(_0x1338c1){_0x5dc5d5[_0x3976('0x45')]=_0x1338c1;return _0x5dc5d5;})[_0x3976('0x22')](respondWithFilteredResult(_0x347eec,_0x33ead1))[_0x3976('0x46')](handleError(_0x347eec,null));};exports['show']=function(_0x524bee,_0x5b5847){var _0x29f3d5={'raw':!![],'where':{'id':_0x524bee[_0x3976('0x47')]['id']}},_0x59ce3d={};_0x59ce3d[_0x3976('0x30')]=_[_0x3976('0x32')](db[_0x3976('0x2b')]['rawAttributes']);_0x59ce3d['query']=_['keys'](_0x524bee[_0x3976('0x31')]);_0x59ce3d[_0x3976('0x33')]=_[_0x3976('0x35')](_0x59ce3d[_0x3976('0x30')],_0x59ce3d[_0x3976('0x31')]);_0x29f3d5['attributes']=_[_0x3976('0x35')](_0x59ce3d[_0x3976('0x30')],qs[_0x3976('0x36')](_0x524bee[_0x3976('0x31')][_0x3976('0x36')]));_0x29f3d5[_0x3976('0x34')]=_0x29f3d5[_0x3976('0x34')][_0x3976('0x37')]?_0x29f3d5[_0x3976('0x34')]:_0x59ce3d[_0x3976('0x30')];if(_0x524bee['query'][_0x3976('0x42')]){_0x29f3d5[_0x3976('0x43')]=[{'all':!![]}];}_0x29f3d5=_[_0x3976('0x3f')]({},_0x29f3d5,_0x524bee[_0x3976('0x40')]);return db[_0x3976('0x2b')][_0x3976('0x48')](_0x29f3d5)[_0x3976('0x22')](handleEntityNotFound(_0x5b5847,null))[_0x3976('0x22')](respondWithResult(_0x5b5847,null))[_0x3976('0x46')](handleError(_0x5b5847,null));};exports[_0x3976('0x49')]=function(_0x1e58fc,_0x35109){return db[_0x3976('0x2b')][_0x3976('0x49')](_0x1e58fc['body'],{})[_0x3976('0x22')](respondWithResult(_0x35109,0xc9))[_0x3976('0x46')](handleError(_0x35109,null));};exports[_0x3976('0x21')]=function(_0x56e1e6,_0x59b474){if(_0x56e1e6[_0x3976('0x4a')]['id']){delete _0x56e1e6[_0x3976('0x4a')]['id'];}return db[_0x3976('0x2b')][_0x3976('0x48')]({'where':{'id':_0x56e1e6[_0x3976('0x47')]['id']}})[_0x3976('0x22')](handleEntityNotFound(_0x59b474,null))['then'](saveUpdates(_0x56e1e6['body'],null))[_0x3976('0x22')](respondWithResult(_0x59b474,null))[_0x3976('0x46')](handleError(_0x59b474,null));};exports['destroy']=function(_0x3ead66,_0x2a6fb0){return db[_0x3976('0x2b')][_0x3976('0x48')]({'where':{'id':_0x3ead66['params']['id']}})[_0x3976('0x22')](handleEntityNotFound(_0x2a6fb0,null))[_0x3976('0x22')](removeEntity(_0x2a6fb0,null))[_0x3976('0x46')](handleError(_0x2a6fb0,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