Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
index e7e9dc5..a3125b9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7c26=['querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','end','json','count','offset','set','Content-Range','reject','save','update','then','sendStatus','error','stack','name','status','map','AnalyticTreeReport','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','destroy','html-pdf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','squel','jsforce','desk.js'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x7c26,0x11f));var _0x67c2=function(_0x1e71bd,_0x45c171){_0x1e71bd=_0x1e71bd-0x0;var _0x1e35c5=_0x7c26[_0x1e71bd];return _0x1e35c5;};'use strict';var pdf=require(_0x67c2('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x67c2('0x1'));var jsonpatch=require(_0x67c2('0x2'));var rp=require(_0x67c2('0x3'));var moment=require(_0x67c2('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x67c2('0x5'));var util=require(_0x67c2('0x6'));var path=require(_0x67c2('0x7'));var sox=require('sox');var csv=require(_0x67c2('0x8'));var ejs=require(_0x67c2('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x67c2('0xa'));var crypto=require('crypto');var jsforce=require(_0x67c2('0xb'));var deskjs=require(_0x67c2('0xc'));var toCsv=require('to-csv');var querystring=require(_0x67c2('0xd'));var Papa=require(_0x67c2('0xe'));var Redis=require(_0x67c2('0xf'));var authService=require(_0x67c2('0x10'));var qs=require(_0x67c2('0x11'));var as=require(_0x67c2('0x12'));var hardwareService=require(_0x67c2('0x13'));var logger=require(_0x67c2('0x14'))(_0x67c2('0x15'));var utils=require(_0x67c2('0x16'));var config=require(_0x67c2('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3bbf24,_0x270dbd){_0x270dbd=_0x270dbd||0xcc;return function(_0x430f20){if(_0x430f20){return _0x3bbf24['sendStatus'](_0x270dbd);}return _0x3bbf24['status'](_0x270dbd)[_0x67c2('0x18')]();};}function respondWithResult(_0x173609,_0x35635d){_0x35635d=_0x35635d||0xc8;return function(_0x53b508){if(_0x53b508){return _0x173609['status'](_0x35635d)[_0x67c2('0x19')](_0x53b508);}};}function respondWithFilteredResult(_0x360344,_0x28925e){return function(_0x3bcd2a){if(_0x3bcd2a){var _0x4f2f62=_0x3bcd2a[_0x67c2('0x1a')],_0x27651d=_0x28925e[_0x67c2('0x1b')],_0x5b4e52=_0x28925e[_0x67c2('0x1b')]+_0x28925e['limit'],_0x295814;if(_0x5b4e52>=_0x4f2f62){_0x5b4e52=_0x4f2f62;_0x295814=0xc8;}else{_0x295814=0xce;}_0x360344['status'](_0x295814);return _0x360344[_0x67c2('0x1c')](_0x67c2('0x1d'),_0x27651d+'-'+_0x5b4e52+'/'+_0x4f2f62)[_0x67c2('0x19')](_0x3bcd2a);}return null;};}function patchUpdates(_0x452313){return function(_0x4f431d){try{jsonpatch['apply'](_0x4f431d,_0x452313,!![]);}catch(_0x5bbfd0){return BPromise[_0x67c2('0x1e')](_0x5bbfd0);}return _0x4f431d[_0x67c2('0x1f')]();};}function saveUpdates(_0x38f814,_0x4a788d){return function(_0x50a517){if(_0x50a517){return _0x50a517[_0x67c2('0x20')](_0x38f814)[_0x67c2('0x21')](function(_0x4f84f8){return _0x4f84f8;});}return null;};}function removeEntity(_0x1622d9,_0x248b0c){return function(_0x17c5db){if(_0x17c5db){return _0x17c5db['destroy']()[_0x67c2('0x21')](function(){_0x1622d9['status'](0xcc)[_0x67c2('0x18')]();});}};}function handleEntityNotFound(_0x5802c1,_0x2816ec){return function(_0x22f696){if(!_0x22f696){_0x5802c1[_0x67c2('0x22')](0x194);}return _0x22f696;};}function handleError(_0xe87aea,_0x18aad9){_0x18aad9=_0x18aad9||0x1f4;return function(_0x2321da){logger[_0x67c2('0x23')](_0x2321da[_0x67c2('0x24')]);if(_0x2321da[_0x67c2('0x25')]){delete _0x2321da[_0x67c2('0x25')];}_0xe87aea[_0x67c2('0x26')](_0x18aad9)['send'](_0x2321da);};}exports['index']=function(_0x4ba017,_0x5ed6cd){var _0x471e42={},_0x42553c={},_0x432f2d={'count':0x0,'rows':[]};var _0x1f4e7c=_[_0x67c2('0x27')](db[_0x67c2('0x28')][_0x67c2('0x29')],function(_0x4b3d25){return{'name':_0x4b3d25[_0x67c2('0x2a')],'type':_0x4b3d25[_0x67c2('0x2b')][_0x67c2('0x2c')]};});_0x42553c[_0x67c2('0x2d')]=_[_0x67c2('0x27')](_0x1f4e7c,_0x67c2('0x25'));_0x42553c['query']=_[_0x67c2('0x2e')](_0x4ba017[_0x67c2('0x2f')]);_0x42553c[_0x67c2('0x30')]=_[_0x67c2('0x31')](_0x42553c[_0x67c2('0x2d')],_0x42553c[_0x67c2('0x2f')]);_0x471e42['attributes']=_[_0x67c2('0x31')](_0x42553c[_0x67c2('0x2d')],qs[_0x67c2('0x32')](_0x4ba017[_0x67c2('0x2f')][_0x67c2('0x32')]));_0x471e42[_0x67c2('0x33')]=_0x471e42[_0x67c2('0x33')][_0x67c2('0x34')]?_0x471e42[_0x67c2('0x33')]:_0x42553c['model'];if(!_0x4ba017['query'][_0x67c2('0x35')](_0x67c2('0x36'))){_0x471e42['limit']=qs[_0x67c2('0x37')](_0x4ba017[_0x67c2('0x2f')]['limit']);_0x471e42['offset']=qs[_0x67c2('0x1b')](_0x4ba017[_0x67c2('0x2f')][_0x67c2('0x1b')]);}_0x471e42[_0x67c2('0x38')]=qs[_0x67c2('0x39')](_0x4ba017[_0x67c2('0x2f')][_0x67c2('0x39')]);_0x471e42[_0x67c2('0x3a')]=qs['filters'](_[_0x67c2('0x3b')](_0x4ba017[_0x67c2('0x2f')],_0x42553c['filters']),_0x1f4e7c);if(_0x4ba017['query'][_0x67c2('0x3c')]){_0x471e42[_0x67c2('0x3a')]=_[_0x67c2('0x3d')](_0x471e42[_0x67c2('0x3a')],{'$or':_['map'](_0x1f4e7c,function(_0x40b2d7){if(_0x40b2d7[_0x67c2('0x2b')]!==_0x67c2('0x3e')){var _0x1e61db={};_0x1e61db[_0x40b2d7[_0x67c2('0x25')]]={'$like':'%'+_0x4ba017[_0x67c2('0x2f')][_0x67c2('0x3c')]+'%'};return _0x1e61db;}})});}_0x471e42=_[_0x67c2('0x3d')]({},_0x471e42,_0x4ba017[_0x67c2('0x3f')]);var _0x13d689={'where':_0x471e42[_0x67c2('0x3a')]};return db['AnalyticTreeReport']['count'](_0x13d689)['then'](function(_0x3eaecc){_0x432f2d[_0x67c2('0x1a')]=_0x3eaecc;if(_0x4ba017[_0x67c2('0x2f')][_0x67c2('0x40')]){_0x471e42[_0x67c2('0x41')]=[{'all':!![]}];}return db[_0x67c2('0x28')][_0x67c2('0x42')](_0x471e42);})['then'](function(_0x21e1d0){_0x432f2d[_0x67c2('0x43')]=_0x21e1d0;return _0x432f2d;})[_0x67c2('0x21')](respondWithFilteredResult(_0x5ed6cd,_0x471e42))[_0x67c2('0x44')](handleError(_0x5ed6cd,null));};exports[_0x67c2('0x45')]=function(_0x3927c1,_0x38c01c){var _0x125968={'raw':!![],'where':{'id':_0x3927c1[_0x67c2('0x46')]['id']}},_0x3ec3c6={};_0x3ec3c6[_0x67c2('0x2d')]=_[_0x67c2('0x2e')](db[_0x67c2('0x28')][_0x67c2('0x29')]);_0x3ec3c6['query']=_[_0x67c2('0x2e')](_0x3927c1[_0x67c2('0x2f')]);_0x3ec3c6[_0x67c2('0x30')]=_[_0x67c2('0x31')](_0x3ec3c6[_0x67c2('0x2d')],_0x3ec3c6[_0x67c2('0x2f')]);_0x125968[_0x67c2('0x33')]=_['intersection'](_0x3ec3c6[_0x67c2('0x2d')],qs['fields'](_0x3927c1['query'][_0x67c2('0x32')]));_0x125968['attributes']=_0x125968['attributes'][_0x67c2('0x34')]?_0x125968[_0x67c2('0x33')]:_0x3ec3c6['model'];if(_0x3927c1[_0x67c2('0x2f')][_0x67c2('0x40')]){_0x125968[_0x67c2('0x41')]=[{'all':!![]}];}_0x125968=_[_0x67c2('0x3d')]({},_0x125968,_0x3927c1['options']);return db[_0x67c2('0x28')][_0x67c2('0x47')](_0x125968)['then'](handleEntityNotFound(_0x38c01c,null))['then'](respondWithResult(_0x38c01c,null))[_0x67c2('0x44')](handleError(_0x38c01c,null));};exports[_0x67c2('0x48')]=function(_0x1ab0f0,_0x364054){return db[_0x67c2('0x28')][_0x67c2('0x48')](_0x1ab0f0[_0x67c2('0x49')],{})[_0x67c2('0x21')](respondWithResult(_0x364054,0xc9))[_0x67c2('0x44')](handleError(_0x364054,null));};exports[_0x67c2('0x20')]=function(_0x35fd3d,_0x5e5ae9){if(_0x35fd3d[_0x67c2('0x49')]['id']){delete _0x35fd3d['body']['id'];}return db[_0x67c2('0x28')]['find']({'where':{'id':_0x35fd3d['params']['id']}})[_0x67c2('0x21')](handleEntityNotFound(_0x5e5ae9,null))['then'](saveUpdates(_0x35fd3d[_0x67c2('0x49')],null))[_0x67c2('0x21')](respondWithResult(_0x5e5ae9,null))[_0x67c2('0x44')](handleError(_0x5e5ae9,null));};exports[_0x67c2('0x4a')]=function(_0x4f2e04,_0x47e6bf){return db['AnalyticTreeReport'][_0x67c2('0x47')]({'where':{'id':_0x4f2e04[_0x67c2('0x46')]['id']}})[_0x67c2('0x21')](handleEntityNotFound(_0x47e6bf,null))['then'](removeEntity(_0x47e6bf,null))[_0x67c2('0x44')](handleError(_0x47e6bf,null));};
\ No newline at end of file
+var _0x7f58=['end','json','offset','undefined','limit','count','set','Content-Range','save','update','then','destroy','stack','name','send','index','map','AnalyticTreeReport','rawAttributes','fieldName','key','query','keys','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','merge','type','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','sendStatus','status'];(function(_0x29632c,_0x57fac4){var _0x2af7b3=function(_0x337512){while(--_0x337512){_0x29632c['push'](_0x29632c['shift']());}};_0x2af7b3(++_0x57fac4);}(_0x7f58,0x1d3));var _0x87f5=function(_0x5daeb2,_0x4b007c){_0x5daeb2=_0x5daeb2-0x0;var _0x2dbb9f=_0x7f58[_0x5daeb2];return _0x2dbb9f;};'use strict';var emlformat=require(_0x87f5('0x0'));var rimraf=require(_0x87f5('0x1'));var zipdir=require(_0x87f5('0x2'));var jsonpatch=require(_0x87f5('0x3'));var rp=require(_0x87f5('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x87f5('0x5'));var util=require('util');var path=require(_0x87f5('0x6'));var sox=require('sox');var csv=require(_0x87f5('0x7'));var ejs=require(_0x87f5('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x87f5('0x9'));var squel=require('squel');var crypto=require(_0x87f5('0xa'));var jsforce=require(_0x87f5('0xb'));var deskjs=require(_0x87f5('0xc'));var toCsv=require(_0x87f5('0x7'));var querystring=require('querystring');var Papa=require(_0x87f5('0xd'));var Redis=require(_0x87f5('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x87f5('0xf'));var as=require(_0x87f5('0x10'));var hardwareService=require(_0x87f5('0x11'));var logger=require('../../config/logger')(_0x87f5('0x12'));var utils=require(_0x87f5('0x13'));var config=require(_0x87f5('0x14'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x165f9c,_0x26634d){_0x26634d=_0x26634d||0xcc;return function(_0x2307a2){if(_0x2307a2){return _0x165f9c[_0x87f5('0x15')](_0x26634d);}return _0x165f9c[_0x87f5('0x16')](_0x26634d)[_0x87f5('0x17')]();};}function respondWithResult(_0x24c4f6,_0x3746a5){_0x3746a5=_0x3746a5||0xc8;return function(_0x56c660){if(_0x56c660){return _0x24c4f6['status'](_0x3746a5)[_0x87f5('0x18')](_0x56c660);}};}function respondWithFilteredResult(_0x3b03a1,_0x261db9){return function(_0x5f1822){if(_0x5f1822){var _0x2d53bd=typeof _0x261db9[_0x87f5('0x19')]===_0x87f5('0x1a')&&typeof _0x261db9[_0x87f5('0x1b')]==='undefined';var _0x51396b=_0x5f1822['count'];var _0x3151ad=_0x2d53bd?0x0:_0x261db9[_0x87f5('0x19')];var _0x519c6d=_0x2d53bd?_0x5f1822[_0x87f5('0x1c')]:_0x261db9[_0x87f5('0x19')]+_0x261db9[_0x87f5('0x1b')];var _0x3a6312;if(_0x519c6d>=_0x51396b){_0x519c6d=_0x51396b;_0x3a6312=0xc8;}else{_0x3a6312=0xce;}_0x3b03a1[_0x87f5('0x16')](_0x3a6312);return _0x3b03a1[_0x87f5('0x1d')](_0x87f5('0x1e'),_0x3151ad+'-'+_0x519c6d+'/'+_0x51396b)[_0x87f5('0x18')](_0x5f1822);}return null;};}function patchUpdates(_0x298a8b){return function(_0x221615){try{jsonpatch['apply'](_0x221615,_0x298a8b,!![]);}catch(_0x2a9489){return BPromise['reject'](_0x2a9489);}return _0x221615[_0x87f5('0x1f')]();};}function saveUpdates(_0x9a6b1e,_0x2f64f1){return function(_0x304661){if(_0x304661){return _0x304661[_0x87f5('0x20')](_0x9a6b1e)[_0x87f5('0x21')](function(_0x57ff86){return _0x57ff86;});}return null;};}function removeEntity(_0x58053c,_0x15e08c){return function(_0x2a8239){if(_0x2a8239){return _0x2a8239[_0x87f5('0x22')]()[_0x87f5('0x21')](function(){_0x58053c[_0x87f5('0x16')](0xcc)[_0x87f5('0x17')]();});}};}function handleEntityNotFound(_0x55194e,_0x59fdb8){return function(_0x543f35){if(!_0x543f35){_0x55194e['sendStatus'](0x194);}return _0x543f35;};}function handleError(_0x170d2c,_0x57e32b){_0x57e32b=_0x57e32b||0x1f4;return function(_0x575872){logger['error'](_0x575872[_0x87f5('0x23')]);if(_0x575872[_0x87f5('0x24')]){delete _0x575872[_0x87f5('0x24')];}_0x170d2c['status'](_0x57e32b)[_0x87f5('0x25')](_0x575872);};}exports[_0x87f5('0x26')]=function(_0x137117,_0x27c096){var _0x21ba1c={},_0x53608d={},_0x3416b4={'count':0x0,'rows':[]};var _0x22997f=_[_0x87f5('0x27')](db[_0x87f5('0x28')][_0x87f5('0x29')],function(_0x2e2509){return{'name':_0x2e2509[_0x87f5('0x2a')],'type':_0x2e2509['type'][_0x87f5('0x2b')]};});_0x53608d['model']=_[_0x87f5('0x27')](_0x22997f,_0x87f5('0x24'));_0x53608d[_0x87f5('0x2c')]=_[_0x87f5('0x2d')](_0x137117[_0x87f5('0x2c')]);_0x53608d[_0x87f5('0x2e')]=_[_0x87f5('0x2f')](_0x53608d[_0x87f5('0x30')],_0x53608d[_0x87f5('0x2c')]);_0x21ba1c[_0x87f5('0x31')]=_['intersection'](_0x53608d[_0x87f5('0x30')],qs[_0x87f5('0x32')](_0x137117[_0x87f5('0x2c')][_0x87f5('0x32')]));_0x21ba1c[_0x87f5('0x31')]=_0x21ba1c[_0x87f5('0x31')][_0x87f5('0x33')]?_0x21ba1c[_0x87f5('0x31')]:_0x53608d['model'];if(!_0x137117['query']['hasOwnProperty'](_0x87f5('0x34'))){_0x21ba1c[_0x87f5('0x1b')]=qs[_0x87f5('0x1b')](_0x137117[_0x87f5('0x2c')][_0x87f5('0x1b')]);_0x21ba1c['offset']=qs[_0x87f5('0x19')](_0x137117[_0x87f5('0x2c')]['offset']);}_0x21ba1c[_0x87f5('0x35')]=qs[_0x87f5('0x36')](_0x137117[_0x87f5('0x2c')][_0x87f5('0x36')]);_0x21ba1c['where']=qs['filters'](_['pick'](_0x137117[_0x87f5('0x2c')],_0x53608d[_0x87f5('0x2e')]),_0x22997f);if(_0x137117[_0x87f5('0x2c')]['filter']){_0x21ba1c[_0x87f5('0x37')]=_[_0x87f5('0x38')](_0x21ba1c['where'],{'$or':_[_0x87f5('0x27')](_0x22997f,function(_0x452006){if(_0x452006[_0x87f5('0x39')]!==_0x87f5('0x3a')){var _0x2b5e11={};_0x2b5e11[_0x452006[_0x87f5('0x24')]]={'$like':'%'+_0x137117[_0x87f5('0x2c')]['filter']+'%'};return _0x2b5e11;}})});}_0x21ba1c=_[_0x87f5('0x38')]({},_0x21ba1c,_0x137117[_0x87f5('0x3b')]);var _0x3801a6={'where':_0x21ba1c['where']};return db[_0x87f5('0x28')][_0x87f5('0x1c')](_0x3801a6)['then'](function(_0x4d9ebb){_0x3416b4[_0x87f5('0x1c')]=_0x4d9ebb;if(_0x137117[_0x87f5('0x2c')][_0x87f5('0x3c')]){_0x21ba1c['include']=[{'all':!![]}];}return db['AnalyticTreeReport'][_0x87f5('0x3d')](_0x21ba1c);})[_0x87f5('0x21')](function(_0x26e817){_0x3416b4[_0x87f5('0x3e')]=_0x26e817;return _0x3416b4;})[_0x87f5('0x21')](respondWithFilteredResult(_0x27c096,_0x21ba1c))[_0x87f5('0x3f')](handleError(_0x27c096,null));};exports[_0x87f5('0x40')]=function(_0x342cef,_0x4200d4){var _0x23e16b={'raw':!![],'where':{'id':_0x342cef[_0x87f5('0x41')]['id']}},_0x46d556={};_0x46d556[_0x87f5('0x30')]=_['keys'](db[_0x87f5('0x28')]['rawAttributes']);_0x46d556['query']=_[_0x87f5('0x2d')](_0x342cef[_0x87f5('0x2c')]);_0x46d556[_0x87f5('0x2e')]=_[_0x87f5('0x2f')](_0x46d556[_0x87f5('0x30')],_0x46d556[_0x87f5('0x2c')]);_0x23e16b[_0x87f5('0x31')]=_[_0x87f5('0x2f')](_0x46d556[_0x87f5('0x30')],qs[_0x87f5('0x32')](_0x342cef[_0x87f5('0x2c')][_0x87f5('0x32')]));_0x23e16b['attributes']=_0x23e16b[_0x87f5('0x31')][_0x87f5('0x33')]?_0x23e16b[_0x87f5('0x31')]:_0x46d556['model'];if(_0x342cef['query'][_0x87f5('0x3c')]){_0x23e16b[_0x87f5('0x42')]=[{'all':!![]}];}_0x23e16b=_[_0x87f5('0x38')]({},_0x23e16b,_0x342cef['options']);return db[_0x87f5('0x28')][_0x87f5('0x43')](_0x23e16b)[_0x87f5('0x21')](handleEntityNotFound(_0x4200d4,null))[_0x87f5('0x21')](respondWithResult(_0x4200d4,null))[_0x87f5('0x3f')](handleError(_0x4200d4,null));};exports[_0x87f5('0x44')]=function(_0x59788b,_0x534fac){return db[_0x87f5('0x28')]['create'](_0x59788b[_0x87f5('0x45')],{})[_0x87f5('0x21')](respondWithResult(_0x534fac,0xc9))[_0x87f5('0x3f')](handleError(_0x534fac,null));};exports[_0x87f5('0x20')]=function(_0x4eecf6,_0x4cb1f0){if(_0x4eecf6['body']['id']){delete _0x4eecf6[_0x87f5('0x45')]['id'];}return db['AnalyticTreeReport'][_0x87f5('0x43')]({'where':{'id':_0x4eecf6[_0x87f5('0x41')]['id']}})[_0x87f5('0x21')](handleEntityNotFound(_0x4cb1f0,null))[_0x87f5('0x21')](saveUpdates(_0x4eecf6[_0x87f5('0x45')],null))['then'](respondWithResult(_0x4cb1f0,null))[_0x87f5('0x3f')](handleError(_0x4cb1f0,null));};exports[_0x87f5('0x22')]=function(_0x455dd0,_0x30902f){return db[_0x87f5('0x28')][_0x87f5('0x43')]({'where':{'id':_0x455dd0['params']['id']}})[_0x87f5('0x21')](handleEntityNotFound(_0x30902f,null))[_0x87f5('0x21')](removeEntity(_0x30902f,null))[_0x87f5('0x3f')](handleError(_0x30902f,null));};
\ No newline at end of file