Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 1919891..a6bd14e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x32eb=['then','destroy','end','error','stack','name','index','map','AnalyticTreeReport','rawAttributes','fieldName','type','query','model','attributes','intersection','fields','length','hasOwnProperty','sort','where','pick','filters','filter','VIRTUAL','merge','count','includeAll','include','findAll','rows','catch','show','keys','find','create','body','params','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','json','offset','limit','set','reject','save','update'];(function(_0x3da966,_0xdc1228){var _0x1f84dc=function(_0x5ea46f){while(--_0x5ea46f){_0x3da966['push'](_0x3da966['shift']());}};_0x1f84dc(++_0xdc1228);}(_0x32eb,0xb2));var _0xb32e=function(_0x4f9b18,_0x2cb5ca){_0x4f9b18=_0x4f9b18-0x0;var _0x29f20c=_0x32eb[_0x4f9b18];return _0x29f20c;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xb32e('0x0'));var rimraf=require(_0xb32e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb32e('0x2'));var rp=require(_0xb32e('0x3'));var moment=require('moment');var BPromise=require(_0xb32e('0x4'));var Mustache=require(_0xb32e('0x5'));var util=require('util');var path=require(_0xb32e('0x6'));var sox=require(_0xb32e('0x7'));var csv=require(_0xb32e('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xb32e('0x9'));var squel=require(_0xb32e('0xa'));var crypto=require('crypto');var jsforce=require(_0xb32e('0xb'));var deskjs=require(_0xb32e('0xc'));var toCsv=require(_0xb32e('0x8'));var querystring=require(_0xb32e('0xd'));var Papa=require('papaparse');var Redis=require(_0xb32e('0xe'));var authService=require(_0xb32e('0xf'));var qs=require(_0xb32e('0x10'));var as=require(_0xb32e('0x11'));var hardwareService=require(_0xb32e('0x12'));var logger=require(_0xb32e('0x13'))(_0xb32e('0x14'));var utils=require(_0xb32e('0x15'));var config=require('../../config/environment');var db=require(_0xb32e('0x16'))['db'];function respondWithStatusCode(_0x244b0a,_0x52123b){_0x52123b=_0x52123b||0xcc;return function(_0x2b9374){if(_0x2b9374){return _0x244b0a[_0xb32e('0x17')](_0x52123b);}return _0x244b0a[_0xb32e('0x18')](_0x52123b)['end']();};}function respondWithResult(_0x410e78,_0x4d7b19){_0x4d7b19=_0x4d7b19||0xc8;return function(_0xe6ee06){if(_0xe6ee06){return _0x410e78['status'](_0x4d7b19)[_0xb32e('0x19')](_0xe6ee06);}};}function respondWithFilteredResult(_0x239524,_0x3ea20c){return function(_0x16df29){if(_0x16df29){var _0x3f1168=_0x16df29['count'],_0x378aee=_0x3ea20c[_0xb32e('0x1a')],_0x2a8f4c=_0x3ea20c[_0xb32e('0x1a')]+_0x3ea20c[_0xb32e('0x1b')],_0x1fba7e;if(_0x2a8f4c>=_0x3f1168){_0x2a8f4c=_0x3f1168;_0x1fba7e=0xc8;}else{_0x1fba7e=0xce;}_0x239524[_0xb32e('0x18')](_0x1fba7e);return _0x239524[_0xb32e('0x1c')]('Content-Range',_0x378aee+'-'+_0x2a8f4c+'/'+_0x3f1168)[_0xb32e('0x19')](_0x16df29);}return null;};}function patchUpdates(_0x2209ff){return function(_0x4022de){try{jsonpatch['apply'](_0x4022de,_0x2209ff,!![]);}catch(_0x49321f){return BPromise[_0xb32e('0x1d')](_0x49321f);}return _0x4022de[_0xb32e('0x1e')]();};}function saveUpdates(_0x149865,_0x594e58){return function(_0x2afe1f){if(_0x2afe1f){return _0x2afe1f[_0xb32e('0x1f')](_0x149865)[_0xb32e('0x20')](function(_0x48db2d){return _0x48db2d;});}return null;};}function removeEntity(_0x3df742,_0x500202){return function(_0x25a7b0){if(_0x25a7b0){return _0x25a7b0[_0xb32e('0x21')]()[_0xb32e('0x20')](function(){_0x3df742[_0xb32e('0x18')](0xcc)[_0xb32e('0x22')]();});}};}function handleEntityNotFound(_0x5bd583,_0x5cc8d1){return function(_0x4cdd7e){if(!_0x4cdd7e){_0x5bd583[_0xb32e('0x17')](0x194);}return _0x4cdd7e;};}function handleError(_0x2c6640,_0x3dd0a0){_0x3dd0a0=_0x3dd0a0||0x1f4;return function(_0x20f18d){logger[_0xb32e('0x23')](_0x20f18d[_0xb32e('0x24')]);if(_0x20f18d[_0xb32e('0x25')]){delete _0x20f18d[_0xb32e('0x25')];}_0x2c6640[_0xb32e('0x18')](_0x3dd0a0)['send'](_0x20f18d);};}exports[_0xb32e('0x26')]=function(_0x3de18f,_0x6a8c04){var _0x3bbcc6={},_0x14372d={},_0x3ce593={'count':0x0,'rows':[]};var _0x49dee7=_[_0xb32e('0x27')](db[_0xb32e('0x28')][_0xb32e('0x29')],function(_0x8eeac6){return{'name':_0x8eeac6[_0xb32e('0x2a')],'type':_0x8eeac6[_0xb32e('0x2b')]['key']};});_0x14372d['model']=_[_0xb32e('0x27')](_0x49dee7,_0xb32e('0x25'));_0x14372d[_0xb32e('0x2c')]=_['keys'](_0x3de18f[_0xb32e('0x2c')]);_0x14372d['filters']=_['intersection'](_0x14372d[_0xb32e('0x2d')],_0x14372d['query']);_0x3bbcc6[_0xb32e('0x2e')]=_[_0xb32e('0x2f')](_0x14372d[_0xb32e('0x2d')],qs[_0xb32e('0x30')](_0x3de18f[_0xb32e('0x2c')][_0xb32e('0x30')]));_0x3bbcc6[_0xb32e('0x2e')]=_0x3bbcc6[_0xb32e('0x2e')][_0xb32e('0x31')]?_0x3bbcc6[_0xb32e('0x2e')]:_0x14372d[_0xb32e('0x2d')];if(!_0x3de18f[_0xb32e('0x2c')][_0xb32e('0x32')]('nolimit')){_0x3bbcc6[_0xb32e('0x1b')]=qs[_0xb32e('0x1b')](_0x3de18f[_0xb32e('0x2c')][_0xb32e('0x1b')]);_0x3bbcc6[_0xb32e('0x1a')]=qs['offset'](_0x3de18f['query'][_0xb32e('0x1a')]);}_0x3bbcc6['order']=qs[_0xb32e('0x33')](_0x3de18f['query'][_0xb32e('0x33')]);_0x3bbcc6[_0xb32e('0x34')]=qs['filters'](_[_0xb32e('0x35')](_0x3de18f['query'],_0x14372d[_0xb32e('0x36')]),_0x49dee7);if(_0x3de18f[_0xb32e('0x2c')][_0xb32e('0x37')]){_0x3bbcc6[_0xb32e('0x34')]=_['merge'](_0x3bbcc6[_0xb32e('0x34')],{'$or':_['map'](_0x49dee7,function(_0x5d9990){if(_0x5d9990[_0xb32e('0x2b')]!==_0xb32e('0x38')){var _0x2c4c24={};_0x2c4c24[_0x5d9990['name']]={'$like':'%'+_0x3de18f['query'][_0xb32e('0x37')]+'%'};return _0x2c4c24;}})});}_0x3bbcc6=_[_0xb32e('0x39')]({},_0x3bbcc6,_0x3de18f['options']);var _0x53051e={'where':_0x3bbcc6[_0xb32e('0x34')]};return db['AnalyticTreeReport'][_0xb32e('0x3a')](_0x53051e)[_0xb32e('0x20')](function(_0x272aa3){_0x3ce593['count']=_0x272aa3;if(_0x3de18f[_0xb32e('0x2c')][_0xb32e('0x3b')]){_0x3bbcc6[_0xb32e('0x3c')]=[{'all':!![]}];}return db['AnalyticTreeReport'][_0xb32e('0x3d')](_0x3bbcc6);})[_0xb32e('0x20')](function(_0x1921ad){_0x3ce593[_0xb32e('0x3e')]=_0x1921ad;return _0x3ce593;})['then'](respondWithFilteredResult(_0x6a8c04,_0x3bbcc6))[_0xb32e('0x3f')](handleError(_0x6a8c04,null));};exports[_0xb32e('0x40')]=function(_0x33fa3d,_0x54cefb){var _0x4f18cf={'raw':!![],'where':{'id':_0x33fa3d['params']['id']}},_0x32bb24={};_0x32bb24['model']=_[_0xb32e('0x41')](db[_0xb32e('0x28')]['rawAttributes']);_0x32bb24['query']=_[_0xb32e('0x41')](_0x33fa3d[_0xb32e('0x2c')]);_0x32bb24[_0xb32e('0x36')]=_[_0xb32e('0x2f')](_0x32bb24['model'],_0x32bb24[_0xb32e('0x2c')]);_0x4f18cf[_0xb32e('0x2e')]=_['intersection'](_0x32bb24[_0xb32e('0x2d')],qs['fields'](_0x33fa3d['query'][_0xb32e('0x30')]));_0x4f18cf[_0xb32e('0x2e')]=_0x4f18cf[_0xb32e('0x2e')][_0xb32e('0x31')]?_0x4f18cf[_0xb32e('0x2e')]:_0x32bb24[_0xb32e('0x2d')];if(_0x33fa3d['query'][_0xb32e('0x3b')]){_0x4f18cf[_0xb32e('0x3c')]=[{'all':!![]}];}_0x4f18cf=_[_0xb32e('0x39')]({},_0x4f18cf,_0x33fa3d['options']);return db[_0xb32e('0x28')][_0xb32e('0x42')](_0x4f18cf)[_0xb32e('0x20')](handleEntityNotFound(_0x54cefb,null))[_0xb32e('0x20')](respondWithResult(_0x54cefb,null))[_0xb32e('0x3f')](handleError(_0x54cefb,null));};exports['create']=function(_0x1b2b66,_0x26f480){return db[_0xb32e('0x28')][_0xb32e('0x43')](_0x1b2b66['body'],{})[_0xb32e('0x20')](respondWithResult(_0x26f480,0xc9))[_0xb32e('0x3f')](handleError(_0x26f480,null));};exports[_0xb32e('0x1f')]=function(_0x528ab6,_0x1a8a9a){if(_0x528ab6['body']['id']){delete _0x528ab6[_0xb32e('0x44')]['id'];}return db[_0xb32e('0x28')][_0xb32e('0x42')]({'where':{'id':_0x528ab6[_0xb32e('0x45')]['id']}})['then'](handleEntityNotFound(_0x1a8a9a,null))['then'](saveUpdates(_0x528ab6[_0xb32e('0x44')],null))[_0xb32e('0x20')](respondWithResult(_0x1a8a9a,null))[_0xb32e('0x3f')](handleError(_0x1a8a9a,null));};exports[_0xb32e('0x21')]=function(_0x3f1e58,_0x1b70a2){return db[_0xb32e('0x28')][_0xb32e('0x42')]({'where':{'id':_0x3f1e58[_0xb32e('0x45')]['id']}})[_0xb32e('0x20')](handleEntityNotFound(_0x1b70a2,null))[_0xb32e('0x20')](removeEntity(_0x1b70a2,null))[_0xb32e('0x3f')](handleError(_0x1b70a2,null));};
\ No newline at end of file
+var _0x746e=['update','then','destroy','end','stack','index','map','AnalyticTreeReport','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','rows','catch','show','find','create','body','params','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','count','set','Content-Range'];(function(_0x387237,_0x22d03c){var _0x14afc6=function(_0x44c280){while(--_0x44c280){_0x387237['push'](_0x387237['shift']());}};_0x14afc6(++_0x22d03c);}(_0x746e,0xf5));var _0xe746=function(_0x57da0a,_0x284aed){_0x57da0a=_0x57da0a-0x0;var _0x3145d5=_0x746e[_0x57da0a];return _0x3145d5;};'use strict';var emlformat=require(_0xe746('0x0'));var rimraf=require(_0xe746('0x1'));var zipdir=require(_0xe746('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe746('0x3'));var moment=require('moment');var BPromise=require(_0xe746('0x4'));var Mustache=require(_0xe746('0x5'));var util=require('util');var path=require('path');var sox=require(_0xe746('0x6'));var csv=require(_0xe746('0x7'));var ejs=require(_0xe746('0x8'));var fs=require('fs');var fs_extra=require(_0xe746('0x9'));var _=require(_0xe746('0xa'));var squel=require('squel');var crypto=require(_0xe746('0xb'));var jsforce=require(_0xe746('0xc'));var deskjs=require(_0xe746('0xd'));var toCsv=require(_0xe746('0x7'));var querystring=require(_0xe746('0xe'));var Papa=require(_0xe746('0xf'));var Redis=require(_0xe746('0x10'));var authService=require(_0xe746('0x11'));var qs=require(_0xe746('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe746('0x13'));var logger=require(_0xe746('0x14'))('api');var utils=require(_0xe746('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xe746('0x16'));var db=require(_0xe746('0x17'))['db'];function respondWithStatusCode(_0x4f0d8f,_0x5de677){_0x5de677=_0x5de677||0xcc;return function(_0x55ac85){if(_0x55ac85){return _0x4f0d8f[_0xe746('0x18')](_0x5de677);}return _0x4f0d8f[_0xe746('0x19')](_0x5de677)['end']();};}function respondWithResult(_0x22a58c,_0x322b9b){_0x322b9b=_0x322b9b||0xc8;return function(_0x3b6164){if(_0x3b6164){return _0x22a58c[_0xe746('0x19')](_0x322b9b)[_0xe746('0x1a')](_0x3b6164);}};}function respondWithFilteredResult(_0x3b98d4,_0x2a1fc9){return function(_0x2f9484){if(_0x2f9484){var _0x577ddb=typeof _0x2a1fc9[_0xe746('0x1b')]==='undefined'&&typeof _0x2a1fc9['limit']==='undefined';var _0x57bb2b=_0x2f9484[_0xe746('0x1c')];var _0xb75c69=_0x577ddb?0x0:_0x2a1fc9[_0xe746('0x1b')];var _0x263a42=_0x577ddb?_0x2f9484[_0xe746('0x1c')]:_0x2a1fc9[_0xe746('0x1b')]+_0x2a1fc9['limit'];var _0xba74fc;if(_0x263a42>=_0x57bb2b){_0x263a42=_0x57bb2b;_0xba74fc=0xc8;}else{_0xba74fc=0xce;}_0x3b98d4[_0xe746('0x19')](_0xba74fc);return _0x3b98d4[_0xe746('0x1d')](_0xe746('0x1e'),_0xb75c69+'-'+_0x263a42+'/'+_0x57bb2b)[_0xe746('0x1a')](_0x2f9484);}return null;};}function patchUpdates(_0x4a1f6d){return function(_0x531c4f){try{jsonpatch['apply'](_0x531c4f,_0x4a1f6d,!![]);}catch(_0x10ff04){return BPromise['reject'](_0x10ff04);}return _0x531c4f['save']();};}function saveUpdates(_0x8546d1,_0xf1c5d7){return function(_0x1dfc60){if(_0x1dfc60){return _0x1dfc60[_0xe746('0x1f')](_0x8546d1)[_0xe746('0x20')](function(_0x50051e){return _0x50051e;});}return null;};}function removeEntity(_0x14794e,_0x379e34){return function(_0x237f1d){if(_0x237f1d){return _0x237f1d[_0xe746('0x21')]()[_0xe746('0x20')](function(){_0x14794e['status'](0xcc)[_0xe746('0x22')]();});}};}function handleEntityNotFound(_0x5a0ee6,_0x134436){return function(_0x435419){if(!_0x435419){_0x5a0ee6[_0xe746('0x18')](0x194);}return _0x435419;};}function handleError(_0x49cf27,_0x555ac8){_0x555ac8=_0x555ac8||0x1f4;return function(_0x326337){logger['error'](_0x326337[_0xe746('0x23')]);if(_0x326337['name']){delete _0x326337['name'];}_0x49cf27[_0xe746('0x19')](_0x555ac8)['send'](_0x326337);};}exports[_0xe746('0x24')]=function(_0x437bec,_0x1cdcc4){var _0x40e572={},_0x2ce164={},_0x1cfd96={'count':0x0,'rows':[]};var _0xb57bbe=_[_0xe746('0x25')](db[_0xe746('0x26')][_0xe746('0x27')],function(_0x165f05){return{'name':_0x165f05[_0xe746('0x28')],'type':_0x165f05[_0xe746('0x29')][_0xe746('0x2a')]};});_0x2ce164[_0xe746('0x2b')]=_[_0xe746('0x25')](_0xb57bbe,'name');_0x2ce164['query']=_[_0xe746('0x2c')](_0x437bec[_0xe746('0x2d')]);_0x2ce164[_0xe746('0x2e')]=_[_0xe746('0x2f')](_0x2ce164[_0xe746('0x2b')],_0x2ce164[_0xe746('0x2d')]);_0x40e572[_0xe746('0x30')]=_[_0xe746('0x2f')](_0x2ce164['model'],qs['fields'](_0x437bec[_0xe746('0x2d')][_0xe746('0x31')]));_0x40e572['attributes']=_0x40e572[_0xe746('0x30')][_0xe746('0x32')]?_0x40e572['attributes']:_0x2ce164[_0xe746('0x2b')];if(!_0x437bec['query']['hasOwnProperty'](_0xe746('0x33'))){_0x40e572[_0xe746('0x34')]=qs[_0xe746('0x34')](_0x437bec[_0xe746('0x2d')][_0xe746('0x34')]);_0x40e572['offset']=qs[_0xe746('0x1b')](_0x437bec[_0xe746('0x2d')][_0xe746('0x1b')]);}_0x40e572[_0xe746('0x35')]=qs['sort'](_0x437bec[_0xe746('0x2d')][_0xe746('0x36')]);_0x40e572[_0xe746('0x37')]=qs[_0xe746('0x2e')](_[_0xe746('0x38')](_0x437bec[_0xe746('0x2d')],_0x2ce164[_0xe746('0x2e')]),_0xb57bbe);if(_0x437bec[_0xe746('0x2d')][_0xe746('0x39')]){_0x40e572['where']=_[_0xe746('0x3a')](_0x40e572[_0xe746('0x37')],{'$or':_[_0xe746('0x25')](_0xb57bbe,function(_0x43d18b){if(_0x43d18b[_0xe746('0x29')]!==_0xe746('0x3b')){var _0x158436={};_0x158436[_0x43d18b['name']]={'$like':'%'+_0x437bec[_0xe746('0x2d')][_0xe746('0x39')]+'%'};return _0x158436;}})});}_0x40e572=_[_0xe746('0x3a')]({},_0x40e572,_0x437bec[_0xe746('0x3c')]);var _0x45293f={'where':_0x40e572['where']};return db['AnalyticTreeReport'][_0xe746('0x1c')](_0x45293f)[_0xe746('0x20')](function(_0x24e986){_0x1cfd96['count']=_0x24e986;if(_0x437bec[_0xe746('0x2d')][_0xe746('0x3d')]){_0x40e572['include']=[{'all':!![]}];}return db['AnalyticTreeReport']['findAll'](_0x40e572);})[_0xe746('0x20')](function(_0x364b4b){_0x1cfd96[_0xe746('0x3e')]=_0x364b4b;return _0x1cfd96;})[_0xe746('0x20')](respondWithFilteredResult(_0x1cdcc4,_0x40e572))[_0xe746('0x3f')](handleError(_0x1cdcc4,null));};exports[_0xe746('0x40')]=function(_0x141028,_0x5153b4){var _0x111745={'raw':!![],'where':{'id':_0x141028['params']['id']}},_0x5d425a={};_0x5d425a[_0xe746('0x2b')]=_[_0xe746('0x2c')](db['AnalyticTreeReport'][_0xe746('0x27')]);_0x5d425a[_0xe746('0x2d')]=_['keys'](_0x141028[_0xe746('0x2d')]);_0x5d425a[_0xe746('0x2e')]=_[_0xe746('0x2f')](_0x5d425a['model'],_0x5d425a[_0xe746('0x2d')]);_0x111745[_0xe746('0x30')]=_[_0xe746('0x2f')](_0x5d425a[_0xe746('0x2b')],qs[_0xe746('0x31')](_0x141028['query'][_0xe746('0x31')]));_0x111745['attributes']=_0x111745[_0xe746('0x30')][_0xe746('0x32')]?_0x111745[_0xe746('0x30')]:_0x5d425a[_0xe746('0x2b')];if(_0x141028[_0xe746('0x2d')][_0xe746('0x3d')]){_0x111745['include']=[{'all':!![]}];}_0x111745=_[_0xe746('0x3a')]({},_0x111745,_0x141028['options']);return db['AnalyticTreeReport'][_0xe746('0x41')](_0x111745)[_0xe746('0x20')](handleEntityNotFound(_0x5153b4,null))[_0xe746('0x20')](respondWithResult(_0x5153b4,null))['catch'](handleError(_0x5153b4,null));};exports['create']=function(_0x5d18da,_0x2f79c9){return db[_0xe746('0x26')][_0xe746('0x42')](_0x5d18da['body'],{})[_0xe746('0x20')](respondWithResult(_0x2f79c9,0xc9))[_0xe746('0x3f')](handleError(_0x2f79c9,null));};exports['update']=function(_0x5883de,_0x187fa9){if(_0x5883de['body']['id']){delete _0x5883de[_0xe746('0x43')]['id'];}return db[_0xe746('0x26')]['find']({'where':{'id':_0x5883de[_0xe746('0x44')]['id']}})[_0xe746('0x20')](handleEntityNotFound(_0x187fa9,null))[_0xe746('0x20')](saveUpdates(_0x5883de['body'],null))[_0xe746('0x20')](respondWithResult(_0x187fa9,null))[_0xe746('0x3f')](handleError(_0x187fa9,null));};exports[_0xe746('0x21')]=function(_0x4477a1,_0x670dbb){return db[_0xe746('0x26')][_0xe746('0x41')]({'where':{'id':_0x4477a1['params']['id']}})['then'](handleEntityNotFound(_0x670dbb,null))[_0xe746('0x20')](removeEntity(_0x670dbb,null))['catch'](handleError(_0x670dbb,null));};
\ No newline at end of file