Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / dashboard / dashboard.controller.js
index b09d253..732c301 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1ff4=['stringify','addItem','DashboardId','getItems','findOne','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','sendStatus','status','end','json','undefined','count','offset','set','Content-Range','apply','reject','save','update','destroy','get','UserProfileResource','then','stack','name','send','index','map','rawAttributes','fieldName','query','keys','intersection','attributes','model','fields','hasOwnProperty','nolimit','limit','order','sort','filters','pick','where','type','filter','merge','options','Dashboard','includeAll','include','findAll','rows','catch','show','length','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','CustomDashboards','UserProfileSection','find','autoAssociation','error','clone','params','omit','updatedAt','body','createdAt','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','iframe','attrUrl','attrs','value','https://','custom','attrPath','attrHourFormat','attrTimezone','0.00','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','voice','attrOpenchannelAccounts','web-report','attrReport','attrRefresh','widgetAttributes:\x20%s'];(function(_0x43c0d8,_0x59449e){var _0x255aaf=function(_0x204b32){while(--_0x204b32){_0x43c0d8['push'](_0x43c0d8['shift']());}};_0x255aaf(++_0x59449e);}(_0x1ff4,0x8d));var _0x41ff=function(_0x1bcff0,_0x1a06cc){_0x1bcff0=_0x1bcff0-0x0;var _0x1c949d=_0x1ff4[_0x1bcff0];return _0x1c949d;};'use strict';var emlformat=require(_0x41ff('0x0'));var rimraf=require(_0x41ff('0x1'));var zipdir=require(_0x41ff('0x2'));var jsonpatch=require(_0x41ff('0x3'));var rp=require(_0x41ff('0x4'));var moment=require(_0x41ff('0x5'));var BPromise=require(_0x41ff('0x6'));var Mustache=require(_0x41ff('0x7'));var util=require(_0x41ff('0x8'));var path=require(_0x41ff('0x9'));var sox=require(_0x41ff('0xa'));var csv=require(_0x41ff('0xb'));var ejs=require(_0x41ff('0xc'));var fs=require('fs');var fs_extra=require(_0x41ff('0xd'));var _=require(_0x41ff('0xe'));var squel=require(_0x41ff('0xf'));var crypto=require(_0x41ff('0x10'));var jsforce=require(_0x41ff('0x11'));var deskjs=require(_0x41ff('0x12'));var toCsv=require(_0x41ff('0xb'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x41ff('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x41ff('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x41ff('0x15'));var logger=require('../../config/logger')(_0x41ff('0x16'));var utils=require(_0x41ff('0x17'));var config=require(_0x41ff('0x18'));var licenseUtil=require(_0x41ff('0x19'));var db=require('../../mysqldb')['db'];config[_0x41ff('0x1a')]=_[_0x41ff('0x1b')](config[_0x41ff('0x1a')],{'host':_0x41ff('0x1c'),'port':0x18eb});var socket=require(_0x41ff('0x1d'))(new Redis(config[_0x41ff('0x1a')]));require(_0x41ff('0x1e'))[_0x41ff('0x1f')](socket);function respondWithStatusCode(_0x57e2fc,_0x309f8e){_0x309f8e=_0x309f8e||0xcc;return function(_0x18a025){if(_0x18a025){return _0x57e2fc[_0x41ff('0x20')](_0x309f8e);}return _0x57e2fc[_0x41ff('0x21')](_0x309f8e)[_0x41ff('0x22')]();};}function respondWithResult(_0x3aa551,_0x342c5b){_0x342c5b=_0x342c5b||0xc8;return function(_0x297f98){if(_0x297f98){return _0x3aa551['status'](_0x342c5b)[_0x41ff('0x23')](_0x297f98);}};}function respondWithFilteredResult(_0x29bdbc,_0x2854a3){return function(_0x6cb750){if(_0x6cb750){var _0x1cc17b=typeof _0x2854a3['offset']===_0x41ff('0x24')&&typeof _0x2854a3['limit']===_0x41ff('0x24');var _0x10ccb8=_0x6cb750[_0x41ff('0x25')];var _0x4bc720=_0x1cc17b?0x0:_0x2854a3[_0x41ff('0x26')];var _0x4f329b=_0x1cc17b?_0x6cb750[_0x41ff('0x25')]:_0x2854a3[_0x41ff('0x26')]+_0x2854a3['limit'];var _0x27740a;if(_0x4f329b>=_0x10ccb8){_0x4f329b=_0x10ccb8;_0x27740a=0xc8;}else{_0x27740a=0xce;}_0x29bdbc[_0x41ff('0x21')](_0x27740a);return _0x29bdbc[_0x41ff('0x27')](_0x41ff('0x28'),_0x4bc720+'-'+_0x4f329b+'/'+_0x10ccb8)[_0x41ff('0x23')](_0x6cb750);}return null;};}function patchUpdates(_0x2d1455){return function(_0xa11725){try{jsonpatch[_0x41ff('0x29')](_0xa11725,_0x2d1455,!![]);}catch(_0xf62ed9){return BPromise[_0x41ff('0x2a')](_0xf62ed9);}return _0xa11725[_0x41ff('0x2b')]();};}function saveUpdates(_0x326bd8,_0x4a1f07){return function(_0x40eba9){if(_0x40eba9){return _0x40eba9[_0x41ff('0x2c')](_0x326bd8)['then'](function(_0x48b7b3){return _0x48b7b3;});}return null;};}function removeEntity(_0x40954c,_0x36a5ca){return function(_0x3307d6){if(_0x3307d6){return _0x3307d6[_0x41ff('0x2d')]()['then'](function(){var _0x3ae6e4=_0x3307d6[_0x41ff('0x2e')]({'plain':!![]});var _0x16296c='CustomDashboards';return db[_0x41ff('0x2f')]['destroy']({'where':{'type':_0x16296c,'resourceId':_0x3ae6e4['id']}})[_0x41ff('0x30')](function(){return _0x3307d6;});})[_0x41ff('0x30')](function(){_0x40954c[_0x41ff('0x21')](0xcc)[_0x41ff('0x22')]();});}};}function handleEntityNotFound(_0x1befc3,_0x2c1e70){return function(_0x1f0267){if(!_0x1f0267){_0x1befc3[_0x41ff('0x20')](0x194);}return _0x1f0267;};}function handleError(_0x3a678c,_0xed2492){_0xed2492=_0xed2492||0x1f4;return function(_0xd8e883){logger['error'](_0xd8e883[_0x41ff('0x31')]);if(_0xd8e883[_0x41ff('0x32')]){delete _0xd8e883[_0x41ff('0x32')];}_0x3a678c[_0x41ff('0x21')](_0xed2492)[_0x41ff('0x33')](_0xd8e883);};}exports[_0x41ff('0x34')]=function(_0x2ad63f,_0x1421ba){var _0x3cb51e={},_0x3c6bce={},_0xd47d75={'count':0x0,'rows':[]};var _0x521f0f=_[_0x41ff('0x35')](db['Dashboard'][_0x41ff('0x36')],function(_0x10252b){return{'name':_0x10252b[_0x41ff('0x37')],'type':_0x10252b['type']['key']};});_0x3c6bce['model']=_[_0x41ff('0x35')](_0x521f0f,_0x41ff('0x32'));_0x3c6bce[_0x41ff('0x38')]=_[_0x41ff('0x39')](_0x2ad63f['query']);_0x3c6bce['filters']=_[_0x41ff('0x3a')](_0x3c6bce['model'],_0x3c6bce[_0x41ff('0x38')]);_0x3cb51e[_0x41ff('0x3b')]=_[_0x41ff('0x3a')](_0x3c6bce[_0x41ff('0x3c')],qs[_0x41ff('0x3d')](_0x2ad63f[_0x41ff('0x38')][_0x41ff('0x3d')]));_0x3cb51e['attributes']=_0x3cb51e[_0x41ff('0x3b')]['length']?_0x3cb51e[_0x41ff('0x3b')]:_0x3c6bce[_0x41ff('0x3c')];if(!_0x2ad63f[_0x41ff('0x38')][_0x41ff('0x3e')](_0x41ff('0x3f'))){_0x3cb51e[_0x41ff('0x40')]=qs['limit'](_0x2ad63f['query'][_0x41ff('0x40')]);_0x3cb51e[_0x41ff('0x26')]=qs['offset'](_0x2ad63f[_0x41ff('0x38')][_0x41ff('0x26')]);}_0x3cb51e[_0x41ff('0x41')]=qs[_0x41ff('0x42')](_0x2ad63f['query'][_0x41ff('0x42')]);_0x3cb51e['where']=qs[_0x41ff('0x43')](_[_0x41ff('0x44')](_0x2ad63f[_0x41ff('0x38')],_0x3c6bce[_0x41ff('0x43')]),_0x521f0f);if(_0x2ad63f[_0x41ff('0x38')]['filter']){_0x3cb51e[_0x41ff('0x45')]=_['merge'](_0x3cb51e[_0x41ff('0x45')],{'$or':_[_0x41ff('0x35')](_0x521f0f,function(_0x4e8335){if(_0x4e8335[_0x41ff('0x46')]!=='VIRTUAL'){var _0x4052b4={};_0x4052b4[_0x4e8335[_0x41ff('0x32')]]={'$like':'%'+_0x2ad63f[_0x41ff('0x38')][_0x41ff('0x47')]+'%'};return _0x4052b4;}})});}_0x3cb51e=_[_0x41ff('0x48')]({},_0x3cb51e,_0x2ad63f[_0x41ff('0x49')]);var _0x18e971={'where':_0x3cb51e[_0x41ff('0x45')]};return db[_0x41ff('0x4a')][_0x41ff('0x25')](_0x18e971)[_0x41ff('0x30')](function(_0x173baf){_0xd47d75[_0x41ff('0x25')]=_0x173baf;if(_0x2ad63f['query'][_0x41ff('0x4b')]){_0x3cb51e[_0x41ff('0x4c')]=[{'all':!![]}];}return db[_0x41ff('0x4a')][_0x41ff('0x4d')](_0x3cb51e);})[_0x41ff('0x30')](function(_0x3ce0b6){_0xd47d75[_0x41ff('0x4e')]=_0x3ce0b6;return _0xd47d75;})[_0x41ff('0x30')](respondWithFilteredResult(_0x1421ba,_0x3cb51e))[_0x41ff('0x4f')](handleError(_0x1421ba,null));};exports[_0x41ff('0x50')]=function(_0x4b1c35,_0x100e66){var _0x493d36={'raw':![],'where':{'id':_0x4b1c35['params']['id']}},_0x5ea425={};_0x5ea425[_0x41ff('0x3c')]=_['keys'](db[_0x41ff('0x4a')]['rawAttributes']);_0x5ea425[_0x41ff('0x38')]=_[_0x41ff('0x39')](_0x4b1c35[_0x41ff('0x38')]);_0x5ea425[_0x41ff('0x43')]=_[_0x41ff('0x3a')](_0x5ea425['model'],_0x5ea425[_0x41ff('0x38')]);_0x493d36[_0x41ff('0x3b')]=_[_0x41ff('0x3a')](_0x5ea425[_0x41ff('0x3c')],qs['fields'](_0x4b1c35[_0x41ff('0x38')][_0x41ff('0x3d')]));_0x493d36[_0x41ff('0x3b')]=_0x493d36[_0x41ff('0x3b')][_0x41ff('0x51')]?_0x493d36['attributes']:_0x5ea425[_0x41ff('0x3c')];if(_0x4b1c35[_0x41ff('0x38')][_0x41ff('0x4b')]){_0x493d36['include']=[{'all':!![]}];}_0x493d36=_[_0x41ff('0x48')]({},_0x493d36,_0x4b1c35[_0x41ff('0x49')]);return db['Dashboard']['find'](_0x493d36)[_0x41ff('0x30')](handleEntityNotFound(_0x100e66,null))[_0x41ff('0x30')](respondWithResult(_0x100e66,null))[_0x41ff('0x4f')](handleError(_0x100e66,null));};exports[_0x41ff('0x52')]=function(_0x44e8e9,_0x7bdb26){return db[_0x41ff('0x4a')][_0x41ff('0x52')](_0x44e8e9['body'],{})[_0x41ff('0x30')](function(_0xd87b75){var _0x2b14ba=_0x44e8e9[_0x41ff('0x53')]['get']({'plain':!![]});if(!_0x2b14ba)throw new Error(_0x41ff('0x54'));if(_0x2b14ba[_0x41ff('0x55')]==='user'){var _0x5209ee=_0xd87b75[_0x41ff('0x2e')]({'plain':!![]});var _0x4394b0=_0x41ff('0x56');return db[_0x41ff('0x57')][_0x41ff('0x58')]({'where':{'name':_0x4394b0,'userProfileId':_0x2b14ba['userProfileId']},'raw':!![]})[_0x41ff('0x30')](function(_0x21d579){if(_0x21d579&&_0x21d579[_0x41ff('0x59')]===0x0){return db[_0x41ff('0x2f')][_0x41ff('0x52')]({'name':_0x5209ee[_0x41ff('0x32')],'resourceId':_0x5209ee['id'],'type':_0x21d579[_0x41ff('0x32')],'sectionId':_0x21d579['id']},{})[_0x41ff('0x30')](function(){return _0xd87b75;});}else{return _0xd87b75;}})[_0x41ff('0x4f')](function(_0x32d007){logger[_0x41ff('0x5a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x32d007);throw _0x32d007;});}return _0xd87b75;})[_0x41ff('0x30')](respondWithResult(_0x7bdb26,0xc9))[_0x41ff('0x4f')](handleError(_0x7bdb26,null));};exports[_0x41ff('0x5b')]=function(_0x486996,_0x309ef9){var _0x165194={'where':{'id':_0x486996[_0x41ff('0x5c')]['id']}},_0x314349={};_0x314349['model']=_['keys'](db[_0x41ff('0x4a')][_0x41ff('0x36')]);_0x165194['attributes']=_[_0x41ff('0x3a')](_0x314349[_0x41ff('0x3c')],qs['fields'](_0x486996[_0x41ff('0x38')][_0x41ff('0x3d')]));_0x165194[_0x41ff('0x3b')]=_0x165194[_0x41ff('0x3b')]['length']?_0x165194[_0x41ff('0x3b')]:_0x314349[_0x41ff('0x3c')];if(_0x486996[_0x41ff('0x38')][_0x41ff('0x4b')]){_0x165194[_0x41ff('0x4c')]=[{'all':!![]}];}_0x165194=_[_0x41ff('0x48')]({},_0x165194,_0x486996[_0x41ff('0x49')]);return db['Dashboard'][_0x41ff('0x58')](_0x165194)[_0x41ff('0x30')](handleEntityNotFound(_0x309ef9,null))[_0x41ff('0x30')](function(_0xcbd45e){if(_0xcbd45e){var _0x641e7f=_0xcbd45e[_0x41ff('0x2e')]({'plain':!![]});_0x641e7f=qs[_0x41ff('0x5d')](_0x641e7f,['id','createdAt',_0x41ff('0x5e')]);_0x486996[_0x41ff('0x5f')]=_[_0x41ff('0x5d')](_0x486996[_0x41ff('0x5f')],['id',_0x41ff('0x60'),_0x41ff('0x5e')]);return db[_0x41ff('0x4a')][_0x41ff('0x52')](_['merge'](_0x641e7f,_0x486996[_0x41ff('0x5f')]),{'include':_0x486996[_0x41ff('0x38')][_0x41ff('0x4b')]?[{'all':!![]}]:undefined})[_0x41ff('0x30')](function(_0x88ae1f){var _0x47e09f=_0x486996[_0x41ff('0x53')][_0x41ff('0x2e')]({'plain':!![]});if(!_0x47e09f)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x47e09f[_0x41ff('0x55')]===_0x41ff('0x53')){var _0x58bd91=_0x88ae1f[_0x41ff('0x2e')]({'plain':!![]});var _0x433658=_0x41ff('0x56');return db[_0x41ff('0x57')][_0x41ff('0x58')]({'where':{'name':_0x433658,'userProfileId':_0x47e09f[_0x41ff('0x61')]},'raw':!![]})['then'](function(_0x23a626){if(_0x23a626&&_0x23a626[_0x41ff('0x59')]===0x0){return db[_0x41ff('0x2f')]['create']({'name':_0x58bd91[_0x41ff('0x32')],'resourceId':_0x58bd91['id'],'type':_0x23a626[_0x41ff('0x32')],'sectionId':_0x23a626['id']},{})['then'](function(){return _0x88ae1f;});}else{return _0x88ae1f;}})[_0x41ff('0x4f')](function(_0x52634a){logger['error'](_0x41ff('0x62'),_0x52634a);throw _0x52634a;});}return _0x88ae1f;});}})[_0x41ff('0x30')](respondWithResult(_0x309ef9,0xc9))[_0x41ff('0x4f')](handleError(_0x309ef9,null));};exports[_0x41ff('0x2c')]=function(_0x3a544a,_0x4a29cb){if(_0x3a544a[_0x41ff('0x5f')]['id']){delete _0x3a544a[_0x41ff('0x5f')]['id'];}return db[_0x41ff('0x4a')]['find']({'where':{'id':_0x3a544a[_0x41ff('0x5c')]['id']}})[_0x41ff('0x30')](handleEntityNotFound(_0x4a29cb,null))[_0x41ff('0x30')](saveUpdates(_0x3a544a[_0x41ff('0x5f')],null))[_0x41ff('0x30')](respondWithResult(_0x4a29cb,null))[_0x41ff('0x4f')](handleError(_0x4a29cb,null));};exports[_0x41ff('0x2d')]=function(_0x3076a7,_0xeb998d){return db['Dashboard']['find']({'where':{'id':_0x3076a7[_0x41ff('0x5c')]['id']}})[_0x41ff('0x30')](handleEntityNotFound(_0xeb998d,null))[_0x41ff('0x30')](removeEntity(_0xeb998d,null))['catch'](handleError(_0xeb998d,null));};function widgetAttributes(_0x865f51){try{switch(_0x865f51[_0x41ff('0x46')]){case _0x41ff('0x63'):return[{'name':_0x41ff('0x64'),'value':_0x865f51['attrUrl']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x0]?_0x865f51[_0x41ff('0x65')][0x0][_0x41ff('0x66')]:undefined)||_0x41ff('0x67')}];case _0x41ff('0x68'):return[{'name':_0x41ff('0x69'),'value':_0x865f51[_0x41ff('0x69')]||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x0]?_0x865f51[_0x41ff('0x65')][0x0][_0x41ff('0x66')]:undefined)||''}];case'clock':return[{'name':'attrHourFormat','value':_0x865f51[_0x41ff('0x6a')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51['attrs'][0x0]?_0x865f51[_0x41ff('0x65')][0x0][_0x41ff('0x66')]:undefined)||'HH:mm:ss'},{'name':_0x41ff('0x6b'),'value':_0x865f51[_0x41ff('0x6b')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x1]?_0x865f51[_0x41ff('0x65')][0x1]['value']:undefined)||_0x41ff('0x6c')},{'name':'attrFontSize','value':_0x865f51[_0x41ff('0x6d')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x2]?_0x865f51['attrs'][0x2][_0x41ff('0x66')]:undefined)||0xc}];case _0x41ff('0x6e'):return[{'name':_0x41ff('0x6f'),'value':_0x865f51[_0x41ff('0x6f')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x0]?_0x865f51[_0x41ff('0x65')][0x0][_0x41ff('0x66')]:undefined)||_0x41ff('0x70')},{'name':'attrVoiceQueues','value':_0x865f51[_0x41ff('0x71')]||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x1]?_0x865f51[_0x41ff('0x65')][0x1][_0x41ff('0x66')]:undefined)||[]},{'name':_0x41ff('0x6d'),'value':_0x865f51[_0x41ff('0x6d')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x2]?_0x865f51[_0x41ff('0x65')][0x2]['value']:undefined)||0x14},{'name':'attrChannel','value':_0x865f51[_0x41ff('0x72')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x3]?_0x865f51[_0x41ff('0x65')][0x3][_0x41ff('0x66')]:undefined)||'voice'},{'name':'attrEmailAccounts','value':_0x865f51[_0x41ff('0x73')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x4]?_0x865f51[_0x41ff('0x65')][0x4]['value']:undefined)||''},{'name':'attrFaxAccounts','value':_0x865f51[_0x41ff('0x74')]||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x5]?_0x865f51[_0x41ff('0x65')][0x5]['value']:undefined)||''},{'name':'attrSmsAccounts','value':_0x865f51[_0x41ff('0x75')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x6]?_0x865f51[_0x41ff('0x65')][0x6][_0x41ff('0x66')]:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x865f51['attrOpenchannelAccounts']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x7]?_0x865f51[_0x41ff('0x65')][0x7][_0x41ff('0x66')]:undefined)||''},{'name':_0x41ff('0x76'),'value':_0x865f51['attrWhatsappAccounts']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51['attrs'][0x8]?_0x865f51[_0x41ff('0x65')][0x8][_0x41ff('0x66')]:undefined)||''},{'name':'attrChatWebsites','value':_0x865f51[_0x41ff('0x77')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51['attrs'][0x9]?_0x865f51[_0x41ff('0x65')][0x9][_0x41ff('0x66')]:undefined)||''}];case _0x41ff('0x78'):case _0x41ff('0x79'):return[{'name':_0x41ff('0x7a'),'value':_0x865f51['attrSerie1']||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x0]?_0x865f51[_0x41ff('0x65')][0x0][_0x41ff('0x66')]:undefined)||'total'},{'name':_0x41ff('0x7b'),'value':_0x865f51[_0x41ff('0x7b')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x1]?_0x865f51['attrs'][0x1][_0x41ff('0x66')]:undefined)||null},{'name':_0x41ff('0x7c'),'value':_0x865f51['attrSerie3']||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x2]?_0x865f51['attrs'][0x2][_0x41ff('0x66')]:undefined)||null},{'name':_0x41ff('0x71'),'value':_0x865f51['attrVoiceQueues']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x3]?_0x865f51['attrs'][0x3][_0x41ff('0x66')]:undefined)||[]},{'name':_0x41ff('0x72'),'value':_0x865f51[_0x41ff('0x72')]||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x4]?_0x865f51[_0x41ff('0x65')][0x4][_0x41ff('0x66')]:undefined)||_0x41ff('0x7d')},{'name':_0x41ff('0x73'),'value':_0x865f51[_0x41ff('0x73')]||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x5]?_0x865f51[_0x41ff('0x65')][0x5][_0x41ff('0x66')]:undefined)||''},{'name':'attrFaxAccounts','value':_0x865f51['attrFaxAccounts']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51['attrs'][0x6]?_0x865f51[_0x41ff('0x65')][0x6][_0x41ff('0x66')]:undefined)||''},{'name':_0x41ff('0x75'),'value':_0x865f51[_0x41ff('0x75')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x7]?_0x865f51[_0x41ff('0x65')][0x7]['value']:undefined)||''},{'name':_0x41ff('0x7e'),'value':_0x865f51[_0x41ff('0x7e')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x8]?_0x865f51['attrs'][0x8][_0x41ff('0x66')]:undefined)||''},{'name':'attrWhatsappAccounts','value':_0x865f51[_0x41ff('0x76')]||(_0x865f51['attrs']&&_0x865f51[_0x41ff('0x65')][0x9]?_0x865f51[_0x41ff('0x65')][0x9][_0x41ff('0x66')]:undefined)||''},{'name':'attrChatWebsites','value':_0x865f51[_0x41ff('0x77')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0xa]?_0x865f51[_0x41ff('0x65')][0xa][_0x41ff('0x66')]:undefined)||''}];case _0x41ff('0x7f'):return[{'name':_0x41ff('0x80'),'type':_0x865f51['reportType']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x0]?_0x865f51['attrs'][0x0]['type']:undefined)||null,'value':_0x865f51['attrReport']||(_0x865f51[_0x41ff('0x65')]&&_0x865f51['attrs'][0x0]?_0x865f51[_0x41ff('0x65')][0x0]['value']:undefined)||null},{'name':_0x41ff('0x81'),'value':_0x865f51[_0x41ff('0x81')]||(_0x865f51[_0x41ff('0x65')]&&_0x865f51[_0x41ff('0x65')][0x1]?_0x865f51[_0x41ff('0x65')][0x1][_0x41ff('0x66')]:undefined)||0x0}];default:return[];}}catch(_0x504106){logger[_0x41ff('0x5a')](_0x41ff('0x82'),JSON[_0x41ff('0x83')](_0x504106));return[];}}exports[_0x41ff('0x84')]=function(_0xd226e9,_0x1e2090,_0x25d5a6){if(_0xd226e9[_0x41ff('0x5f')]['id']){delete _0xd226e9[_0x41ff('0x5f')]['id'];}return db['Dashboard'][_0x41ff('0x58')]({'where':{'id':_0xd226e9['params']['id']}})[_0x41ff('0x30')](handleEntityNotFound(_0x1e2090,null))[_0x41ff('0x30')](function(_0x22fa61){if(_0x22fa61){_0xd226e9[_0x41ff('0x5f')][_0x41ff('0x85')]=_0x22fa61['id'];_0xd226e9[_0x41ff('0x5f')][_0x41ff('0x65')]=widgetAttributes(_0xd226e9[_0x41ff('0x5f')]);return db['DashboardItem'][_0x41ff('0x52')](_0xd226e9[_0x41ff('0x5f')]);}})[_0x41ff('0x30')](respondWithResult(_0x1e2090,null))[_0x41ff('0x4f')](handleError(_0x1e2090,null));};exports[_0x41ff('0x86')]=function(_0x379c97,_0xc2e4a8,_0x2fba78){var _0x1a09df={};var _0x16275b={};var _0x16e4e0;var _0x2a9f83;return db[_0x41ff('0x4a')][_0x41ff('0x87')]({'where':{'id':_0x379c97[_0x41ff('0x5c')]['id']}})['then'](handleEntityNotFound(_0xc2e4a8,null))['then'](function(_0x9d657d){if(_0x9d657d){_0x16e4e0=_0x9d657d;_0x16275b[_0x41ff('0x3c')]=_[_0x41ff('0x39')](db['DashboardItem']['rawAttributes']);_0x16275b[_0x41ff('0x38')]=_['keys'](_0x379c97['query']);_0x16275b[_0x41ff('0x43')]=_[_0x41ff('0x3a')](_0x16275b[_0x41ff('0x3c')],_0x16275b[_0x41ff('0x38')]);_0x1a09df[_0x41ff('0x3b')]=_[_0x41ff('0x3a')](_0x16275b['model'],qs[_0x41ff('0x3d')](_0x379c97[_0x41ff('0x38')][_0x41ff('0x3d')]));_0x1a09df[_0x41ff('0x3b')]=_0x1a09df[_0x41ff('0x3b')][_0x41ff('0x51')]?_0x1a09df['attributes']:_0x16275b[_0x41ff('0x3c')];_0x1a09df['order']=qs[_0x41ff('0x42')](_0x379c97[_0x41ff('0x38')]['sort']);_0x1a09df[_0x41ff('0x45')]=qs[_0x41ff('0x43')](_[_0x41ff('0x44')](_0x379c97[_0x41ff('0x38')],_0x16275b['filters']));if(_0x379c97['query'][_0x41ff('0x47')]){_0x1a09df[_0x41ff('0x45')]=_[_0x41ff('0x48')](_0x1a09df[_0x41ff('0x45')],{'$or':_[_0x41ff('0x35')](_0x1a09df['attributes'],function(_0x5576d9){var _0x89966f={};_0x89966f[_0x5576d9]={'$like':'%'+_0x379c97[_0x41ff('0x38')]['filter']+'%'};return _0x89966f;})});}_0x1a09df=_['merge']({},_0x1a09df,_0x379c97[_0x41ff('0x49')]);return _0x16e4e0[_0x41ff('0x86')](_0x1a09df);}})[_0x41ff('0x30')](function(_0x4e62c2){if(_0x4e62c2){_0x2a9f83=_0x4e62c2[_0x41ff('0x51')];if(!_0x379c97[_0x41ff('0x38')][_0x41ff('0x3e')]('nolimit')){_0x1a09df[_0x41ff('0x40')]=qs[_0x41ff('0x40')](_0x379c97[_0x41ff('0x38')][_0x41ff('0x40')]);_0x1a09df[_0x41ff('0x26')]=qs[_0x41ff('0x26')](_0x379c97[_0x41ff('0x38')][_0x41ff('0x26')]);}return _0x16e4e0[_0x41ff('0x86')](_0x1a09df);}})['then'](function(_0x3fcf78){if(_0x3fcf78){return _0x3fcf78?{'count':_0x2a9f83,'rows':_0x3fcf78}:null;}})['then'](respondWithResult(_0xc2e4a8,null))[_0x41ff('0x4f')](handleError(_0xc2e4a8,null));};
\ No newline at end of file
+var _0x790c=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','socket.io-emitter','./dashboard.socket','sendStatus','end','json','offset','undefined','limit','count','Content-Range','then','destroy','get','CustomDashboards','UserProfileResource','stack','name','status','send','index','map','rawAttributes','fieldName','type','model','query','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','filter','merge','VIRTUAL','options','Dashboard','includeAll','include','rows','catch','show','params','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','error','clone','keys','omit','createdAt','role','update','iframe','attrUrl','attrs','https://','custom','attrPath','clock','attrHourFormat','value','attrTimezone','0.00','attrFontSize','total','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','attrVoiceQueues','web-report','attrReport','attrRefresh','stringify','addItem','DashboardId','getItems','findOne','pick','nolimit','eml-format','rimraf','zip-dir','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service'];(function(_0x36bc58,_0x27f03c){var _0x4a547e=function(_0x6326c6){while(--_0x6326c6){_0x36bc58['push'](_0x36bc58['shift']());}};_0x4a547e(++_0x27f03c);}(_0x790c,0x15d));var _0xc790=function(_0x3dd3ed,_0x22611d){_0x3dd3ed=_0x3dd3ed-0x0;var _0x260711=_0x790c[_0x3dd3ed];return _0x260711;};'use strict';var emlformat=require(_0xc790('0x0'));var rimraf=require(_0xc790('0x1'));var zipdir=require(_0xc790('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xc790('0x3'));var util=require(_0xc790('0x4'));var path=require(_0xc790('0x5'));var sox=require(_0xc790('0x6'));var csv=require('to-csv');var ejs=require(_0xc790('0x7'));var fs=require('fs');var fs_extra=require(_0xc790('0x8'));var _=require('lodash');var squel=require(_0xc790('0x9'));var crypto=require(_0xc790('0xa'));var jsforce=require(_0xc790('0xb'));var deskjs=require(_0xc790('0xc'));var toCsv=require(_0xc790('0xd'));var querystring=require('querystring');var Papa=require(_0xc790('0xe'));var Redis=require(_0xc790('0xf'));var authService=require(_0xc790('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xc790('0x11'));var hardwareService=require(_0xc790('0x12'));var logger=require(_0xc790('0x13'))(_0xc790('0x14'));var utils=require(_0xc790('0x15'));var config=require(_0xc790('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xc790('0x17'))['db'];config[_0xc790('0x18')]=_['defaults'](config[_0xc790('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0xc790('0x19'))(new Redis(config[_0xc790('0x18')]));require(_0xc790('0x1a'))['register'](socket);function respondWithStatusCode(_0x3bf5f7,_0x4e1e29){_0x4e1e29=_0x4e1e29||0xcc;return function(_0x5e8c7f){if(_0x5e8c7f){return _0x3bf5f7[_0xc790('0x1b')](_0x4e1e29);}return _0x3bf5f7['status'](_0x4e1e29)[_0xc790('0x1c')]();};}function respondWithResult(_0x3a2d50,_0x4ad282){_0x4ad282=_0x4ad282||0xc8;return function(_0x41ac43){if(_0x41ac43){return _0x3a2d50['status'](_0x4ad282)[_0xc790('0x1d')](_0x41ac43);}};}function respondWithFilteredResult(_0x49be8d,_0x6b3e7a){return function(_0x28e7f4){if(_0x28e7f4){var _0x13da69=typeof _0x6b3e7a[_0xc790('0x1e')]===_0xc790('0x1f')&&typeof _0x6b3e7a[_0xc790('0x20')]===_0xc790('0x1f');var _0x584a10=_0x28e7f4[_0xc790('0x21')];var _0x5146a4=_0x13da69?0x0:_0x6b3e7a['offset'];var _0x4671a4=_0x13da69?_0x28e7f4[_0xc790('0x21')]:_0x6b3e7a['offset']+_0x6b3e7a[_0xc790('0x20')];var _0xab84f7;if(_0x4671a4>=_0x584a10){_0x4671a4=_0x584a10;_0xab84f7=0xc8;}else{_0xab84f7=0xce;}_0x49be8d['status'](_0xab84f7);return _0x49be8d['set'](_0xc790('0x22'),_0x5146a4+'-'+_0x4671a4+'/'+_0x584a10)[_0xc790('0x1d')](_0x28e7f4);}return null;};}function patchUpdates(_0x5393ba){return function(_0x4cfe5e){try{jsonpatch['apply'](_0x4cfe5e,_0x5393ba,!![]);}catch(_0x3b5aea){return BPromise['reject'](_0x3b5aea);}return _0x4cfe5e['save']();};}function saveUpdates(_0xe860fc,_0x2cfd7b){return function(_0x21c5db){if(_0x21c5db){return _0x21c5db['update'](_0xe860fc)[_0xc790('0x23')](function(_0xeae9f0){return _0xeae9f0;});}return null;};}function removeEntity(_0x3d0b26,_0x59402b){return function(_0x1dd701){if(_0x1dd701){return _0x1dd701[_0xc790('0x24')]()['then'](function(){var _0x14b56f=_0x1dd701[_0xc790('0x25')]({'plain':!![]});var _0x292b3e=_0xc790('0x26');return db[_0xc790('0x27')][_0xc790('0x24')]({'where':{'type':_0x292b3e,'resourceId':_0x14b56f['id']}})[_0xc790('0x23')](function(){return _0x1dd701;});})[_0xc790('0x23')](function(){_0x3d0b26['status'](0xcc)[_0xc790('0x1c')]();});}};}function handleEntityNotFound(_0x4913b3,_0x57ed14){return function(_0x5bb184){if(!_0x5bb184){_0x4913b3[_0xc790('0x1b')](0x194);}return _0x5bb184;};}function handleError(_0x4f1cf3,_0x1d71c8){_0x1d71c8=_0x1d71c8||0x1f4;return function(_0x51097c){logger['error'](_0x51097c[_0xc790('0x28')]);if(_0x51097c[_0xc790('0x29')]){delete _0x51097c[_0xc790('0x29')];}_0x4f1cf3[_0xc790('0x2a')](_0x1d71c8)[_0xc790('0x2b')](_0x51097c);};}exports[_0xc790('0x2c')]=function(_0x5e7101,_0x1a6e60){var _0xd968fb={},_0x35397c={},_0x438281={'count':0x0,'rows':[]};var _0x2abe1a=_[_0xc790('0x2d')](db['Dashboard'][_0xc790('0x2e')],function(_0x1c2912){return{'name':_0x1c2912[_0xc790('0x2f')],'type':_0x1c2912[_0xc790('0x30')]['key']};});_0x35397c[_0xc790('0x31')]=_['map'](_0x2abe1a,_0xc790('0x29'));_0x35397c[_0xc790('0x32')]=_['keys'](_0x5e7101[_0xc790('0x32')]);_0x35397c['filters']=_[_0xc790('0x33')](_0x35397c[_0xc790('0x31')],_0x35397c[_0xc790('0x32')]);_0xd968fb[_0xc790('0x34')]=_[_0xc790('0x33')](_0x35397c[_0xc790('0x31')],qs['fields'](_0x5e7101['query'][_0xc790('0x35')]));_0xd968fb['attributes']=_0xd968fb[_0xc790('0x34')]['length']?_0xd968fb['attributes']:_0x35397c['model'];if(!_0x5e7101[_0xc790('0x32')][_0xc790('0x36')]('nolimit')){_0xd968fb[_0xc790('0x20')]=qs[_0xc790('0x20')](_0x5e7101['query'][_0xc790('0x20')]);_0xd968fb[_0xc790('0x1e')]=qs[_0xc790('0x1e')](_0x5e7101[_0xc790('0x32')]['offset']);}_0xd968fb[_0xc790('0x37')]=qs[_0xc790('0x38')](_0x5e7101[_0xc790('0x32')][_0xc790('0x38')]);_0xd968fb[_0xc790('0x39')]=qs[_0xc790('0x3a')](_['pick'](_0x5e7101['query'],_0x35397c['filters']),_0x2abe1a);if(_0x5e7101[_0xc790('0x32')][_0xc790('0x3b')]){_0xd968fb[_0xc790('0x39')]=_[_0xc790('0x3c')](_0xd968fb['where'],{'$or':_[_0xc790('0x2d')](_0x2abe1a,function(_0x45fd86){if(_0x45fd86[_0xc790('0x30')]!==_0xc790('0x3d')){var _0x34ff7e={};_0x34ff7e[_0x45fd86[_0xc790('0x29')]]={'$like':'%'+_0x5e7101[_0xc790('0x32')]['filter']+'%'};return _0x34ff7e;}})});}_0xd968fb=_['merge']({},_0xd968fb,_0x5e7101[_0xc790('0x3e')]);var _0x4825f5={'where':_0xd968fb[_0xc790('0x39')]};return db[_0xc790('0x3f')]['count'](_0x4825f5)[_0xc790('0x23')](function(_0x32611a){_0x438281['count']=_0x32611a;if(_0x5e7101[_0xc790('0x32')][_0xc790('0x40')]){_0xd968fb[_0xc790('0x41')]=[{'all':!![]}];}return db[_0xc790('0x3f')]['findAll'](_0xd968fb);})[_0xc790('0x23')](function(_0x10ea5c){_0x438281[_0xc790('0x42')]=_0x10ea5c;return _0x438281;})[_0xc790('0x23')](respondWithFilteredResult(_0x1a6e60,_0xd968fb))[_0xc790('0x43')](handleError(_0x1a6e60,null));};exports[_0xc790('0x44')]=function(_0xd34289,_0x2fd402){var _0x482ea1={'raw':![],'where':{'id':_0xd34289[_0xc790('0x45')]['id']}},_0x31dc14={};_0x31dc14[_0xc790('0x31')]=_['keys'](db[_0xc790('0x3f')][_0xc790('0x2e')]);_0x31dc14[_0xc790('0x32')]=_['keys'](_0xd34289[_0xc790('0x32')]);_0x31dc14[_0xc790('0x3a')]=_['intersection'](_0x31dc14['model'],_0x31dc14[_0xc790('0x32')]);_0x482ea1['attributes']=_[_0xc790('0x33')](_0x31dc14['model'],qs[_0xc790('0x35')](_0xd34289[_0xc790('0x32')][_0xc790('0x35')]));_0x482ea1['attributes']=_0x482ea1[_0xc790('0x34')][_0xc790('0x46')]?_0x482ea1[_0xc790('0x34')]:_0x31dc14[_0xc790('0x31')];if(_0xd34289['query'][_0xc790('0x40')]){_0x482ea1[_0xc790('0x41')]=[{'all':!![]}];}_0x482ea1=_[_0xc790('0x3c')]({},_0x482ea1,_0xd34289[_0xc790('0x3e')]);return db[_0xc790('0x3f')][_0xc790('0x47')](_0x482ea1)['then'](handleEntityNotFound(_0x2fd402,null))[_0xc790('0x23')](respondWithResult(_0x2fd402,null))['catch'](handleError(_0x2fd402,null));};exports[_0xc790('0x48')]=function(_0x19ac0d,_0x24b5b3){return db[_0xc790('0x3f')][_0xc790('0x48')](_0x19ac0d[_0xc790('0x49')],{})[_0xc790('0x23')](function(_0x34888a){var _0x4447e0=_0x19ac0d[_0xc790('0x4a')][_0xc790('0x25')]({'plain':!![]});if(!_0x4447e0)throw new Error(_0xc790('0x4b'));if(_0x4447e0['role']==='user'){var _0xcc8e3c=_0x34888a['get']({'plain':!![]});var _0x2e5272=_0xc790('0x26');return db[_0xc790('0x4c')][_0xc790('0x47')]({'where':{'name':_0x2e5272,'userProfileId':_0x4447e0[_0xc790('0x4d')]},'raw':!![]})[_0xc790('0x23')](function(_0x2aee79){if(_0x2aee79&&_0x2aee79['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0xcc8e3c[_0xc790('0x29')],'resourceId':_0xcc8e3c['id'],'type':_0x2aee79[_0xc790('0x29')],'sectionId':_0x2aee79['id']},{})[_0xc790('0x23')](function(){return _0x34888a;});}else{return _0x34888a;}})[_0xc790('0x43')](function(_0x31f028){logger[_0xc790('0x4e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x31f028);throw _0x31f028;});}return _0x34888a;})[_0xc790('0x23')](respondWithResult(_0x24b5b3,0xc9))[_0xc790('0x43')](handleError(_0x24b5b3,null));};exports[_0xc790('0x4f')]=function(_0x5735e6,_0x52ee17){var _0x45509d={'where':{'id':_0x5735e6[_0xc790('0x45')]['id']}},_0x5b1850={};_0x5b1850['model']=_[_0xc790('0x50')](db['Dashboard']['rawAttributes']);_0x45509d['attributes']=_['intersection'](_0x5b1850['model'],qs['fields'](_0x5735e6[_0xc790('0x32')][_0xc790('0x35')]));_0x45509d[_0xc790('0x34')]=_0x45509d[_0xc790('0x34')][_0xc790('0x46')]?_0x45509d[_0xc790('0x34')]:_0x5b1850[_0xc790('0x31')];if(_0x5735e6[_0xc790('0x32')][_0xc790('0x40')]){_0x45509d[_0xc790('0x41')]=[{'all':!![]}];}_0x45509d=_[_0xc790('0x3c')]({},_0x45509d,_0x5735e6[_0xc790('0x3e')]);return db[_0xc790('0x3f')][_0xc790('0x47')](_0x45509d)['then'](handleEntityNotFound(_0x52ee17,null))[_0xc790('0x23')](function(_0x847ee8){if(_0x847ee8){var _0x10519f=_0x847ee8[_0xc790('0x25')]({'plain':!![]});_0x10519f=qs[_0xc790('0x51')](_0x10519f,['id',_0xc790('0x52'),'updatedAt']);_0x5735e6[_0xc790('0x49')]=_[_0xc790('0x51')](_0x5735e6['body'],['id',_0xc790('0x52'),'updatedAt']);return db['Dashboard'][_0xc790('0x48')](_[_0xc790('0x3c')](_0x10519f,_0x5735e6[_0xc790('0x49')]),{'include':_0x5735e6['query']['includeAll']?[{'all':!![]}]:undefined})[_0xc790('0x23')](function(_0x4fc1cd){var _0x2b1178=_0x5735e6[_0xc790('0x4a')]['get']({'plain':!![]});if(!_0x2b1178)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2b1178[_0xc790('0x53')]===_0xc790('0x4a')){var _0x105bde=_0x4fc1cd[_0xc790('0x25')]({'plain':!![]});var _0x19b66d=_0xc790('0x26');return db[_0xc790('0x4c')][_0xc790('0x47')]({'where':{'name':_0x19b66d,'userProfileId':_0x2b1178[_0xc790('0x4d')]},'raw':!![]})[_0xc790('0x23')](function(_0x1171bd){if(_0x1171bd&&_0x1171bd['autoAssociation']===0x0){return db['UserProfileResource'][_0xc790('0x48')]({'name':_0x105bde[_0xc790('0x29')],'resourceId':_0x105bde['id'],'type':_0x1171bd[_0xc790('0x29')],'sectionId':_0x1171bd['id']},{})['then'](function(){return _0x4fc1cd;});}else{return _0x4fc1cd;}})['catch'](function(_0x33c991){logger[_0xc790('0x4e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x33c991);throw _0x33c991;});}return _0x4fc1cd;});}})[_0xc790('0x23')](respondWithResult(_0x52ee17,0xc9))[_0xc790('0x43')](handleError(_0x52ee17,null));};exports[_0xc790('0x54')]=function(_0x37151f,_0x4b7c98){if(_0x37151f[_0xc790('0x49')]['id']){delete _0x37151f[_0xc790('0x49')]['id'];}return db[_0xc790('0x3f')][_0xc790('0x47')]({'where':{'id':_0x37151f['params']['id']}})[_0xc790('0x23')](handleEntityNotFound(_0x4b7c98,null))[_0xc790('0x23')](saveUpdates(_0x37151f[_0xc790('0x49')],null))[_0xc790('0x23')](respondWithResult(_0x4b7c98,null))['catch'](handleError(_0x4b7c98,null));};exports[_0xc790('0x24')]=function(_0x3912eb,_0x4882ba){return db[_0xc790('0x3f')][_0xc790('0x47')]({'where':{'id':_0x3912eb[_0xc790('0x45')]['id']}})[_0xc790('0x23')](handleEntityNotFound(_0x4882ba,null))[_0xc790('0x23')](removeEntity(_0x4882ba,null))['catch'](handleError(_0x4882ba,null));};function widgetAttributes(_0x277b32){try{switch(_0x277b32[_0xc790('0x30')]){case _0xc790('0x55'):return[{'name':_0xc790('0x56'),'value':_0x277b32['attrUrl']||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32[_0xc790('0x57')][0x0]['value']:undefined)||_0xc790('0x58')}];case _0xc790('0x59'):return[{'name':_0xc790('0x5a'),'value':_0x277b32[_0xc790('0x5a')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32[_0xc790('0x57')][0x0]['value']:undefined)||''}];case _0xc790('0x5b'):return[{'name':'attrHourFormat','value':_0x277b32[_0xc790('0x5c')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32['attrs'][0x0][_0xc790('0x5d')]:undefined)||'HH:mm:ss'},{'name':_0xc790('0x5e'),'value':_0x277b32[_0xc790('0x5e')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x1]?_0x277b32[_0xc790('0x57')][0x1][_0xc790('0x5d')]:undefined)||_0xc790('0x5f')},{'name':_0xc790('0x60'),'value':_0x277b32[_0xc790('0x60')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x2]?_0x277b32['attrs'][0x2][_0xc790('0x5d')]:undefined)||0xc}];case'counter':return[{'name':'attrMetric','value':_0x277b32['attrMetric']||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32['attrs'][0x0][_0xc790('0x5d')]:undefined)||_0xc790('0x61')},{'name':'attrVoiceQueues','value':_0x277b32['attrVoiceQueues']||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x1]?_0x277b32['attrs'][0x1][_0xc790('0x5d')]:undefined)||[]},{'name':'attrFontSize','value':_0x277b32[_0xc790('0x60')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x2]?_0x277b32[_0xc790('0x57')][0x2][_0xc790('0x5d')]:undefined)||0x14},{'name':_0xc790('0x62'),'value':_0x277b32[_0xc790('0x62')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x3]?_0x277b32[_0xc790('0x57')][0x3]['value']:undefined)||_0xc790('0x63')},{'name':_0xc790('0x64'),'value':_0x277b32[_0xc790('0x64')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x4]?_0x277b32[_0xc790('0x57')][0x4]['value']:undefined)||''},{'name':'attrFaxAccounts','value':_0x277b32[_0xc790('0x65')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32['attrs'][0x5]?_0x277b32[_0xc790('0x57')][0x5]['value']:undefined)||''},{'name':_0xc790('0x66'),'value':_0x277b32[_0xc790('0x66')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x6]?_0x277b32[_0xc790('0x57')][0x6][_0xc790('0x5d')]:undefined)||''},{'name':_0xc790('0x67'),'value':_0x277b32[_0xc790('0x67')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32['attrs'][0x7]?_0x277b32[_0xc790('0x57')][0x7][_0xc790('0x5d')]:undefined)||''},{'name':_0xc790('0x68'),'value':_0x277b32[_0xc790('0x68')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x8]?_0x277b32['attrs'][0x8][_0xc790('0x5d')]:undefined)||''},{'name':_0xc790('0x69'),'value':_0x277b32['attrChatWebsites']||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x9]?_0x277b32['attrs'][0x9][_0xc790('0x5d')]:undefined)||''}];case _0xc790('0x6a'):case _0xc790('0x6b'):return[{'name':_0xc790('0x6c'),'value':_0x277b32[_0xc790('0x6c')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32['attrs'][0x0][_0xc790('0x5d')]:undefined)||'total'},{'name':_0xc790('0x6d'),'value':_0x277b32[_0xc790('0x6d')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x1]?_0x277b32['attrs'][0x1][_0xc790('0x5d')]:undefined)||null},{'name':_0xc790('0x6e'),'value':_0x277b32[_0xc790('0x6e')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x2]?_0x277b32['attrs'][0x2][_0xc790('0x5d')]:undefined)||null},{'name':_0xc790('0x6f'),'value':_0x277b32[_0xc790('0x6f')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x3]?_0x277b32[_0xc790('0x57')][0x3]['value']:undefined)||[]},{'name':_0xc790('0x62'),'value':_0x277b32[_0xc790('0x62')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0x4]?_0x277b32[_0xc790('0x57')][0x4][_0xc790('0x5d')]:undefined)||_0xc790('0x63')},{'name':_0xc790('0x64'),'value':_0x277b32['attrEmailAccounts']||(_0x277b32[_0xc790('0x57')]&&_0x277b32['attrs'][0x5]?_0x277b32[_0xc790('0x57')][0x5][_0xc790('0x5d')]:undefined)||''},{'name':'attrFaxAccounts','value':_0x277b32[_0xc790('0x65')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x6]?_0x277b32[_0xc790('0x57')][0x6][_0xc790('0x5d')]:undefined)||''},{'name':_0xc790('0x66'),'value':_0x277b32[_0xc790('0x66')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32['attrs'][0x7]?_0x277b32['attrs'][0x7][_0xc790('0x5d')]:undefined)||''},{'name':_0xc790('0x67'),'value':_0x277b32[_0xc790('0x67')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32['attrs'][0x8]?_0x277b32[_0xc790('0x57')][0x8][_0xc790('0x5d')]:undefined)||''},{'name':'attrWhatsappAccounts','value':_0x277b32[_0xc790('0x68')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x9]?_0x277b32['attrs'][0x9][_0xc790('0x5d')]:undefined)||''},{'name':_0xc790('0x69'),'value':_0x277b32[_0xc790('0x69')]||(_0x277b32['attrs']&&_0x277b32[_0xc790('0x57')][0xa]?_0x277b32[_0xc790('0x57')][0xa]['value']:undefined)||''}];case _0xc790('0x70'):return[{'name':'attrReport','type':_0x277b32['reportType']||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32[_0xc790('0x57')][0x0]['type']:undefined)||null,'value':_0x277b32[_0xc790('0x71')]||(_0x277b32[_0xc790('0x57')]&&_0x277b32[_0xc790('0x57')][0x0]?_0x277b32[_0xc790('0x57')][0x0][_0xc790('0x5d')]:undefined)||null},{'name':_0xc790('0x72'),'value':_0x277b32[_0xc790('0x72')]||(_0x277b32['attrs']&&_0x277b32['attrs'][0x1]?_0x277b32[_0xc790('0x57')][0x1][_0xc790('0x5d')]:undefined)||0x0}];default:return[];}}catch(_0x33d2c6){logger[_0xc790('0x4e')]('widgetAttributes:\x20%s',JSON[_0xc790('0x73')](_0x33d2c6));return[];}}exports[_0xc790('0x74')]=function(_0x2143fe,_0x331b58,_0x3c329c){if(_0x2143fe['body']['id']){delete _0x2143fe[_0xc790('0x49')]['id'];}return db[_0xc790('0x3f')][_0xc790('0x47')]({'where':{'id':_0x2143fe[_0xc790('0x45')]['id']}})[_0xc790('0x23')](handleEntityNotFound(_0x331b58,null))[_0xc790('0x23')](function(_0x31c0b7){if(_0x31c0b7){_0x2143fe[_0xc790('0x49')][_0xc790('0x75')]=_0x31c0b7['id'];_0x2143fe[_0xc790('0x49')][_0xc790('0x57')]=widgetAttributes(_0x2143fe[_0xc790('0x49')]);return db['DashboardItem'][_0xc790('0x48')](_0x2143fe[_0xc790('0x49')]);}})[_0xc790('0x23')](respondWithResult(_0x331b58,null))[_0xc790('0x43')](handleError(_0x331b58,null));};exports[_0xc790('0x76')]=function(_0xa7f7c0,_0x6e55a6,_0x233863){var _0x38efb2={};var _0x2e031f={};var _0x2b32ba;var _0x1f8ad2;return db['Dashboard'][_0xc790('0x77')]({'where':{'id':_0xa7f7c0[_0xc790('0x45')]['id']}})[_0xc790('0x23')](handleEntityNotFound(_0x6e55a6,null))['then'](function(_0x407bcb){if(_0x407bcb){_0x2b32ba=_0x407bcb;_0x2e031f[_0xc790('0x31')]=_['keys'](db['DashboardItem'][_0xc790('0x2e')]);_0x2e031f[_0xc790('0x32')]=_[_0xc790('0x50')](_0xa7f7c0[_0xc790('0x32')]);_0x2e031f[_0xc790('0x3a')]=_[_0xc790('0x33')](_0x2e031f[_0xc790('0x31')],_0x2e031f['query']);_0x38efb2[_0xc790('0x34')]=_[_0xc790('0x33')](_0x2e031f[_0xc790('0x31')],qs[_0xc790('0x35')](_0xa7f7c0[_0xc790('0x32')][_0xc790('0x35')]));_0x38efb2[_0xc790('0x34')]=_0x38efb2['attributes'][_0xc790('0x46')]?_0x38efb2['attributes']:_0x2e031f[_0xc790('0x31')];_0x38efb2['order']=qs['sort'](_0xa7f7c0[_0xc790('0x32')][_0xc790('0x38')]);_0x38efb2[_0xc790('0x39')]=qs[_0xc790('0x3a')](_[_0xc790('0x78')](_0xa7f7c0[_0xc790('0x32')],_0x2e031f[_0xc790('0x3a')]));if(_0xa7f7c0[_0xc790('0x32')][_0xc790('0x3b')]){_0x38efb2[_0xc790('0x39')]=_[_0xc790('0x3c')](_0x38efb2[_0xc790('0x39')],{'$or':_[_0xc790('0x2d')](_0x38efb2[_0xc790('0x34')],function(_0x5931cb){var _0xf7d3f9={};_0xf7d3f9[_0x5931cb]={'$like':'%'+_0xa7f7c0[_0xc790('0x32')][_0xc790('0x3b')]+'%'};return _0xf7d3f9;})});}_0x38efb2=_[_0xc790('0x3c')]({},_0x38efb2,_0xa7f7c0['options']);return _0x2b32ba['getItems'](_0x38efb2);}})[_0xc790('0x23')](function(_0x238aea){if(_0x238aea){_0x1f8ad2=_0x238aea[_0xc790('0x46')];if(!_0xa7f7c0[_0xc790('0x32')]['hasOwnProperty'](_0xc790('0x79'))){_0x38efb2[_0xc790('0x20')]=qs['limit'](_0xa7f7c0[_0xc790('0x32')][_0xc790('0x20')]);_0x38efb2[_0xc790('0x1e')]=qs[_0xc790('0x1e')](_0xa7f7c0['query'][_0xc790('0x1e')]);}return _0x2b32ba[_0xc790('0x76')](_0x38efb2);}})[_0xc790('0x23')](function(_0xcb89c6){if(_0xcb89c6){return _0xcb89c6?{'count':_0x1f8ad2,'rows':_0xcb89c6}:null;}})[_0xc790('0x23')](respondWithResult(_0x6e55a6,null))[_0xc790('0x43')](handleError(_0x6e55a6,null));};
\ No newline at end of file