Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / dashboard / dashboard.controller.js
index c936392..9d8466e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa5d9=['attrSerie3','web-report','attrReport','attrRefresh','widgetAttributes:\x20%s','stringify','DashboardId','DashboardItem','getItems','findOne','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','redis','defaults','localhost','./dashboard.socket','register','sendStatus','end','status','offset','undefined','count','set','Content-Range','json','apply','reject','save','update','then','destroy','get','UserProfileResource','stack','name','send','index','map','Dashboard','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','VIRTUAL','filter','merge','options','includeAll','include','findAll','rows','catch','params','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','createdAt','updatedAt','iframe','attrUrl','attrs','value','https://','custom','attrPath','clock','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2'];(function(_0x5037ab,_0x43209e){var _0x512adb=function(_0x261783){while(--_0x261783){_0x5037ab['push'](_0x5037ab['shift']());}};_0x512adb(++_0x43209e);}(_0xa5d9,0x190));var _0x9a5d=function(_0x5a081e,_0x252d58){_0x5a081e=_0x5a081e-0x0;var _0x405998=_0xa5d9[_0x5a081e];return _0x405998;};'use strict';var emlformat=require(_0x9a5d('0x0'));var rimraf=require(_0x9a5d('0x1'));var zipdir=require(_0x9a5d('0x2'));var jsonpatch=require(_0x9a5d('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x9a5d('0x4'));var Mustache=require(_0x9a5d('0x5'));var util=require(_0x9a5d('0x6'));var path=require(_0x9a5d('0x7'));var sox=require('sox');var csv=require(_0x9a5d('0x8'));var ejs=require(_0x9a5d('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9a5d('0xa'));var squel=require(_0x9a5d('0xb'));var crypto=require(_0x9a5d('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x9a5d('0xd'));var toCsv=require('to-csv');var querystring=require(_0x9a5d('0xe'));var Papa=require(_0x9a5d('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x9a5d('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x9a5d('0x11'))(_0x9a5d('0x12'));var utils=require(_0x9a5d('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x9a5d('0x14'));var db=require('../../mysqldb')['db'];config[_0x9a5d('0x15')]=_[_0x9a5d('0x16')](config['redis'],{'host':_0x9a5d('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x9a5d('0x18'))[_0x9a5d('0x19')](socket);function respondWithStatusCode(_0x360fb9,_0x55828c){_0x55828c=_0x55828c||0xcc;return function(_0x13e2f6){if(_0x13e2f6){return _0x360fb9[_0x9a5d('0x1a')](_0x55828c);}return _0x360fb9['status'](_0x55828c)[_0x9a5d('0x1b')]();};}function respondWithResult(_0x2b428a,_0x2470f7){_0x2470f7=_0x2470f7||0xc8;return function(_0x4bc09b){if(_0x4bc09b){return _0x2b428a[_0x9a5d('0x1c')](_0x2470f7)['json'](_0x4bc09b);}};}function respondWithFilteredResult(_0x3c86a6,_0x550164){return function(_0x4b3c5d){if(_0x4b3c5d){var _0x42f985=typeof _0x550164[_0x9a5d('0x1d')]===_0x9a5d('0x1e')&&typeof _0x550164['limit']==='undefined';var _0x1555b9=_0x4b3c5d[_0x9a5d('0x1f')];var _0x56748a=_0x42f985?0x0:_0x550164[_0x9a5d('0x1d')];var _0x27a1f3=_0x42f985?_0x4b3c5d[_0x9a5d('0x1f')]:_0x550164['offset']+_0x550164['limit'];var _0x34008d;if(_0x27a1f3>=_0x1555b9){_0x27a1f3=_0x1555b9;_0x34008d=0xc8;}else{_0x34008d=0xce;}_0x3c86a6[_0x9a5d('0x1c')](_0x34008d);return _0x3c86a6[_0x9a5d('0x20')](_0x9a5d('0x21'),_0x56748a+'-'+_0x27a1f3+'/'+_0x1555b9)[_0x9a5d('0x22')](_0x4b3c5d);}return null;};}function patchUpdates(_0x14b5b5){return function(_0x6fa541){try{jsonpatch[_0x9a5d('0x23')](_0x6fa541,_0x14b5b5,!![]);}catch(_0x9023f6){return BPromise[_0x9a5d('0x24')](_0x9023f6);}return _0x6fa541[_0x9a5d('0x25')]();};}function saveUpdates(_0x14fe28,_0x3c71e1){return function(_0x18b0b9){if(_0x18b0b9){return _0x18b0b9[_0x9a5d('0x26')](_0x14fe28)[_0x9a5d('0x27')](function(_0x216ef4){return _0x216ef4;});}return null;};}function removeEntity(_0x301890,_0x4b88bb){return function(_0x581476){if(_0x581476){return _0x581476[_0x9a5d('0x28')]()['then'](function(){var _0x24bd48=_0x581476[_0x9a5d('0x29')]({'plain':!![]});var _0x5cbd40='CustomDashboards';return db[_0x9a5d('0x2a')]['destroy']({'where':{'type':_0x5cbd40,'resourceId':_0x24bd48['id']}})['then'](function(){return _0x581476;});})[_0x9a5d('0x27')](function(){_0x301890[_0x9a5d('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3c6d95,_0x4bd045){return function(_0x5bf163){if(!_0x5bf163){_0x3c6d95['sendStatus'](0x194);}return _0x5bf163;};}function handleError(_0x5201d8,_0x45bacd){_0x45bacd=_0x45bacd||0x1f4;return function(_0x580c54){logger['error'](_0x580c54[_0x9a5d('0x2b')]);if(_0x580c54[_0x9a5d('0x2c')]){delete _0x580c54[_0x9a5d('0x2c')];}_0x5201d8[_0x9a5d('0x1c')](_0x45bacd)[_0x9a5d('0x2d')](_0x580c54);};}exports[_0x9a5d('0x2e')]=function(_0x4aea56,_0x5e1a76){var _0x173bfa={},_0xebb329={},_0x328440={'count':0x0,'rows':[]};var _0x430182=_[_0x9a5d('0x2f')](db[_0x9a5d('0x30')][_0x9a5d('0x31')],function(_0x202647){return{'name':_0x202647[_0x9a5d('0x32')],'type':_0x202647[_0x9a5d('0x33')][_0x9a5d('0x34')]};});_0xebb329[_0x9a5d('0x35')]=_[_0x9a5d('0x2f')](_0x430182,_0x9a5d('0x2c'));_0xebb329[_0x9a5d('0x36')]=_[_0x9a5d('0x37')](_0x4aea56[_0x9a5d('0x36')]);_0xebb329[_0x9a5d('0x38')]=_[_0x9a5d('0x39')](_0xebb329['model'],_0xebb329[_0x9a5d('0x36')]);_0x173bfa[_0x9a5d('0x3a')]=_[_0x9a5d('0x39')](_0xebb329['model'],qs[_0x9a5d('0x3b')](_0x4aea56['query'][_0x9a5d('0x3b')]));_0x173bfa[_0x9a5d('0x3a')]=_0x173bfa[_0x9a5d('0x3a')][_0x9a5d('0x3c')]?_0x173bfa[_0x9a5d('0x3a')]:_0xebb329[_0x9a5d('0x35')];if(!_0x4aea56[_0x9a5d('0x36')][_0x9a5d('0x3d')](_0x9a5d('0x3e'))){_0x173bfa[_0x9a5d('0x3f')]=qs['limit'](_0x4aea56['query']['limit']);_0x173bfa[_0x9a5d('0x1d')]=qs[_0x9a5d('0x1d')](_0x4aea56['query'][_0x9a5d('0x1d')]);}_0x173bfa[_0x9a5d('0x40')]=qs['sort'](_0x4aea56[_0x9a5d('0x36')][_0x9a5d('0x41')]);_0x173bfa[_0x9a5d('0x42')]=qs['filters'](_[_0x9a5d('0x43')](_0x4aea56[_0x9a5d('0x36')],_0xebb329['filters']),_0x430182);if(_0x4aea56[_0x9a5d('0x36')]['filter']){_0x173bfa[_0x9a5d('0x42')]=_['merge'](_0x173bfa[_0x9a5d('0x42')],{'$or':_[_0x9a5d('0x2f')](_0x430182,function(_0x40bd2b){if(_0x40bd2b[_0x9a5d('0x33')]!==_0x9a5d('0x44')){var _0x419af1={};_0x419af1[_0x40bd2b[_0x9a5d('0x2c')]]={'$like':'%'+_0x4aea56[_0x9a5d('0x36')][_0x9a5d('0x45')]+'%'};return _0x419af1;}})});}_0x173bfa=_[_0x9a5d('0x46')]({},_0x173bfa,_0x4aea56[_0x9a5d('0x47')]);var _0x1f6a26={'where':_0x173bfa['where']};return db[_0x9a5d('0x30')][_0x9a5d('0x1f')](_0x1f6a26)[_0x9a5d('0x27')](function(_0x5f43ca){_0x328440[_0x9a5d('0x1f')]=_0x5f43ca;if(_0x4aea56[_0x9a5d('0x36')][_0x9a5d('0x48')]){_0x173bfa[_0x9a5d('0x49')]=[{'all':!![]}];}return db[_0x9a5d('0x30')][_0x9a5d('0x4a')](_0x173bfa);})[_0x9a5d('0x27')](function(_0x8cb22){_0x328440[_0x9a5d('0x4b')]=_0x8cb22;return _0x328440;})['then'](respondWithFilteredResult(_0x5e1a76,_0x173bfa))[_0x9a5d('0x4c')](handleError(_0x5e1a76,null));};exports['show']=function(_0x32f451,_0x291da1){var _0x189528={'raw':![],'where':{'id':_0x32f451[_0x9a5d('0x4d')]['id']}},_0x35f654={};_0x35f654[_0x9a5d('0x35')]=_['keys'](db[_0x9a5d('0x30')][_0x9a5d('0x31')]);_0x35f654[_0x9a5d('0x36')]=_[_0x9a5d('0x37')](_0x32f451[_0x9a5d('0x36')]);_0x35f654['filters']=_[_0x9a5d('0x39')](_0x35f654[_0x9a5d('0x35')],_0x35f654[_0x9a5d('0x36')]);_0x189528[_0x9a5d('0x3a')]=_[_0x9a5d('0x39')](_0x35f654[_0x9a5d('0x35')],qs[_0x9a5d('0x3b')](_0x32f451[_0x9a5d('0x36')][_0x9a5d('0x3b')]));_0x189528[_0x9a5d('0x3a')]=_0x189528[_0x9a5d('0x3a')][_0x9a5d('0x3c')]?_0x189528['attributes']:_0x35f654[_0x9a5d('0x35')];if(_0x32f451[_0x9a5d('0x36')]['includeAll']){_0x189528['include']=[{'all':!![]}];}_0x189528=_['merge']({},_0x189528,_0x32f451[_0x9a5d('0x47')]);return db['Dashboard'][_0x9a5d('0x4e')](_0x189528)['then'](handleEntityNotFound(_0x291da1,null))[_0x9a5d('0x27')](respondWithResult(_0x291da1,null))['catch'](handleError(_0x291da1,null));};exports[_0x9a5d('0x4f')]=function(_0x571d3e,_0x24aa21){return db[_0x9a5d('0x30')][_0x9a5d('0x4f')](_0x571d3e[_0x9a5d('0x50')],{})[_0x9a5d('0x27')](function(_0x53e995){var _0x4a8aa9=_0x571d3e[_0x9a5d('0x51')][_0x9a5d('0x29')]({'plain':!![]});if(!_0x4a8aa9)throw new Error(_0x9a5d('0x52'));if(_0x4a8aa9[_0x9a5d('0x53')]==='user'){var _0x36ac97=_0x53e995[_0x9a5d('0x29')]({'plain':!![]});var _0x28f033='CustomDashboards';return db[_0x9a5d('0x54')][_0x9a5d('0x4e')]({'where':{'name':_0x28f033,'userProfileId':_0x4a8aa9[_0x9a5d('0x55')]},'raw':!![]})['then'](function(_0x44e912){if(_0x44e912&&_0x44e912[_0x9a5d('0x56')]===0x0){return db[_0x9a5d('0x2a')][_0x9a5d('0x4f')]({'name':_0x36ac97[_0x9a5d('0x2c')],'resourceId':_0x36ac97['id'],'type':_0x44e912[_0x9a5d('0x2c')],'sectionId':_0x44e912['id']},{})['then'](function(){return _0x53e995;});}else{return _0x53e995;}})[_0x9a5d('0x4c')](function(_0x6efa2f){logger[_0x9a5d('0x57')](_0x9a5d('0x58'),_0x6efa2f);throw _0x6efa2f;});}return _0x53e995;})[_0x9a5d('0x27')](respondWithResult(_0x24aa21,0xc9))[_0x9a5d('0x4c')](handleError(_0x24aa21,null));};exports[_0x9a5d('0x59')]=function(_0x475618,_0x24d85f){var _0x2fb3f4={'where':{'id':_0x475618[_0x9a5d('0x4d')]['id']}},_0x45f433={};_0x45f433[_0x9a5d('0x35')]=_[_0x9a5d('0x37')](db[_0x9a5d('0x30')][_0x9a5d('0x31')]);_0x2fb3f4[_0x9a5d('0x3a')]=_['intersection'](_0x45f433[_0x9a5d('0x35')],qs[_0x9a5d('0x3b')](_0x475618['query'][_0x9a5d('0x3b')]));_0x2fb3f4[_0x9a5d('0x3a')]=_0x2fb3f4[_0x9a5d('0x3a')][_0x9a5d('0x3c')]?_0x2fb3f4[_0x9a5d('0x3a')]:_0x45f433[_0x9a5d('0x35')];if(_0x475618['query'][_0x9a5d('0x48')]){_0x2fb3f4[_0x9a5d('0x49')]=[{'all':!![]}];}_0x2fb3f4=_[_0x9a5d('0x46')]({},_0x2fb3f4,_0x475618['options']);return db[_0x9a5d('0x30')]['find'](_0x2fb3f4)[_0x9a5d('0x27')](handleEntityNotFound(_0x24d85f,null))[_0x9a5d('0x27')](function(_0x3aa98e){if(_0x3aa98e){var _0x4977af=_0x3aa98e['get']({'plain':!![]});_0x4977af=qs['omit'](_0x4977af,['id',_0x9a5d('0x5a'),'updatedAt']);_0x475618[_0x9a5d('0x50')]=_['omit'](_0x475618[_0x9a5d('0x50')],['id','createdAt',_0x9a5d('0x5b')]);return db[_0x9a5d('0x30')][_0x9a5d('0x4f')](_[_0x9a5d('0x46')](_0x4977af,_0x475618['body']),{'include':_0x475618['query']['includeAll']?[{'all':!![]}]:undefined})['then'](function(_0x2f3928){var _0x29553b=_0x475618[_0x9a5d('0x51')]['get']({'plain':!![]});if(!_0x29553b)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x29553b[_0x9a5d('0x53')]===_0x9a5d('0x51')){var _0x4bceb9=_0x2f3928[_0x9a5d('0x29')]({'plain':!![]});var _0x27d008='CustomDashboards';return db[_0x9a5d('0x54')][_0x9a5d('0x4e')]({'where':{'name':_0x27d008,'userProfileId':_0x29553b['userProfileId']},'raw':!![]})[_0x9a5d('0x27')](function(_0x7ef1c6){if(_0x7ef1c6&&_0x7ef1c6['autoAssociation']===0x0){return db[_0x9a5d('0x2a')][_0x9a5d('0x4f')]({'name':_0x4bceb9['name'],'resourceId':_0x4bceb9['id'],'type':_0x7ef1c6['name'],'sectionId':_0x7ef1c6['id']},{})['then'](function(){return _0x2f3928;});}else{return _0x2f3928;}})[_0x9a5d('0x4c')](function(_0x142878){logger[_0x9a5d('0x57')](_0x9a5d('0x58'),_0x142878);throw _0x142878;});}return _0x2f3928;});}})[_0x9a5d('0x27')](respondWithResult(_0x24d85f,0xc9))[_0x9a5d('0x4c')](handleError(_0x24d85f,null));};exports[_0x9a5d('0x26')]=function(_0x4bd79a,_0x30eadb){if(_0x4bd79a[_0x9a5d('0x50')]['id']){delete _0x4bd79a[_0x9a5d('0x50')]['id'];}return db['Dashboard'][_0x9a5d('0x4e')]({'where':{'id':_0x4bd79a[_0x9a5d('0x4d')]['id']}})['then'](handleEntityNotFound(_0x30eadb,null))[_0x9a5d('0x27')](saveUpdates(_0x4bd79a['body'],null))[_0x9a5d('0x27')](respondWithResult(_0x30eadb,null))[_0x9a5d('0x4c')](handleError(_0x30eadb,null));};exports[_0x9a5d('0x28')]=function(_0x21d5f9,_0x1f62e3){return db[_0x9a5d('0x30')]['find']({'where':{'id':_0x21d5f9[_0x9a5d('0x4d')]['id']}})['then'](handleEntityNotFound(_0x1f62e3,null))[_0x9a5d('0x27')](removeEntity(_0x1f62e3,null))[_0x9a5d('0x4c')](handleError(_0x1f62e3,null));};function widgetAttributes(_0x4a37bf){try{switch(_0x4a37bf[_0x9a5d('0x33')]){case _0x9a5d('0x5c'):return[{'name':_0x9a5d('0x5d'),'value':_0x4a37bf[_0x9a5d('0x5d')]||(_0x4a37bf['attrs']&&_0x4a37bf['attrs'][0x0]?_0x4a37bf[_0x9a5d('0x5e')][0x0][_0x9a5d('0x5f')]:undefined)||_0x9a5d('0x60')}];case _0x9a5d('0x61'):return[{'name':_0x9a5d('0x62'),'value':_0x4a37bf[_0x9a5d('0x62')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x0]?_0x4a37bf[_0x9a5d('0x5e')][0x0][_0x9a5d('0x5f')]:undefined)||''}];case _0x9a5d('0x63'):return[{'name':_0x9a5d('0x64'),'value':_0x4a37bf[_0x9a5d('0x64')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x0]?_0x4a37bf[_0x9a5d('0x5e')][0x0][_0x9a5d('0x5f')]:undefined)||_0x9a5d('0x65')},{'name':_0x9a5d('0x66'),'value':_0x4a37bf[_0x9a5d('0x66')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x1]?_0x4a37bf[_0x9a5d('0x5e')][0x1]['value']:undefined)||_0x9a5d('0x67')},{'name':_0x9a5d('0x68'),'value':_0x4a37bf[_0x9a5d('0x68')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x2]?_0x4a37bf[_0x9a5d('0x5e')][0x2][_0x9a5d('0x5f')]:undefined)||0xc}];case'counter':return[{'name':_0x9a5d('0x69'),'value':_0x4a37bf[_0x9a5d('0x69')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x0]?_0x4a37bf['attrs'][0x0]['value']:undefined)||_0x9a5d('0x6a')},{'name':_0x9a5d('0x6b'),'value':_0x4a37bf[_0x9a5d('0x6b')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x1]?_0x4a37bf[_0x9a5d('0x5e')][0x1][_0x9a5d('0x5f')]:undefined)||[]},{'name':_0x9a5d('0x68'),'value':_0x4a37bf[_0x9a5d('0x68')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x2]?_0x4a37bf[_0x9a5d('0x5e')][0x2][_0x9a5d('0x5f')]:undefined)||0x14},{'name':_0x9a5d('0x6c'),'value':_0x4a37bf[_0x9a5d('0x6c')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x3]?_0x4a37bf['attrs'][0x3]['value']:undefined)||_0x9a5d('0x6d')},{'name':'attrEmailAccounts','value':_0x4a37bf[_0x9a5d('0x6e')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x4]?_0x4a37bf[_0x9a5d('0x5e')][0x4][_0x9a5d('0x5f')]:undefined)||''},{'name':_0x9a5d('0x6f'),'value':_0x4a37bf[_0x9a5d('0x6f')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf['attrs'][0x5]?_0x4a37bf[_0x9a5d('0x5e')][0x5][_0x9a5d('0x5f')]:undefined)||''},{'name':_0x9a5d('0x70'),'value':_0x4a37bf[_0x9a5d('0x70')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x6]?_0x4a37bf['attrs'][0x6][_0x9a5d('0x5f')]:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x4a37bf[_0x9a5d('0x71')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x7]?_0x4a37bf[_0x9a5d('0x5e')][0x7][_0x9a5d('0x5f')]:undefined)||''},{'name':_0x9a5d('0x72'),'value':_0x4a37bf['attrWhatsappAccounts']||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf['attrs'][0x8]?_0x4a37bf[_0x9a5d('0x5e')][0x8][_0x9a5d('0x5f')]:undefined)||''},{'name':_0x9a5d('0x73'),'value':_0x4a37bf[_0x9a5d('0x73')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x9]?_0x4a37bf[_0x9a5d('0x5e')][0x9][_0x9a5d('0x5f')]:undefined)||''}];case _0x9a5d('0x74'):case _0x9a5d('0x75'):return[{'name':'attrSerie1','value':_0x4a37bf[_0x9a5d('0x76')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf['attrs'][0x0]?_0x4a37bf[_0x9a5d('0x5e')][0x0][_0x9a5d('0x5f')]:undefined)||_0x9a5d('0x6a')},{'name':_0x9a5d('0x77'),'value':_0x4a37bf[_0x9a5d('0x77')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x1]?_0x4a37bf[_0x9a5d('0x5e')][0x1]['value']:undefined)||null},{'name':_0x9a5d('0x78'),'value':_0x4a37bf[_0x9a5d('0x78')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf['attrs'][0x2]?_0x4a37bf[_0x9a5d('0x5e')][0x2]['value']:undefined)||null},{'name':_0x9a5d('0x6b'),'value':_0x4a37bf['attrVoiceQueues']||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x3]?_0x4a37bf['attrs'][0x3][_0x9a5d('0x5f')]:undefined)||[]},{'name':_0x9a5d('0x6c'),'value':_0x4a37bf[_0x9a5d('0x6c')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x4]?_0x4a37bf[_0x9a5d('0x5e')][0x4]['value']:undefined)||_0x9a5d('0x6d')},{'name':_0x9a5d('0x6e'),'value':_0x4a37bf[_0x9a5d('0x6e')]||(_0x4a37bf['attrs']&&_0x4a37bf['attrs'][0x5]?_0x4a37bf['attrs'][0x5]['value']:undefined)||''},{'name':_0x9a5d('0x6f'),'value':_0x4a37bf['attrFaxAccounts']||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x6]?_0x4a37bf[_0x9a5d('0x5e')][0x6][_0x9a5d('0x5f')]:undefined)||''},{'name':_0x9a5d('0x70'),'value':_0x4a37bf[_0x9a5d('0x70')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf['attrs'][0x7]?_0x4a37bf[_0x9a5d('0x5e')][0x7][_0x9a5d('0x5f')]:undefined)||''},{'name':_0x9a5d('0x71'),'value':_0x4a37bf[_0x9a5d('0x71')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0x8]?_0x4a37bf[_0x9a5d('0x5e')][0x8]['value']:undefined)||''},{'name':_0x9a5d('0x72'),'value':_0x4a37bf[_0x9a5d('0x72')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x9]?_0x4a37bf[_0x9a5d('0x5e')][0x9][_0x9a5d('0x5f')]:undefined)||''},{'name':'attrChatWebsites','value':_0x4a37bf[_0x9a5d('0x73')]||(_0x4a37bf['attrs']&&_0x4a37bf[_0x9a5d('0x5e')][0xa]?_0x4a37bf[_0x9a5d('0x5e')][0xa][_0x9a5d('0x5f')]:undefined)||''}];case _0x9a5d('0x79'):return[{'name':_0x9a5d('0x7a'),'type':_0x4a37bf['reportType']||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x0]?_0x4a37bf[_0x9a5d('0x5e')][0x0][_0x9a5d('0x33')]:undefined)||null,'value':_0x4a37bf[_0x9a5d('0x7a')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf[_0x9a5d('0x5e')][0x0]?_0x4a37bf[_0x9a5d('0x5e')][0x0][_0x9a5d('0x5f')]:undefined)||null},{'name':_0x9a5d('0x7b'),'value':_0x4a37bf[_0x9a5d('0x7b')]||(_0x4a37bf[_0x9a5d('0x5e')]&&_0x4a37bf['attrs'][0x1]?_0x4a37bf[_0x9a5d('0x5e')][0x1][_0x9a5d('0x5f')]:undefined)||0x0}];default:return[];}}catch(_0x476673){logger['error'](_0x9a5d('0x7c'),JSON[_0x9a5d('0x7d')](_0x476673));return[];}}exports['addItem']=function(_0x1aee3a,_0x3be7dc,_0x58e69d){if(_0x1aee3a['body']['id']){delete _0x1aee3a[_0x9a5d('0x50')]['id'];}return db['Dashboard']['find']({'where':{'id':_0x1aee3a[_0x9a5d('0x4d')]['id']}})[_0x9a5d('0x27')](handleEntityNotFound(_0x3be7dc,null))[_0x9a5d('0x27')](function(_0x3ff621){if(_0x3ff621){_0x1aee3a[_0x9a5d('0x50')][_0x9a5d('0x7e')]=_0x3ff621['id'];_0x1aee3a[_0x9a5d('0x50')][_0x9a5d('0x5e')]=widgetAttributes(_0x1aee3a[_0x9a5d('0x50')]);return db[_0x9a5d('0x7f')][_0x9a5d('0x4f')](_0x1aee3a[_0x9a5d('0x50')]);}})[_0x9a5d('0x27')](respondWithResult(_0x3be7dc,null))[_0x9a5d('0x4c')](handleError(_0x3be7dc,null));};exports[_0x9a5d('0x80')]=function(_0x2374ef,_0x3da880,_0x15c6a5){var _0x1655b9={};var _0x2ad926={};var _0xda2d06;var _0x52d340;return db[_0x9a5d('0x30')][_0x9a5d('0x81')]({'where':{'id':_0x2374ef[_0x9a5d('0x4d')]['id']}})[_0x9a5d('0x27')](handleEntityNotFound(_0x3da880,null))[_0x9a5d('0x27')](function(_0x1c3097){if(_0x1c3097){_0xda2d06=_0x1c3097;_0x2ad926['model']=_[_0x9a5d('0x37')](db[_0x9a5d('0x7f')]['rawAttributes']);_0x2ad926[_0x9a5d('0x36')]=_['keys'](_0x2374ef['query']);_0x2ad926[_0x9a5d('0x38')]=_[_0x9a5d('0x39')](_0x2ad926[_0x9a5d('0x35')],_0x2ad926[_0x9a5d('0x36')]);_0x1655b9['attributes']=_[_0x9a5d('0x39')](_0x2ad926[_0x9a5d('0x35')],qs[_0x9a5d('0x3b')](_0x2374ef[_0x9a5d('0x36')]['fields']));_0x1655b9[_0x9a5d('0x3a')]=_0x1655b9['attributes'][_0x9a5d('0x3c')]?_0x1655b9[_0x9a5d('0x3a')]:_0x2ad926[_0x9a5d('0x35')];_0x1655b9[_0x9a5d('0x40')]=qs['sort'](_0x2374ef['query'][_0x9a5d('0x41')]);_0x1655b9[_0x9a5d('0x42')]=qs[_0x9a5d('0x38')](_[_0x9a5d('0x43')](_0x2374ef['query'],_0x2ad926[_0x9a5d('0x38')]));if(_0x2374ef[_0x9a5d('0x36')]['filter']){_0x1655b9[_0x9a5d('0x42')]=_[_0x9a5d('0x46')](_0x1655b9['where'],{'$or':_[_0x9a5d('0x2f')](_0x1655b9[_0x9a5d('0x3a')],function(_0x557dc4){var _0x56715e={};_0x56715e[_0x557dc4]={'$like':'%'+_0x2374ef[_0x9a5d('0x36')][_0x9a5d('0x45')]+'%'};return _0x56715e;})});}_0x1655b9=_['merge']({},_0x1655b9,_0x2374ef['options']);return _0xda2d06[_0x9a5d('0x80')](_0x1655b9);}})[_0x9a5d('0x27')](function(_0x537f0f){if(_0x537f0f){_0x52d340=_0x537f0f[_0x9a5d('0x3c')];if(!_0x2374ef[_0x9a5d('0x36')]['hasOwnProperty'](_0x9a5d('0x3e'))){_0x1655b9['limit']=qs[_0x9a5d('0x3f')](_0x2374ef['query'][_0x9a5d('0x3f')]);_0x1655b9[_0x9a5d('0x1d')]=qs[_0x9a5d('0x1d')](_0x2374ef['query'][_0x9a5d('0x1d')]);}return _0xda2d06[_0x9a5d('0x80')](_0x1655b9);}})[_0x9a5d('0x27')](function(_0x3e99fe){if(_0x3e99fe){return _0x3e99fe?{'count':_0x52d340,'rows':_0x3e99fe}:null;}})[_0x9a5d('0x27')](respondWithResult(_0x3da880,null))[_0x9a5d('0x4c')](handleError(_0x3da880,null));};
\ No newline at end of file
+var _0x141c=['offset','limit','undefined','count','Content-Range','apply','update','then','destroy','get','CustomDashboards','UserProfileResource','sendStatus','stack','name','map','Dashboard','rawAttributes','fieldName','type','key','query','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','include','findAll','rows','catch','show','params','keys','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','role','iframe','attrUrl','attrs','value','https://','custom','attrPath','clock','attrHourFormat','HH:mm:ss','attrTimezone','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrChatWebsites','pie-chart','attrSerie1','attrSerie3','attrEmailAccounts','attrWhatsappAccounts','web-report','reportType','attrReport','attrRefresh','widgetAttributes:\x20%s','addItem','DashboardId','DashboardItem','getItems','findOne','filter','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','./dashboard.socket','register','status','end','json'];(function(_0x111a73,_0x3e7548){var _0x4a826e=function(_0x226723){while(--_0x226723){_0x111a73['push'](_0x111a73['shift']());}};_0x4a826e(++_0x3e7548);}(_0x141c,0x1eb));var _0xc141=function(_0x8f48ee,_0x4496a1){_0x8f48ee=_0x8f48ee-0x0;var _0x1a03e2=_0x141c[_0x8f48ee];return _0x1a03e2;};'use strict';var emlformat=require(_0xc141('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc141('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc141('0x2'));var moment=require(_0xc141('0x3'));var BPromise=require(_0xc141('0x4'));var Mustache=require(_0xc141('0x5'));var util=require(_0xc141('0x6'));var path=require(_0xc141('0x7'));var sox=require(_0xc141('0x8'));var csv=require('to-csv');var ejs=require(_0xc141('0x9'));var fs=require('fs');var fs_extra=require(_0xc141('0xa'));var _=require(_0xc141('0xb'));var squel=require('squel');var crypto=require(_0xc141('0xc'));var jsforce=require(_0xc141('0xd'));var deskjs=require(_0xc141('0xe'));var toCsv=require(_0xc141('0xf'));var querystring=require(_0xc141('0x10'));var Papa=require(_0xc141('0x11'));var Redis=require('ioredis');var authService=require(_0xc141('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc141('0x13'));var logger=require(_0xc141('0x14'))(_0xc141('0x15'));var utils=require(_0xc141('0x16'));var config=require(_0xc141('0x17'));var licenseUtil=require(_0xc141('0x18'));var db=require('../../mysqldb')['db'];config[_0xc141('0x19')]=_[_0xc141('0x1a')](config[_0xc141('0x19')],{'host':_0xc141('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc141('0x19')]));require(_0xc141('0x1c'))[_0xc141('0x1d')](socket);function respondWithStatusCode(_0x3f646d,_0x49dfc7){_0x49dfc7=_0x49dfc7||0xcc;return function(_0x3634c0){if(_0x3634c0){return _0x3f646d['sendStatus'](_0x49dfc7);}return _0x3f646d[_0xc141('0x1e')](_0x49dfc7)[_0xc141('0x1f')]();};}function respondWithResult(_0x564cab,_0x255ebb){_0x255ebb=_0x255ebb||0xc8;return function(_0x3d457a){if(_0x3d457a){return _0x564cab[_0xc141('0x1e')](_0x255ebb)[_0xc141('0x20')](_0x3d457a);}};}function respondWithFilteredResult(_0xee860b,_0x16f438){return function(_0x50eb18){if(_0x50eb18){var _0x250bfd=typeof _0x16f438[_0xc141('0x21')]==='undefined'&&typeof _0x16f438[_0xc141('0x22')]===_0xc141('0x23');var _0x7fb083=_0x50eb18[_0xc141('0x24')];var _0x3bd363=_0x250bfd?0x0:_0x16f438[_0xc141('0x21')];var _0x3e4835=_0x250bfd?_0x50eb18[_0xc141('0x24')]:_0x16f438['offset']+_0x16f438[_0xc141('0x22')];var _0x3634c3;if(_0x3e4835>=_0x7fb083){_0x3e4835=_0x7fb083;_0x3634c3=0xc8;}else{_0x3634c3=0xce;}_0xee860b[_0xc141('0x1e')](_0x3634c3);return _0xee860b['set'](_0xc141('0x25'),_0x3bd363+'-'+_0x3e4835+'/'+_0x7fb083)[_0xc141('0x20')](_0x50eb18);}return null;};}function patchUpdates(_0x4a113d){return function(_0x55d4bb){try{jsonpatch[_0xc141('0x26')](_0x55d4bb,_0x4a113d,!![]);}catch(_0x540dd1){return BPromise['reject'](_0x540dd1);}return _0x55d4bb['save']();};}function saveUpdates(_0x28dbb4,_0x4af5ae){return function(_0x5f2170){if(_0x5f2170){return _0x5f2170[_0xc141('0x27')](_0x28dbb4)[_0xc141('0x28')](function(_0x5b3bf6){return _0x5b3bf6;});}return null;};}function removeEntity(_0x8fdecb,_0x92a542){return function(_0x18daff){if(_0x18daff){return _0x18daff[_0xc141('0x29')]()[_0xc141('0x28')](function(){var _0x443431=_0x18daff[_0xc141('0x2a')]({'plain':!![]});var _0x88ec40=_0xc141('0x2b');return db[_0xc141('0x2c')]['destroy']({'where':{'type':_0x88ec40,'resourceId':_0x443431['id']}})[_0xc141('0x28')](function(){return _0x18daff;});})[_0xc141('0x28')](function(){_0x8fdecb[_0xc141('0x1e')](0xcc)[_0xc141('0x1f')]();});}};}function handleEntityNotFound(_0x4a7101,_0x252a73){return function(_0x385661){if(!_0x385661){_0x4a7101[_0xc141('0x2d')](0x194);}return _0x385661;};}function handleError(_0x5cdd0d,_0xf1009a){_0xf1009a=_0xf1009a||0x1f4;return function(_0xe76bb2){logger['error'](_0xe76bb2[_0xc141('0x2e')]);if(_0xe76bb2[_0xc141('0x2f')]){delete _0xe76bb2[_0xc141('0x2f')];}_0x5cdd0d[_0xc141('0x1e')](_0xf1009a)['send'](_0xe76bb2);};}exports['index']=function(_0x3cb08a,_0xc80cc5){var _0x575f79={},_0x733eba={},_0x332e79={'count':0x0,'rows':[]};var _0x861019=_[_0xc141('0x30')](db[_0xc141('0x31')][_0xc141('0x32')],function(_0xf5c7e6){return{'name':_0xf5c7e6[_0xc141('0x33')],'type':_0xf5c7e6[_0xc141('0x34')][_0xc141('0x35')]};});_0x733eba['model']=_['map'](_0x861019,'name');_0x733eba[_0xc141('0x36')]=_['keys'](_0x3cb08a[_0xc141('0x36')]);_0x733eba[_0xc141('0x37')]=_['intersection'](_0x733eba[_0xc141('0x38')],_0x733eba[_0xc141('0x36')]);_0x575f79[_0xc141('0x39')]=_[_0xc141('0x3a')](_0x733eba[_0xc141('0x38')],qs[_0xc141('0x3b')](_0x3cb08a[_0xc141('0x36')][_0xc141('0x3b')]));_0x575f79['attributes']=_0x575f79[_0xc141('0x39')][_0xc141('0x3c')]?_0x575f79[_0xc141('0x39')]:_0x733eba['model'];if(!_0x3cb08a[_0xc141('0x36')][_0xc141('0x3d')](_0xc141('0x3e'))){_0x575f79[_0xc141('0x22')]=qs['limit'](_0x3cb08a[_0xc141('0x36')][_0xc141('0x22')]);_0x575f79[_0xc141('0x21')]=qs[_0xc141('0x21')](_0x3cb08a[_0xc141('0x36')][_0xc141('0x21')]);}_0x575f79[_0xc141('0x3f')]=qs[_0xc141('0x40')](_0x3cb08a[_0xc141('0x36')][_0xc141('0x40')]);_0x575f79[_0xc141('0x41')]=qs['filters'](_[_0xc141('0x42')](_0x3cb08a[_0xc141('0x36')],_0x733eba[_0xc141('0x37')]),_0x861019);if(_0x3cb08a[_0xc141('0x36')]['filter']){_0x575f79['where']=_[_0xc141('0x43')](_0x575f79[_0xc141('0x41')],{'$or':_[_0xc141('0x30')](_0x861019,function(_0x473b80){if(_0x473b80[_0xc141('0x34')]!==_0xc141('0x44')){var _0xb5151b={};_0xb5151b[_0x473b80[_0xc141('0x2f')]]={'$like':'%'+_0x3cb08a[_0xc141('0x36')]['filter']+'%'};return _0xb5151b;}})});}_0x575f79=_[_0xc141('0x43')]({},_0x575f79,_0x3cb08a[_0xc141('0x45')]);var _0x1b678b={'where':_0x575f79[_0xc141('0x41')]};return db[_0xc141('0x31')][_0xc141('0x24')](_0x1b678b)[_0xc141('0x28')](function(_0x33c39c){_0x332e79[_0xc141('0x24')]=_0x33c39c;if(_0x3cb08a[_0xc141('0x36')]['includeAll']){_0x575f79[_0xc141('0x46')]=[{'all':!![]}];}return db['Dashboard'][_0xc141('0x47')](_0x575f79);})[_0xc141('0x28')](function(_0x29c153){_0x332e79[_0xc141('0x48')]=_0x29c153;return _0x332e79;})['then'](respondWithFilteredResult(_0xc80cc5,_0x575f79))[_0xc141('0x49')](handleError(_0xc80cc5,null));};exports[_0xc141('0x4a')]=function(_0x42a370,_0x593cb1){var _0x23265f={'raw':![],'where':{'id':_0x42a370[_0xc141('0x4b')]['id']}},_0x464ce5={};_0x464ce5[_0xc141('0x38')]=_[_0xc141('0x4c')](db[_0xc141('0x31')][_0xc141('0x32')]);_0x464ce5[_0xc141('0x36')]=_[_0xc141('0x4c')](_0x42a370['query']);_0x464ce5['filters']=_[_0xc141('0x3a')](_0x464ce5['model'],_0x464ce5[_0xc141('0x36')]);_0x23265f['attributes']=_['intersection'](_0x464ce5['model'],qs[_0xc141('0x3b')](_0x42a370['query'][_0xc141('0x3b')]));_0x23265f[_0xc141('0x39')]=_0x23265f[_0xc141('0x39')][_0xc141('0x3c')]?_0x23265f[_0xc141('0x39')]:_0x464ce5[_0xc141('0x38')];if(_0x42a370['query'][_0xc141('0x4d')]){_0x23265f[_0xc141('0x46')]=[{'all':!![]}];}_0x23265f=_[_0xc141('0x43')]({},_0x23265f,_0x42a370[_0xc141('0x45')]);return db[_0xc141('0x31')][_0xc141('0x4e')](_0x23265f)[_0xc141('0x28')](handleEntityNotFound(_0x593cb1,null))['then'](respondWithResult(_0x593cb1,null))[_0xc141('0x49')](handleError(_0x593cb1,null));};exports[_0xc141('0x4f')]=function(_0x230999,_0x1c5504){return db[_0xc141('0x31')][_0xc141('0x4f')](_0x230999[_0xc141('0x50')],{})[_0xc141('0x28')](function(_0x2a8092){var _0x3f00fc=_0x230999[_0xc141('0x51')][_0xc141('0x2a')]({'plain':!![]});if(!_0x3f00fc)throw new Error(_0xc141('0x52'));if(_0x3f00fc['role']===_0xc141('0x51')){var _0x13b1ed=_0x2a8092[_0xc141('0x2a')]({'plain':!![]});var _0x4d71fc='CustomDashboards';return db[_0xc141('0x53')][_0xc141('0x4e')]({'where':{'name':_0x4d71fc,'userProfileId':_0x3f00fc[_0xc141('0x54')]},'raw':!![]})['then'](function(_0x508f32){if(_0x508f32&&_0x508f32[_0xc141('0x55')]===0x0){return db[_0xc141('0x2c')]['create']({'name':_0x13b1ed[_0xc141('0x2f')],'resourceId':_0x13b1ed['id'],'type':_0x508f32[_0xc141('0x2f')],'sectionId':_0x508f32['id']},{})[_0xc141('0x28')](function(){return _0x2a8092;});}else{return _0x2a8092;}})[_0xc141('0x49')](function(_0x5a8040){logger[_0xc141('0x56')](_0xc141('0x57'),_0x5a8040);throw _0x5a8040;});}return _0x2a8092;})[_0xc141('0x28')](respondWithResult(_0x1c5504,0xc9))['catch'](handleError(_0x1c5504,null));};exports[_0xc141('0x58')]=function(_0xba9b28,_0x154e8c){var _0x4efec0={'where':{'id':_0xba9b28[_0xc141('0x4b')]['id']}},_0x3adcc6={};_0x3adcc6[_0xc141('0x38')]=_[_0xc141('0x4c')](db[_0xc141('0x31')]['rawAttributes']);_0x4efec0['attributes']=_[_0xc141('0x3a')](_0x3adcc6[_0xc141('0x38')],qs['fields'](_0xba9b28[_0xc141('0x36')][_0xc141('0x3b')]));_0x4efec0[_0xc141('0x39')]=_0x4efec0[_0xc141('0x39')][_0xc141('0x3c')]?_0x4efec0[_0xc141('0x39')]:_0x3adcc6[_0xc141('0x38')];if(_0xba9b28[_0xc141('0x36')][_0xc141('0x4d')]){_0x4efec0[_0xc141('0x46')]=[{'all':!![]}];}_0x4efec0=_[_0xc141('0x43')]({},_0x4efec0,_0xba9b28[_0xc141('0x45')]);return db[_0xc141('0x31')][_0xc141('0x4e')](_0x4efec0)[_0xc141('0x28')](handleEntityNotFound(_0x154e8c,null))[_0xc141('0x28')](function(_0x5d88bf){if(_0x5d88bf){var _0x5bdd95=_0x5d88bf['get']({'plain':!![]});_0x5bdd95=qs[_0xc141('0x59')](_0x5bdd95,['id',_0xc141('0x5a'),_0xc141('0x5b')]);_0xba9b28[_0xc141('0x50')]=_[_0xc141('0x59')](_0xba9b28[_0xc141('0x50')],['id','createdAt',_0xc141('0x5b')]);return db['Dashboard']['create'](_['merge'](_0x5bdd95,_0xba9b28[_0xc141('0x50')]),{'include':_0xba9b28[_0xc141('0x36')][_0xc141('0x4d')]?[{'all':!![]}]:undefined})['then'](function(_0x13356f){var _0x62d7ee=_0xba9b28[_0xc141('0x51')][_0xc141('0x2a')]({'plain':!![]});if(!_0x62d7ee)throw new Error(_0xc141('0x52'));if(_0x62d7ee[_0xc141('0x5c')]===_0xc141('0x51')){var _0x27aa58=_0x13356f[_0xc141('0x2a')]({'plain':!![]});var _0x35b34a=_0xc141('0x2b');return db[_0xc141('0x53')][_0xc141('0x4e')]({'where':{'name':_0x35b34a,'userProfileId':_0x62d7ee['userProfileId']},'raw':!![]})[_0xc141('0x28')](function(_0x590369){if(_0x590369&&_0x590369[_0xc141('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0x27aa58[_0xc141('0x2f')],'resourceId':_0x27aa58['id'],'type':_0x590369[_0xc141('0x2f')],'sectionId':_0x590369['id']},{})[_0xc141('0x28')](function(){return _0x13356f;});}else{return _0x13356f;}})[_0xc141('0x49')](function(_0xa8d038){logger[_0xc141('0x56')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xa8d038);throw _0xa8d038;});}return _0x13356f;});}})[_0xc141('0x28')](respondWithResult(_0x154e8c,0xc9))['catch'](handleError(_0x154e8c,null));};exports[_0xc141('0x27')]=function(_0x212ece,_0x432190){if(_0x212ece['body']['id']){delete _0x212ece[_0xc141('0x50')]['id'];}return db[_0xc141('0x31')]['find']({'where':{'id':_0x212ece[_0xc141('0x4b')]['id']}})[_0xc141('0x28')](handleEntityNotFound(_0x432190,null))[_0xc141('0x28')](saveUpdates(_0x212ece[_0xc141('0x50')],null))['then'](respondWithResult(_0x432190,null))[_0xc141('0x49')](handleError(_0x432190,null));};exports[_0xc141('0x29')]=function(_0x2ef07e,_0x40e09e){return db[_0xc141('0x31')]['find']({'where':{'id':_0x2ef07e[_0xc141('0x4b')]['id']}})[_0xc141('0x28')](handleEntityNotFound(_0x40e09e,null))[_0xc141('0x28')](removeEntity(_0x40e09e,null))[_0xc141('0x49')](handleError(_0x40e09e,null));};function widgetAttributes(_0x3985f3){try{switch(_0x3985f3[_0xc141('0x34')]){case _0xc141('0x5d'):return[{'name':_0xc141('0x5e'),'value':_0x3985f3[_0xc141('0x5e')]||(_0x3985f3['attrs']&&_0x3985f3[_0xc141('0x5f')][0x0]?_0x3985f3['attrs'][0x0][_0xc141('0x60')]:undefined)||_0xc141('0x61')}];case _0xc141('0x62'):return[{'name':'attrPath','value':_0x3985f3[_0xc141('0x63')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x0]?_0x3985f3['attrs'][0x0][_0xc141('0x60')]:undefined)||''}];case _0xc141('0x64'):return[{'name':'attrHourFormat','value':_0x3985f3[_0xc141('0x65')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x0]?_0x3985f3['attrs'][0x0][_0xc141('0x60')]:undefined)||_0xc141('0x66')},{'name':_0xc141('0x67'),'value':_0x3985f3[_0xc141('0x67')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x1]?_0x3985f3[_0xc141('0x5f')][0x1][_0xc141('0x60')]:undefined)||'0.00'},{'name':_0xc141('0x68'),'value':_0x3985f3[_0xc141('0x68')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x2]?_0x3985f3['attrs'][0x2][_0xc141('0x60')]:undefined)||0xc}];case _0xc141('0x69'):return[{'name':_0xc141('0x6a'),'value':_0x3985f3[_0xc141('0x6a')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x0]?_0x3985f3['attrs'][0x0][_0xc141('0x60')]:undefined)||_0xc141('0x6b')},{'name':_0xc141('0x6c'),'value':_0x3985f3[_0xc141('0x6c')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x1]?_0x3985f3[_0xc141('0x5f')][0x1][_0xc141('0x60')]:undefined)||[]},{'name':_0xc141('0x68'),'value':_0x3985f3['attrFontSize']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x2]?_0x3985f3['attrs'][0x2]['value']:undefined)||0x14},{'name':_0xc141('0x6d'),'value':_0x3985f3['attrChannel']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x3]?_0x3985f3[_0xc141('0x5f')][0x3]['value']:undefined)||_0xc141('0x6e')},{'name':'attrEmailAccounts','value':_0x3985f3['attrEmailAccounts']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x4]?_0x3985f3[_0xc141('0x5f')][0x4][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x6f'),'value':_0x3985f3[_0xc141('0x6f')]||(_0x3985f3['attrs']&&_0x3985f3[_0xc141('0x5f')][0x5]?_0x3985f3[_0xc141('0x5f')][0x5][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x70'),'value':_0x3985f3['attrSmsAccounts']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x6]?_0x3985f3['attrs'][0x6][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x71'),'value':_0x3985f3['attrOpenchannelAccounts']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x7]?_0x3985f3[_0xc141('0x5f')][0x7]['value']:undefined)||''},{'name':'attrWhatsappAccounts','value':_0x3985f3['attrWhatsappAccounts']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x8]?_0x3985f3[_0xc141('0x5f')][0x8][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x72'),'value':_0x3985f3[_0xc141('0x72')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x9]?_0x3985f3[_0xc141('0x5f')][0x9]['value']:undefined)||''}];case'multibar-chart':case _0xc141('0x73'):return[{'name':_0xc141('0x74'),'value':_0x3985f3['attrSerie1']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x0]?_0x3985f3[_0xc141('0x5f')][0x0][_0xc141('0x60')]:undefined)||_0xc141('0x6b')},{'name':'attrSerie2','value':_0x3985f3['attrSerie2']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x1]?_0x3985f3[_0xc141('0x5f')][0x1][_0xc141('0x60')]:undefined)||null},{'name':'attrSerie3','value':_0x3985f3[_0xc141('0x75')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x2]?_0x3985f3[_0xc141('0x5f')][0x2][_0xc141('0x60')]:undefined)||null},{'name':_0xc141('0x6c'),'value':_0x3985f3[_0xc141('0x6c')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x3]?_0x3985f3[_0xc141('0x5f')][0x3][_0xc141('0x60')]:undefined)||[]},{'name':_0xc141('0x6d'),'value':_0x3985f3['attrChannel']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x4]?_0x3985f3[_0xc141('0x5f')][0x4][_0xc141('0x60')]:undefined)||_0xc141('0x6e')},{'name':_0xc141('0x76'),'value':_0x3985f3['attrEmailAccounts']||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x5]?_0x3985f3[_0xc141('0x5f')][0x5]['value']:undefined)||''},{'name':_0xc141('0x6f'),'value':_0x3985f3[_0xc141('0x6f')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x6]?_0x3985f3[_0xc141('0x5f')][0x6][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x70'),'value':_0x3985f3[_0xc141('0x70')]||(_0x3985f3['attrs']&&_0x3985f3['attrs'][0x7]?_0x3985f3[_0xc141('0x5f')][0x7][_0xc141('0x60')]:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x3985f3[_0xc141('0x71')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x8]?_0x3985f3[_0xc141('0x5f')][0x8][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x77'),'value':_0x3985f3[_0xc141('0x77')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x9]?_0x3985f3[_0xc141('0x5f')][0x9][_0xc141('0x60')]:undefined)||''},{'name':_0xc141('0x72'),'value':_0x3985f3[_0xc141('0x72')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0xa]?_0x3985f3[_0xc141('0x5f')][0xa][_0xc141('0x60')]:undefined)||''}];case _0xc141('0x78'):return[{'name':'attrReport','type':_0x3985f3[_0xc141('0x79')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x0]?_0x3985f3[_0xc141('0x5f')][0x0]['type']:undefined)||null,'value':_0x3985f3[_0xc141('0x7a')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3['attrs'][0x0]?_0x3985f3['attrs'][0x0][_0xc141('0x60')]:undefined)||null},{'name':_0xc141('0x7b'),'value':_0x3985f3[_0xc141('0x7b')]||(_0x3985f3[_0xc141('0x5f')]&&_0x3985f3[_0xc141('0x5f')][0x1]?_0x3985f3[_0xc141('0x5f')][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0xe57fa1){logger[_0xc141('0x56')](_0xc141('0x7c'),JSON['stringify'](_0xe57fa1));return[];}}exports[_0xc141('0x7d')]=function(_0x27cc28,_0x192ca8,_0x13f7db){if(_0x27cc28['body']['id']){delete _0x27cc28['body']['id'];}return db[_0xc141('0x31')][_0xc141('0x4e')]({'where':{'id':_0x27cc28['params']['id']}})[_0xc141('0x28')](handleEntityNotFound(_0x192ca8,null))['then'](function(_0x23a62b){if(_0x23a62b){_0x27cc28[_0xc141('0x50')][_0xc141('0x7e')]=_0x23a62b['id'];_0x27cc28['body'][_0xc141('0x5f')]=widgetAttributes(_0x27cc28[_0xc141('0x50')]);return db[_0xc141('0x7f')][_0xc141('0x4f')](_0x27cc28[_0xc141('0x50')]);}})[_0xc141('0x28')](respondWithResult(_0x192ca8,null))[_0xc141('0x49')](handleError(_0x192ca8,null));};exports[_0xc141('0x80')]=function(_0x27838e,_0x176b58,_0x597f24){var _0x5c231f={};var _0x5271ef={};var _0x3613b5;var _0x52ea51;return db[_0xc141('0x31')][_0xc141('0x81')]({'where':{'id':_0x27838e[_0xc141('0x4b')]['id']}})[_0xc141('0x28')](handleEntityNotFound(_0x176b58,null))['then'](function(_0x59371a){if(_0x59371a){_0x3613b5=_0x59371a;_0x5271ef[_0xc141('0x38')]=_[_0xc141('0x4c')](db[_0xc141('0x7f')][_0xc141('0x32')]);_0x5271ef[_0xc141('0x36')]=_[_0xc141('0x4c')](_0x27838e[_0xc141('0x36')]);_0x5271ef['filters']=_[_0xc141('0x3a')](_0x5271ef[_0xc141('0x38')],_0x5271ef[_0xc141('0x36')]);_0x5c231f['attributes']=_[_0xc141('0x3a')](_0x5271ef[_0xc141('0x38')],qs['fields'](_0x27838e[_0xc141('0x36')][_0xc141('0x3b')]));_0x5c231f[_0xc141('0x39')]=_0x5c231f[_0xc141('0x39')][_0xc141('0x3c')]?_0x5c231f['attributes']:_0x5271ef[_0xc141('0x38')];_0x5c231f[_0xc141('0x3f')]=qs['sort'](_0x27838e[_0xc141('0x36')][_0xc141('0x40')]);_0x5c231f[_0xc141('0x41')]=qs[_0xc141('0x37')](_[_0xc141('0x42')](_0x27838e[_0xc141('0x36')],_0x5271ef[_0xc141('0x37')]));if(_0x27838e['query'][_0xc141('0x82')]){_0x5c231f['where']=_[_0xc141('0x43')](_0x5c231f[_0xc141('0x41')],{'$or':_[_0xc141('0x30')](_0x5c231f[_0xc141('0x39')],function(_0x31a524){var _0x4caf0f={};_0x4caf0f[_0x31a524]={'$like':'%'+_0x27838e[_0xc141('0x36')][_0xc141('0x82')]+'%'};return _0x4caf0f;})});}_0x5c231f=_['merge']({},_0x5c231f,_0x27838e[_0xc141('0x45')]);return _0x3613b5[_0xc141('0x80')](_0x5c231f);}})[_0xc141('0x28')](function(_0x1770fe){if(_0x1770fe){_0x52ea51=_0x1770fe[_0xc141('0x3c')];if(!_0x27838e[_0xc141('0x36')][_0xc141('0x3d')](_0xc141('0x3e'))){_0x5c231f['limit']=qs[_0xc141('0x22')](_0x27838e[_0xc141('0x36')][_0xc141('0x22')]);_0x5c231f[_0xc141('0x21')]=qs[_0xc141('0x21')](_0x27838e[_0xc141('0x36')][_0xc141('0x21')]);}return _0x3613b5[_0xc141('0x80')](_0x5c231f);}})[_0xc141('0x28')](function(_0x26fb21){if(_0x26fb21){return _0x26fb21?{'count':_0x52ea51,'rows':_0x26fb21}:null;}})[_0xc141('0x28')](respondWithResult(_0x176b58,null))[_0xc141('0x49')](handleError(_0x176b58,null));};
\ No newline at end of file