Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / intDeskField / intDeskField.controller.js
index aee23ad..6ed1ebf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa26b=['model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','includeAll','rows','catch','show','params','find','create','body','update','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','then','destroy','error','stack','name','send','DeskField','rawAttributes','fieldName','type','key'];(function(_0x1c8c28,_0x3ee093){var _0x1f59b4=function(_0x29bcc0){while(--_0x29bcc0){_0x1c8c28['push'](_0x1c8c28['shift']());}};_0x1f59b4(++_0x3ee093);}(_0xa26b,0x142));var _0xba26=function(_0x2c6a2d,_0x28d8e5){_0x2c6a2d=_0x2c6a2d-0x0;var _0xe748cc=_0xa26b[_0x2c6a2d];return _0xe748cc;};'use strict';var pdf=require(_0xba26('0x0'));var emlformat=require(_0xba26('0x1'));var rimraf=require(_0xba26('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xba26('0x3'));var rp=require(_0xba26('0x4'));var moment=require(_0xba26('0x5'));var BPromise=require(_0xba26('0x6'));var Mustache=require(_0xba26('0x7'));var util=require(_0xba26('0x8'));var path=require(_0xba26('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xba26('0xa'));var squel=require(_0xba26('0xb'));var crypto=require(_0xba26('0xc'));var jsforce=require(_0xba26('0xd'));var deskjs=require(_0xba26('0xe'));var toCsv=require(_0xba26('0xf'));var querystring=require(_0xba26('0x10'));var Papa=require('papaparse');var Redis=require(_0xba26('0x11'));var authService=require(_0xba26('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xba26('0x13'));var hardwareService=require(_0xba26('0x14'));var logger=require(_0xba26('0x15'))(_0xba26('0x16'));var utils=require(_0xba26('0x17'));var config=require(_0xba26('0x18'));var db=require(_0xba26('0x19'))['db'];function respondWithStatusCode(_0x1ee964,_0x2255a2){_0x2255a2=_0x2255a2||0xcc;return function(_0x4773a3){if(_0x4773a3){return _0x1ee964[_0xba26('0x1a')](_0x2255a2);}return _0x1ee964[_0xba26('0x1b')](_0x2255a2)[_0xba26('0x1c')]();};}function respondWithResult(_0x4e5fc3,_0x1c2342){_0x1c2342=_0x1c2342||0xc8;return function(_0x199313){if(_0x199313){return _0x4e5fc3['status'](_0x1c2342)[_0xba26('0x1d')](_0x199313);}};}function respondWithFilteredResult(_0x5c818e,_0x26a18a){return function(_0x16108a){if(_0x16108a){var _0x3eb60d=_0x16108a[_0xba26('0x1e')],_0x284da6=_0x26a18a['offset'],_0x54b65b=_0x26a18a[_0xba26('0x1f')]+_0x26a18a[_0xba26('0x20')],_0x2a1f4d;if(_0x54b65b>=_0x3eb60d){_0x54b65b=_0x3eb60d;_0x2a1f4d=0xc8;}else{_0x2a1f4d=0xce;}_0x5c818e['status'](_0x2a1f4d);return _0x5c818e[_0xba26('0x21')](_0xba26('0x22'),_0x284da6+'-'+_0x54b65b+'/'+_0x3eb60d)[_0xba26('0x1d')](_0x16108a);}return null;};}function patchUpdates(_0x57f127){return function(_0x3c799d){try{jsonpatch[_0xba26('0x23')](_0x3c799d,_0x57f127,!![]);}catch(_0x55824c){return BPromise[_0xba26('0x24')](_0x55824c);}return _0x3c799d['save']();};}function saveUpdates(_0x4d84e6,_0x5c0c63){return function(_0x7ea60d){if(_0x7ea60d){return _0x7ea60d['update'](_0x4d84e6)[_0xba26('0x25')](function(_0x46cebf){return _0x46cebf;});}return null;};}function removeEntity(_0x3fb164,_0x2ebe35){return function(_0x2c9bdd){if(_0x2c9bdd){return _0x2c9bdd[_0xba26('0x26')]()[_0xba26('0x25')](function(){_0x3fb164[_0xba26('0x1b')](0xcc)[_0xba26('0x1c')]();});}};}function handleEntityNotFound(_0x1e36ab,_0x396bbe){return function(_0x4e0f3e){if(!_0x4e0f3e){_0x1e36ab[_0xba26('0x1a')](0x194);}return _0x4e0f3e;};}function handleError(_0x379700,_0x4991f8){_0x4991f8=_0x4991f8||0x1f4;return function(_0x414138){logger[_0xba26('0x27')](_0x414138[_0xba26('0x28')]);if(_0x414138[_0xba26('0x29')]){delete _0x414138['name'];}_0x379700[_0xba26('0x1b')](_0x4991f8)[_0xba26('0x2a')](_0x414138);};}exports['index']=function(_0x59a27e,_0x137644){var _0x1f3f83={},_0x2b828b={},_0x5ab90a={'count':0x0,'rows':[]};var _0x3f021c=_['map'](db[_0xba26('0x2b')][_0xba26('0x2c')],function(_0x1c1588){return{'name':_0x1c1588[_0xba26('0x2d')],'type':_0x1c1588[_0xba26('0x2e')][_0xba26('0x2f')]};});_0x2b828b[_0xba26('0x30')]=_[_0xba26('0x31')](_0x3f021c,_0xba26('0x29'));_0x2b828b[_0xba26('0x32')]=_[_0xba26('0x33')](_0x59a27e[_0xba26('0x32')]);_0x2b828b[_0xba26('0x34')]=_[_0xba26('0x35')](_0x2b828b[_0xba26('0x30')],_0x2b828b['query']);_0x1f3f83['attributes']=_['intersection'](_0x2b828b['model'],qs[_0xba26('0x36')](_0x59a27e['query'][_0xba26('0x36')]));_0x1f3f83[_0xba26('0x37')]=_0x1f3f83[_0xba26('0x37')][_0xba26('0x38')]?_0x1f3f83[_0xba26('0x37')]:_0x2b828b['model'];if(!_0x59a27e[_0xba26('0x32')][_0xba26('0x39')]('nolimit')){_0x1f3f83[_0xba26('0x20')]=qs[_0xba26('0x20')](_0x59a27e[_0xba26('0x32')][_0xba26('0x20')]);_0x1f3f83[_0xba26('0x1f')]=qs[_0xba26('0x1f')](_0x59a27e['query'][_0xba26('0x1f')]);}_0x1f3f83[_0xba26('0x3a')]=qs[_0xba26('0x3b')](_0x59a27e['query']['sort']);_0x1f3f83[_0xba26('0x3c')]=qs[_0xba26('0x34')](_[_0xba26('0x3d')](_0x59a27e[_0xba26('0x32')],_0x2b828b[_0xba26('0x34')]),_0x3f021c);if(_0x59a27e['query']['filter']){_0x1f3f83['where']=_['merge'](_0x1f3f83[_0xba26('0x3c')],{'$or':_[_0xba26('0x31')](_0x3f021c,function(_0x5c88be){if(_0x5c88be[_0xba26('0x2e')]!=='VIRTUAL'){var _0x81e3c2={};_0x81e3c2[_0x5c88be['name']]={'$like':'%'+_0x59a27e['query'][_0xba26('0x3e')]+'%'};return _0x81e3c2;}})});}_0x1f3f83=_[_0xba26('0x3f')]({},_0x1f3f83,_0x59a27e[_0xba26('0x40')]);var _0x24295e={'where':_0x1f3f83[_0xba26('0x3c')]};return db[_0xba26('0x2b')][_0xba26('0x1e')](_0x24295e)[_0xba26('0x25')](function(_0x6a6e48){_0x5ab90a[_0xba26('0x1e')]=_0x6a6e48;if(_0x59a27e[_0xba26('0x32')][_0xba26('0x41')]){_0x1f3f83['include']=[{'all':!![]}];}return db['DeskField']['findAll'](_0x1f3f83);})[_0xba26('0x25')](function(_0xa7787c){_0x5ab90a[_0xba26('0x42')]=_0xa7787c;return _0x5ab90a;})[_0xba26('0x25')](respondWithFilteredResult(_0x137644,_0x1f3f83))[_0xba26('0x43')](handleError(_0x137644,null));};exports[_0xba26('0x44')]=function(_0x2337dc,_0x4236b6){var _0x2fd123={'raw':!![],'where':{'id':_0x2337dc[_0xba26('0x45')]['id']}},_0x48f056={};_0x48f056['model']=_[_0xba26('0x33')](db[_0xba26('0x2b')][_0xba26('0x2c')]);_0x48f056[_0xba26('0x32')]=_[_0xba26('0x33')](_0x2337dc[_0xba26('0x32')]);_0x48f056[_0xba26('0x34')]=_[_0xba26('0x35')](_0x48f056[_0xba26('0x30')],_0x48f056['query']);_0x2fd123[_0xba26('0x37')]=_[_0xba26('0x35')](_0x48f056[_0xba26('0x30')],qs[_0xba26('0x36')](_0x2337dc[_0xba26('0x32')][_0xba26('0x36')]));_0x2fd123[_0xba26('0x37')]=_0x2fd123['attributes'][_0xba26('0x38')]?_0x2fd123[_0xba26('0x37')]:_0x48f056[_0xba26('0x30')];if(_0x2337dc[_0xba26('0x32')][_0xba26('0x41')]){_0x2fd123['include']=[{'all':!![]}];}_0x2fd123=_['merge']({},_0x2fd123,_0x2337dc[_0xba26('0x40')]);return db[_0xba26('0x2b')][_0xba26('0x46')](_0x2fd123)[_0xba26('0x25')](handleEntityNotFound(_0x4236b6,null))['then'](respondWithResult(_0x4236b6,null))[_0xba26('0x43')](handleError(_0x4236b6,null));};exports['create']=function(_0x233389,_0x5edabd){return db[_0xba26('0x2b')][_0xba26('0x47')](_0x233389[_0xba26('0x48')],{})[_0xba26('0x25')](respondWithResult(_0x5edabd,0xc9))[_0xba26('0x43')](handleError(_0x5edabd,null));};exports[_0xba26('0x49')]=function(_0xb50fa5,_0x3ba0a9){if(_0xb50fa5['body']['id']){delete _0xb50fa5[_0xba26('0x48')]['id'];}return db[_0xba26('0x2b')][_0xba26('0x46')]({'where':{'id':_0xb50fa5[_0xba26('0x45')]['id']}})[_0xba26('0x25')](handleEntityNotFound(_0x3ba0a9,null))[_0xba26('0x25')](saveUpdates(_0xb50fa5[_0xba26('0x48')],null))['then'](respondWithResult(_0x3ba0a9,null))['catch'](handleError(_0x3ba0a9,null));};exports[_0xba26('0x26')]=function(_0x48a9d7,_0x26dc00){return db['DeskField'][_0xba26('0x46')]({'where':{'id':_0x48a9d7[_0xba26('0x45')]['id']}})['then'](handleEntityNotFound(_0x26dc00,null))[_0xba26('0x25')](removeEntity(_0x26dc00,null))[_0xba26('0x43')](handleError(_0x26dc00,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