Built motion from commit (unavailable).|2.5.27
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 7a5d604..05b3176 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff58=['zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','count','offset','limit','set','Content-Range','json','apply','reject','save','update','then','destroy','stack','name','send','index','map','AnalyticTreeReport','rawAttributes','type','key','model','query','keys','intersection','fields','attributes','hasOwnProperty','sort','where','pick','filter','merge','options','include','findAll','rows','catch','show','params','length','includeAll','find','create','body','eml-format','rimraf'];(function(_0x2db12b,_0x30ab1d){var _0x20990b=function(_0x589477){while(--_0x589477){_0x2db12b['push'](_0x2db12b['shift']());}};_0x20990b(++_0x30ab1d);}(_0xff58,0x1a8));var _0x8ff5=function(_0x539709,_0x2c9edd){_0x539709=_0x539709-0x0;var _0x73cc7e=_0xff58[_0x539709];return _0x73cc7e;};'use strict';var emlformat=require(_0x8ff5('0x0'));var rimraf=require(_0x8ff5('0x1'));var zipdir=require(_0x8ff5('0x2'));var jsonpatch=require(_0x8ff5('0x3'));var rp=require(_0x8ff5('0x4'));var moment=require(_0x8ff5('0x5'));var BPromise=require(_0x8ff5('0x6'));var Mustache=require(_0x8ff5('0x7'));var util=require(_0x8ff5('0x8'));var path=require(_0x8ff5('0x9'));var sox=require(_0x8ff5('0xa'));var csv=require(_0x8ff5('0xb'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x8ff5('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x8ff5('0xd'));var toCsv=require(_0x8ff5('0xb'));var querystring=require('querystring');var Papa=require(_0x8ff5('0xe'));var Redis=require(_0x8ff5('0xf'));var authService=require(_0x8ff5('0x10'));var qs=require(_0x8ff5('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8ff5('0x12'));var logger=require(_0x8ff5('0x13'))(_0x8ff5('0x14'));var utils=require('../../config/utils');var config=require(_0x8ff5('0x15'));var licenseUtil=require(_0x8ff5('0x16'));var db=require(_0x8ff5('0x17'))['db'];function respondWithStatusCode(_0xd228df,_0x1819fc){_0x1819fc=_0x1819fc||0xcc;return function(_0x5c772c){if(_0x5c772c){return _0xd228df[_0x8ff5('0x18')](_0x1819fc);}return _0xd228df[_0x8ff5('0x19')](_0x1819fc)['end']();};}function respondWithResult(_0x1c4799,_0x5e953c){_0x5e953c=_0x5e953c||0xc8;return function(_0x5bbd7b){if(_0x5bbd7b){return _0x1c4799['status'](_0x5e953c)['json'](_0x5bbd7b);}};}function respondWithFilteredResult(_0x32ebc1,_0x188133){return function(_0x32a964){if(_0x32a964){var _0x45aebf=_0x32a964[_0x8ff5('0x1a')],_0x2b8eeb=_0x188133[_0x8ff5('0x1b')],_0x1be1ec=_0x188133['offset']+_0x188133[_0x8ff5('0x1c')],_0x50a485;if(_0x1be1ec>=_0x45aebf){_0x1be1ec=_0x45aebf;_0x50a485=0xc8;}else{_0x50a485=0xce;}_0x32ebc1[_0x8ff5('0x19')](_0x50a485);return _0x32ebc1[_0x8ff5('0x1d')](_0x8ff5('0x1e'),_0x2b8eeb+'-'+_0x1be1ec+'/'+_0x45aebf)[_0x8ff5('0x1f')](_0x32a964);}return null;};}function patchUpdates(_0x59a904){return function(_0x53d5df){try{jsonpatch[_0x8ff5('0x20')](_0x53d5df,_0x59a904,!![]);}catch(_0x424415){return BPromise[_0x8ff5('0x21')](_0x424415);}return _0x53d5df[_0x8ff5('0x22')]();};}function saveUpdates(_0x145395,_0x347c3c){return function(_0x5a9d5f){if(_0x5a9d5f){return _0x5a9d5f[_0x8ff5('0x23')](_0x145395)[_0x8ff5('0x24')](function(_0x1692f1){return _0x1692f1;});}return null;};}function removeEntity(_0x34a6f1,_0x2ce2e7){return function(_0x5b2689){if(_0x5b2689){return _0x5b2689[_0x8ff5('0x25')]()['then'](function(){_0x34a6f1['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x15f7c4,_0x443a58){return function(_0x171358){if(!_0x171358){_0x15f7c4[_0x8ff5('0x18')](0x194);}return _0x171358;};}function handleError(_0x1983df,_0x524983){_0x524983=_0x524983||0x1f4;return function(_0x953f02){logger['error'](_0x953f02[_0x8ff5('0x26')]);if(_0x953f02['name']){delete _0x953f02[_0x8ff5('0x27')];}_0x1983df[_0x8ff5('0x19')](_0x524983)[_0x8ff5('0x28')](_0x953f02);};}exports[_0x8ff5('0x29')]=function(_0x132062,_0x4b4b44){var _0x78ff10={},_0x574afd={},_0x4ff319={'count':0x0,'rows':[]};var _0x3ef133=_[_0x8ff5('0x2a')](db[_0x8ff5('0x2b')][_0x8ff5('0x2c')],function(_0x3f6649){return{'name':_0x3f6649['fieldName'],'type':_0x3f6649[_0x8ff5('0x2d')][_0x8ff5('0x2e')]};});_0x574afd[_0x8ff5('0x2f')]=_[_0x8ff5('0x2a')](_0x3ef133,'name');_0x574afd[_0x8ff5('0x30')]=_[_0x8ff5('0x31')](_0x132062['query']);_0x574afd['filters']=_[_0x8ff5('0x32')](_0x574afd[_0x8ff5('0x2f')],_0x574afd['query']);_0x78ff10['attributes']=_[_0x8ff5('0x32')](_0x574afd[_0x8ff5('0x2f')],qs['fields'](_0x132062[_0x8ff5('0x30')][_0x8ff5('0x33')]));_0x78ff10[_0x8ff5('0x34')]=_0x78ff10['attributes']['length']?_0x78ff10['attributes']:_0x574afd[_0x8ff5('0x2f')];if(!_0x132062['query'][_0x8ff5('0x35')]('nolimit')){_0x78ff10[_0x8ff5('0x1c')]=qs[_0x8ff5('0x1c')](_0x132062[_0x8ff5('0x30')][_0x8ff5('0x1c')]);_0x78ff10[_0x8ff5('0x1b')]=qs[_0x8ff5('0x1b')](_0x132062['query']['offset']);}_0x78ff10['order']=qs[_0x8ff5('0x36')](_0x132062[_0x8ff5('0x30')][_0x8ff5('0x36')]);_0x78ff10[_0x8ff5('0x37')]=qs['filters'](_[_0x8ff5('0x38')](_0x132062[_0x8ff5('0x30')],_0x574afd['filters']),_0x3ef133);if(_0x132062[_0x8ff5('0x30')][_0x8ff5('0x39')]){_0x78ff10['where']=_[_0x8ff5('0x3a')](_0x78ff10['where'],{'$or':_[_0x8ff5('0x2a')](_0x3ef133,function(_0x3b55fe){if(_0x3b55fe[_0x8ff5('0x2d')]!=='VIRTUAL'){var _0x461a87={};_0x461a87[_0x3b55fe['name']]={'$like':'%'+_0x132062['query']['filter']+'%'};return _0x461a87;}})});}_0x78ff10=_['merge']({},_0x78ff10,_0x132062[_0x8ff5('0x3b')]);var _0x40796b={'where':_0x78ff10[_0x8ff5('0x37')]};return db[_0x8ff5('0x2b')][_0x8ff5('0x1a')](_0x40796b)['then'](function(_0x3a5ec7){_0x4ff319[_0x8ff5('0x1a')]=_0x3a5ec7;if(_0x132062['query']['includeAll']){_0x78ff10[_0x8ff5('0x3c')]=[{'all':!![]}];}return db[_0x8ff5('0x2b')][_0x8ff5('0x3d')](_0x78ff10);})[_0x8ff5('0x24')](function(_0xea44db){_0x4ff319[_0x8ff5('0x3e')]=_0xea44db;return _0x4ff319;})[_0x8ff5('0x24')](respondWithFilteredResult(_0x4b4b44,_0x78ff10))[_0x8ff5('0x3f')](handleError(_0x4b4b44,null));};exports[_0x8ff5('0x40')]=function(_0x2d1dd8,_0x2f8a47){var _0x52e7fd={'raw':!![],'where':{'id':_0x2d1dd8[_0x8ff5('0x41')]['id']}},_0x57a37b={};_0x57a37b[_0x8ff5('0x2f')]=_[_0x8ff5('0x31')](db[_0x8ff5('0x2b')][_0x8ff5('0x2c')]);_0x57a37b[_0x8ff5('0x30')]=_[_0x8ff5('0x31')](_0x2d1dd8[_0x8ff5('0x30')]);_0x57a37b['filters']=_[_0x8ff5('0x32')](_0x57a37b[_0x8ff5('0x2f')],_0x57a37b[_0x8ff5('0x30')]);_0x52e7fd['attributes']=_[_0x8ff5('0x32')](_0x57a37b[_0x8ff5('0x2f')],qs[_0x8ff5('0x33')](_0x2d1dd8[_0x8ff5('0x30')]['fields']));_0x52e7fd[_0x8ff5('0x34')]=_0x52e7fd['attributes'][_0x8ff5('0x42')]?_0x52e7fd[_0x8ff5('0x34')]:_0x57a37b[_0x8ff5('0x2f')];if(_0x2d1dd8[_0x8ff5('0x30')][_0x8ff5('0x43')]){_0x52e7fd['include']=[{'all':!![]}];}_0x52e7fd=_[_0x8ff5('0x3a')]({},_0x52e7fd,_0x2d1dd8[_0x8ff5('0x3b')]);return db[_0x8ff5('0x2b')][_0x8ff5('0x44')](_0x52e7fd)[_0x8ff5('0x24')](handleEntityNotFound(_0x2f8a47,null))[_0x8ff5('0x24')](respondWithResult(_0x2f8a47,null))[_0x8ff5('0x3f')](handleError(_0x2f8a47,null));};exports[_0x8ff5('0x45')]=function(_0x4c83c8,_0x5b4fae){return db[_0x8ff5('0x2b')]['create'](_0x4c83c8[_0x8ff5('0x46')],{})[_0x8ff5('0x24')](respondWithResult(_0x5b4fae,0xc9))[_0x8ff5('0x3f')](handleError(_0x5b4fae,null));};exports[_0x8ff5('0x23')]=function(_0x4abb8d,_0x11d879){if(_0x4abb8d['body']['id']){delete _0x4abb8d[_0x8ff5('0x46')]['id'];}return db[_0x8ff5('0x2b')][_0x8ff5('0x44')]({'where':{'id':_0x4abb8d['params']['id']}})[_0x8ff5('0x24')](handleEntityNotFound(_0x11d879,null))[_0x8ff5('0x24')](saveUpdates(_0x4abb8d[_0x8ff5('0x46')],null))['then'](respondWithResult(_0x11d879,null))[_0x8ff5('0x3f')](handleError(_0x11d879,null));};exports[_0x8ff5('0x25')]=function(_0x57eec9,_0xe0e14b){return db[_0x8ff5('0x2b')]['find']({'where':{'id':_0x57eec9[_0x8ff5('0x41')]['id']}})['then'](handleEntityNotFound(_0xe0e14b,null))[_0x8ff5('0x24')](removeEntity(_0xe0e14b,null))[_0x8ff5('0x3f')](handleError(_0xe0e14b,null));};
\ No newline at end of file
+var _0x7995=['../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','count','offset','Content-Range','apply','reject','update','then','destroy','end','error','name','send','index','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','filter','where','VIRTUAL','merge','AnalyticTreeReport','includeAll','findAll','rows','catch','show','rawAttributes','include','options','find','create','body','params','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring'];(function(_0x50d059,_0x4bfc87){var _0x387988=function(_0x28c79f){while(--_0x28c79f){_0x50d059['push'](_0x50d059['shift']());}};_0x387988(++_0x4bfc87);}(_0x7995,0xd3));var _0x5799=function(_0x2406c6,_0x3a8996){_0x2406c6=_0x2406c6-0x0;var _0xef14dd=_0x7995[_0x2406c6];return _0xef14dd;};'use strict';var emlformat=require(_0x5799('0x0'));var rimraf=require(_0x5799('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x5799('0x2'));var rp=require(_0x5799('0x3'));var moment=require(_0x5799('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x5799('0x5'));var util=require(_0x5799('0x6'));var path=require(_0x5799('0x7'));var sox=require(_0x5799('0x8'));var csv=require(_0x5799('0x9'));var ejs=require(_0x5799('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5799('0xb'));var squel=require(_0x5799('0xc'));var crypto=require(_0x5799('0xd'));var jsforce=require(_0x5799('0xe'));var deskjs=require(_0x5799('0xf'));var toCsv=require(_0x5799('0x9'));var querystring=require(_0x5799('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x5799('0x11'));var qs=require(_0x5799('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5799('0x13'));var logger=require(_0x5799('0x14'))(_0x5799('0x15'));var utils=require(_0x5799('0x16'));var config=require(_0x5799('0x17'));var licenseUtil=require(_0x5799('0x18'));var db=require(_0x5799('0x19'))['db'];function respondWithStatusCode(_0x16eff8,_0x515a5b){_0x515a5b=_0x515a5b||0xcc;return function(_0x337ef8){if(_0x337ef8){return _0x16eff8[_0x5799('0x1a')](_0x515a5b);}return _0x16eff8[_0x5799('0x1b')](_0x515a5b)['end']();};}function respondWithResult(_0x2cfc80,_0x276754){_0x276754=_0x276754||0xc8;return function(_0x27888b){if(_0x27888b){return _0x2cfc80['status'](_0x276754)[_0x5799('0x1c')](_0x27888b);}};}function respondWithFilteredResult(_0x2368fb,_0x304c2a){return function(_0x5aa2bc){if(_0x5aa2bc){var _0x168d63=_0x5aa2bc[_0x5799('0x1d')],_0x1d8028=_0x304c2a[_0x5799('0x1e')],_0x4bf898=_0x304c2a[_0x5799('0x1e')]+_0x304c2a['limit'],_0x28d476;if(_0x4bf898>=_0x168d63){_0x4bf898=_0x168d63;_0x28d476=0xc8;}else{_0x28d476=0xce;}_0x2368fb['status'](_0x28d476);return _0x2368fb['set'](_0x5799('0x1f'),_0x1d8028+'-'+_0x4bf898+'/'+_0x168d63)['json'](_0x5aa2bc);}return null;};}function patchUpdates(_0xb25a24){return function(_0x17cbd4){try{jsonpatch[_0x5799('0x20')](_0x17cbd4,_0xb25a24,!![]);}catch(_0x4b1d5a){return BPromise[_0x5799('0x21')](_0x4b1d5a);}return _0x17cbd4['save']();};}function saveUpdates(_0x22c0b9,_0x2d293c){return function(_0x25acff){if(_0x25acff){return _0x25acff[_0x5799('0x22')](_0x22c0b9)[_0x5799('0x23')](function(_0x339cb3){return _0x339cb3;});}return null;};}function removeEntity(_0x4d1c38,_0x3b05b4){return function(_0x355801){if(_0x355801){return _0x355801[_0x5799('0x24')]()[_0x5799('0x23')](function(){_0x4d1c38[_0x5799('0x1b')](0xcc)[_0x5799('0x25')]();});}};}function handleEntityNotFound(_0x5a34e5,_0x2f9302){return function(_0x42007c){if(!_0x42007c){_0x5a34e5[_0x5799('0x1a')](0x194);}return _0x42007c;};}function handleError(_0x56f227,_0x33319e){_0x33319e=_0x33319e||0x1f4;return function(_0x52326f){logger[_0x5799('0x26')](_0x52326f['stack']);if(_0x52326f[_0x5799('0x27')]){delete _0x52326f[_0x5799('0x27')];}_0x56f227['status'](_0x33319e)[_0x5799('0x28')](_0x52326f);};}exports[_0x5799('0x29')]=function(_0x145682,_0x28a830){var _0x4b8f1b={},_0x24d665={},_0x22e2cc={'count':0x0,'rows':[]};var _0x1dc96a=_['map'](db['AnalyticTreeReport']['rawAttributes'],function(_0x55343f){return{'name':_0x55343f[_0x5799('0x2a')],'type':_0x55343f[_0x5799('0x2b')][_0x5799('0x2c')]};});_0x24d665[_0x5799('0x2d')]=_[_0x5799('0x2e')](_0x1dc96a,'name');_0x24d665[_0x5799('0x2f')]=_[_0x5799('0x30')](_0x145682[_0x5799('0x2f')]);_0x24d665[_0x5799('0x31')]=_[_0x5799('0x32')](_0x24d665[_0x5799('0x2d')],_0x24d665[_0x5799('0x2f')]);_0x4b8f1b['attributes']=_[_0x5799('0x32')](_0x24d665[_0x5799('0x2d')],qs[_0x5799('0x33')](_0x145682[_0x5799('0x2f')][_0x5799('0x33')]));_0x4b8f1b[_0x5799('0x34')]=_0x4b8f1b[_0x5799('0x34')][_0x5799('0x35')]?_0x4b8f1b[_0x5799('0x34')]:_0x24d665[_0x5799('0x2d')];if(!_0x145682[_0x5799('0x2f')][_0x5799('0x36')](_0x5799('0x37'))){_0x4b8f1b[_0x5799('0x38')]=qs[_0x5799('0x38')](_0x145682[_0x5799('0x2f')][_0x5799('0x38')]);_0x4b8f1b[_0x5799('0x1e')]=qs[_0x5799('0x1e')](_0x145682[_0x5799('0x2f')][_0x5799('0x1e')]);}_0x4b8f1b[_0x5799('0x39')]=qs['sort'](_0x145682[_0x5799('0x2f')][_0x5799('0x3a')]);_0x4b8f1b['where']=qs[_0x5799('0x31')](_['pick'](_0x145682[_0x5799('0x2f')],_0x24d665[_0x5799('0x31')]),_0x1dc96a);if(_0x145682[_0x5799('0x2f')][_0x5799('0x3b')]){_0x4b8f1b[_0x5799('0x3c')]=_['merge'](_0x4b8f1b[_0x5799('0x3c')],{'$or':_['map'](_0x1dc96a,function(_0x5286c8){if(_0x5286c8[_0x5799('0x2b')]!==_0x5799('0x3d')){var _0x1e641d={};_0x1e641d[_0x5286c8['name']]={'$like':'%'+_0x145682[_0x5799('0x2f')][_0x5799('0x3b')]+'%'};return _0x1e641d;}})});}_0x4b8f1b=_[_0x5799('0x3e')]({},_0x4b8f1b,_0x145682['options']);var _0x38eb01={'where':_0x4b8f1b['where']};return db[_0x5799('0x3f')][_0x5799('0x1d')](_0x38eb01)[_0x5799('0x23')](function(_0x1bc136){_0x22e2cc[_0x5799('0x1d')]=_0x1bc136;if(_0x145682[_0x5799('0x2f')][_0x5799('0x40')]){_0x4b8f1b['include']=[{'all':!![]}];}return db[_0x5799('0x3f')][_0x5799('0x41')](_0x4b8f1b);})[_0x5799('0x23')](function(_0x2d9ec9){_0x22e2cc[_0x5799('0x42')]=_0x2d9ec9;return _0x22e2cc;})[_0x5799('0x23')](respondWithFilteredResult(_0x28a830,_0x4b8f1b))[_0x5799('0x43')](handleError(_0x28a830,null));};exports[_0x5799('0x44')]=function(_0x106027,_0x45f7d9){var _0x3db009={'raw':!![],'where':{'id':_0x106027['params']['id']}},_0x4aeef6={};_0x4aeef6['model']=_['keys'](db['AnalyticTreeReport'][_0x5799('0x45')]);_0x4aeef6[_0x5799('0x2f')]=_[_0x5799('0x30')](_0x106027[_0x5799('0x2f')]);_0x4aeef6[_0x5799('0x31')]=_[_0x5799('0x32')](_0x4aeef6[_0x5799('0x2d')],_0x4aeef6[_0x5799('0x2f')]);_0x3db009[_0x5799('0x34')]=_['intersection'](_0x4aeef6[_0x5799('0x2d')],qs['fields'](_0x106027[_0x5799('0x2f')][_0x5799('0x33')]));_0x3db009[_0x5799('0x34')]=_0x3db009[_0x5799('0x34')][_0x5799('0x35')]?_0x3db009[_0x5799('0x34')]:_0x4aeef6['model'];if(_0x106027[_0x5799('0x2f')][_0x5799('0x40')]){_0x3db009[_0x5799('0x46')]=[{'all':!![]}];}_0x3db009=_[_0x5799('0x3e')]({},_0x3db009,_0x106027[_0x5799('0x47')]);return db[_0x5799('0x3f')][_0x5799('0x48')](_0x3db009)[_0x5799('0x23')](handleEntityNotFound(_0x45f7d9,null))['then'](respondWithResult(_0x45f7d9,null))['catch'](handleError(_0x45f7d9,null));};exports[_0x5799('0x49')]=function(_0x391632,_0x531be7){return db[_0x5799('0x3f')][_0x5799('0x49')](_0x391632[_0x5799('0x4a')],{})[_0x5799('0x23')](respondWithResult(_0x531be7,0xc9))[_0x5799('0x43')](handleError(_0x531be7,null));};exports['update']=function(_0x5dc581,_0x18979a){if(_0x5dc581[_0x5799('0x4a')]['id']){delete _0x5dc581[_0x5799('0x4a')]['id'];}return db['AnalyticTreeReport'][_0x5799('0x48')]({'where':{'id':_0x5dc581[_0x5799('0x4b')]['id']}})[_0x5799('0x23')](handleEntityNotFound(_0x18979a,null))[_0x5799('0x23')](saveUpdates(_0x5dc581[_0x5799('0x4a')],null))['then'](respondWithResult(_0x18979a,null))[_0x5799('0x43')](handleError(_0x18979a,null));};exports[_0x5799('0x24')]=function(_0x598594,_0x1d0366){return db[_0x5799('0x3f')]['find']({'where':{'id':_0x598594[_0x5799('0x4b')]['id']}})[_0x5799('0x23')](handleEntityNotFound(_0x1d0366,null))[_0x5799('0x23')](removeEntity(_0x1d0366,null))[_0x5799('0x43')](handleError(_0x1d0366,null));};
\ No newline at end of file