Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / cmHopperHistory / cmHopperHistory.controller.js
index fc07cc0..496b851 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xef3f=['destroy','end','sendStatus','error','stack','name','index','map','CmHopperHistory','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','VIRTUAL','options','includeAll','include','findAll','rows','show','rawAttributes','merge','find','catch','create','describe','update','body','uniqueid','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','status','json','count','offset','limit','apply','reject','save','then'];(function(_0x3e2480,_0x2eed70){var _0x652c0=function(_0xaae5d2){while(--_0xaae5d2){_0x3e2480['push'](_0x3e2480['shift']());}};_0x652c0(++_0x2eed70);}(_0xef3f,0x1d9));var _0xfef3=function(_0x279ba0,_0x484056){_0x279ba0=_0x279ba0-0x0;var _0x5c0127=_0xef3f[_0x279ba0];return _0x5c0127;};'use strict';var pdf=require(_0xfef3('0x0'));var emlformat=require(_0xfef3('0x1'));var rimraf=require(_0xfef3('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xfef3('0x3'));var moment=require('moment');var BPromise=require(_0xfef3('0x4'));var Mustache=require(_0xfef3('0x5'));var util=require(_0xfef3('0x6'));var path=require(_0xfef3('0x7'));var sox=require('sox');var csv=require(_0xfef3('0x8'));var ejs=require(_0xfef3('0x9'));var fs=require('fs');var _=require(_0xfef3('0xa'));var squel=require(_0xfef3('0xb'));var crypto=require(_0xfef3('0xc'));var jsforce=require(_0xfef3('0xd'));var deskjs=require(_0xfef3('0xe'));var toCsv=require(_0xfef3('0x8'));var querystring=require(_0xfef3('0xf'));var Papa=require('papaparse');var Redis=require(_0xfef3('0x10'));var authService=require(_0xfef3('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xfef3('0x12'));var logger=require(_0xfef3('0x13'))('api');var utils=require('../../config/utils');var config=require(_0xfef3('0x14'));var db=require(_0xfef3('0x15'))['db'];function respondWithStatusCode(_0x2478f2,_0x23d71c){_0x23d71c=_0x23d71c||0xcc;return function(_0x353e93){if(_0x353e93){return _0x2478f2['sendStatus'](_0x23d71c);}return _0x2478f2[_0xfef3('0x16')](_0x23d71c)['end']();};}function respondWithResult(_0x5e6eb3,_0x4a3f27){_0x4a3f27=_0x4a3f27||0xc8;return function(_0x3de294){if(_0x3de294){return _0x5e6eb3['status'](_0x4a3f27)[_0xfef3('0x17')](_0x3de294);}};}function respondWithFilteredResult(_0x530be7,_0x1582f7){return function(_0x2537ae){if(_0x2537ae){var _0x3314f1=_0x2537ae[_0xfef3('0x18')],_0x2ff7b2=_0x1582f7[_0xfef3('0x19')],_0x2a91d3=_0x1582f7[_0xfef3('0x19')]+_0x1582f7[_0xfef3('0x1a')],_0x17be76;if(_0x2a91d3>=_0x3314f1){_0x2a91d3=_0x3314f1;_0x17be76=0xc8;}else{_0x17be76=0xce;}_0x530be7[_0xfef3('0x16')](_0x17be76);return _0x530be7['set']('Content-Range',_0x2ff7b2+'-'+_0x2a91d3+'/'+_0x3314f1)[_0xfef3('0x17')](_0x2537ae);}return null;};}function patchUpdates(_0xdda888){return function(_0x3d21ef){try{jsonpatch[_0xfef3('0x1b')](_0x3d21ef,_0xdda888,!![]);}catch(_0x4a1385){return BPromise[_0xfef3('0x1c')](_0x4a1385);}return _0x3d21ef[_0xfef3('0x1d')]();};}function saveUpdates(_0x31a8ac,_0x4f62b6){return function(_0x227d53){if(_0x227d53){return _0x227d53['update'](_0x31a8ac)[_0xfef3('0x1e')](function(_0x5b7104){return _0x5b7104;});}return null;};}function removeEntity(_0x5109fa,_0xb77309){return function(_0x276cf0){if(_0x276cf0){return _0x276cf0[_0xfef3('0x1f')]()[_0xfef3('0x1e')](function(){_0x5109fa[_0xfef3('0x16')](0xcc)[_0xfef3('0x20')]();});}};}function handleEntityNotFound(_0x3eaa3e,_0x3e6a6a){return function(_0x2a4f91){if(!_0x2a4f91){_0x3eaa3e[_0xfef3('0x21')](0x194);}return _0x2a4f91;};}function handleError(_0x433cfd,_0x513264){_0x513264=_0x513264||0x1f4;return function(_0x494e39){logger[_0xfef3('0x22')](_0x494e39[_0xfef3('0x23')]);if(_0x494e39[_0xfef3('0x24')]){delete _0x494e39[_0xfef3('0x24')];}_0x433cfd[_0xfef3('0x16')](_0x513264)['send'](_0x494e39);};}exports[_0xfef3('0x25')]=function(_0xbd66e,_0x3f52b6){var _0x213814={},_0xd38814={},_0x4d1c83={'count':0x0,'rows':[]};var _0x5edd37=_[_0xfef3('0x26')](db[_0xfef3('0x27')]['rawAttributes'],function(_0xe4b312){return{'name':_0xe4b312[_0xfef3('0x28')],'type':_0xe4b312[_0xfef3('0x29')][_0xfef3('0x2a')]};});_0xd38814[_0xfef3('0x2b')]=_[_0xfef3('0x26')](_0x5edd37,'name');_0xd38814[_0xfef3('0x2c')]=_[_0xfef3('0x2d')](_0xbd66e[_0xfef3('0x2c')]);_0xd38814['filters']=_[_0xfef3('0x2e')](_0xd38814[_0xfef3('0x2b')],_0xd38814['query']);_0x213814[_0xfef3('0x2f')]=_['intersection'](_0xd38814[_0xfef3('0x2b')],qs['fields'](_0xbd66e[_0xfef3('0x2c')][_0xfef3('0x30')]));_0x213814[_0xfef3('0x2f')]=_0x213814['attributes']['length']?_0x213814[_0xfef3('0x2f')]:_0xd38814[_0xfef3('0x2b')];if(!_0xbd66e[_0xfef3('0x2c')][_0xfef3('0x31')]('nolimit')){_0x213814['limit']=qs[_0xfef3('0x1a')](_0xbd66e[_0xfef3('0x2c')][_0xfef3('0x1a')]);_0x213814[_0xfef3('0x19')]=qs['offset'](_0xbd66e[_0xfef3('0x2c')]['offset']);}_0x213814[_0xfef3('0x32')]=qs[_0xfef3('0x33')](_0xbd66e[_0xfef3('0x2c')][_0xfef3('0x33')]);_0x213814[_0xfef3('0x34')]=qs[_0xfef3('0x35')](_[_0xfef3('0x36')](_0xbd66e[_0xfef3('0x2c')],_0xd38814[_0xfef3('0x35')]),_0x5edd37);if(_0xbd66e['query'][_0xfef3('0x37')]){_0x213814[_0xfef3('0x34')]=_['merge'](_0x213814[_0xfef3('0x34')],{'$or':_['map'](_0x5edd37,function(_0x203382){if(_0x203382[_0xfef3('0x29')]!==_0xfef3('0x38')){var _0x175b3e={};_0x175b3e[_0x203382[_0xfef3('0x24')]]={'$like':'%'+_0xbd66e[_0xfef3('0x2c')]['filter']+'%'};return _0x175b3e;}})});}_0x213814=_['merge']({},_0x213814,_0xbd66e[_0xfef3('0x39')]);var _0xbaab00={'where':_0x213814[_0xfef3('0x34')]};return db[_0xfef3('0x27')][_0xfef3('0x18')](_0xbaab00)[_0xfef3('0x1e')](function(_0x4b14d1){_0x4d1c83[_0xfef3('0x18')]=_0x4b14d1;if(_0xbd66e[_0xfef3('0x2c')][_0xfef3('0x3a')]){_0x213814[_0xfef3('0x3b')]=[{'all':!![]}];}return db[_0xfef3('0x27')][_0xfef3('0x3c')](_0x213814);})['then'](function(_0x556790){_0x4d1c83[_0xfef3('0x3d')]=_0x556790;return _0x4d1c83;})[_0xfef3('0x1e')](respondWithFilteredResult(_0x3f52b6,_0x213814))['catch'](handleError(_0x3f52b6,null));};exports[_0xfef3('0x3e')]=function(_0x3e3193,_0x5188eb){var _0x2461cd={'raw':!![],'where':{'id':_0x3e3193['params']['id']}},_0x191a53={};_0x191a53[_0xfef3('0x2b')]=_[_0xfef3('0x2d')](db['CmHopperHistory'][_0xfef3('0x3f')]);_0x191a53['query']=_[_0xfef3('0x2d')](_0x3e3193[_0xfef3('0x2c')]);_0x191a53[_0xfef3('0x35')]=_[_0xfef3('0x2e')](_0x191a53[_0xfef3('0x2b')],_0x191a53['query']);_0x2461cd[_0xfef3('0x2f')]=_[_0xfef3('0x2e')](_0x191a53[_0xfef3('0x2b')],qs[_0xfef3('0x30')](_0x3e3193[_0xfef3('0x2c')]['fields']));_0x2461cd['attributes']=_0x2461cd['attributes']['length']?_0x2461cd[_0xfef3('0x2f')]:_0x191a53[_0xfef3('0x2b')];if(_0x3e3193[_0xfef3('0x2c')]['includeAll']){_0x2461cd['include']=[{'all':!![]}];}_0x2461cd=_[_0xfef3('0x40')]({},_0x2461cd,_0x3e3193['options']);return db[_0xfef3('0x27')][_0xfef3('0x41')](_0x2461cd)[_0xfef3('0x1e')](handleEntityNotFound(_0x5188eb,null))['then'](respondWithResult(_0x5188eb,null))[_0xfef3('0x42')](handleError(_0x5188eb,null));};exports[_0xfef3('0x43')]=function(_0x2196c1,_0x10f9d1){return db[_0xfef3('0x27')][_0xfef3('0x43')](_0x2196c1['body'],{})[_0xfef3('0x1e')](respondWithResult(_0x10f9d1,0xc9))[_0xfef3('0x42')](handleError(_0x10f9d1,null));};exports['describe']=function(_0x3af5ea,_0x163077){return db[_0xfef3('0x27')][_0xfef3('0x44')]()[_0xfef3('0x1e')](respondWithResult(_0x163077,null))[_0xfef3('0x42')](handleError(_0x163077,null));};exports[_0xfef3('0x45')]=function(_0x19392f,_0x4bcb78){if(_0x19392f[_0xfef3('0x46')][_0xfef3('0x47')]){delete _0x19392f['body'][_0xfef3('0x47')];}return db[_0xfef3('0x27')][_0xfef3('0x41')]({'where':{'uniqueid':_0x19392f['params']['id']}})[_0xfef3('0x1e')](handleEntityNotFound(_0x4bcb78,null))[_0xfef3('0x1e')](saveUpdates(_0x19392f['body'],null))[_0xfef3('0x1e')](respondWithResult(_0x4bcb78,null))[_0xfef3('0x42')](handleError(_0x4bcb78,null));};
\ No newline at end of file
+var _0x58df=['save','update','then','destroy','sendStatus','error','stack','name','index','rawAttributes','type','key','map','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','include','CmHopperHistory','rows','catch','show','find','create','body','describe','uniqueid','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject'];(function(_0x354315,_0x4eacf9){var _0x193970=function(_0x1790f4){while(--_0x1790f4){_0x354315['push'](_0x354315['shift']());}};_0x193970(++_0x4eacf9);}(_0x58df,0x79));var _0xf58d=function(_0x12e058,_0x3d4576){_0x12e058=_0x12e058-0x0;var _0x57d432=_0x58df[_0x12e058];return _0x57d432;};'use strict';var emlformat=require(_0xf58d('0x0'));var rimraf=require(_0xf58d('0x1'));var zipdir=require(_0xf58d('0x2'));var jsonpatch=require(_0xf58d('0x3'));var rp=require(_0xf58d('0x4'));var moment=require(_0xf58d('0x5'));var BPromise=require(_0xf58d('0x6'));var Mustache=require(_0xf58d('0x7'));var util=require('util');var path=require(_0xf58d('0x8'));var sox=require(_0xf58d('0x9'));var csv=require(_0xf58d('0xa'));var ejs=require(_0xf58d('0xb'));var fs=require('fs');var fs_extra=require(_0xf58d('0xc'));var _=require(_0xf58d('0xd'));var squel=require('squel');var crypto=require(_0xf58d('0xe'));var jsforce=require(_0xf58d('0xf'));var deskjs=require(_0xf58d('0x10'));var toCsv=require(_0xf58d('0xa'));var querystring=require(_0xf58d('0x11'));var Papa=require(_0xf58d('0x12'));var Redis=require(_0xf58d('0x13'));var authService=require(_0xf58d('0x14'));var qs=require(_0xf58d('0x15'));var as=require(_0xf58d('0x16'));var hardwareService=require(_0xf58d('0x17'));var logger=require(_0xf58d('0x18'))(_0xf58d('0x19'));var utils=require(_0xf58d('0x1a'));var config=require('../../config/environment');var licenseUtil=require(_0xf58d('0x1b'));var db=require(_0xf58d('0x1c'))['db'];function respondWithStatusCode(_0x1ecfa0,_0x130830){_0x130830=_0x130830||0xcc;return function(_0x47cdf3){if(_0x47cdf3){return _0x1ecfa0['sendStatus'](_0x130830);}return _0x1ecfa0[_0xf58d('0x1d')](_0x130830)[_0xf58d('0x1e')]();};}function respondWithResult(_0x9c215c,_0x25c4a7){_0x25c4a7=_0x25c4a7||0xc8;return function(_0x1be56b){if(_0x1be56b){return _0x9c215c[_0xf58d('0x1d')](_0x25c4a7)[_0xf58d('0x1f')](_0x1be56b);}};}function respondWithFilteredResult(_0x37d031,_0x2b1a3f){return function(_0x360aa7){if(_0x360aa7){var _0x22c0f8=typeof _0x2b1a3f[_0xf58d('0x20')]===_0xf58d('0x21')&&typeof _0x2b1a3f[_0xf58d('0x22')]===_0xf58d('0x21');var _0x124526=_0x360aa7['count'];var _0x295728=_0x22c0f8?0x0:_0x2b1a3f[_0xf58d('0x20')];var _0x82fb80=_0x22c0f8?_0x360aa7[_0xf58d('0x23')]:_0x2b1a3f[_0xf58d('0x20')]+_0x2b1a3f[_0xf58d('0x22')];var _0x5396d3;if(_0x82fb80>=_0x124526){_0x82fb80=_0x124526;_0x5396d3=0xc8;}else{_0x5396d3=0xce;}_0x37d031['status'](_0x5396d3);return _0x37d031['set'](_0xf58d('0x24'),_0x295728+'-'+_0x82fb80+'/'+_0x124526)[_0xf58d('0x1f')](_0x360aa7);}return null;};}function patchUpdates(_0x5bf79d){return function(_0x3ab161){try{jsonpatch[_0xf58d('0x25')](_0x3ab161,_0x5bf79d,!![]);}catch(_0x34d75e){return BPromise[_0xf58d('0x26')](_0x34d75e);}return _0x3ab161[_0xf58d('0x27')]();};}function saveUpdates(_0x42f789,_0x5c9f1d){return function(_0xd9bab1){if(_0xd9bab1){return _0xd9bab1[_0xf58d('0x28')](_0x42f789)[_0xf58d('0x29')](function(_0x598add){return _0x598add;});}return null;};}function removeEntity(_0x38e021,_0x13f151){return function(_0x302e24){if(_0x302e24){return _0x302e24[_0xf58d('0x2a')]()['then'](function(){_0x38e021['status'](0xcc)[_0xf58d('0x1e')]();});}};}function handleEntityNotFound(_0x5a48f4,_0x2258c2){return function(_0x388bc5){if(!_0x388bc5){_0x5a48f4[_0xf58d('0x2b')](0x194);}return _0x388bc5;};}function handleError(_0x1f7590,_0x12c52f){_0x12c52f=_0x12c52f||0x1f4;return function(_0xd868df){logger[_0xf58d('0x2c')](_0xd868df[_0xf58d('0x2d')]);if(_0xd868df[_0xf58d('0x2e')]){delete _0xd868df[_0xf58d('0x2e')];}_0x1f7590[_0xf58d('0x1d')](_0x12c52f)['send'](_0xd868df);};}exports[_0xf58d('0x2f')]=function(_0xb7b533,_0x1a987d){var _0xc91b46={},_0x1171f2={},_0x26a938={'count':0x0,'rows':[]};var _0x10cb40=_['map'](db['CmHopperHistory'][_0xf58d('0x30')],function(_0xf5b358){return{'name':_0xf5b358['fieldName'],'type':_0xf5b358[_0xf58d('0x31')][_0xf58d('0x32')]};});_0x1171f2['model']=_[_0xf58d('0x33')](_0x10cb40,'name');_0x1171f2[_0xf58d('0x34')]=_[_0xf58d('0x35')](_0xb7b533[_0xf58d('0x34')]);_0x1171f2[_0xf58d('0x36')]=_[_0xf58d('0x37')](_0x1171f2[_0xf58d('0x38')],_0x1171f2[_0xf58d('0x34')]);_0xc91b46[_0xf58d('0x39')]=_[_0xf58d('0x37')](_0x1171f2[_0xf58d('0x38')],qs[_0xf58d('0x3a')](_0xb7b533[_0xf58d('0x34')][_0xf58d('0x3a')]));_0xc91b46[_0xf58d('0x39')]=_0xc91b46['attributes'][_0xf58d('0x3b')]?_0xc91b46[_0xf58d('0x39')]:_0x1171f2[_0xf58d('0x38')];if(!_0xb7b533[_0xf58d('0x34')][_0xf58d('0x3c')](_0xf58d('0x3d'))){_0xc91b46['limit']=qs['limit'](_0xb7b533[_0xf58d('0x34')][_0xf58d('0x22')]);_0xc91b46[_0xf58d('0x20')]=qs[_0xf58d('0x20')](_0xb7b533[_0xf58d('0x34')][_0xf58d('0x20')]);}_0xc91b46[_0xf58d('0x3e')]=qs[_0xf58d('0x3f')](_0xb7b533[_0xf58d('0x34')][_0xf58d('0x3f')]);_0xc91b46[_0xf58d('0x40')]=qs['filters'](_[_0xf58d('0x41')](_0xb7b533[_0xf58d('0x34')],_0x1171f2[_0xf58d('0x36')]),_0x10cb40);if(_0xb7b533[_0xf58d('0x34')]['filter']){_0xc91b46[_0xf58d('0x40')]=_[_0xf58d('0x42')](_0xc91b46[_0xf58d('0x40')],{'$or':_[_0xf58d('0x33')](_0x10cb40,function(_0x15d3df){if(_0x15d3df[_0xf58d('0x31')]!==_0xf58d('0x43')){var _0x261508={};_0x261508[_0x15d3df[_0xf58d('0x2e')]]={'$like':'%'+_0xb7b533[_0xf58d('0x34')][_0xf58d('0x44')]+'%'};return _0x261508;}})});}_0xc91b46=_[_0xf58d('0x42')]({},_0xc91b46,_0xb7b533[_0xf58d('0x45')]);var _0x1a494f={'where':_0xc91b46[_0xf58d('0x40')]};return db['CmHopperHistory']['count'](_0x1a494f)[_0xf58d('0x29')](function(_0x208718){_0x26a938[_0xf58d('0x23')]=_0x208718;if(_0xb7b533['query']['includeAll']){_0xc91b46[_0xf58d('0x46')]=[{'all':!![]}];}return db[_0xf58d('0x47')]['findAll'](_0xc91b46);})[_0xf58d('0x29')](function(_0x1f0bf5){_0x26a938[_0xf58d('0x48')]=_0x1f0bf5;return _0x26a938;})[_0xf58d('0x29')](respondWithFilteredResult(_0x1a987d,_0xc91b46))[_0xf58d('0x49')](handleError(_0x1a987d,null));};exports[_0xf58d('0x4a')]=function(_0xe90363,_0xe41b89){var _0x1fb3e9={'raw':!![],'where':{'id':_0xe90363['params']['id']}},_0xae1615={};_0xae1615[_0xf58d('0x38')]=_[_0xf58d('0x35')](db[_0xf58d('0x47')][_0xf58d('0x30')]);_0xae1615[_0xf58d('0x34')]=_['keys'](_0xe90363[_0xf58d('0x34')]);_0xae1615[_0xf58d('0x36')]=_[_0xf58d('0x37')](_0xae1615['model'],_0xae1615[_0xf58d('0x34')]);_0x1fb3e9[_0xf58d('0x39')]=_[_0xf58d('0x37')](_0xae1615[_0xf58d('0x38')],qs[_0xf58d('0x3a')](_0xe90363[_0xf58d('0x34')]['fields']));_0x1fb3e9['attributes']=_0x1fb3e9[_0xf58d('0x39')][_0xf58d('0x3b')]?_0x1fb3e9[_0xf58d('0x39')]:_0xae1615[_0xf58d('0x38')];if(_0xe90363[_0xf58d('0x34')]['includeAll']){_0x1fb3e9[_0xf58d('0x46')]=[{'all':!![]}];}_0x1fb3e9=_[_0xf58d('0x42')]({},_0x1fb3e9,_0xe90363['options']);return db[_0xf58d('0x47')][_0xf58d('0x4b')](_0x1fb3e9)['then'](handleEntityNotFound(_0xe41b89,null))['then'](respondWithResult(_0xe41b89,null))[_0xf58d('0x49')](handleError(_0xe41b89,null));};exports[_0xf58d('0x4c')]=function(_0x4eeb2e,_0x3d48af){return db[_0xf58d('0x47')][_0xf58d('0x4c')](_0x4eeb2e[_0xf58d('0x4d')],{})['then'](respondWithResult(_0x3d48af,0xc9))[_0xf58d('0x49')](handleError(_0x3d48af,null));};exports[_0xf58d('0x4e')]=function(_0x5848d3,_0x3799b1){return db[_0xf58d('0x47')]['describe']()['then'](respondWithResult(_0x3799b1,null))['catch'](handleError(_0x3799b1,null));};exports[_0xf58d('0x28')]=function(_0x21c437,_0x37a3a0){if(_0x21c437['body'][_0xf58d('0x4f')]){delete _0x21c437[_0xf58d('0x4d')][_0xf58d('0x4f')];}return db[_0xf58d('0x47')]['find']({'where':{'uniqueid':_0x21c437['params']['id']}})[_0xf58d('0x29')](handleEntityNotFound(_0x37a3a0,null))[_0xf58d('0x29')](saveUpdates(_0x21c437[_0xf58d('0x4d')],null))[_0xf58d('0x29')](respondWithResult(_0x37a3a0,null))['catch'](handleError(_0x37a3a0,null));};
\ No newline at end of file