Built motion from commit 9e1399f3.|2.5.37
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index 595bf7c..fa53e40 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe27d=['update','then','destroy','error','stack','name','send','map','AnalyticTreeReport','rawAttributes','key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','catch','body','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject'];(function(_0x1e7b16,_0x4607a1){var _0x37fadc=function(_0x1fc9ce){while(--_0x1fc9ce){_0x1e7b16['push'](_0x1e7b16['shift']());}};_0x37fadc(++_0x4607a1);}(_0xe27d,0x14f));var _0xde27=function(_0x6aad74,_0x32ecf4){_0x6aad74=_0x6aad74-0x0;var _0x5b1c38=_0xe27d[_0x6aad74];return _0x5b1c38;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xde27('0x0'));var rimraf=require(_0xde27('0x1'));var zipdir=require(_0xde27('0x2'));var jsonpatch=require(_0xde27('0x3'));var rp=require('request-promise');var moment=require(_0xde27('0x4'));var BPromise=require(_0xde27('0x5'));var Mustache=require(_0xde27('0x6'));var util=require('util');var path=require(_0xde27('0x7'));var sox=require(_0xde27('0x8'));var csv=require(_0xde27('0x9'));var ejs=require(_0xde27('0xa'));var fs=require('fs');var _=require(_0xde27('0xb'));var squel=require('squel');var crypto=require(_0xde27('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xde27('0xd'));var toCsv=require('to-csv');var querystring=require(_0xde27('0xe'));var Papa=require(_0xde27('0xf'));var Redis=require(_0xde27('0x10'));var authService=require(_0xde27('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xde27('0x12'));var hardwareService=require(_0xde27('0x13'));var logger=require(_0xde27('0x14'))(_0xde27('0x15'));var utils=require(_0xde27('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xde27('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4894ff,_0x21b6af){_0x21b6af=_0x21b6af||0xcc;return function(_0x587c7b){if(_0x587c7b){return _0x4894ff[_0xde27('0x18')](_0x21b6af);}return _0x4894ff[_0xde27('0x19')](_0x21b6af)[_0xde27('0x1a')]();};}function respondWithResult(_0x53ee50,_0x2e3400){_0x2e3400=_0x2e3400||0xc8;return function(_0xe8d388){if(_0xe8d388){return _0x53ee50[_0xde27('0x19')](_0x2e3400)[_0xde27('0x1b')](_0xe8d388);}};}function respondWithFilteredResult(_0x1a4932,_0x42b3a2){return function(_0x37ffeb){if(_0x37ffeb){var _0x547176=_0x37ffeb[_0xde27('0x1c')],_0x2179a3=_0x42b3a2[_0xde27('0x1d')],_0xef3eea=_0x42b3a2[_0xde27('0x1d')]+_0x42b3a2[_0xde27('0x1e')],_0x795e3b;if(_0xef3eea>=_0x547176){_0xef3eea=_0x547176;_0x795e3b=0xc8;}else{_0x795e3b=0xce;}_0x1a4932[_0xde27('0x19')](_0x795e3b);return _0x1a4932[_0xde27('0x1f')](_0xde27('0x20'),_0x2179a3+'-'+_0xef3eea+'/'+_0x547176)[_0xde27('0x1b')](_0x37ffeb);}return null;};}function patchUpdates(_0x1f33e7){return function(_0x14b0e9){try{jsonpatch[_0xde27('0x21')](_0x14b0e9,_0x1f33e7,!![]);}catch(_0x573a7a){return BPromise[_0xde27('0x22')](_0x573a7a);}return _0x14b0e9['save']();};}function saveUpdates(_0x27bc61,_0x4e6294){return function(_0x481330){if(_0x481330){return _0x481330[_0xde27('0x23')](_0x27bc61)[_0xde27('0x24')](function(_0xc1ed6a){return _0xc1ed6a;});}return null;};}function removeEntity(_0x847fd0,_0x31b89e){return function(_0x4c58f2){if(_0x4c58f2){return _0x4c58f2[_0xde27('0x25')]()['then'](function(){_0x847fd0['status'](0xcc)[_0xde27('0x1a')]();});}};}function handleEntityNotFound(_0xd756,_0x5e1c53){return function(_0x527cbc){if(!_0x527cbc){_0xd756[_0xde27('0x18')](0x194);}return _0x527cbc;};}function handleError(_0x4976fa,_0x1ae891){_0x1ae891=_0x1ae891||0x1f4;return function(_0x4432fb){logger[_0xde27('0x26')](_0x4432fb[_0xde27('0x27')]);if(_0x4432fb[_0xde27('0x28')]){delete _0x4432fb[_0xde27('0x28')];}_0x4976fa[_0xde27('0x19')](_0x1ae891)[_0xde27('0x29')](_0x4432fb);};}exports['index']=function(_0x26a65e,_0x2eb32a){var _0x252eec={},_0x477f62={},_0x3bda58={'count':0x0,'rows':[]};var _0x499888=_[_0xde27('0x2a')](db[_0xde27('0x2b')][_0xde27('0x2c')],function(_0x3968d3){return{'name':_0x3968d3['fieldName'],'type':_0x3968d3['type'][_0xde27('0x2d')]};});_0x477f62[_0xde27('0x2e')]=_[_0xde27('0x2a')](_0x499888,_0xde27('0x28'));_0x477f62['query']=_[_0xde27('0x2f')](_0x26a65e[_0xde27('0x30')]);_0x477f62['filters']=_[_0xde27('0x31')](_0x477f62['model'],_0x477f62[_0xde27('0x30')]);_0x252eec[_0xde27('0x32')]=_[_0xde27('0x31')](_0x477f62[_0xde27('0x2e')],qs[_0xde27('0x33')](_0x26a65e[_0xde27('0x30')][_0xde27('0x33')]));_0x252eec[_0xde27('0x32')]=_0x252eec[_0xde27('0x32')][_0xde27('0x34')]?_0x252eec['attributes']:_0x477f62[_0xde27('0x2e')];if(!_0x26a65e['query'][_0xde27('0x35')](_0xde27('0x36'))){_0x252eec[_0xde27('0x1e')]=qs[_0xde27('0x1e')](_0x26a65e[_0xde27('0x30')][_0xde27('0x1e')]);_0x252eec[_0xde27('0x1d')]=qs[_0xde27('0x1d')](_0x26a65e[_0xde27('0x30')][_0xde27('0x1d')]);}_0x252eec[_0xde27('0x37')]=qs['sort'](_0x26a65e[_0xde27('0x30')][_0xde27('0x38')]);_0x252eec[_0xde27('0x39')]=qs['filters'](_[_0xde27('0x3a')](_0x26a65e[_0xde27('0x30')],_0x477f62[_0xde27('0x3b')]),_0x499888);if(_0x26a65e['query'][_0xde27('0x3c')]){_0x252eec[_0xde27('0x39')]=_[_0xde27('0x3d')](_0x252eec[_0xde27('0x39')],{'$or':_[_0xde27('0x2a')](_0x499888,function(_0x3b99c9){if(_0x3b99c9[_0xde27('0x3e')]!==_0xde27('0x3f')){var _0xd4b8aa={};_0xd4b8aa[_0x3b99c9[_0xde27('0x28')]]={'$like':'%'+_0x26a65e['query'][_0xde27('0x3c')]+'%'};return _0xd4b8aa;}})});}_0x252eec=_[_0xde27('0x3d')]({},_0x252eec,_0x26a65e[_0xde27('0x40')]);var _0x8f9a42={'where':_0x252eec['where']};return db[_0xde27('0x2b')][_0xde27('0x1c')](_0x8f9a42)[_0xde27('0x24')](function(_0x1686c7){_0x3bda58[_0xde27('0x1c')]=_0x1686c7;if(_0x26a65e[_0xde27('0x30')][_0xde27('0x41')]){_0x252eec[_0xde27('0x42')]=[{'all':!![]}];}return db[_0xde27('0x2b')][_0xde27('0x43')](_0x252eec);})[_0xde27('0x24')](function(_0x5596fe){_0x3bda58[_0xde27('0x44')]=_0x5596fe;return _0x3bda58;})[_0xde27('0x24')](respondWithFilteredResult(_0x2eb32a,_0x252eec))['catch'](handleError(_0x2eb32a,null));};exports[_0xde27('0x45')]=function(_0x3ae4ba,_0x4961c5){var _0x2d007f={'raw':!![],'where':{'id':_0x3ae4ba[_0xde27('0x46')]['id']}},_0x56b793={};_0x56b793[_0xde27('0x2e')]=_[_0xde27('0x2f')](db[_0xde27('0x2b')][_0xde27('0x2c')]);_0x56b793[_0xde27('0x30')]=_[_0xde27('0x2f')](_0x3ae4ba[_0xde27('0x30')]);_0x56b793[_0xde27('0x3b')]=_[_0xde27('0x31')](_0x56b793['model'],_0x56b793[_0xde27('0x30')]);_0x2d007f[_0xde27('0x32')]=_[_0xde27('0x31')](_0x56b793['model'],qs['fields'](_0x3ae4ba[_0xde27('0x30')][_0xde27('0x33')]));_0x2d007f[_0xde27('0x32')]=_0x2d007f[_0xde27('0x32')][_0xde27('0x34')]?_0x2d007f[_0xde27('0x32')]:_0x56b793[_0xde27('0x2e')];if(_0x3ae4ba[_0xde27('0x30')][_0xde27('0x41')]){_0x2d007f[_0xde27('0x42')]=[{'all':!![]}];}_0x2d007f=_[_0xde27('0x3d')]({},_0x2d007f,_0x3ae4ba[_0xde27('0x40')]);return db[_0xde27('0x2b')][_0xde27('0x47')](_0x2d007f)[_0xde27('0x24')](handleEntityNotFound(_0x4961c5,null))[_0xde27('0x24')](respondWithResult(_0x4961c5,null))[_0xde27('0x48')](handleError(_0x4961c5,null));};exports['create']=function(_0x4fdf23,_0x155415){return db[_0xde27('0x2b')]['create'](_0x4fdf23[_0xde27('0x49')],{})[_0xde27('0x24')](respondWithResult(_0x155415,0xc9))[_0xde27('0x48')](handleError(_0x155415,null));};exports[_0xde27('0x23')]=function(_0x58360b,_0x2e10e2){if(_0x58360b[_0xde27('0x49')]['id']){delete _0x58360b[_0xde27('0x49')]['id'];}return db[_0xde27('0x2b')][_0xde27('0x47')]({'where':{'id':_0x58360b[_0xde27('0x46')]['id']}})[_0xde27('0x24')](handleEntityNotFound(_0x2e10e2,null))[_0xde27('0x24')](saveUpdates(_0x58360b[_0xde27('0x49')],null))[_0xde27('0x24')](respondWithResult(_0x2e10e2,null))[_0xde27('0x48')](handleError(_0x2e10e2,null));};exports[_0xde27('0x25')]=function(_0x21aefc,_0x579757){return db['AnalyticTreeReport'][_0xde27('0x47')]({'where':{'id':_0x21aefc[_0xde27('0x46')]['id']}})[_0xde27('0x24')](handleEntityNotFound(_0x579757,null))['then'](removeEntity(_0x579757,null))[_0xde27('0x48')](handleError(_0x579757,null));};
\ No newline at end of file
+var _0x3ff1=['squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','status','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','then','end','sendStatus','error','stack','name','send','map','AnalyticTreeReport','rawAttributes','fieldName','type','model','query','keys','intersection','fields','attributes','length','nolimit','order','sort','filters','pick','filter','where','merge','options','includeAll','include','findAll','rows','catch','show','params','find','body','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash'];(function(_0x2a5651,_0x4b9dfa){var _0xcf4e0b=function(_0x1f9c18){while(--_0x1f9c18){_0x2a5651['push'](_0x2a5651['shift']());}};_0xcf4e0b(++_0x4b9dfa);}(_0x3ff1,0xd0));var _0x13ff=function(_0x5efb91,_0x39b378){_0x5efb91=_0x5efb91-0x0;var _0x57ff36=_0x3ff1[_0x5efb91];return _0x57ff36;};'use strict';var emlformat=require(_0x13ff('0x0'));var rimraf=require(_0x13ff('0x1'));var zipdir=require(_0x13ff('0x2'));var jsonpatch=require(_0x13ff('0x3'));var rp=require(_0x13ff('0x4'));var moment=require(_0x13ff('0x5'));var BPromise=require(_0x13ff('0x6'));var Mustache=require(_0x13ff('0x7'));var util=require(_0x13ff('0x8'));var path=require('path');var sox=require(_0x13ff('0x9'));var csv=require(_0x13ff('0xa'));var ejs=require(_0x13ff('0xb'));var fs=require('fs');var fs_extra=require(_0x13ff('0xc'));var _=require(_0x13ff('0xd'));var squel=require(_0x13ff('0xe'));var crypto=require(_0x13ff('0xf'));var jsforce=require('jsforce');var deskjs=require(_0x13ff('0x10'));var toCsv=require(_0x13ff('0xa'));var querystring=require(_0x13ff('0x11'));var Papa=require('papaparse');var Redis=require(_0x13ff('0x12'));var authService=require(_0x13ff('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x13ff('0x14'));var logger=require(_0x13ff('0x15'))('api');var utils=require(_0x13ff('0x16'));var config=require(_0x13ff('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2352a7,_0x39e8a5){_0x39e8a5=_0x39e8a5||0xcc;return function(_0x21adfa){if(_0x21adfa){return _0x2352a7['sendStatus'](_0x39e8a5);}return _0x2352a7['status'](_0x39e8a5)['end']();};}function respondWithResult(_0x2a93fb,_0x257af3){_0x257af3=_0x257af3||0xc8;return function(_0xe80015){if(_0xe80015){return _0x2a93fb[_0x13ff('0x18')](_0x257af3)['json'](_0xe80015);}};}function respondWithFilteredResult(_0x379d58,_0x2740a8){return function(_0x5f2bdf){if(_0x5f2bdf){var _0x3b529d=typeof _0x2740a8[_0x13ff('0x19')]===_0x13ff('0x1a')&&typeof _0x2740a8[_0x13ff('0x1b')]==='undefined';var _0x240f05=_0x5f2bdf[_0x13ff('0x1c')];var _0x2440e9=_0x3b529d?0x0:_0x2740a8['offset'];var _0x262056=_0x3b529d?_0x5f2bdf[_0x13ff('0x1c')]:_0x2740a8[_0x13ff('0x19')]+_0x2740a8[_0x13ff('0x1b')];var _0x399a58;if(_0x262056>=_0x240f05){_0x262056=_0x240f05;_0x399a58=0xc8;}else{_0x399a58=0xce;}_0x379d58[_0x13ff('0x18')](_0x399a58);return _0x379d58[_0x13ff('0x1d')](_0x13ff('0x1e'),_0x2440e9+'-'+_0x262056+'/'+_0x240f05)[_0x13ff('0x1f')](_0x5f2bdf);}return null;};}function patchUpdates(_0x58e0ea){return function(_0xc27205){try{jsonpatch[_0x13ff('0x20')](_0xc27205,_0x58e0ea,!![]);}catch(_0xd89295){return BPromise[_0x13ff('0x21')](_0xd89295);}return _0xc27205[_0x13ff('0x22')]();};}function saveUpdates(_0xa7ab1a,_0x27876e){return function(_0x46f3e5){if(_0x46f3e5){return _0x46f3e5[_0x13ff('0x23')](_0xa7ab1a)[_0x13ff('0x24')](function(_0x686019){return _0x686019;});}return null;};}function removeEntity(_0x5b5d91,_0x268ccc){return function(_0x2f1b0d){if(_0x2f1b0d){return _0x2f1b0d['destroy']()[_0x13ff('0x24')](function(){_0x5b5d91['status'](0xcc)[_0x13ff('0x25')]();});}};}function handleEntityNotFound(_0x178baa,_0x3ace5a){return function(_0x367bc9){if(!_0x367bc9){_0x178baa[_0x13ff('0x26')](0x194);}return _0x367bc9;};}function handleError(_0x386e4c,_0x32cf49){_0x32cf49=_0x32cf49||0x1f4;return function(_0xdbc369){logger[_0x13ff('0x27')](_0xdbc369[_0x13ff('0x28')]);if(_0xdbc369[_0x13ff('0x29')]){delete _0xdbc369[_0x13ff('0x29')];}_0x386e4c[_0x13ff('0x18')](_0x32cf49)[_0x13ff('0x2a')](_0xdbc369);};}exports['index']=function(_0x21a766,_0x3eae4f){var _0x514578={},_0x234960={},_0xa1c997={'count':0x0,'rows':[]};var _0x1bc2b1=_[_0x13ff('0x2b')](db[_0x13ff('0x2c')][_0x13ff('0x2d')],function(_0x3f9e94){return{'name':_0x3f9e94[_0x13ff('0x2e')],'type':_0x3f9e94[_0x13ff('0x2f')]['key']};});_0x234960[_0x13ff('0x30')]=_[_0x13ff('0x2b')](_0x1bc2b1,_0x13ff('0x29'));_0x234960[_0x13ff('0x31')]=_[_0x13ff('0x32')](_0x21a766['query']);_0x234960['filters']=_[_0x13ff('0x33')](_0x234960[_0x13ff('0x30')],_0x234960[_0x13ff('0x31')]);_0x514578['attributes']=_['intersection'](_0x234960['model'],qs[_0x13ff('0x34')](_0x21a766[_0x13ff('0x31')][_0x13ff('0x34')]));_0x514578[_0x13ff('0x35')]=_0x514578[_0x13ff('0x35')][_0x13ff('0x36')]?_0x514578[_0x13ff('0x35')]:_0x234960[_0x13ff('0x30')];if(!_0x21a766[_0x13ff('0x31')]['hasOwnProperty'](_0x13ff('0x37'))){_0x514578[_0x13ff('0x1b')]=qs[_0x13ff('0x1b')](_0x21a766['query'][_0x13ff('0x1b')]);_0x514578[_0x13ff('0x19')]=qs['offset'](_0x21a766[_0x13ff('0x31')][_0x13ff('0x19')]);}_0x514578[_0x13ff('0x38')]=qs[_0x13ff('0x39')](_0x21a766[_0x13ff('0x31')]['sort']);_0x514578['where']=qs[_0x13ff('0x3a')](_[_0x13ff('0x3b')](_0x21a766[_0x13ff('0x31')],_0x234960['filters']),_0x1bc2b1);if(_0x21a766['query'][_0x13ff('0x3c')]){_0x514578[_0x13ff('0x3d')]=_[_0x13ff('0x3e')](_0x514578[_0x13ff('0x3d')],{'$or':_['map'](_0x1bc2b1,function(_0x6b14c5){if(_0x6b14c5['type']!=='VIRTUAL'){var _0x3b9aad={};_0x3b9aad[_0x6b14c5[_0x13ff('0x29')]]={'$like':'%'+_0x21a766['query'][_0x13ff('0x3c')]+'%'};return _0x3b9aad;}})});}_0x514578=_[_0x13ff('0x3e')]({},_0x514578,_0x21a766[_0x13ff('0x3f')]);var _0x549d72={'where':_0x514578[_0x13ff('0x3d')]};return db[_0x13ff('0x2c')][_0x13ff('0x1c')](_0x549d72)['then'](function(_0x30bff7){_0xa1c997[_0x13ff('0x1c')]=_0x30bff7;if(_0x21a766['query'][_0x13ff('0x40')]){_0x514578[_0x13ff('0x41')]=[{'all':!![]}];}return db[_0x13ff('0x2c')][_0x13ff('0x42')](_0x514578);})[_0x13ff('0x24')](function(_0x2eef82){_0xa1c997[_0x13ff('0x43')]=_0x2eef82;return _0xa1c997;})['then'](respondWithFilteredResult(_0x3eae4f,_0x514578))[_0x13ff('0x44')](handleError(_0x3eae4f,null));};exports[_0x13ff('0x45')]=function(_0x91196e,_0x594a8e){var _0x552d7d={'raw':!![],'where':{'id':_0x91196e[_0x13ff('0x46')]['id']}},_0x2a98bf={};_0x2a98bf['model']=_[_0x13ff('0x32')](db[_0x13ff('0x2c')]['rawAttributes']);_0x2a98bf[_0x13ff('0x31')]=_[_0x13ff('0x32')](_0x91196e[_0x13ff('0x31')]);_0x2a98bf[_0x13ff('0x3a')]=_[_0x13ff('0x33')](_0x2a98bf['model'],_0x2a98bf['query']);_0x552d7d[_0x13ff('0x35')]=_[_0x13ff('0x33')](_0x2a98bf[_0x13ff('0x30')],qs[_0x13ff('0x34')](_0x91196e[_0x13ff('0x31')][_0x13ff('0x34')]));_0x552d7d[_0x13ff('0x35')]=_0x552d7d['attributes'][_0x13ff('0x36')]?_0x552d7d['attributes']:_0x2a98bf[_0x13ff('0x30')];if(_0x91196e[_0x13ff('0x31')][_0x13ff('0x40')]){_0x552d7d[_0x13ff('0x41')]=[{'all':!![]}];}_0x552d7d=_[_0x13ff('0x3e')]({},_0x552d7d,_0x91196e['options']);return db[_0x13ff('0x2c')][_0x13ff('0x47')](_0x552d7d)[_0x13ff('0x24')](handleEntityNotFound(_0x594a8e,null))['then'](respondWithResult(_0x594a8e,null))[_0x13ff('0x44')](handleError(_0x594a8e,null));};exports['create']=function(_0x4d60f6,_0x306363){return db[_0x13ff('0x2c')]['create'](_0x4d60f6[_0x13ff('0x48')],{})[_0x13ff('0x24')](respondWithResult(_0x306363,0xc9))['catch'](handleError(_0x306363,null));};exports['update']=function(_0x4ce620,_0x25453e){if(_0x4ce620[_0x13ff('0x48')]['id']){delete _0x4ce620[_0x13ff('0x48')]['id'];}return db[_0x13ff('0x2c')][_0x13ff('0x47')]({'where':{'id':_0x4ce620[_0x13ff('0x46')]['id']}})[_0x13ff('0x24')](handleEntityNotFound(_0x25453e,null))[_0x13ff('0x24')](saveUpdates(_0x4ce620[_0x13ff('0x48')],null))[_0x13ff('0x24')](respondWithResult(_0x25453e,null))[_0x13ff('0x44')](handleError(_0x25453e,null));};exports[_0x13ff('0x49')]=function(_0x217ca5,_0x1d6b33){return db[_0x13ff('0x2c')][_0x13ff('0x47')]({'where':{'id':_0x217ca5[_0x13ff('0x46')]['id']}})['then'](handleEntityNotFound(_0x1d6b33,null))[_0x13ff('0x24')](removeEntity(_0x1d6b33,null))[_0x13ff('0x44')](handleError(_0x1d6b33,null));};
\ No newline at end of file