Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / dashboard / dashboard.controller.js
index a2c7017..5d028e9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3490=['map','Dashboard','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filter','merge','include','findAll','catch','show','params','length','includeAll','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','updatedAt','createdAt','iframe','attrUrl','attrs','value','https://','custom','attrPath','clock','attrHourFormat','HH:mm:ss','attrTimezone','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','attrSerie1','attrSerie2','attrSerie3','attrReport','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardItem','findOne','getItems','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','sendStatus','status','limit','count','offset','set','Content-Range','json','reject','save','update','then','destroy','get','CustomDashboards','end','stack','name','index'];(function(_0x380213,_0x4ce407){var _0x5c640d=function(_0x2f71ad){while(--_0x2f71ad){_0x380213['push'](_0x380213['shift']());}};_0x5c640d(++_0x4ce407);}(_0x3490,0xd1));var _0x0349=function(_0x144b19,_0x459235){_0x144b19=_0x144b19-0x0;var _0x35b0dd=_0x3490[_0x144b19];return _0x35b0dd;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0349('0x0'));var zipdir=require(_0x0349('0x1'));var jsonpatch=require(_0x0349('0x2'));var rp=require('request-promise');var moment=require(_0x0349('0x3'));var BPromise=require(_0x0349('0x4'));var Mustache=require(_0x0349('0x5'));var util=require(_0x0349('0x6'));var path=require('path');var sox=require(_0x0349('0x7'));var csv=require(_0x0349('0x8'));var ejs=require(_0x0349('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0349('0xa'));var squel=require(_0x0349('0xb'));var crypto=require(_0x0349('0xc'));var jsforce=require(_0x0349('0xd'));var deskjs=require(_0x0349('0xe'));var toCsv=require(_0x0349('0x8'));var querystring=require(_0x0349('0xf'));var Papa=require(_0x0349('0x10'));var Redis=require(_0x0349('0x11'));var authService=require(_0x0349('0x12'));var qs=require(_0x0349('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0349('0x14'));var logger=require(_0x0349('0x15'))('api');var utils=require(_0x0349('0x16'));var config=require(_0x0349('0x17'));var licenseUtil=require(_0x0349('0x18'));var db=require(_0x0349('0x19'))['db'];config[_0x0349('0x1a')]=_[_0x0349('0x1b')](config[_0x0349('0x1a')],{'host':_0x0349('0x1c'),'port':0x18eb});var socket=require(_0x0349('0x1d'))(new Redis(config[_0x0349('0x1a')]));require(_0x0349('0x1e'))[_0x0349('0x1f')](socket);function respondWithStatusCode(_0x222154,_0x5e8e92){_0x5e8e92=_0x5e8e92||0xcc;return function(_0x389102){if(_0x389102){return _0x222154[_0x0349('0x20')](_0x5e8e92);}return _0x222154[_0x0349('0x21')](_0x5e8e92)['end']();};}function respondWithResult(_0x2ae420,_0x59b856){_0x59b856=_0x59b856||0xc8;return function(_0x5e2160){if(_0x5e2160){return _0x2ae420[_0x0349('0x21')](_0x59b856)['json'](_0x5e2160);}};}function respondWithFilteredResult(_0xec8e5a,_0x4d6c45){return function(_0x92e41d){if(_0x92e41d){var _0x2c96aa=typeof _0x4d6c45['offset']==='undefined'&&typeof _0x4d6c45[_0x0349('0x22')]==='undefined';var _0x8500f=_0x92e41d[_0x0349('0x23')];var _0x5d08d9=_0x2c96aa?0x0:_0x4d6c45[_0x0349('0x24')];var _0x963475=_0x2c96aa?_0x92e41d[_0x0349('0x23')]:_0x4d6c45[_0x0349('0x24')]+_0x4d6c45[_0x0349('0x22')];var _0x28bb81;if(_0x963475>=_0x8500f){_0x963475=_0x8500f;_0x28bb81=0xc8;}else{_0x28bb81=0xce;}_0xec8e5a[_0x0349('0x21')](_0x28bb81);return _0xec8e5a[_0x0349('0x25')](_0x0349('0x26'),_0x5d08d9+'-'+_0x963475+'/'+_0x8500f)[_0x0349('0x27')](_0x92e41d);}return null;};}function patchUpdates(_0x18105d){return function(_0x1b511f){try{jsonpatch['apply'](_0x1b511f,_0x18105d,!![]);}catch(_0x382629){return BPromise[_0x0349('0x28')](_0x382629);}return _0x1b511f[_0x0349('0x29')]();};}function saveUpdates(_0x4b3290,_0x55fb97){return function(_0x948f6a){if(_0x948f6a){return _0x948f6a[_0x0349('0x2a')](_0x4b3290)[_0x0349('0x2b')](function(_0x429544){return _0x429544;});}return null;};}function removeEntity(_0x9eae4b,_0x4c4ebc){return function(_0x11e9cd){if(_0x11e9cd){return _0x11e9cd[_0x0349('0x2c')]()['then'](function(){var _0x201e5d=_0x11e9cd[_0x0349('0x2d')]({'plain':!![]});var _0x388a7d=_0x0349('0x2e');return db['UserProfileResource'][_0x0349('0x2c')]({'where':{'type':_0x388a7d,'resourceId':_0x201e5d['id']}})[_0x0349('0x2b')](function(){return _0x11e9cd;});})['then'](function(){_0x9eae4b[_0x0349('0x21')](0xcc)[_0x0349('0x2f')]();});}};}function handleEntityNotFound(_0x4a3ed7,_0x50728b){return function(_0x2feb05){if(!_0x2feb05){_0x4a3ed7[_0x0349('0x20')](0x194);}return _0x2feb05;};}function handleError(_0xc2b731,_0x18b29b){_0x18b29b=_0x18b29b||0x1f4;return function(_0x1f333b){logger['error'](_0x1f333b[_0x0349('0x30')]);if(_0x1f333b[_0x0349('0x31')]){delete _0x1f333b[_0x0349('0x31')];}_0xc2b731[_0x0349('0x21')](_0x18b29b)['send'](_0x1f333b);};}exports[_0x0349('0x32')]=function(_0x2ce75f,_0x3843ed){var _0x2ddc47={},_0x3223a6={},_0x23f1c4={'count':0x0,'rows':[]};var _0x110ffa=_[_0x0349('0x33')](db[_0x0349('0x34')][_0x0349('0x35')],function(_0x2ab877){return{'name':_0x2ab877[_0x0349('0x36')],'type':_0x2ab877[_0x0349('0x37')][_0x0349('0x38')]};});_0x3223a6['model']=_[_0x0349('0x33')](_0x110ffa,_0x0349('0x31'));_0x3223a6['query']=_[_0x0349('0x39')](_0x2ce75f[_0x0349('0x3a')]);_0x3223a6[_0x0349('0x3b')]=_[_0x0349('0x3c')](_0x3223a6[_0x0349('0x3d')],_0x3223a6['query']);_0x2ddc47[_0x0349('0x3e')]=_[_0x0349('0x3c')](_0x3223a6[_0x0349('0x3d')],qs[_0x0349('0x3f')](_0x2ce75f[_0x0349('0x3a')]['fields']));_0x2ddc47[_0x0349('0x3e')]=_0x2ddc47[_0x0349('0x3e')]['length']?_0x2ddc47[_0x0349('0x3e')]:_0x3223a6[_0x0349('0x3d')];if(!_0x2ce75f[_0x0349('0x3a')][_0x0349('0x40')](_0x0349('0x41'))){_0x2ddc47['limit']=qs[_0x0349('0x22')](_0x2ce75f[_0x0349('0x3a')][_0x0349('0x22')]);_0x2ddc47[_0x0349('0x24')]=qs[_0x0349('0x24')](_0x2ce75f['query'][_0x0349('0x24')]);}_0x2ddc47[_0x0349('0x42')]=qs['sort'](_0x2ce75f['query'][_0x0349('0x43')]);_0x2ddc47[_0x0349('0x44')]=qs[_0x0349('0x3b')](_['pick'](_0x2ce75f[_0x0349('0x3a')],_0x3223a6[_0x0349('0x3b')]),_0x110ffa);if(_0x2ce75f[_0x0349('0x3a')][_0x0349('0x45')]){_0x2ddc47[_0x0349('0x44')]=_[_0x0349('0x46')](_0x2ddc47['where'],{'$or':_[_0x0349('0x33')](_0x110ffa,function(_0x4f36f1){if(_0x4f36f1['type']!=='VIRTUAL'){var _0x4402ca={};_0x4402ca[_0x4f36f1[_0x0349('0x31')]]={'$like':'%'+_0x2ce75f[_0x0349('0x3a')][_0x0349('0x45')]+'%'};return _0x4402ca;}})});}_0x2ddc47=_[_0x0349('0x46')]({},_0x2ddc47,_0x2ce75f['options']);var _0x2b050d={'where':_0x2ddc47['where']};return db[_0x0349('0x34')][_0x0349('0x23')](_0x2b050d)['then'](function(_0x172703){_0x23f1c4[_0x0349('0x23')]=_0x172703;if(_0x2ce75f[_0x0349('0x3a')]['includeAll']){_0x2ddc47[_0x0349('0x47')]=[{'all':!![]}];}return db[_0x0349('0x34')][_0x0349('0x48')](_0x2ddc47);})[_0x0349('0x2b')](function(_0x110d80){_0x23f1c4['rows']=_0x110d80;return _0x23f1c4;})['then'](respondWithFilteredResult(_0x3843ed,_0x2ddc47))[_0x0349('0x49')](handleError(_0x3843ed,null));};exports[_0x0349('0x4a')]=function(_0x1cc8eb,_0x24fd6d){var _0x5b7a52={'raw':![],'where':{'id':_0x1cc8eb[_0x0349('0x4b')]['id']}},_0x2978f5={};_0x2978f5[_0x0349('0x3d')]=_['keys'](db['Dashboard'][_0x0349('0x35')]);_0x2978f5['query']=_[_0x0349('0x39')](_0x1cc8eb['query']);_0x2978f5[_0x0349('0x3b')]=_[_0x0349('0x3c')](_0x2978f5[_0x0349('0x3d')],_0x2978f5[_0x0349('0x3a')]);_0x5b7a52[_0x0349('0x3e')]=_[_0x0349('0x3c')](_0x2978f5['model'],qs[_0x0349('0x3f')](_0x1cc8eb[_0x0349('0x3a')][_0x0349('0x3f')]));_0x5b7a52['attributes']=_0x5b7a52[_0x0349('0x3e')][_0x0349('0x4c')]?_0x5b7a52[_0x0349('0x3e')]:_0x2978f5[_0x0349('0x3d')];if(_0x1cc8eb[_0x0349('0x3a')][_0x0349('0x4d')]){_0x5b7a52[_0x0349('0x47')]=[{'all':!![]}];}_0x5b7a52=_[_0x0349('0x46')]({},_0x5b7a52,_0x1cc8eb[_0x0349('0x4e')]);return db['Dashboard'][_0x0349('0x4f')](_0x5b7a52)[_0x0349('0x2b')](handleEntityNotFound(_0x24fd6d,null))[_0x0349('0x2b')](respondWithResult(_0x24fd6d,null))[_0x0349('0x49')](handleError(_0x24fd6d,null));};exports[_0x0349('0x50')]=function(_0x5a1ab2,_0x4b850d){return db[_0x0349('0x34')][_0x0349('0x50')](_0x5a1ab2[_0x0349('0x51')],{})[_0x0349('0x2b')](function(_0x49e0d1){var _0x283a40=_0x5a1ab2[_0x0349('0x52')][_0x0349('0x2d')]({'plain':!![]});if(!_0x283a40)throw new Error(_0x0349('0x53'));if(_0x283a40[_0x0349('0x54')]===_0x0349('0x52')){var _0x2290bb=_0x49e0d1[_0x0349('0x2d')]({'plain':!![]});var _0x483dac=_0x0349('0x2e');return db[_0x0349('0x55')][_0x0349('0x4f')]({'where':{'name':_0x483dac,'userProfileId':_0x283a40[_0x0349('0x56')]},'raw':!![]})[_0x0349('0x2b')](function(_0x59c965){if(_0x59c965&&_0x59c965[_0x0349('0x57')]===0x0){return db['UserProfileResource'][_0x0349('0x50')]({'name':_0x2290bb[_0x0349('0x31')],'resourceId':_0x2290bb['id'],'type':_0x59c965[_0x0349('0x31')],'sectionId':_0x59c965['id']},{})[_0x0349('0x2b')](function(){return _0x49e0d1;});}else{return _0x49e0d1;}})[_0x0349('0x49')](function(_0x2da907){logger[_0x0349('0x58')](_0x0349('0x59'),_0x2da907);throw _0x2da907;});}return _0x49e0d1;})[_0x0349('0x2b')](respondWithResult(_0x4b850d,0xc9))['catch'](handleError(_0x4b850d,null));};exports[_0x0349('0x5a')]=function(_0x3536e,_0x220fd2){var _0x42a137={'where':{'id':_0x3536e[_0x0349('0x4b')]['id']}},_0x122ce7={};_0x122ce7[_0x0349('0x3d')]=_[_0x0349('0x39')](db['Dashboard'][_0x0349('0x35')]);_0x42a137['attributes']=_[_0x0349('0x3c')](_0x122ce7[_0x0349('0x3d')],qs[_0x0349('0x3f')](_0x3536e[_0x0349('0x3a')][_0x0349('0x3f')]));_0x42a137[_0x0349('0x3e')]=_0x42a137[_0x0349('0x3e')][_0x0349('0x4c')]?_0x42a137[_0x0349('0x3e')]:_0x122ce7['model'];if(_0x3536e[_0x0349('0x3a')][_0x0349('0x4d')]){_0x42a137[_0x0349('0x47')]=[{'all':!![]}];}_0x42a137=_['merge']({},_0x42a137,_0x3536e[_0x0349('0x4e')]);return db[_0x0349('0x34')]['find'](_0x42a137)['then'](handleEntityNotFound(_0x220fd2,null))[_0x0349('0x2b')](function(_0x56c424){if(_0x56c424){var _0x51fe1b=_0x56c424[_0x0349('0x2d')]({'plain':!![]});_0x51fe1b=qs[_0x0349('0x5b')](_0x51fe1b,['id','createdAt',_0x0349('0x5c')]);_0x3536e[_0x0349('0x51')]=_[_0x0349('0x5b')](_0x3536e[_0x0349('0x51')],['id',_0x0349('0x5d'),'updatedAt']);return db[_0x0349('0x34')]['create'](_['merge'](_0x51fe1b,_0x3536e[_0x0349('0x51')]),{'include':_0x3536e[_0x0349('0x3a')][_0x0349('0x4d')]?[{'all':!![]}]:undefined})[_0x0349('0x2b')](function(_0x4f0050){var _0x2e403e=_0x3536e[_0x0349('0x52')][_0x0349('0x2d')]({'plain':!![]});if(!_0x2e403e)throw new Error(_0x0349('0x53'));if(_0x2e403e[_0x0349('0x54')]===_0x0349('0x52')){var _0x2ee72b=_0x4f0050[_0x0349('0x2d')]({'plain':!![]});var _0x1c16d3='CustomDashboards';return db[_0x0349('0x55')][_0x0349('0x4f')]({'where':{'name':_0x1c16d3,'userProfileId':_0x2e403e[_0x0349('0x56')]},'raw':!![]})[_0x0349('0x2b')](function(_0x5b5944){if(_0x5b5944&&_0x5b5944[_0x0349('0x57')]===0x0){return db['UserProfileResource'][_0x0349('0x50')]({'name':_0x2ee72b[_0x0349('0x31')],'resourceId':_0x2ee72b['id'],'type':_0x5b5944[_0x0349('0x31')],'sectionId':_0x5b5944['id']},{})[_0x0349('0x2b')](function(){return _0x4f0050;});}else{return _0x4f0050;}})[_0x0349('0x49')](function(_0x106299){logger[_0x0349('0x58')](_0x0349('0x59'),_0x106299);throw _0x106299;});}return _0x4f0050;});}})['then'](respondWithResult(_0x220fd2,0xc9))[_0x0349('0x49')](handleError(_0x220fd2,null));};exports['update']=function(_0x33b131,_0x4f2e75){if(_0x33b131[_0x0349('0x51')]['id']){delete _0x33b131['body']['id'];}return db['Dashboard'][_0x0349('0x4f')]({'where':{'id':_0x33b131[_0x0349('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4f2e75,null))[_0x0349('0x2b')](saveUpdates(_0x33b131[_0x0349('0x51')],null))['then'](respondWithResult(_0x4f2e75,null))[_0x0349('0x49')](handleError(_0x4f2e75,null));};exports[_0x0349('0x2c')]=function(_0x165453,_0x15572a){return db['Dashboard'][_0x0349('0x4f')]({'where':{'id':_0x165453['params']['id']}})['then'](handleEntityNotFound(_0x15572a,null))[_0x0349('0x2b')](removeEntity(_0x15572a,null))[_0x0349('0x49')](handleError(_0x15572a,null));};function widgetAttributes(_0x5ef109){try{switch(_0x5ef109[_0x0349('0x37')]){case _0x0349('0x5e'):return[{'name':_0x0349('0x5f'),'value':_0x5ef109[_0x0349('0x5f')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x0]?_0x5ef109['attrs'][0x0][_0x0349('0x61')]:undefined)||_0x0349('0x62')}];case _0x0349('0x63'):return[{'name':_0x0349('0x64'),'value':_0x5ef109[_0x0349('0x64')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x0]?_0x5ef109[_0x0349('0x60')][0x0][_0x0349('0x61')]:undefined)||''}];case _0x0349('0x65'):return[{'name':_0x0349('0x66'),'value':_0x5ef109[_0x0349('0x66')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109['attrs'][0x0]?_0x5ef109[_0x0349('0x60')][0x0][_0x0349('0x61')]:undefined)||_0x0349('0x67')},{'name':_0x0349('0x68'),'value':_0x5ef109[_0x0349('0x68')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x1]?_0x5ef109[_0x0349('0x60')][0x1][_0x0349('0x61')]:undefined)||'0.00'},{'name':'attrFontSize','value':_0x5ef109[_0x0349('0x69')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x2]?_0x5ef109[_0x0349('0x60')][0x2]['value']:undefined)||0xc}];case _0x0349('0x6a'):return[{'name':_0x0349('0x6b'),'value':_0x5ef109[_0x0349('0x6b')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109['attrs'][0x0]?_0x5ef109['attrs'][0x0][_0x0349('0x61')]:undefined)||_0x0349('0x6c')},{'name':_0x0349('0x6d'),'value':_0x5ef109[_0x0349('0x6d')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x1]?_0x5ef109[_0x0349('0x60')][0x1]['value']:undefined)||[]},{'name':_0x0349('0x69'),'value':_0x5ef109['attrFontSize']||(_0x5ef109['attrs']&&_0x5ef109['attrs'][0x2]?_0x5ef109[_0x0349('0x60')][0x2]['value']:undefined)||0x14},{'name':'attrChannel','value':_0x5ef109[_0x0349('0x6e')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x3]?_0x5ef109[_0x0349('0x60')][0x3][_0x0349('0x61')]:undefined)||_0x0349('0x6f')},{'name':_0x0349('0x70'),'value':_0x5ef109[_0x0349('0x70')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x4]?_0x5ef109[_0x0349('0x60')][0x4][_0x0349('0x61')]:undefined)||''},{'name':_0x0349('0x71'),'value':_0x5ef109[_0x0349('0x71')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109['attrs'][0x5]?_0x5ef109[_0x0349('0x60')][0x5]['value']:undefined)||''},{'name':_0x0349('0x72'),'value':_0x5ef109[_0x0349('0x72')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x6]?_0x5ef109[_0x0349('0x60')][0x6]['value']:undefined)||''},{'name':_0x0349('0x73'),'value':_0x5ef109[_0x0349('0x73')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x7]?_0x5ef109[_0x0349('0x60')][0x7]['value']:undefined)||''},{'name':_0x0349('0x74'),'value':_0x5ef109['attrWhatsappAccounts']||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x8]?_0x5ef109[_0x0349('0x60')][0x8][_0x0349('0x61')]:undefined)||''},{'name':_0x0349('0x75'),'value':_0x5ef109[_0x0349('0x75')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x9]?_0x5ef109['attrs'][0x9]['value']:undefined)||''}];case _0x0349('0x76'):case'pie-chart':return[{'name':_0x0349('0x77'),'value':_0x5ef109[_0x0349('0x77')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x0]?_0x5ef109['attrs'][0x0][_0x0349('0x61')]:undefined)||'total'},{'name':_0x0349('0x78'),'value':_0x5ef109[_0x0349('0x78')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x1]?_0x5ef109['attrs'][0x1]['value']:undefined)||null},{'name':_0x0349('0x79'),'value':_0x5ef109[_0x0349('0x79')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x2]?_0x5ef109['attrs'][0x2]['value']:undefined)||null},{'name':'attrVoiceQueues','value':_0x5ef109[_0x0349('0x6d')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109['attrs'][0x3]?_0x5ef109['attrs'][0x3]['value']:undefined)||[]},{'name':'attrChannel','value':_0x5ef109[_0x0349('0x6e')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109['attrs'][0x4]?_0x5ef109['attrs'][0x4][_0x0349('0x61')]:undefined)||'voice'},{'name':_0x0349('0x70'),'value':_0x5ef109[_0x0349('0x70')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x5]?_0x5ef109['attrs'][0x5][_0x0349('0x61')]:undefined)||''},{'name':_0x0349('0x71'),'value':_0x5ef109[_0x0349('0x71')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x6]?_0x5ef109[_0x0349('0x60')][0x6][_0x0349('0x61')]:undefined)||''},{'name':'attrSmsAccounts','value':_0x5ef109[_0x0349('0x72')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x7]?_0x5ef109[_0x0349('0x60')][0x7]['value']:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x5ef109[_0x0349('0x73')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x8]?_0x5ef109[_0x0349('0x60')][0x8]['value']:undefined)||''},{'name':_0x0349('0x74'),'value':_0x5ef109[_0x0349('0x74')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x9]?_0x5ef109[_0x0349('0x60')][0x9][_0x0349('0x61')]:undefined)||''},{'name':_0x0349('0x75'),'value':_0x5ef109[_0x0349('0x75')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0xa]?_0x5ef109[_0x0349('0x60')][0xa][_0x0349('0x61')]:undefined)||''}];case'web-report':return[{'name':'attrReport','type':_0x5ef109['reportType']||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109[_0x0349('0x60')][0x0]?_0x5ef109[_0x0349('0x60')][0x0][_0x0349('0x37')]:undefined)||null,'value':_0x5ef109[_0x0349('0x7a')]||(_0x5ef109['attrs']&&_0x5ef109[_0x0349('0x60')][0x0]?_0x5ef109['attrs'][0x0][_0x0349('0x61')]:undefined)||null},{'name':'attrRefresh','value':_0x5ef109[_0x0349('0x7b')]||(_0x5ef109[_0x0349('0x60')]&&_0x5ef109['attrs'][0x1]?_0x5ef109[_0x0349('0x60')][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0x363a11){logger['error'](_0x0349('0x7c'),JSON[_0x0349('0x7d')](_0x363a11));return[];}}exports[_0x0349('0x7e')]=function(_0x4ae153,_0x1087d3,_0x524851){if(_0x4ae153[_0x0349('0x51')]['id']){delete _0x4ae153[_0x0349('0x51')]['id'];}return db['Dashboard'][_0x0349('0x4f')]({'where':{'id':_0x4ae153[_0x0349('0x4b')]['id']}})['then'](handleEntityNotFound(_0x1087d3,null))['then'](function(_0x1376c6){if(_0x1376c6){_0x4ae153['body']['DashboardId']=_0x1376c6['id'];_0x4ae153[_0x0349('0x51')][_0x0349('0x60')]=widgetAttributes(_0x4ae153['body']);return db[_0x0349('0x7f')]['create'](_0x4ae153['body']);}})[_0x0349('0x2b')](respondWithResult(_0x1087d3,null))[_0x0349('0x49')](handleError(_0x1087d3,null));};exports['getItems']=function(_0x5d27ac,_0xc9cb3b,_0x184109){var _0x270701={};var _0x59a801={};var _0x1809d8;var _0x31b5c1;return db['Dashboard'][_0x0349('0x80')]({'where':{'id':_0x5d27ac[_0x0349('0x4b')]['id']}})[_0x0349('0x2b')](handleEntityNotFound(_0xc9cb3b,null))['then'](function(_0x53c693){if(_0x53c693){_0x1809d8=_0x53c693;_0x59a801[_0x0349('0x3d')]=_[_0x0349('0x39')](db[_0x0349('0x7f')][_0x0349('0x35')]);_0x59a801[_0x0349('0x3a')]=_[_0x0349('0x39')](_0x5d27ac[_0x0349('0x3a')]);_0x59a801[_0x0349('0x3b')]=_[_0x0349('0x3c')](_0x59a801[_0x0349('0x3d')],_0x59a801[_0x0349('0x3a')]);_0x270701['attributes']=_[_0x0349('0x3c')](_0x59a801[_0x0349('0x3d')],qs[_0x0349('0x3f')](_0x5d27ac[_0x0349('0x3a')][_0x0349('0x3f')]));_0x270701['attributes']=_0x270701['attributes'][_0x0349('0x4c')]?_0x270701['attributes']:_0x59a801['model'];_0x270701[_0x0349('0x42')]=qs['sort'](_0x5d27ac['query'][_0x0349('0x43')]);_0x270701[_0x0349('0x44')]=qs[_0x0349('0x3b')](_['pick'](_0x5d27ac['query'],_0x59a801[_0x0349('0x3b')]));if(_0x5d27ac[_0x0349('0x3a')][_0x0349('0x45')]){_0x270701[_0x0349('0x44')]=_['merge'](_0x270701[_0x0349('0x44')],{'$or':_[_0x0349('0x33')](_0x270701[_0x0349('0x3e')],function(_0x3bf102){var _0x3e5589={};_0x3e5589[_0x3bf102]={'$like':'%'+_0x5d27ac[_0x0349('0x3a')][_0x0349('0x45')]+'%'};return _0x3e5589;})});}_0x270701=_[_0x0349('0x46')]({},_0x270701,_0x5d27ac['options']);return _0x1809d8[_0x0349('0x81')](_0x270701);}})[_0x0349('0x2b')](function(_0x2f186e){if(_0x2f186e){_0x31b5c1=_0x2f186e[_0x0349('0x4c')];if(!_0x5d27ac['query']['hasOwnProperty']('nolimit')){_0x270701[_0x0349('0x22')]=qs[_0x0349('0x22')](_0x5d27ac[_0x0349('0x3a')][_0x0349('0x22')]);_0x270701['offset']=qs[_0x0349('0x24')](_0x5d27ac[_0x0349('0x3a')][_0x0349('0x24')]);}return _0x1809d8['getItems'](_0x270701);}})[_0x0349('0x2b')](function(_0x47b4d2){if(_0x47b4d2){return _0x47b4d2?{'count':_0x31b5c1,'rows':_0x47b4d2}:null;}})[_0x0349('0x2b')](respondWithResult(_0xc9cb3b,null))[_0x0349('0x49')](handleError(_0xc9cb3b,null));};
\ No newline at end of file
+var _0x2cf2=['moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','end','status','json','offset','undefined','limit','count','Content-Range','reject','update','then','get','CustomDashboards','destroy','sendStatus','error','stack','name','send','index','rawAttributes','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','Dashboard','findAll','rows','catch','show','params','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','Unable\x20to\x20retrieve\x20the\x20current\x20user','attrUrl','attrs','value','https://','custom','attrPath','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','total','attrSerie2','web-report','attrReport','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardId','DashboardItem','getItems','findOne','eml-format','rimraf','zip-dir','request-promise'];(function(_0x5e17e7,_0x551ed9){var _0x19a417=function(_0x10c981){while(--_0x10c981){_0x5e17e7['push'](_0x5e17e7['shift']());}};_0x19a417(++_0x551ed9);}(_0x2cf2,0x102));var _0x22cf=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2cf2[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0x22cf('0x0'));var rimraf=require(_0x22cf('0x1'));var zipdir=require(_0x22cf('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x22cf('0x3'));var moment=require(_0x22cf('0x4'));var BPromise=require(_0x22cf('0x5'));var Mustache=require(_0x22cf('0x6'));var util=require(_0x22cf('0x7'));var path=require(_0x22cf('0x8'));var sox=require(_0x22cf('0x9'));var csv=require(_0x22cf('0xa'));var ejs=require(_0x22cf('0xb'));var fs=require('fs');var fs_extra=require(_0x22cf('0xc'));var _=require(_0x22cf('0xd'));var squel=require('squel');var crypto=require(_0x22cf('0xe'));var jsforce=require(_0x22cf('0xf'));var deskjs=require(_0x22cf('0x10'));var toCsv=require('to-csv');var querystring=require(_0x22cf('0x11'));var Papa=require(_0x22cf('0x12'));var Redis=require('ioredis');var authService=require(_0x22cf('0x13'));var qs=require(_0x22cf('0x14'));var as=require(_0x22cf('0x15'));var hardwareService=require(_0x22cf('0x16'));var logger=require(_0x22cf('0x17'))('api');var utils=require(_0x22cf('0x18'));var config=require(_0x22cf('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x22cf('0x1a'))['db'];config[_0x22cf('0x1b')]=_[_0x22cf('0x1c')](config['redis'],{'host':_0x22cf('0x1d'),'port':0x18eb});var socket=require(_0x22cf('0x1e'))(new Redis(config[_0x22cf('0x1b')]));require('./dashboard.socket')[_0x22cf('0x1f')](socket);function respondWithStatusCode(_0x228146,_0x8cc58d){_0x8cc58d=_0x8cc58d||0xcc;return function(_0x12c29a){if(_0x12c29a){return _0x228146['sendStatus'](_0x8cc58d);}return _0x228146['status'](_0x8cc58d)[_0x22cf('0x20')]();};}function respondWithResult(_0x531159,_0x4d0aae){_0x4d0aae=_0x4d0aae||0xc8;return function(_0x53dc03){if(_0x53dc03){return _0x531159[_0x22cf('0x21')](_0x4d0aae)[_0x22cf('0x22')](_0x53dc03);}};}function respondWithFilteredResult(_0x57f6dd,_0x2707da){return function(_0x355275){if(_0x355275){var _0x314aad=typeof _0x2707da[_0x22cf('0x23')]===_0x22cf('0x24')&&typeof _0x2707da[_0x22cf('0x25')]===_0x22cf('0x24');var _0x2268eb=_0x355275[_0x22cf('0x26')];var _0x2fee6b=_0x314aad?0x0:_0x2707da['offset'];var _0x2bf1de=_0x314aad?_0x355275['count']:_0x2707da['offset']+_0x2707da['limit'];var _0x4857e7;if(_0x2bf1de>=_0x2268eb){_0x2bf1de=_0x2268eb;_0x4857e7=0xc8;}else{_0x4857e7=0xce;}_0x57f6dd[_0x22cf('0x21')](_0x4857e7);return _0x57f6dd['set'](_0x22cf('0x27'),_0x2fee6b+'-'+_0x2bf1de+'/'+_0x2268eb)['json'](_0x355275);}return null;};}function patchUpdates(_0x1d4fb3){return function(_0x596b8c){try{jsonpatch['apply'](_0x596b8c,_0x1d4fb3,!![]);}catch(_0x380bb5){return BPromise[_0x22cf('0x28')](_0x380bb5);}return _0x596b8c['save']();};}function saveUpdates(_0x1fcaca,_0x4dec09){return function(_0xea9d20){if(_0xea9d20){return _0xea9d20[_0x22cf('0x29')](_0x1fcaca)[_0x22cf('0x2a')](function(_0x4a9844){return _0x4a9844;});}return null;};}function removeEntity(_0x2787f7,_0x54392e){return function(_0x11790e){if(_0x11790e){return _0x11790e['destroy']()[_0x22cf('0x2a')](function(){var _0x314a51=_0x11790e[_0x22cf('0x2b')]({'plain':!![]});var _0x18750d=_0x22cf('0x2c');return db['UserProfileResource'][_0x22cf('0x2d')]({'where':{'type':_0x18750d,'resourceId':_0x314a51['id']}})[_0x22cf('0x2a')](function(){return _0x11790e;});})[_0x22cf('0x2a')](function(){_0x2787f7[_0x22cf('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2e1247,_0x490389){return function(_0x558d75){if(!_0x558d75){_0x2e1247[_0x22cf('0x2e')](0x194);}return _0x558d75;};}function handleError(_0x5734bb,_0x6caeca){_0x6caeca=_0x6caeca||0x1f4;return function(_0x2b4cce){logger[_0x22cf('0x2f')](_0x2b4cce[_0x22cf('0x30')]);if(_0x2b4cce[_0x22cf('0x31')]){delete _0x2b4cce['name'];}_0x5734bb['status'](_0x6caeca)[_0x22cf('0x32')](_0x2b4cce);};}exports[_0x22cf('0x33')]=function(_0x318ee6,_0x326655){var _0x3e7d9b={},_0x40498e={},_0x15265b={'count':0x0,'rows':[]};var _0x467e95=_['map'](db['Dashboard'][_0x22cf('0x34')],function(_0x4530e5){return{'name':_0x4530e5['fieldName'],'type':_0x4530e5[_0x22cf('0x35')][_0x22cf('0x36')]};});_0x40498e[_0x22cf('0x37')]=_[_0x22cf('0x38')](_0x467e95,_0x22cf('0x31'));_0x40498e[_0x22cf('0x39')]=_[_0x22cf('0x3a')](_0x318ee6[_0x22cf('0x39')]);_0x40498e[_0x22cf('0x3b')]=_[_0x22cf('0x3c')](_0x40498e[_0x22cf('0x37')],_0x40498e['query']);_0x3e7d9b[_0x22cf('0x3d')]=_[_0x22cf('0x3c')](_0x40498e[_0x22cf('0x37')],qs[_0x22cf('0x3e')](_0x318ee6[_0x22cf('0x39')][_0x22cf('0x3e')]));_0x3e7d9b[_0x22cf('0x3d')]=_0x3e7d9b[_0x22cf('0x3d')][_0x22cf('0x3f')]?_0x3e7d9b[_0x22cf('0x3d')]:_0x40498e['model'];if(!_0x318ee6[_0x22cf('0x39')][_0x22cf('0x40')]('nolimit')){_0x3e7d9b[_0x22cf('0x25')]=qs['limit'](_0x318ee6['query'][_0x22cf('0x25')]);_0x3e7d9b[_0x22cf('0x23')]=qs[_0x22cf('0x23')](_0x318ee6[_0x22cf('0x39')][_0x22cf('0x23')]);}_0x3e7d9b[_0x22cf('0x41')]=qs[_0x22cf('0x42')](_0x318ee6[_0x22cf('0x39')][_0x22cf('0x42')]);_0x3e7d9b[_0x22cf('0x43')]=qs[_0x22cf('0x3b')](_[_0x22cf('0x44')](_0x318ee6[_0x22cf('0x39')],_0x40498e[_0x22cf('0x3b')]),_0x467e95);if(_0x318ee6[_0x22cf('0x39')]['filter']){_0x3e7d9b[_0x22cf('0x43')]=_[_0x22cf('0x45')](_0x3e7d9b['where'],{'$or':_['map'](_0x467e95,function(_0x5cf9a2){if(_0x5cf9a2[_0x22cf('0x35')]!==_0x22cf('0x46')){var _0x17eeb0={};_0x17eeb0[_0x5cf9a2[_0x22cf('0x31')]]={'$like':'%'+_0x318ee6[_0x22cf('0x39')][_0x22cf('0x47')]+'%'};return _0x17eeb0;}})});}_0x3e7d9b=_[_0x22cf('0x45')]({},_0x3e7d9b,_0x318ee6[_0x22cf('0x48')]);var _0x27a672={'where':_0x3e7d9b['where']};return db['Dashboard']['count'](_0x27a672)[_0x22cf('0x2a')](function(_0x3ce04d){_0x15265b[_0x22cf('0x26')]=_0x3ce04d;if(_0x318ee6[_0x22cf('0x39')][_0x22cf('0x49')]){_0x3e7d9b[_0x22cf('0x4a')]=[{'all':!![]}];}return db[_0x22cf('0x4b')][_0x22cf('0x4c')](_0x3e7d9b);})[_0x22cf('0x2a')](function(_0xa7e36f){_0x15265b[_0x22cf('0x4d')]=_0xa7e36f;return _0x15265b;})[_0x22cf('0x2a')](respondWithFilteredResult(_0x326655,_0x3e7d9b))[_0x22cf('0x4e')](handleError(_0x326655,null));};exports[_0x22cf('0x4f')]=function(_0x9997c8,_0x2c60f0){var _0x49964f={'raw':![],'where':{'id':_0x9997c8[_0x22cf('0x50')]['id']}},_0x5516c7={};_0x5516c7['model']=_[_0x22cf('0x3a')](db[_0x22cf('0x4b')]['rawAttributes']);_0x5516c7['query']=_[_0x22cf('0x3a')](_0x9997c8[_0x22cf('0x39')]);_0x5516c7[_0x22cf('0x3b')]=_[_0x22cf('0x3c')](_0x5516c7[_0x22cf('0x37')],_0x5516c7[_0x22cf('0x39')]);_0x49964f[_0x22cf('0x3d')]=_[_0x22cf('0x3c')](_0x5516c7['model'],qs[_0x22cf('0x3e')](_0x9997c8['query'][_0x22cf('0x3e')]));_0x49964f[_0x22cf('0x3d')]=_0x49964f['attributes'][_0x22cf('0x3f')]?_0x49964f[_0x22cf('0x3d')]:_0x5516c7['model'];if(_0x9997c8[_0x22cf('0x39')][_0x22cf('0x49')]){_0x49964f[_0x22cf('0x4a')]=[{'all':!![]}];}_0x49964f=_[_0x22cf('0x45')]({},_0x49964f,_0x9997c8[_0x22cf('0x48')]);return db['Dashboard'][_0x22cf('0x51')](_0x49964f)[_0x22cf('0x2a')](handleEntityNotFound(_0x2c60f0,null))[_0x22cf('0x2a')](respondWithResult(_0x2c60f0,null))['catch'](handleError(_0x2c60f0,null));};exports[_0x22cf('0x52')]=function(_0x325a5e,_0x273df9){return db[_0x22cf('0x4b')][_0x22cf('0x52')](_0x325a5e[_0x22cf('0x53')],{})[_0x22cf('0x2a')](function(_0x2487c1){var _0x4f4374=_0x325a5e[_0x22cf('0x54')][_0x22cf('0x2b')]({'plain':!![]});if(!_0x4f4374)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4f4374[_0x22cf('0x55')]===_0x22cf('0x54')){var _0x39efce=_0x2487c1[_0x22cf('0x2b')]({'plain':!![]});var _0x29b3b6=_0x22cf('0x2c');return db[_0x22cf('0x56')][_0x22cf('0x51')]({'where':{'name':_0x29b3b6,'userProfileId':_0x4f4374[_0x22cf('0x57')]},'raw':!![]})['then'](function(_0x4e510){if(_0x4e510&&_0x4e510[_0x22cf('0x58')]===0x0){return db[_0x22cf('0x59')]['create']({'name':_0x39efce['name'],'resourceId':_0x39efce['id'],'type':_0x4e510[_0x22cf('0x31')],'sectionId':_0x4e510['id']},{})[_0x22cf('0x2a')](function(){return _0x2487c1;});}else{return _0x2487c1;}})[_0x22cf('0x4e')](function(_0x510f50){logger[_0x22cf('0x2f')](_0x22cf('0x5a'),_0x510f50);throw _0x510f50;});}return _0x2487c1;})[_0x22cf('0x2a')](respondWithResult(_0x273df9,0xc9))[_0x22cf('0x4e')](handleError(_0x273df9,null));};exports[_0x22cf('0x5b')]=function(_0x64da9d,_0x55df79){var _0x5306de={'where':{'id':_0x64da9d[_0x22cf('0x50')]['id']}},_0x32599d={};_0x32599d['model']=_['keys'](db[_0x22cf('0x4b')][_0x22cf('0x34')]);_0x5306de['attributes']=_[_0x22cf('0x3c')](_0x32599d[_0x22cf('0x37')],qs[_0x22cf('0x3e')](_0x64da9d[_0x22cf('0x39')][_0x22cf('0x3e')]));_0x5306de['attributes']=_0x5306de['attributes'][_0x22cf('0x3f')]?_0x5306de['attributes']:_0x32599d['model'];if(_0x64da9d[_0x22cf('0x39')][_0x22cf('0x49')]){_0x5306de['include']=[{'all':!![]}];}_0x5306de=_['merge']({},_0x5306de,_0x64da9d['options']);return db[_0x22cf('0x4b')][_0x22cf('0x51')](_0x5306de)[_0x22cf('0x2a')](handleEntityNotFound(_0x55df79,null))[_0x22cf('0x2a')](function(_0xc8e42c){if(_0xc8e42c){var _0x58dc22=_0xc8e42c[_0x22cf('0x2b')]({'plain':!![]});_0x58dc22=qs[_0x22cf('0x5c')](_0x58dc22,['id',_0x22cf('0x5d'),'updatedAt']);_0x64da9d[_0x22cf('0x53')]=_[_0x22cf('0x5c')](_0x64da9d[_0x22cf('0x53')],['id',_0x22cf('0x5d'),_0x22cf('0x5e')]);return db[_0x22cf('0x4b')][_0x22cf('0x52')](_['merge'](_0x58dc22,_0x64da9d['body']),{'include':_0x64da9d[_0x22cf('0x39')][_0x22cf('0x49')]?[{'all':!![]}]:undefined})['then'](function(_0x36cbeb){var _0x9b6db3=_0x64da9d[_0x22cf('0x54')][_0x22cf('0x2b')]({'plain':!![]});if(!_0x9b6db3)throw new Error(_0x22cf('0x5f'));if(_0x9b6db3['role']===_0x22cf('0x54')){var _0x2788ff=_0x36cbeb[_0x22cf('0x2b')]({'plain':!![]});var _0x22ef22=_0x22cf('0x2c');return db['UserProfileSection'][_0x22cf('0x51')]({'where':{'name':_0x22ef22,'userProfileId':_0x9b6db3[_0x22cf('0x57')]},'raw':!![]})[_0x22cf('0x2a')](function(_0x5592f0){if(_0x5592f0&&_0x5592f0[_0x22cf('0x58')]===0x0){return db[_0x22cf('0x59')][_0x22cf('0x52')]({'name':_0x2788ff[_0x22cf('0x31')],'resourceId':_0x2788ff['id'],'type':_0x5592f0['name'],'sectionId':_0x5592f0['id']},{})[_0x22cf('0x2a')](function(){return _0x36cbeb;});}else{return _0x36cbeb;}})[_0x22cf('0x4e')](function(_0x248518){logger[_0x22cf('0x2f')](_0x22cf('0x5a'),_0x248518);throw _0x248518;});}return _0x36cbeb;});}})[_0x22cf('0x2a')](respondWithResult(_0x55df79,0xc9))['catch'](handleError(_0x55df79,null));};exports[_0x22cf('0x29')]=function(_0x2c9168,_0x33bfe2){if(_0x2c9168[_0x22cf('0x53')]['id']){delete _0x2c9168[_0x22cf('0x53')]['id'];}return db[_0x22cf('0x4b')][_0x22cf('0x51')]({'where':{'id':_0x2c9168[_0x22cf('0x50')]['id']}})[_0x22cf('0x2a')](handleEntityNotFound(_0x33bfe2,null))[_0x22cf('0x2a')](saveUpdates(_0x2c9168[_0x22cf('0x53')],null))[_0x22cf('0x2a')](respondWithResult(_0x33bfe2,null))[_0x22cf('0x4e')](handleError(_0x33bfe2,null));};exports[_0x22cf('0x2d')]=function(_0x149be4,_0x379995){return db[_0x22cf('0x4b')][_0x22cf('0x51')]({'where':{'id':_0x149be4[_0x22cf('0x50')]['id']}})[_0x22cf('0x2a')](handleEntityNotFound(_0x379995,null))[_0x22cf('0x2a')](removeEntity(_0x379995,null))['catch'](handleError(_0x379995,null));};function widgetAttributes(_0xe3f29b){try{switch(_0xe3f29b[_0x22cf('0x35')]){case'iframe':return[{'name':_0x22cf('0x60'),'value':_0xe3f29b['attrUrl']||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b['attrs'][0x0][_0x22cf('0x62')]:undefined)||_0x22cf('0x63')}];case _0x22cf('0x64'):return[{'name':_0x22cf('0x65'),'value':_0xe3f29b[_0x22cf('0x65')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||''}];case'clock':return[{'name':_0x22cf('0x66'),'value':_0xe3f29b[_0x22cf('0x66')]||(_0xe3f29b['attrs']&&_0xe3f29b['attrs'][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||_0x22cf('0x67')},{'name':'attrTimezone','value':_0xe3f29b[_0x22cf('0x68')]||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x1]?_0xe3f29b[_0x22cf('0x61')][0x1][_0x22cf('0x62')]:undefined)||_0x22cf('0x69')},{'name':'attrFontSize','value':_0xe3f29b[_0x22cf('0x6a')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x2]?_0xe3f29b['attrs'][0x2][_0x22cf('0x62')]:undefined)||0xc}];case'counter':return[{'name':'attrMetric','value':_0xe3f29b['attrMetric']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||'total'},{'name':_0x22cf('0x6b'),'value':_0xe3f29b[_0x22cf('0x6b')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x1]?_0xe3f29b[_0x22cf('0x61')][0x1][_0x22cf('0x62')]:undefined)||[]},{'name':_0x22cf('0x6a'),'value':_0xe3f29b[_0x22cf('0x6a')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x2]?_0xe3f29b[_0x22cf('0x61')][0x2][_0x22cf('0x62')]:undefined)||0x14},{'name':'attrChannel','value':_0xe3f29b[_0x22cf('0x6c')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x3]?_0xe3f29b[_0x22cf('0x61')][0x3][_0x22cf('0x62')]:undefined)||_0x22cf('0x6d')},{'name':_0x22cf('0x6e'),'value':_0xe3f29b[_0x22cf('0x6e')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x4]?_0xe3f29b[_0x22cf('0x61')][0x4][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x6f'),'value':_0xe3f29b[_0x22cf('0x6f')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x5]?_0xe3f29b[_0x22cf('0x61')][0x5][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x70'),'value':_0xe3f29b['attrSmsAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x6]?_0xe3f29b[_0x22cf('0x61')][0x6][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x71'),'value':_0xe3f29b[_0x22cf('0x71')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x7]?_0xe3f29b['attrs'][0x7]['value']:undefined)||''},{'name':_0x22cf('0x72'),'value':_0xe3f29b['attrWhatsappAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x8]?_0xe3f29b[_0x22cf('0x61')][0x8][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x73'),'value':_0xe3f29b['attrChatWebsites']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x9]?_0xe3f29b[_0x22cf('0x61')][0x9]['value']:undefined)||''}];case _0x22cf('0x74'):case _0x22cf('0x75'):return[{'name':_0x22cf('0x76'),'value':_0xe3f29b['attrSerie1']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||_0x22cf('0x77')},{'name':_0x22cf('0x78'),'value':_0xe3f29b[_0x22cf('0x78')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x1]?_0xe3f29b['attrs'][0x1]['value']:undefined)||null},{'name':'attrSerie3','value':_0xe3f29b['attrSerie3']||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x2]?_0xe3f29b[_0x22cf('0x61')][0x2][_0x22cf('0x62')]:undefined)||null},{'name':_0x22cf('0x6b'),'value':_0xe3f29b[_0x22cf('0x6b')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x3]?_0xe3f29b['attrs'][0x3][_0x22cf('0x62')]:undefined)||[]},{'name':_0x22cf('0x6c'),'value':_0xe3f29b[_0x22cf('0x6c')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x4]?_0xe3f29b['attrs'][0x4][_0x22cf('0x62')]:undefined)||_0x22cf('0x6d')},{'name':_0x22cf('0x6e'),'value':_0xe3f29b['attrEmailAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x5]?_0xe3f29b[_0x22cf('0x61')][0x5][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x6f'),'value':_0xe3f29b['attrFaxAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x6]?_0xe3f29b[_0x22cf('0x61')][0x6][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x70'),'value':_0xe3f29b[_0x22cf('0x70')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x7]?_0xe3f29b[_0x22cf('0x61')][0x7][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x71'),'value':_0xe3f29b[_0x22cf('0x71')]||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x8]?_0xe3f29b['attrs'][0x8]['value']:undefined)||''},{'name':_0x22cf('0x72'),'value':_0xe3f29b[_0x22cf('0x72')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x9]?_0xe3f29b['attrs'][0x9][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x73'),'value':_0xe3f29b[_0x22cf('0x73')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0xa]?_0xe3f29b['attrs'][0xa][_0x22cf('0x62')]:undefined)||''}];case _0x22cf('0x79'):return[{'name':_0x22cf('0x7a'),'type':_0xe3f29b['reportType']||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x35')]:undefined)||null,'value':_0xe3f29b[_0x22cf('0x7a')]||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||null},{'name':_0x22cf('0x7b'),'value':_0xe3f29b[_0x22cf('0x7b')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x1]?_0xe3f29b['attrs'][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0x980153){logger[_0x22cf('0x2f')](_0x22cf('0x7c'),JSON[_0x22cf('0x7d')](_0x980153));return[];}}exports[_0x22cf('0x7e')]=function(_0x5a4174,_0x3d4ae2,_0x74dca1){if(_0x5a4174[_0x22cf('0x53')]['id']){delete _0x5a4174[_0x22cf('0x53')]['id'];}return db[_0x22cf('0x4b')][_0x22cf('0x51')]({'where':{'id':_0x5a4174[_0x22cf('0x50')]['id']}})['then'](handleEntityNotFound(_0x3d4ae2,null))[_0x22cf('0x2a')](function(_0x8fdf62){if(_0x8fdf62){_0x5a4174[_0x22cf('0x53')][_0x22cf('0x7f')]=_0x8fdf62['id'];_0x5a4174[_0x22cf('0x53')][_0x22cf('0x61')]=widgetAttributes(_0x5a4174[_0x22cf('0x53')]);return db[_0x22cf('0x80')][_0x22cf('0x52')](_0x5a4174[_0x22cf('0x53')]);}})[_0x22cf('0x2a')](respondWithResult(_0x3d4ae2,null))[_0x22cf('0x4e')](handleError(_0x3d4ae2,null));};exports[_0x22cf('0x81')]=function(_0x48e629,_0x3fcb39,_0x2cd54b){var _0x30a94d={};var _0xcf8394={};var _0x5b626d;var _0x1f04cb;return db[_0x22cf('0x4b')][_0x22cf('0x82')]({'where':{'id':_0x48e629[_0x22cf('0x50')]['id']}})[_0x22cf('0x2a')](handleEntityNotFound(_0x3fcb39,null))[_0x22cf('0x2a')](function(_0x434b30){if(_0x434b30){_0x5b626d=_0x434b30;_0xcf8394['model']=_[_0x22cf('0x3a')](db['DashboardItem']['rawAttributes']);_0xcf8394['query']=_[_0x22cf('0x3a')](_0x48e629[_0x22cf('0x39')]);_0xcf8394['filters']=_[_0x22cf('0x3c')](_0xcf8394[_0x22cf('0x37')],_0xcf8394[_0x22cf('0x39')]);_0x30a94d['attributes']=_[_0x22cf('0x3c')](_0xcf8394[_0x22cf('0x37')],qs[_0x22cf('0x3e')](_0x48e629[_0x22cf('0x39')][_0x22cf('0x3e')]));_0x30a94d[_0x22cf('0x3d')]=_0x30a94d[_0x22cf('0x3d')][_0x22cf('0x3f')]?_0x30a94d[_0x22cf('0x3d')]:_0xcf8394['model'];_0x30a94d[_0x22cf('0x41')]=qs[_0x22cf('0x42')](_0x48e629['query'][_0x22cf('0x42')]);_0x30a94d[_0x22cf('0x43')]=qs[_0x22cf('0x3b')](_[_0x22cf('0x44')](_0x48e629['query'],_0xcf8394[_0x22cf('0x3b')]));if(_0x48e629['query'][_0x22cf('0x47')]){_0x30a94d['where']=_[_0x22cf('0x45')](_0x30a94d[_0x22cf('0x43')],{'$or':_[_0x22cf('0x38')](_0x30a94d['attributes'],function(_0x3914e2){var _0x2e3b41={};_0x2e3b41[_0x3914e2]={'$like':'%'+_0x48e629[_0x22cf('0x39')][_0x22cf('0x47')]+'%'};return _0x2e3b41;})});}_0x30a94d=_[_0x22cf('0x45')]({},_0x30a94d,_0x48e629[_0x22cf('0x48')]);return _0x5b626d[_0x22cf('0x81')](_0x30a94d);}})[_0x22cf('0x2a')](function(_0x140b6c){if(_0x140b6c){_0x1f04cb=_0x140b6c[_0x22cf('0x3f')];if(!_0x48e629['query'][_0x22cf('0x40')]('nolimit')){_0x30a94d['limit']=qs[_0x22cf('0x25')](_0x48e629[_0x22cf('0x39')][_0x22cf('0x25')]);_0x30a94d['offset']=qs[_0x22cf('0x23')](_0x48e629[_0x22cf('0x39')][_0x22cf('0x23')]);}return _0x5b626d[_0x22cf('0x81')](_0x30a94d);}})['then'](function(_0x5c101e){if(_0x5c101e){return _0x5c101e?{'count':_0x1f04cb,'rows':_0x5c101e}:null;}})[_0x22cf('0x2a')](respondWithResult(_0x3fcb39,null))[_0x22cf('0x4e')](handleError(_0x3fcb39,null));};
\ No newline at end of file