Built motion from commit 9b156c94.|2.6.22
[motion2.git] / server / api / openchannelQueueReport / openchannelQueueReport.controller.js
index 5bee333..74add95 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x17fb=['mustache','sox','fs-extra','squel','crypto','desk.js','to-csv','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','limit','undefined','count','offset','set','apply','reject','save','update','then','destroy','stack','name','send','index','fieldName','type','key','model','query','keys','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','map','VIRTUAL','OpenchannelQueueReport','includeAll','include','rows','show','length','options','catch','create','body','params','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird'];(function(_0x526ce1,_0x22c244){var _0x3d889a=function(_0x5d59fc){while(--_0x5d59fc){_0x526ce1['push'](_0x526ce1['shift']());}};_0x3d889a(++_0x22c244);}(_0x17fb,0x1f2));var _0xb17f=function(_0xbb9dbf,_0x5dafa4){_0xbb9dbf=_0xbb9dbf-0x0;var _0x30223c=_0x17fb[_0xbb9dbf];return _0x30223c;};'use strict';var emlformat=require(_0xb17f('0x0'));var rimraf=require(_0xb17f('0x1'));var zipdir=require(_0xb17f('0x2'));var jsonpatch=require(_0xb17f('0x3'));var rp=require(_0xb17f('0x4'));var moment=require('moment');var BPromise=require(_0xb17f('0x5'));var Mustache=require(_0xb17f('0x6'));var util=require('util');var path=require('path');var sox=require(_0xb17f('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb17f('0x8'));var _=require('lodash');var squel=require(_0xb17f('0x9'));var crypto=require(_0xb17f('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xb17f('0xb'));var toCsv=require(_0xb17f('0xc'));var querystring=require(_0xb17f('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xb17f('0xe'));var qs=require(_0xb17f('0xf'));var as=require(_0xb17f('0x10'));var hardwareService=require(_0xb17f('0x11'));var logger=require(_0xb17f('0x12'))('api');var utils=require(_0xb17f('0x13'));var config=require(_0xb17f('0x14'));var licenseUtil=require(_0xb17f('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1baee8,_0x18fc1d){_0x18fc1d=_0x18fc1d||0xcc;return function(_0x3fbcc0){if(_0x3fbcc0){return _0x1baee8[_0xb17f('0x16')](_0x18fc1d);}return _0x1baee8[_0xb17f('0x17')](_0x18fc1d)[_0xb17f('0x18')]();};}function respondWithResult(_0x2fa78e,_0x33b4ef){_0x33b4ef=_0x33b4ef||0xc8;return function(_0x49371d){if(_0x49371d){return _0x2fa78e[_0xb17f('0x17')](_0x33b4ef)[_0xb17f('0x19')](_0x49371d);}};}function respondWithFilteredResult(_0x38061a,_0x143d5c){return function(_0x5ccffd){if(_0x5ccffd){var _0x29f411=typeof _0x143d5c['offset']==='undefined'&&typeof _0x143d5c[_0xb17f('0x1a')]===_0xb17f('0x1b');var _0xf9fa71=_0x5ccffd[_0xb17f('0x1c')];var _0x34fe81=_0x29f411?0x0:_0x143d5c[_0xb17f('0x1d')];var _0x2d527b=_0x29f411?_0x5ccffd[_0xb17f('0x1c')]:_0x143d5c['offset']+_0x143d5c[_0xb17f('0x1a')];var _0x8ab79f;if(_0x2d527b>=_0xf9fa71){_0x2d527b=_0xf9fa71;_0x8ab79f=0xc8;}else{_0x8ab79f=0xce;}_0x38061a[_0xb17f('0x17')](_0x8ab79f);return _0x38061a[_0xb17f('0x1e')]('Content-Range',_0x34fe81+'-'+_0x2d527b+'/'+_0xf9fa71)[_0xb17f('0x19')](_0x5ccffd);}return null;};}function patchUpdates(_0x1d1fc3){return function(_0x35904c){try{jsonpatch[_0xb17f('0x1f')](_0x35904c,_0x1d1fc3,!![]);}catch(_0x356766){return BPromise[_0xb17f('0x20')](_0x356766);}return _0x35904c[_0xb17f('0x21')]();};}function saveUpdates(_0x34e04f,_0x4dab5d){return function(_0x44e69f){if(_0x44e69f){return _0x44e69f[_0xb17f('0x22')](_0x34e04f)[_0xb17f('0x23')](function(_0x1b7e68){return _0x1b7e68;});}return null;};}function removeEntity(_0x260382,_0x2a7e68){return function(_0x54863f){if(_0x54863f){return _0x54863f[_0xb17f('0x24')]()[_0xb17f('0x23')](function(){_0x260382[_0xb17f('0x17')](0xcc)[_0xb17f('0x18')]();});}};}function handleEntityNotFound(_0x3d26d2,_0x2a11e5){return function(_0x19020a){if(!_0x19020a){_0x3d26d2[_0xb17f('0x16')](0x194);}return _0x19020a;};}function handleError(_0xd12182,_0x4b74d9){_0x4b74d9=_0x4b74d9||0x1f4;return function(_0x1a2c33){logger['error'](_0x1a2c33[_0xb17f('0x25')]);if(_0x1a2c33['name']){delete _0x1a2c33[_0xb17f('0x26')];}_0xd12182[_0xb17f('0x17')](_0x4b74d9)[_0xb17f('0x27')](_0x1a2c33);};}exports[_0xb17f('0x28')]=function(_0x490a92,_0x18f3f9){var _0x560f72={},_0x130f9a={},_0x205160={'count':0x0,'rows':[]};var _0x362b26=_['map'](db['OpenchannelQueueReport']['rawAttributes'],function(_0x15bddb){return{'name':_0x15bddb[_0xb17f('0x29')],'type':_0x15bddb[_0xb17f('0x2a')][_0xb17f('0x2b')]};});_0x130f9a[_0xb17f('0x2c')]=_['map'](_0x362b26,_0xb17f('0x26'));_0x130f9a[_0xb17f('0x2d')]=_[_0xb17f('0x2e')](_0x490a92[_0xb17f('0x2d')]);_0x130f9a['filters']=_[_0xb17f('0x2f')](_0x130f9a['model'],_0x130f9a[_0xb17f('0x2d')]);_0x560f72['attributes']=_['intersection'](_0x130f9a[_0xb17f('0x2c')],qs[_0xb17f('0x30')](_0x490a92['query'][_0xb17f('0x30')]));_0x560f72['attributes']=_0x560f72[_0xb17f('0x31')]['length']?_0x560f72[_0xb17f('0x31')]:_0x130f9a['model'];if(!_0x490a92['query'][_0xb17f('0x32')](_0xb17f('0x33'))){_0x560f72[_0xb17f('0x1a')]=qs[_0xb17f('0x1a')](_0x490a92['query']['limit']);_0x560f72[_0xb17f('0x1d')]=qs['offset'](_0x490a92[_0xb17f('0x2d')][_0xb17f('0x1d')]);}_0x560f72[_0xb17f('0x34')]=qs[_0xb17f('0x35')](_0x490a92[_0xb17f('0x2d')][_0xb17f('0x35')]);_0x560f72[_0xb17f('0x36')]=qs[_0xb17f('0x37')](_[_0xb17f('0x38')](_0x490a92[_0xb17f('0x2d')],_0x130f9a['filters']),_0x362b26);if(_0x490a92[_0xb17f('0x2d')][_0xb17f('0x39')]){_0x560f72[_0xb17f('0x36')]=_[_0xb17f('0x3a')](_0x560f72[_0xb17f('0x36')],{'$or':_[_0xb17f('0x3b')](_0x362b26,function(_0x5dc947){if(_0x5dc947['type']!==_0xb17f('0x3c')){var _0x43ce23={};_0x43ce23[_0x5dc947[_0xb17f('0x26')]]={'$like':'%'+_0x490a92['query'][_0xb17f('0x39')]+'%'};return _0x43ce23;}})});}_0x560f72=_[_0xb17f('0x3a')]({},_0x560f72,_0x490a92['options']);var _0x26fd78={'where':_0x560f72[_0xb17f('0x36')]};return db[_0xb17f('0x3d')][_0xb17f('0x1c')](_0x26fd78)[_0xb17f('0x23')](function(_0x3dfefd){_0x205160[_0xb17f('0x1c')]=_0x3dfefd;if(_0x490a92[_0xb17f('0x2d')][_0xb17f('0x3e')]){_0x560f72[_0xb17f('0x3f')]=[{'all':!![]}];}return db[_0xb17f('0x3d')]['findAll'](_0x560f72);})['then'](function(_0x17f499){_0x205160[_0xb17f('0x40')]=_0x17f499;return _0x205160;})[_0xb17f('0x23')](respondWithFilteredResult(_0x18f3f9,_0x560f72))['catch'](handleError(_0x18f3f9,null));};exports[_0xb17f('0x41')]=function(_0x17c879,_0x3adb42){var _0x1a1994={'raw':!![],'where':{'id':_0x17c879['params']['id']}},_0x3f8379={};_0x3f8379['model']=_[_0xb17f('0x2e')](db[_0xb17f('0x3d')]['rawAttributes']);_0x3f8379[_0xb17f('0x2d')]=_['keys'](_0x17c879[_0xb17f('0x2d')]);_0x3f8379[_0xb17f('0x37')]=_[_0xb17f('0x2f')](_0x3f8379[_0xb17f('0x2c')],_0x3f8379[_0xb17f('0x2d')]);_0x1a1994[_0xb17f('0x31')]=_['intersection'](_0x3f8379[_0xb17f('0x2c')],qs[_0xb17f('0x30')](_0x17c879[_0xb17f('0x2d')][_0xb17f('0x30')]));_0x1a1994[_0xb17f('0x31')]=_0x1a1994[_0xb17f('0x31')][_0xb17f('0x42')]?_0x1a1994[_0xb17f('0x31')]:_0x3f8379['model'];if(_0x17c879[_0xb17f('0x2d')][_0xb17f('0x3e')]){_0x1a1994[_0xb17f('0x3f')]=[{'all':!![]}];}_0x1a1994=_['merge']({},_0x1a1994,_0x17c879[_0xb17f('0x43')]);return db[_0xb17f('0x3d')]['find'](_0x1a1994)[_0xb17f('0x23')](handleEntityNotFound(_0x3adb42,null))[_0xb17f('0x23')](respondWithResult(_0x3adb42,null))[_0xb17f('0x44')](handleError(_0x3adb42,null));};exports[_0xb17f('0x45')]=function(_0x2bb944,_0x4eb0a8){return db['OpenchannelQueueReport'][_0xb17f('0x45')](_0x2bb944['body'],{})[_0xb17f('0x23')](respondWithResult(_0x4eb0a8,0xc9))[_0xb17f('0x44')](handleError(_0x4eb0a8,null));};exports[_0xb17f('0x22')]=function(_0x494366,_0x21c392){if(_0x494366['body']['id']){delete _0x494366[_0xb17f('0x46')]['id'];}return db[_0xb17f('0x3d')]['find']({'where':{'id':_0x494366[_0xb17f('0x47')]['id']}})[_0xb17f('0x23')](handleEntityNotFound(_0x21c392,null))[_0xb17f('0x23')](saveUpdates(_0x494366['body'],null))[_0xb17f('0x23')](respondWithResult(_0x21c392,null))[_0xb17f('0x44')](handleError(_0x21c392,null));};exports['destroy']=function(_0x191c3d,_0x1d5988){return db[_0xb17f('0x3d')]['find']({'where':{'id':_0x191c3d['params']['id']}})[_0xb17f('0x23')](handleEntityNotFound(_0x1d5988,null))['then'](removeEntity(_0x1d5988,null))[_0xb17f('0x44')](handleError(_0x1d5988,null));};exports['describe']=function(_0x19e61a,_0x28cab0){return db[_0xb17f('0x3d')]['describe']()[_0xb17f('0x23')](respondWithResult(_0x28cab0,null))[_0xb17f('0x44')](handleError(_0x28cab0,null));};
\ No newline at end of file
+var _0x6991=['to-csv','ejs','fs-extra','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','status','end','json','offset','undefined','set','Content-Range','apply','reject','then','stack','name','send','map','rawAttributes','type','model','query','filters','attributes','intersection','fields','length','nolimit','limit','order','sort','where','merge','filter','options','OpenchannelQueueReport','count','includeAll','include','findAll','keys','catch','create','body','update','find','params','destroy','describe','rimraf','zip-dir','fast-json-patch','moment','mustache','util','sox'];(function(_0x2bae7f,_0x4dabe4){var _0x248a0b=function(_0x307c22){while(--_0x307c22){_0x2bae7f['push'](_0x2bae7f['shift']());}};_0x248a0b(++_0x4dabe4);}(_0x6991,0x13e));var _0x1699=function(_0x3c2a69,_0x4c8b41){_0x3c2a69=_0x3c2a69-0x0;var _0x596bc8=_0x6991[_0x3c2a69];return _0x596bc8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1699('0x0'));var zipdir=require(_0x1699('0x1'));var jsonpatch=require(_0x1699('0x2'));var rp=require('request-promise');var moment=require(_0x1699('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x1699('0x4'));var util=require(_0x1699('0x5'));var path=require('path');var sox=require(_0x1699('0x6'));var csv=require(_0x1699('0x7'));var ejs=require(_0x1699('0x8'));var fs=require('fs');var fs_extra=require(_0x1699('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x1699('0xa'));var deskjs=require(_0x1699('0xb'));var toCsv=require(_0x1699('0x7'));var querystring=require(_0x1699('0xc'));var Papa=require(_0x1699('0xd'));var Redis=require('ioredis');var authService=require(_0x1699('0xe'));var qs=require(_0x1699('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x1699('0x10'));var logger=require(_0x1699('0x11'))(_0x1699('0x12'));var utils=require('../../config/utils');var config=require(_0x1699('0x13'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x542362,_0x102ed6){_0x102ed6=_0x102ed6||0xcc;return function(_0x44c60e){if(_0x44c60e){return _0x542362['sendStatus'](_0x102ed6);}return _0x542362[_0x1699('0x14')](_0x102ed6)[_0x1699('0x15')]();};}function respondWithResult(_0x1faacc,_0xc483b){_0xc483b=_0xc483b||0xc8;return function(_0xaae928){if(_0xaae928){return _0x1faacc[_0x1699('0x14')](_0xc483b)[_0x1699('0x16')](_0xaae928);}};}function respondWithFilteredResult(_0x91d227,_0x4094a1){return function(_0x5b3800){if(_0x5b3800){var _0x37ebc8=typeof _0x4094a1[_0x1699('0x17')]===_0x1699('0x18')&&typeof _0x4094a1['limit']===_0x1699('0x18');var _0x1f7842=_0x5b3800['count'];var _0x2f1c25=_0x37ebc8?0x0:_0x4094a1[_0x1699('0x17')];var _0x4cf68c=_0x37ebc8?_0x5b3800['count']:_0x4094a1[_0x1699('0x17')]+_0x4094a1['limit'];var _0x123b7f;if(_0x4cf68c>=_0x1f7842){_0x4cf68c=_0x1f7842;_0x123b7f=0xc8;}else{_0x123b7f=0xce;}_0x91d227[_0x1699('0x14')](_0x123b7f);return _0x91d227[_0x1699('0x19')](_0x1699('0x1a'),_0x2f1c25+'-'+_0x4cf68c+'/'+_0x1f7842)[_0x1699('0x16')](_0x5b3800);}return null;};}function patchUpdates(_0x1a2759){return function(_0x1c8c2e){try{jsonpatch[_0x1699('0x1b')](_0x1c8c2e,_0x1a2759,!![]);}catch(_0x5e23c4){return BPromise[_0x1699('0x1c')](_0x5e23c4);}return _0x1c8c2e['save']();};}function saveUpdates(_0x3ae62f,_0x3683cf){return function(_0x2a2cea){if(_0x2a2cea){return _0x2a2cea['update'](_0x3ae62f)[_0x1699('0x1d')](function(_0x1f9333){return _0x1f9333;});}return null;};}function removeEntity(_0x3c18a4,_0x2f9d63){return function(_0x320aea){if(_0x320aea){return _0x320aea['destroy']()[_0x1699('0x1d')](function(){_0x3c18a4[_0x1699('0x14')](0xcc)[_0x1699('0x15')]();});}};}function handleEntityNotFound(_0x1cb2c3,_0x58cd50){return function(_0x7140e1){if(!_0x7140e1){_0x1cb2c3['sendStatus'](0x194);}return _0x7140e1;};}function handleError(_0x1cc7a8,_0x46f52d){_0x46f52d=_0x46f52d||0x1f4;return function(_0x1d4764){logger['error'](_0x1d4764[_0x1699('0x1e')]);if(_0x1d4764['name']){delete _0x1d4764[_0x1699('0x1f')];}_0x1cc7a8[_0x1699('0x14')](_0x46f52d)[_0x1699('0x20')](_0x1d4764);};}exports['index']=function(_0x566ffe,_0x115f03){var _0x32a831={},_0x2b514d={},_0x469da5={'count':0x0,'rows':[]};var _0x5413f8=_[_0x1699('0x21')](db['OpenchannelQueueReport'][_0x1699('0x22')],function(_0x2e9f79){return{'name':_0x2e9f79['fieldName'],'type':_0x2e9f79[_0x1699('0x23')]['key']};});_0x2b514d[_0x1699('0x24')]=_[_0x1699('0x21')](_0x5413f8,_0x1699('0x1f'));_0x2b514d['query']=_['keys'](_0x566ffe[_0x1699('0x25')]);_0x2b514d[_0x1699('0x26')]=_['intersection'](_0x2b514d[_0x1699('0x24')],_0x2b514d['query']);_0x32a831[_0x1699('0x27')]=_[_0x1699('0x28')](_0x2b514d[_0x1699('0x24')],qs[_0x1699('0x29')](_0x566ffe['query']['fields']));_0x32a831[_0x1699('0x27')]=_0x32a831['attributes'][_0x1699('0x2a')]?_0x32a831['attributes']:_0x2b514d['model'];if(!_0x566ffe[_0x1699('0x25')]['hasOwnProperty'](_0x1699('0x2b'))){_0x32a831[_0x1699('0x2c')]=qs[_0x1699('0x2c')](_0x566ffe[_0x1699('0x25')]['limit']);_0x32a831[_0x1699('0x17')]=qs[_0x1699('0x17')](_0x566ffe[_0x1699('0x25')][_0x1699('0x17')]);}_0x32a831[_0x1699('0x2d')]=qs[_0x1699('0x2e')](_0x566ffe[_0x1699('0x25')][_0x1699('0x2e')]);_0x32a831[_0x1699('0x2f')]=qs[_0x1699('0x26')](_['pick'](_0x566ffe[_0x1699('0x25')],_0x2b514d['filters']),_0x5413f8);if(_0x566ffe[_0x1699('0x25')]['filter']){_0x32a831['where']=_[_0x1699('0x30')](_0x32a831[_0x1699('0x2f')],{'$or':_[_0x1699('0x21')](_0x5413f8,function(_0x11b055){if(_0x11b055[_0x1699('0x23')]!=='VIRTUAL'){var _0x303727={};_0x303727[_0x11b055[_0x1699('0x1f')]]={'$like':'%'+_0x566ffe['query'][_0x1699('0x31')]+'%'};return _0x303727;}})});}_0x32a831=_[_0x1699('0x30')]({},_0x32a831,_0x566ffe[_0x1699('0x32')]);var _0x577dc9={'where':_0x32a831[_0x1699('0x2f')]};return db[_0x1699('0x33')][_0x1699('0x34')](_0x577dc9)['then'](function(_0x5df915){_0x469da5[_0x1699('0x34')]=_0x5df915;if(_0x566ffe[_0x1699('0x25')][_0x1699('0x35')]){_0x32a831[_0x1699('0x36')]=[{'all':!![]}];}return db[_0x1699('0x33')][_0x1699('0x37')](_0x32a831);})['then'](function(_0x1960af){_0x469da5['rows']=_0x1960af;return _0x469da5;})[_0x1699('0x1d')](respondWithFilteredResult(_0x115f03,_0x32a831))['catch'](handleError(_0x115f03,null));};exports['show']=function(_0x3c893f,_0x5caf68){var _0x50aced={'raw':!![],'where':{'id':_0x3c893f['params']['id']}},_0x51383f={};_0x51383f[_0x1699('0x24')]=_['keys'](db[_0x1699('0x33')][_0x1699('0x22')]);_0x51383f[_0x1699('0x25')]=_[_0x1699('0x38')](_0x3c893f[_0x1699('0x25')]);_0x51383f[_0x1699('0x26')]=_[_0x1699('0x28')](_0x51383f[_0x1699('0x24')],_0x51383f[_0x1699('0x25')]);_0x50aced[_0x1699('0x27')]=_[_0x1699('0x28')](_0x51383f[_0x1699('0x24')],qs[_0x1699('0x29')](_0x3c893f[_0x1699('0x25')]['fields']));_0x50aced['attributes']=_0x50aced[_0x1699('0x27')][_0x1699('0x2a')]?_0x50aced[_0x1699('0x27')]:_0x51383f['model'];if(_0x3c893f[_0x1699('0x25')]['includeAll']){_0x50aced[_0x1699('0x36')]=[{'all':!![]}];}_0x50aced=_[_0x1699('0x30')]({},_0x50aced,_0x3c893f['options']);return db[_0x1699('0x33')]['find'](_0x50aced)[_0x1699('0x1d')](handleEntityNotFound(_0x5caf68,null))[_0x1699('0x1d')](respondWithResult(_0x5caf68,null))[_0x1699('0x39')](handleError(_0x5caf68,null));};exports[_0x1699('0x3a')]=function(_0x59d3bd,_0x8325f9){return db[_0x1699('0x33')][_0x1699('0x3a')](_0x59d3bd[_0x1699('0x3b')],{})[_0x1699('0x1d')](respondWithResult(_0x8325f9,0xc9))[_0x1699('0x39')](handleError(_0x8325f9,null));};exports[_0x1699('0x3c')]=function(_0x57606b,_0xa0db4b){if(_0x57606b['body']['id']){delete _0x57606b[_0x1699('0x3b')]['id'];}return db[_0x1699('0x33')][_0x1699('0x3d')]({'where':{'id':_0x57606b[_0x1699('0x3e')]['id']}})[_0x1699('0x1d')](handleEntityNotFound(_0xa0db4b,null))['then'](saveUpdates(_0x57606b['body'],null))[_0x1699('0x1d')](respondWithResult(_0xa0db4b,null))[_0x1699('0x39')](handleError(_0xa0db4b,null));};exports[_0x1699('0x3f')]=function(_0x9fb58c,_0x549080){return db[_0x1699('0x33')][_0x1699('0x3d')]({'where':{'id':_0x9fb58c[_0x1699('0x3e')]['id']}})[_0x1699('0x1d')](handleEntityNotFound(_0x549080,null))[_0x1699('0x1d')](removeEntity(_0x549080,null))[_0x1699('0x39')](handleError(_0x549080,null));};exports[_0x1699('0x40')]=function(_0xf4f825,_0x1a05e8){return db[_0x1699('0x33')][_0x1699('0x40')]()['then'](respondWithResult(_0x1a05e8,null))[_0x1699('0x39')](handleError(_0x1a05e8,null));};
\ No newline at end of file