Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 6914a64..bdc39a7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x757a=['map','VIRTUAL','options','AnalyticTreeReport','count','findAll','rows','catch','params','keys','includeAll','include','create','body','find','eml-format','rimraf','moment','bluebird','mustache','util','path','sox','ejs','lodash','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','end','status','json','offset','limit','Content-Range','apply','save','update','then','destroy','stack','name','send','index','rawAttributes','fieldName','type','model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter'];(function(_0x3b7fc4,_0x154baa){var _0x228787=function(_0x1617cc){while(--_0x1617cc){_0x3b7fc4['push'](_0x3b7fc4['shift']());}};_0x228787(++_0x154baa);}(_0x757a,0xde));var _0xa757=function(_0x2edfed,_0x4f38c6){_0x2edfed=_0x2edfed-0x0;var _0x4bbbb4=_0x757a[_0x2edfed];return _0x4bbbb4;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xa757('0x0'));var rimraf=require(_0xa757('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xa757('0x2'));var BPromise=require(_0xa757('0x3'));var Mustache=require(_0xa757('0x4'));var util=require(_0xa757('0x5'));var path=require(_0xa757('0x6'));var sox=require(_0xa757('0x7'));var csv=require('to-csv');var ejs=require(_0xa757('0x8'));var fs=require('fs');var _=require(_0xa757('0x9'));var squel=require('squel');var crypto=require(_0xa757('0xa'));var jsforce=require(_0xa757('0xb'));var deskjs=require(_0xa757('0xc'));var toCsv=require(_0xa757('0xd'));var querystring=require(_0xa757('0xe'));var Papa=require('papaparse');var Redis=require(_0xa757('0xf'));var authService=require(_0xa757('0x10'));var qs=require(_0xa757('0x11'));var as=require(_0xa757('0x12'));var hardwareService=require(_0xa757('0x13'));var logger=require(_0xa757('0x14'))(_0xa757('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x56acfb,_0x4db68e){_0x4db68e=_0x4db68e||0xcc;return function(_0x421040){if(_0x421040){return _0x56acfb['sendStatus'](_0x4db68e);}return _0x56acfb['status'](_0x4db68e)[_0xa757('0x16')]();};}function respondWithResult(_0x513b1f,_0x481508){_0x481508=_0x481508||0xc8;return function(_0x32112b){if(_0x32112b){return _0x513b1f[_0xa757('0x17')](_0x481508)[_0xa757('0x18')](_0x32112b);}};}function respondWithFilteredResult(_0x4a0c38,_0x86abd){return function(_0x31cfd2){if(_0x31cfd2){var _0xf12b68=_0x31cfd2['count'],_0x2f7947=_0x86abd[_0xa757('0x19')],_0x185011=_0x86abd[_0xa757('0x19')]+_0x86abd[_0xa757('0x1a')],_0x3df1f9;if(_0x185011>=_0xf12b68){_0x185011=_0xf12b68;_0x3df1f9=0xc8;}else{_0x3df1f9=0xce;}_0x4a0c38['status'](_0x3df1f9);return _0x4a0c38['set'](_0xa757('0x1b'),_0x2f7947+'-'+_0x185011+'/'+_0xf12b68)[_0xa757('0x18')](_0x31cfd2);}return null;};}function patchUpdates(_0x1bd14c){return function(_0x340599){try{jsonpatch[_0xa757('0x1c')](_0x340599,_0x1bd14c,!![]);}catch(_0xe2d567){return BPromise['reject'](_0xe2d567);}return _0x340599[_0xa757('0x1d')]();};}function saveUpdates(_0x4fec52,_0x32c2a1){return function(_0x167640){if(_0x167640){return _0x167640[_0xa757('0x1e')](_0x4fec52)[_0xa757('0x1f')](function(_0x4d598c){return _0x4d598c;});}return null;};}function removeEntity(_0x5638c7,_0x40ec48){return function(_0x2159cf){if(_0x2159cf){return _0x2159cf[_0xa757('0x20')]()[_0xa757('0x1f')](function(){_0x5638c7[_0xa757('0x17')](0xcc)[_0xa757('0x16')]();});}};}function handleEntityNotFound(_0x2ca10d,_0x21f1af){return function(_0x2bf276){if(!_0x2bf276){_0x2ca10d['sendStatus'](0x194);}return _0x2bf276;};}function handleError(_0x3707c1,_0x59e9d4){_0x59e9d4=_0x59e9d4||0x1f4;return function(_0x422e9e){logger['error'](_0x422e9e[_0xa757('0x21')]);if(_0x422e9e[_0xa757('0x22')]){delete _0x422e9e[_0xa757('0x22')];}_0x3707c1['status'](_0x59e9d4)[_0xa757('0x23')](_0x422e9e);};}exports[_0xa757('0x24')]=function(_0x471e84,_0x3bf7f3){var _0x5b4779={},_0x449a7d={},_0x54263b={'count':0x0,'rows':[]};var _0x5a5664=_['map'](db['AnalyticTreeReport'][_0xa757('0x25')],function(_0x596ae2){return{'name':_0x596ae2[_0xa757('0x26')],'type':_0x596ae2[_0xa757('0x27')]['key']};});_0x449a7d[_0xa757('0x28')]=_['map'](_0x5a5664,_0xa757('0x22'));_0x449a7d[_0xa757('0x29')]=_['keys'](_0x471e84[_0xa757('0x29')]);_0x449a7d['filters']=_[_0xa757('0x2a')](_0x449a7d[_0xa757('0x28')],_0x449a7d[_0xa757('0x29')]);_0x5b4779[_0xa757('0x2b')]=_[_0xa757('0x2a')](_0x449a7d[_0xa757('0x28')],qs[_0xa757('0x2c')](_0x471e84[_0xa757('0x29')][_0xa757('0x2c')]));_0x5b4779[_0xa757('0x2b')]=_0x5b4779[_0xa757('0x2b')][_0xa757('0x2d')]?_0x5b4779[_0xa757('0x2b')]:_0x449a7d[_0xa757('0x28')];if(!_0x471e84[_0xa757('0x29')][_0xa757('0x2e')](_0xa757('0x2f'))){_0x5b4779[_0xa757('0x1a')]=qs[_0xa757('0x1a')](_0x471e84[_0xa757('0x29')][_0xa757('0x1a')]);_0x5b4779[_0xa757('0x19')]=qs[_0xa757('0x19')](_0x471e84[_0xa757('0x29')]['offset']);}_0x5b4779[_0xa757('0x30')]=qs[_0xa757('0x31')](_0x471e84[_0xa757('0x29')][_0xa757('0x31')]);_0x5b4779[_0xa757('0x32')]=qs['filters'](_[_0xa757('0x33')](_0x471e84[_0xa757('0x29')],_0x449a7d[_0xa757('0x34')]));if(_0x471e84[_0xa757('0x29')][_0xa757('0x35')]){_0x5b4779[_0xa757('0x32')]=_['merge'](_0x5b4779[_0xa757('0x32')],{'$or':_[_0xa757('0x36')](_0x5a5664,function(_0x2cade7){if(_0x2cade7[_0xa757('0x27')]!==_0xa757('0x37')){var _0x111cfe={};_0x111cfe[_0x2cade7[_0xa757('0x22')]]={'$like':'%'+_0x471e84[_0xa757('0x29')][_0xa757('0x35')]+'%'};return _0x111cfe;}})});}_0x5b4779=_['merge']({},_0x5b4779,_0x471e84[_0xa757('0x38')]);var _0x34fba8={'where':_0x5b4779[_0xa757('0x32')]};return db[_0xa757('0x39')][_0xa757('0x3a')](_0x34fba8)[_0xa757('0x1f')](function(_0x501e26){_0x54263b[_0xa757('0x3a')]=_0x501e26;if(_0x471e84[_0xa757('0x29')]['includeAll']){_0x5b4779['include']=[{'all':!![]}];}return db[_0xa757('0x39')][_0xa757('0x3b')](_0x5b4779);})['then'](function(_0x51c3d1){_0x54263b[_0xa757('0x3c')]=_0x51c3d1;return _0x54263b;})[_0xa757('0x1f')](respondWithFilteredResult(_0x3bf7f3,_0x5b4779))[_0xa757('0x3d')](handleError(_0x3bf7f3,null));};exports['show']=function(_0x830dc4,_0x13a8f4){var _0x26802c={'raw':!![],'where':{'id':_0x830dc4[_0xa757('0x3e')]['id']}},_0x1ba399={};_0x1ba399['model']=_[_0xa757('0x3f')](db['AnalyticTreeReport']['rawAttributes']);_0x1ba399[_0xa757('0x29')]=_[_0xa757('0x3f')](_0x830dc4[_0xa757('0x29')]);_0x1ba399[_0xa757('0x34')]=_[_0xa757('0x2a')](_0x1ba399['model'],_0x1ba399['query']);_0x26802c[_0xa757('0x2b')]=_[_0xa757('0x2a')](_0x1ba399[_0xa757('0x28')],qs[_0xa757('0x2c')](_0x830dc4[_0xa757('0x29')][_0xa757('0x2c')]));_0x26802c['attributes']=_0x26802c[_0xa757('0x2b')][_0xa757('0x2d')]?_0x26802c['attributes']:_0x1ba399[_0xa757('0x28')];if(_0x830dc4['query'][_0xa757('0x40')]){_0x26802c[_0xa757('0x41')]=[{'all':!![]}];}_0x26802c=_['merge']({},_0x26802c,_0x830dc4[_0xa757('0x38')]);return db[_0xa757('0x39')]['find'](_0x26802c)[_0xa757('0x1f')](handleEntityNotFound(_0x13a8f4,null))[_0xa757('0x1f')](respondWithResult(_0x13a8f4,null))[_0xa757('0x3d')](handleError(_0x13a8f4,null));};exports[_0xa757('0x42')]=function(_0x543b5b,_0x199dc9){return db[_0xa757('0x39')][_0xa757('0x42')](_0x543b5b[_0xa757('0x43')],{})['then'](respondWithResult(_0x199dc9,0xc9))[_0xa757('0x3d')](handleError(_0x199dc9,null));};exports['update']=function(_0x50c131,_0x2acf88){if(_0x50c131[_0xa757('0x43')]['id']){delete _0x50c131[_0xa757('0x43')]['id'];}return db['AnalyticTreeReport'][_0xa757('0x44')]({'where':{'id':_0x50c131['params']['id']}})[_0xa757('0x1f')](handleEntityNotFound(_0x2acf88,null))[_0xa757('0x1f')](saveUpdates(_0x50c131[_0xa757('0x43')],null))[_0xa757('0x1f')](respondWithResult(_0x2acf88,null))[_0xa757('0x3d')](handleError(_0x2acf88,null));};exports[_0xa757('0x20')]=function(_0x57bf73,_0x505cd){return db['AnalyticTreeReport'][_0xa757('0x44')]({'where':{'id':_0x57bf73[_0xa757('0x3e')]['id']}})[_0xa757('0x1f')](handleEntityNotFound(_0x505cd,null))[_0xa757('0x1f')](removeEntity(_0x505cd,null))[_0xa757('0x3d')](handleError(_0x505cd,null));};
\ No newline at end of file
+var _0x5f93=['reject','save','update','then','destroy','end','error','stack','name','index','AnalyticTreeReport','rawAttributes','fieldName','type','key','keys','query','intersection','model','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','map','filter','merge','includeAll','include','findAll','rows','catch','params','options','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','count','limit','set','apply'];(function(_0x4e7e03,_0x5b0f86){var _0x50b732=function(_0x170c2c){while(--_0x170c2c){_0x4e7e03['push'](_0x4e7e03['shift']());}};_0x50b732(++_0x5b0f86);}(_0x5f93,0x10d));var _0x35f9=function(_0x5e3e18,_0xd16a93){_0x5e3e18=_0x5e3e18-0x0;var _0x2502b2=_0x5f93[_0x5e3e18];return _0x2502b2;};'use strict';var emlformat=require(_0x35f9('0x0'));var rimraf=require(_0x35f9('0x1'));var zipdir=require(_0x35f9('0x2'));var jsonpatch=require(_0x35f9('0x3'));var rp=require(_0x35f9('0x4'));var moment=require(_0x35f9('0x5'));var BPromise=require(_0x35f9('0x6'));var Mustache=require('mustache');var util=require(_0x35f9('0x7'));var path=require('path');var sox=require(_0x35f9('0x8'));var csv=require(_0x35f9('0x9'));var ejs=require(_0x35f9('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x35f9('0xb'));var squel=require('squel');var crypto=require(_0x35f9('0xc'));var jsforce=require(_0x35f9('0xd'));var deskjs=require(_0x35f9('0xe'));var toCsv=require('to-csv');var querystring=require(_0x35f9('0xf'));var Papa=require(_0x35f9('0x10'));var Redis=require(_0x35f9('0x11'));var authService=require(_0x35f9('0x12'));var qs=require(_0x35f9('0x13'));var as=require(_0x35f9('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x35f9('0x15'))(_0x35f9('0x16'));var utils=require(_0x35f9('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x35f9('0x18'));var db=require(_0x35f9('0x19'))['db'];function respondWithStatusCode(_0x5656f4,_0x2d960b){_0x2d960b=_0x2d960b||0xcc;return function(_0xa5c57f){if(_0xa5c57f){return _0x5656f4[_0x35f9('0x1a')](_0x2d960b);}return _0x5656f4['status'](_0x2d960b)['end']();};}function respondWithResult(_0x2d2896,_0x215272){_0x215272=_0x215272||0xc8;return function(_0xe60b2c){if(_0xe60b2c){return _0x2d2896[_0x35f9('0x1b')](_0x215272)[_0x35f9('0x1c')](_0xe60b2c);}};}function respondWithFilteredResult(_0xb58759,_0xabebb5){return function(_0x3220f8){if(_0x3220f8){var _0xcb0c8d=typeof _0xabebb5[_0x35f9('0x1d')]===_0x35f9('0x1e')&&typeof _0xabebb5['limit']===_0x35f9('0x1e');var _0x15631e=_0x3220f8[_0x35f9('0x1f')];var _0x172718=_0xcb0c8d?0x0:_0xabebb5[_0x35f9('0x1d')];var _0x42ad48=_0xcb0c8d?_0x3220f8[_0x35f9('0x1f')]:_0xabebb5[_0x35f9('0x1d')]+_0xabebb5[_0x35f9('0x20')];var _0x5b7a62;if(_0x42ad48>=_0x15631e){_0x42ad48=_0x15631e;_0x5b7a62=0xc8;}else{_0x5b7a62=0xce;}_0xb58759['status'](_0x5b7a62);return _0xb58759[_0x35f9('0x21')]('Content-Range',_0x172718+'-'+_0x42ad48+'/'+_0x15631e)['json'](_0x3220f8);}return null;};}function patchUpdates(_0x5af511){return function(_0x5e0a36){try{jsonpatch[_0x35f9('0x22')](_0x5e0a36,_0x5af511,!![]);}catch(_0x4c6c4b){return BPromise[_0x35f9('0x23')](_0x4c6c4b);}return _0x5e0a36[_0x35f9('0x24')]();};}function saveUpdates(_0x32effc,_0x3e33e0){return function(_0x4f4165){if(_0x4f4165){return _0x4f4165[_0x35f9('0x25')](_0x32effc)[_0x35f9('0x26')](function(_0x58ccbe){return _0x58ccbe;});}return null;};}function removeEntity(_0xa06b49,_0x53c33a){return function(_0x48f98b){if(_0x48f98b){return _0x48f98b[_0x35f9('0x27')]()[_0x35f9('0x26')](function(){_0xa06b49[_0x35f9('0x1b')](0xcc)[_0x35f9('0x28')]();});}};}function handleEntityNotFound(_0x5bfe29,_0x51c4b4){return function(_0x76ca49){if(!_0x76ca49){_0x5bfe29[_0x35f9('0x1a')](0x194);}return _0x76ca49;};}function handleError(_0x383625,_0x37d273){_0x37d273=_0x37d273||0x1f4;return function(_0x27b5e7){logger[_0x35f9('0x29')](_0x27b5e7[_0x35f9('0x2a')]);if(_0x27b5e7[_0x35f9('0x2b')]){delete _0x27b5e7[_0x35f9('0x2b')];}_0x383625['status'](_0x37d273)['send'](_0x27b5e7);};}exports[_0x35f9('0x2c')]=function(_0x591461,_0x2fdb4c){var _0x4293d0={},_0x324f93={},_0x5049d6={'count':0x0,'rows':[]};var _0x2831d6=_['map'](db[_0x35f9('0x2d')][_0x35f9('0x2e')],function(_0x4ed1de){return{'name':_0x4ed1de[_0x35f9('0x2f')],'type':_0x4ed1de[_0x35f9('0x30')][_0x35f9('0x31')]};});_0x324f93['model']=_['map'](_0x2831d6,'name');_0x324f93['query']=_[_0x35f9('0x32')](_0x591461[_0x35f9('0x33')]);_0x324f93['filters']=_[_0x35f9('0x34')](_0x324f93[_0x35f9('0x35')],_0x324f93[_0x35f9('0x33')]);_0x4293d0[_0x35f9('0x36')]=_['intersection'](_0x324f93['model'],qs[_0x35f9('0x37')](_0x591461[_0x35f9('0x33')][_0x35f9('0x37')]));_0x4293d0[_0x35f9('0x36')]=_0x4293d0[_0x35f9('0x36')][_0x35f9('0x38')]?_0x4293d0[_0x35f9('0x36')]:_0x324f93[_0x35f9('0x35')];if(!_0x591461[_0x35f9('0x33')][_0x35f9('0x39')]('nolimit')){_0x4293d0[_0x35f9('0x20')]=qs[_0x35f9('0x20')](_0x591461['query'][_0x35f9('0x20')]);_0x4293d0['offset']=qs[_0x35f9('0x1d')](_0x591461[_0x35f9('0x33')][_0x35f9('0x1d')]);}_0x4293d0[_0x35f9('0x3a')]=qs[_0x35f9('0x3b')](_0x591461[_0x35f9('0x33')][_0x35f9('0x3b')]);_0x4293d0[_0x35f9('0x3c')]=qs[_0x35f9('0x3d')](_[_0x35f9('0x3e')](_0x591461[_0x35f9('0x33')],_0x324f93[_0x35f9('0x3d')]),_0x2831d6);if(_0x591461[_0x35f9('0x33')]['filter']){_0x4293d0[_0x35f9('0x3c')]=_['merge'](_0x4293d0[_0x35f9('0x3c')],{'$or':_[_0x35f9('0x3f')](_0x2831d6,function(_0x40bc4c){if(_0x40bc4c['type']!=='VIRTUAL'){var _0x54e652={};_0x54e652[_0x40bc4c[_0x35f9('0x2b')]]={'$like':'%'+_0x591461[_0x35f9('0x33')][_0x35f9('0x40')]+'%'};return _0x54e652;}})});}_0x4293d0=_[_0x35f9('0x41')]({},_0x4293d0,_0x591461['options']);var _0xf64f19={'where':_0x4293d0['where']};return db[_0x35f9('0x2d')][_0x35f9('0x1f')](_0xf64f19)[_0x35f9('0x26')](function(_0x429da7){_0x5049d6[_0x35f9('0x1f')]=_0x429da7;if(_0x591461[_0x35f9('0x33')][_0x35f9('0x42')]){_0x4293d0[_0x35f9('0x43')]=[{'all':!![]}];}return db[_0x35f9('0x2d')][_0x35f9('0x44')](_0x4293d0);})[_0x35f9('0x26')](function(_0x9488fc){_0x5049d6[_0x35f9('0x45')]=_0x9488fc;return _0x5049d6;})[_0x35f9('0x26')](respondWithFilteredResult(_0x2fdb4c,_0x4293d0))[_0x35f9('0x46')](handleError(_0x2fdb4c,null));};exports['show']=function(_0x2f37b6,_0x44f293){var _0x53ccb7={'raw':!![],'where':{'id':_0x2f37b6[_0x35f9('0x47')]['id']}},_0x240800={};_0x240800[_0x35f9('0x35')]=_[_0x35f9('0x32')](db[_0x35f9('0x2d')]['rawAttributes']);_0x240800[_0x35f9('0x33')]=_[_0x35f9('0x32')](_0x2f37b6[_0x35f9('0x33')]);_0x240800['filters']=_[_0x35f9('0x34')](_0x240800[_0x35f9('0x35')],_0x240800[_0x35f9('0x33')]);_0x53ccb7['attributes']=_[_0x35f9('0x34')](_0x240800[_0x35f9('0x35')],qs[_0x35f9('0x37')](_0x2f37b6[_0x35f9('0x33')][_0x35f9('0x37')]));_0x53ccb7['attributes']=_0x53ccb7[_0x35f9('0x36')]['length']?_0x53ccb7[_0x35f9('0x36')]:_0x240800['model'];if(_0x2f37b6[_0x35f9('0x33')][_0x35f9('0x42')]){_0x53ccb7[_0x35f9('0x43')]=[{'all':!![]}];}_0x53ccb7=_['merge']({},_0x53ccb7,_0x2f37b6[_0x35f9('0x48')]);return db[_0x35f9('0x2d')][_0x35f9('0x49')](_0x53ccb7)[_0x35f9('0x26')](handleEntityNotFound(_0x44f293,null))[_0x35f9('0x26')](respondWithResult(_0x44f293,null))['catch'](handleError(_0x44f293,null));};exports[_0x35f9('0x4a')]=function(_0x42e93a,_0x3a02da){return db['AnalyticTreeReport']['create'](_0x42e93a['body'],{})[_0x35f9('0x26')](respondWithResult(_0x3a02da,0xc9))[_0x35f9('0x46')](handleError(_0x3a02da,null));};exports[_0x35f9('0x25')]=function(_0x4121bd,_0x450214){if(_0x4121bd[_0x35f9('0x4b')]['id']){delete _0x4121bd[_0x35f9('0x4b')]['id'];}return db['AnalyticTreeReport'][_0x35f9('0x49')]({'where':{'id':_0x4121bd[_0x35f9('0x47')]['id']}})[_0x35f9('0x26')](handleEntityNotFound(_0x450214,null))[_0x35f9('0x26')](saveUpdates(_0x4121bd['body'],null))[_0x35f9('0x26')](respondWithResult(_0x450214,null))[_0x35f9('0x46')](handleError(_0x450214,null));};exports['destroy']=function(_0x5be265,_0x5979f4){return db['AnalyticTreeReport'][_0x35f9('0x49')]({'where':{'id':_0x5be265[_0x35f9('0x47')]['id']}})['then'](handleEntityNotFound(_0x5979f4,null))[_0x35f9('0x26')](removeEntity(_0x5979f4,null))[_0x35f9('0x46')](handleError(_0x5979f4,null));};
\ No newline at end of file