Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 2401685..4f07c3a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3bc9=['desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','sendStatus','offset','undefined','count','limit','status','set','Content-Range','json','apply','reject','update','end','error','stack','name','index','map','AnalyticTreeReport','rawAttributes','fieldName','key','query','keys','filters','intersection','model','attributes','fields','length','nolimit','order','pick','filter','VIRTUAL','merge','where','then','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce'];(function(_0x52ee7c,_0x14fb87){var _0x1b0208=function(_0x38e261){while(--_0x38e261){_0x52ee7c['push'](_0x52ee7c['shift']());}};_0x1b0208(++_0x14fb87);}(_0x3bc9,0x1b1));var _0x93bc=function(_0x3a5dbe,_0x1633de){_0x3a5dbe=_0x3a5dbe-0x0;var _0x2f1823=_0x3bc9[_0x3a5dbe];return _0x2f1823;};'use strict';var emlformat=require(_0x93bc('0x0'));var rimraf=require(_0x93bc('0x1'));var zipdir=require(_0x93bc('0x2'));var jsonpatch=require(_0x93bc('0x3'));var rp=require(_0x93bc('0x4'));var moment=require(_0x93bc('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x93bc('0x6'));var util=require(_0x93bc('0x7'));var path=require(_0x93bc('0x8'));var sox=require(_0x93bc('0x9'));var csv=require(_0x93bc('0xa'));var ejs=require(_0x93bc('0xb'));var fs=require('fs');var fs_extra=require(_0x93bc('0xc'));var _=require(_0x93bc('0xd'));var squel=require(_0x93bc('0xe'));var crypto=require(_0x93bc('0xf'));var jsforce=require(_0x93bc('0x10'));var deskjs=require(_0x93bc('0x11'));var toCsv=require(_0x93bc('0xa'));var querystring=require(_0x93bc('0x12'));var Papa=require(_0x93bc('0x13'));var Redis=require(_0x93bc('0x14'));var authService=require(_0x93bc('0x15'));var qs=require('../../components/parsers/qs');var as=require(_0x93bc('0x16'));var hardwareService=require(_0x93bc('0x17'));var logger=require(_0x93bc('0x18'))(_0x93bc('0x19'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x45ccad,_0x158e82){_0x158e82=_0x158e82||0xcc;return function(_0x52df3e){if(_0x52df3e){return _0x45ccad[_0x93bc('0x1a')](_0x158e82);}return _0x45ccad['status'](_0x158e82)['end']();};}function respondWithResult(_0x442967,_0x1acdcd){_0x1acdcd=_0x1acdcd||0xc8;return function(_0x3452ad){if(_0x3452ad){return _0x442967['status'](_0x1acdcd)['json'](_0x3452ad);}};}function respondWithFilteredResult(_0x12c80f,_0x7a09d0){return function(_0x46ebd9){if(_0x46ebd9){var _0x516627=typeof _0x7a09d0[_0x93bc('0x1b')]===_0x93bc('0x1c')&&typeof _0x7a09d0['limit']==='undefined';var _0x1ce611=_0x46ebd9['count'];var _0x429497=_0x516627?0x0:_0x7a09d0['offset'];var _0x4c39d9=_0x516627?_0x46ebd9[_0x93bc('0x1d')]:_0x7a09d0['offset']+_0x7a09d0[_0x93bc('0x1e')];var _0x15f63d;if(_0x4c39d9>=_0x1ce611){_0x4c39d9=_0x1ce611;_0x15f63d=0xc8;}else{_0x15f63d=0xce;}_0x12c80f[_0x93bc('0x1f')](_0x15f63d);return _0x12c80f[_0x93bc('0x20')](_0x93bc('0x21'),_0x429497+'-'+_0x4c39d9+'/'+_0x1ce611)[_0x93bc('0x22')](_0x46ebd9);}return null;};}function patchUpdates(_0x3c112f){return function(_0x4df767){try{jsonpatch[_0x93bc('0x23')](_0x4df767,_0x3c112f,!![]);}catch(_0x2d2142){return BPromise[_0x93bc('0x24')](_0x2d2142);}return _0x4df767['save']();};}function saveUpdates(_0x436f43,_0x3ec55b){return function(_0x19fa69){if(_0x19fa69){return _0x19fa69[_0x93bc('0x25')](_0x436f43)['then'](function(_0x5d17ee){return _0x5d17ee;});}return null;};}function removeEntity(_0x4afac1,_0x165540){return function(_0x11098a){if(_0x11098a){return _0x11098a['destroy']()['then'](function(){_0x4afac1[_0x93bc('0x1f')](0xcc)[_0x93bc('0x26')]();});}};}function handleEntityNotFound(_0x45cc4b,_0x547ded){return function(_0x3bafb6){if(!_0x3bafb6){_0x45cc4b['sendStatus'](0x194);}return _0x3bafb6;};}function handleError(_0x48b378,_0x5d28a8){_0x5d28a8=_0x5d28a8||0x1f4;return function(_0x501827){logger[_0x93bc('0x27')](_0x501827[_0x93bc('0x28')]);if(_0x501827['name']){delete _0x501827[_0x93bc('0x29')];}_0x48b378[_0x93bc('0x1f')](_0x5d28a8)['send'](_0x501827);};}exports[_0x93bc('0x2a')]=function(_0x1fc515,_0x244dde){var _0x5ac41b={},_0x39efef={},_0x245a15={'count':0x0,'rows':[]};var _0x227222=_[_0x93bc('0x2b')](db[_0x93bc('0x2c')][_0x93bc('0x2d')],function(_0x6c8209){return{'name':_0x6c8209[_0x93bc('0x2e')],'type':_0x6c8209['type'][_0x93bc('0x2f')]};});_0x39efef['model']=_[_0x93bc('0x2b')](_0x227222,_0x93bc('0x29'));_0x39efef[_0x93bc('0x30')]=_[_0x93bc('0x31')](_0x1fc515[_0x93bc('0x30')]);_0x39efef[_0x93bc('0x32')]=_[_0x93bc('0x33')](_0x39efef[_0x93bc('0x34')],_0x39efef['query']);_0x5ac41b[_0x93bc('0x35')]=_[_0x93bc('0x33')](_0x39efef['model'],qs[_0x93bc('0x36')](_0x1fc515[_0x93bc('0x30')][_0x93bc('0x36')]));_0x5ac41b[_0x93bc('0x35')]=_0x5ac41b['attributes'][_0x93bc('0x37')]?_0x5ac41b[_0x93bc('0x35')]:_0x39efef[_0x93bc('0x34')];if(!_0x1fc515['query']['hasOwnProperty'](_0x93bc('0x38'))){_0x5ac41b[_0x93bc('0x1e')]=qs[_0x93bc('0x1e')](_0x1fc515['query']['limit']);_0x5ac41b[_0x93bc('0x1b')]=qs[_0x93bc('0x1b')](_0x1fc515['query'][_0x93bc('0x1b')]);}_0x5ac41b[_0x93bc('0x39')]=qs['sort'](_0x1fc515[_0x93bc('0x30')]['sort']);_0x5ac41b['where']=qs['filters'](_[_0x93bc('0x3a')](_0x1fc515[_0x93bc('0x30')],_0x39efef[_0x93bc('0x32')]),_0x227222);if(_0x1fc515['query'][_0x93bc('0x3b')]){_0x5ac41b['where']=_['merge'](_0x5ac41b['where'],{'$or':_['map'](_0x227222,function(_0x3d0a91){if(_0x3d0a91['type']!==_0x93bc('0x3c')){var _0x142dfd={};_0x142dfd[_0x3d0a91[_0x93bc('0x29')]]={'$like':'%'+_0x1fc515['query'][_0x93bc('0x3b')]+'%'};return _0x142dfd;}})});}_0x5ac41b=_[_0x93bc('0x3d')]({},_0x5ac41b,_0x1fc515['options']);var _0x4ac3e1={'where':_0x5ac41b[_0x93bc('0x3e')]};return db[_0x93bc('0x2c')][_0x93bc('0x1d')](_0x4ac3e1)[_0x93bc('0x3f')](function(_0x2f1a2a){_0x245a15[_0x93bc('0x1d')]=_0x2f1a2a;if(_0x1fc515[_0x93bc('0x30')][_0x93bc('0x40')]){_0x5ac41b[_0x93bc('0x41')]=[{'all':!![]}];}return db[_0x93bc('0x2c')][_0x93bc('0x42')](_0x5ac41b);})[_0x93bc('0x3f')](function(_0x1f93b2){_0x245a15[_0x93bc('0x43')]=_0x1f93b2;return _0x245a15;})['then'](respondWithFilteredResult(_0x244dde,_0x5ac41b))[_0x93bc('0x44')](handleError(_0x244dde,null));};exports[_0x93bc('0x45')]=function(_0x3e3ce9,_0x1bdf8a){var _0x2a51ea={'raw':!![],'where':{'id':_0x3e3ce9[_0x93bc('0x46')]['id']}},_0x302ddd={};_0x302ddd['model']=_['keys'](db['AnalyticTreeReport'][_0x93bc('0x2d')]);_0x302ddd[_0x93bc('0x30')]=_['keys'](_0x3e3ce9['query']);_0x302ddd[_0x93bc('0x32')]=_[_0x93bc('0x33')](_0x302ddd['model'],_0x302ddd[_0x93bc('0x30')]);_0x2a51ea[_0x93bc('0x35')]=_['intersection'](_0x302ddd['model'],qs[_0x93bc('0x36')](_0x3e3ce9[_0x93bc('0x30')]['fields']));_0x2a51ea[_0x93bc('0x35')]=_0x2a51ea[_0x93bc('0x35')][_0x93bc('0x37')]?_0x2a51ea[_0x93bc('0x35')]:_0x302ddd[_0x93bc('0x34')];if(_0x3e3ce9['query'][_0x93bc('0x40')]){_0x2a51ea[_0x93bc('0x41')]=[{'all':!![]}];}_0x2a51ea=_[_0x93bc('0x3d')]({},_0x2a51ea,_0x3e3ce9[_0x93bc('0x47')]);return db[_0x93bc('0x2c')][_0x93bc('0x48')](_0x2a51ea)['then'](handleEntityNotFound(_0x1bdf8a,null))[_0x93bc('0x3f')](respondWithResult(_0x1bdf8a,null))[_0x93bc('0x44')](handleError(_0x1bdf8a,null));};exports[_0x93bc('0x49')]=function(_0xc9fe5b,_0x40d3ff){return db[_0x93bc('0x2c')][_0x93bc('0x49')](_0xc9fe5b['body'],{})['then'](respondWithResult(_0x40d3ff,0xc9))['catch'](handleError(_0x40d3ff,null));};exports[_0x93bc('0x25')]=function(_0xe4ce3c,_0x2289c4){if(_0xe4ce3c['body']['id']){delete _0xe4ce3c[_0x93bc('0x4a')]['id'];}return db[_0x93bc('0x2c')][_0x93bc('0x48')]({'where':{'id':_0xe4ce3c[_0x93bc('0x46')]['id']}})[_0x93bc('0x3f')](handleEntityNotFound(_0x2289c4,null))[_0x93bc('0x3f')](saveUpdates(_0xe4ce3c[_0x93bc('0x4a')],null))[_0x93bc('0x3f')](respondWithResult(_0x2289c4,null))[_0x93bc('0x44')](handleError(_0x2289c4,null));};exports['destroy']=function(_0x237b04,_0x28c806){return db[_0x93bc('0x2c')][_0x93bc('0x48')]({'where':{'id':_0x237b04[_0x93bc('0x46')]['id']}})[_0x93bc('0x3f')](handleEntityNotFound(_0x28c806,null))[_0x93bc('0x3f')](removeEntity(_0x28c806,null))[_0x93bc('0x44')](handleError(_0x28c806,null));};
\ No newline at end of file
+var _0x37f0=['intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','options','includeAll','findAll','rows','catch','params','keys','rawAttributes','include','find','create','body','update','eml-format','rimraf','fast-json-patch','moment','bluebird','path','sox','ejs','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','end','json','offset','undefined','limit','count','status','set','Content-Range','apply','reject','then','destroy','sendStatus','error','stack','name','send','map','AnalyticTreeReport','type','key','model','query','filters'];(function(_0x48344e,_0xb33d4e){var _0xc4b94e=function(_0x7b996){while(--_0x7b996){_0x48344e['push'](_0x48344e['shift']());}};_0xc4b94e(++_0xb33d4e);}(_0x37f0,0xea));var _0x037f=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x37f0[_0x19e35c];return _0x3e1fe8;};'use strict';var emlformat=require(_0x037f('0x0'));var rimraf=require(_0x037f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x037f('0x2'));var rp=require('request-promise');var moment=require(_0x037f('0x3'));var BPromise=require(_0x037f('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x037f('0x5'));var sox=require(_0x037f('0x6'));var csv=require('to-csv');var ejs=require(_0x037f('0x7'));var fs=require('fs');var fs_extra=require(_0x037f('0x8'));var _=require(_0x037f('0x9'));var squel=require('squel');var crypto=require(_0x037f('0xa'));var jsforce=require(_0x037f('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x037f('0xc'));var Papa=require(_0x037f('0xd'));var Redis=require(_0x037f('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x037f('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x037f('0x10'));var logger=require(_0x037f('0x11'))('api');var utils=require(_0x037f('0x12'));var config=require(_0x037f('0x13'));var licenseUtil=require(_0x037f('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3b675b,_0x36ab88){_0x36ab88=_0x36ab88||0xcc;return function(_0xf41ab9){if(_0xf41ab9){return _0x3b675b['sendStatus'](_0x36ab88);}return _0x3b675b['status'](_0x36ab88)[_0x037f('0x15')]();};}function respondWithResult(_0x1e701b,_0x358db1){_0x358db1=_0x358db1||0xc8;return function(_0x17d6cc){if(_0x17d6cc){return _0x1e701b['status'](_0x358db1)[_0x037f('0x16')](_0x17d6cc);}};}function respondWithFilteredResult(_0x1ed015,_0x2cf606){return function(_0x191304){if(_0x191304){var _0x51cdd6=typeof _0x2cf606[_0x037f('0x17')]===_0x037f('0x18')&&typeof _0x2cf606[_0x037f('0x19')]==='undefined';var _0x2d9ec1=_0x191304[_0x037f('0x1a')];var _0x29c47b=_0x51cdd6?0x0:_0x2cf606[_0x037f('0x17')];var _0x25913e=_0x51cdd6?_0x191304[_0x037f('0x1a')]:_0x2cf606['offset']+_0x2cf606[_0x037f('0x19')];var _0x54274a;if(_0x25913e>=_0x2d9ec1){_0x25913e=_0x2d9ec1;_0x54274a=0xc8;}else{_0x54274a=0xce;}_0x1ed015[_0x037f('0x1b')](_0x54274a);return _0x1ed015[_0x037f('0x1c')](_0x037f('0x1d'),_0x29c47b+'-'+_0x25913e+'/'+_0x2d9ec1)[_0x037f('0x16')](_0x191304);}return null;};}function patchUpdates(_0x3c22b4){return function(_0x477689){try{jsonpatch[_0x037f('0x1e')](_0x477689,_0x3c22b4,!![]);}catch(_0x73574d){return BPromise[_0x037f('0x1f')](_0x73574d);}return _0x477689['save']();};}function saveUpdates(_0x582781,_0x2bfde4){return function(_0x4e3d82){if(_0x4e3d82){return _0x4e3d82['update'](_0x582781)[_0x037f('0x20')](function(_0x506cf2){return _0x506cf2;});}return null;};}function removeEntity(_0x197637,_0x40458f){return function(_0x5794c7){if(_0x5794c7){return _0x5794c7[_0x037f('0x21')]()[_0x037f('0x20')](function(){_0x197637['status'](0xcc)[_0x037f('0x15')]();});}};}function handleEntityNotFound(_0x59085f,_0x448e63){return function(_0x311e16){if(!_0x311e16){_0x59085f[_0x037f('0x22')](0x194);}return _0x311e16;};}function handleError(_0x45ab36,_0x31d4b9){_0x31d4b9=_0x31d4b9||0x1f4;return function(_0x37dfdd){logger[_0x037f('0x23')](_0x37dfdd[_0x037f('0x24')]);if(_0x37dfdd['name']){delete _0x37dfdd[_0x037f('0x25')];}_0x45ab36[_0x037f('0x1b')](_0x31d4b9)[_0x037f('0x26')](_0x37dfdd);};}exports['index']=function(_0x3a1c35,_0x2f33e8){var _0x3f2a5f={},_0x37c4e2={},_0x24cc2d={'count':0x0,'rows':[]};var _0x132f24=_[_0x037f('0x27')](db[_0x037f('0x28')]['rawAttributes'],function(_0x2ecd11){return{'name':_0x2ecd11['fieldName'],'type':_0x2ecd11[_0x037f('0x29')][_0x037f('0x2a')]};});_0x37c4e2[_0x037f('0x2b')]=_[_0x037f('0x27')](_0x132f24,_0x037f('0x25'));_0x37c4e2[_0x037f('0x2c')]=_['keys'](_0x3a1c35[_0x037f('0x2c')]);_0x37c4e2[_0x037f('0x2d')]=_[_0x037f('0x2e')](_0x37c4e2['model'],_0x37c4e2[_0x037f('0x2c')]);_0x3f2a5f[_0x037f('0x2f')]=_[_0x037f('0x2e')](_0x37c4e2[_0x037f('0x2b')],qs[_0x037f('0x30')](_0x3a1c35[_0x037f('0x2c')]['fields']));_0x3f2a5f[_0x037f('0x2f')]=_0x3f2a5f[_0x037f('0x2f')][_0x037f('0x31')]?_0x3f2a5f['attributes']:_0x37c4e2['model'];if(!_0x3a1c35[_0x037f('0x2c')][_0x037f('0x32')](_0x037f('0x33'))){_0x3f2a5f['limit']=qs[_0x037f('0x19')](_0x3a1c35['query'][_0x037f('0x19')]);_0x3f2a5f[_0x037f('0x17')]=qs['offset'](_0x3a1c35[_0x037f('0x2c')][_0x037f('0x17')]);}_0x3f2a5f[_0x037f('0x34')]=qs[_0x037f('0x35')](_0x3a1c35[_0x037f('0x2c')][_0x037f('0x35')]);_0x3f2a5f['where']=qs[_0x037f('0x2d')](_['pick'](_0x3a1c35[_0x037f('0x2c')],_0x37c4e2[_0x037f('0x2d')]),_0x132f24);if(_0x3a1c35['query'][_0x037f('0x36')]){_0x3f2a5f[_0x037f('0x37')]=_[_0x037f('0x38')](_0x3f2a5f[_0x037f('0x37')],{'$or':_[_0x037f('0x27')](_0x132f24,function(_0x1561b1){if(_0x1561b1[_0x037f('0x29')]!=='VIRTUAL'){var _0x40240c={};_0x40240c[_0x1561b1['name']]={'$like':'%'+_0x3a1c35[_0x037f('0x2c')]['filter']+'%'};return _0x40240c;}})});}_0x3f2a5f=_[_0x037f('0x38')]({},_0x3f2a5f,_0x3a1c35[_0x037f('0x39')]);var _0x4f01a0={'where':_0x3f2a5f['where']};return db[_0x037f('0x28')][_0x037f('0x1a')](_0x4f01a0)[_0x037f('0x20')](function(_0x2a25e7){_0x24cc2d[_0x037f('0x1a')]=_0x2a25e7;if(_0x3a1c35[_0x037f('0x2c')][_0x037f('0x3a')]){_0x3f2a5f['include']=[{'all':!![]}];}return db[_0x037f('0x28')][_0x037f('0x3b')](_0x3f2a5f);})[_0x037f('0x20')](function(_0x857818){_0x24cc2d[_0x037f('0x3c')]=_0x857818;return _0x24cc2d;})['then'](respondWithFilteredResult(_0x2f33e8,_0x3f2a5f))[_0x037f('0x3d')](handleError(_0x2f33e8,null));};exports['show']=function(_0x2f7d96,_0x35200e){var _0x33dbb3={'raw':!![],'where':{'id':_0x2f7d96[_0x037f('0x3e')]['id']}},_0x4a720f={};_0x4a720f['model']=_[_0x037f('0x3f')](db[_0x037f('0x28')][_0x037f('0x40')]);_0x4a720f[_0x037f('0x2c')]=_[_0x037f('0x3f')](_0x2f7d96[_0x037f('0x2c')]);_0x4a720f[_0x037f('0x2d')]=_[_0x037f('0x2e')](_0x4a720f[_0x037f('0x2b')],_0x4a720f[_0x037f('0x2c')]);_0x33dbb3[_0x037f('0x2f')]=_['intersection'](_0x4a720f[_0x037f('0x2b')],qs[_0x037f('0x30')](_0x2f7d96[_0x037f('0x2c')][_0x037f('0x30')]));_0x33dbb3[_0x037f('0x2f')]=_0x33dbb3['attributes'][_0x037f('0x31')]?_0x33dbb3[_0x037f('0x2f')]:_0x4a720f[_0x037f('0x2b')];if(_0x2f7d96[_0x037f('0x2c')]['includeAll']){_0x33dbb3[_0x037f('0x41')]=[{'all':!![]}];}_0x33dbb3=_[_0x037f('0x38')]({},_0x33dbb3,_0x2f7d96[_0x037f('0x39')]);return db[_0x037f('0x28')][_0x037f('0x42')](_0x33dbb3)[_0x037f('0x20')](handleEntityNotFound(_0x35200e,null))[_0x037f('0x20')](respondWithResult(_0x35200e,null))[_0x037f('0x3d')](handleError(_0x35200e,null));};exports[_0x037f('0x43')]=function(_0x5dd678,_0x3cfe0c){return db['AnalyticTreeReport'][_0x037f('0x43')](_0x5dd678[_0x037f('0x44')],{})[_0x037f('0x20')](respondWithResult(_0x3cfe0c,0xc9))['catch'](handleError(_0x3cfe0c,null));};exports[_0x037f('0x45')]=function(_0x38a06a,_0xea7a8f){if(_0x38a06a[_0x037f('0x44')]['id']){delete _0x38a06a[_0x037f('0x44')]['id'];}return db[_0x037f('0x28')][_0x037f('0x42')]({'where':{'id':_0x38a06a[_0x037f('0x3e')]['id']}})[_0x037f('0x20')](handleEntityNotFound(_0xea7a8f,null))['then'](saveUpdates(_0x38a06a[_0x037f('0x44')],null))[_0x037f('0x20')](respondWithResult(_0xea7a8f,null))[_0x037f('0x3d')](handleError(_0xea7a8f,null));};exports[_0x037f('0x21')]=function(_0x5dab04,_0x55f3e6){return db[_0x037f('0x28')]['find']({'where':{'id':_0x5dab04[_0x037f('0x3e')]['id']}})[_0x037f('0x20')](handleEntityNotFound(_0x55f3e6,null))['then'](removeEntity(_0x55f3e6,null))['catch'](handleError(_0x55f3e6,null));};
\ No newline at end of file