Built motion from commit f6d7e26c.|2.6.14
[motion2.git] / server / api / dashboard / dashboard.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xf8c6=['../../config/license/util','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','get','CustomDashboards','UserProfileResource','error','stack','name','send','index','map','Dashboard','rawAttributes','type','key','model','keys','query','filters','intersection','attributes','fields','length','order','sort','filter','merge','where','options','includeAll','include','show','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','createdAt','omit','iframe','attrUrl','attrs','https://','custom','attrPath','value','clock','attrHourFormat','HH:mm:ss','attrTimezone','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','attrSmsAccounts','web-report','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardItem','getItems','findOne','pick','hasOwnProperty','nolimit','eml-format','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment'];(function(_0x19d7e9,_0x359dd7){var _0x3b74db=function(_0x5bb01f){while(--_0x5bb01f){_0x19d7e9['push'](_0x19d7e9['shift']());}};_0x3b74db(++_0x359dd7);}(_0xf8c6,0xf0));var _0x6f8c=function(_0x277d4d,_0x2d74d4){_0x277d4d=_0x277d4d-0x0;var _0x67cac2=_0xf8c6[_0x277d4d];return _0x67cac2;};'use strict';var emlformat=require(_0x6f8c('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x6f8c('0x1'));var rp=require(_0x6f8c('0x2'));var moment=require(_0x6f8c('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x6f8c('0x4'));var util=require(_0x6f8c('0x5'));var path=require(_0x6f8c('0x6'));var sox=require(_0x6f8c('0x7'));var csv=require(_0x6f8c('0x8'));var ejs=require(_0x6f8c('0x9'));var fs=require('fs');var fs_extra=require(_0x6f8c('0xa'));var _=require(_0x6f8c('0xb'));var squel=require(_0x6f8c('0xc'));var crypto=require('crypto');var jsforce=require(_0x6f8c('0xd'));var deskjs=require(_0x6f8c('0xe'));var toCsv=require(_0x6f8c('0x8'));var querystring=require(_0x6f8c('0xf'));var Papa=require(_0x6f8c('0x10'));var Redis=require(_0x6f8c('0x11'));var authService=require(_0x6f8c('0x12'));var qs=require(_0x6f8c('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6f8c('0x14'));var logger=require('../../config/logger')(_0x6f8c('0x15'));var utils=require(_0x6f8c('0x16'));var config=require(_0x6f8c('0x17'));var licenseUtil=require(_0x6f8c('0x18'));var db=require('../../mysqldb')['db'];config[_0x6f8c('0x19')]=_[_0x6f8c('0x1a')](config[_0x6f8c('0x19')],{'host':_0x6f8c('0x1b'),'port':0x18eb});var socket=require(_0x6f8c('0x1c'))(new Redis(config[_0x6f8c('0x19')]));require(_0x6f8c('0x1d'))['register'](socket);function respondWithStatusCode(_0x41d0f7,_0x124364){_0x124364=_0x124364||0xcc;return function(_0x508256){if(_0x508256){return _0x41d0f7[_0x6f8c('0x1e')](_0x124364);}return _0x41d0f7[_0x6f8c('0x1f')](_0x124364)[_0x6f8c('0x20')]();};}function respondWithResult(_0x1f659f,_0x30a623){_0x30a623=_0x30a623||0xc8;return function(_0x224b86){if(_0x224b86){return _0x1f659f['status'](_0x30a623)[_0x6f8c('0x21')](_0x224b86);}};}function respondWithFilteredResult(_0x1a4f96,_0x10f77a){return function(_0x198b6e){if(_0x198b6e){var _0x57e295=typeof _0x10f77a[_0x6f8c('0x22')]===_0x6f8c('0x23')&&typeof _0x10f77a[_0x6f8c('0x24')]==='undefined';var _0x1cc40b=_0x198b6e[_0x6f8c('0x25')];var _0x59083a=_0x57e295?0x0:_0x10f77a[_0x6f8c('0x22')];var _0x4b7a47=_0x57e295?_0x198b6e[_0x6f8c('0x25')]:_0x10f77a[_0x6f8c('0x22')]+_0x10f77a[_0x6f8c('0x24')];var _0x3ec83d;if(_0x4b7a47>=_0x1cc40b){_0x4b7a47=_0x1cc40b;_0x3ec83d=0xc8;}else{_0x3ec83d=0xce;}_0x1a4f96[_0x6f8c('0x1f')](_0x3ec83d);return _0x1a4f96[_0x6f8c('0x26')](_0x6f8c('0x27'),_0x59083a+'-'+_0x4b7a47+'/'+_0x1cc40b)[_0x6f8c('0x21')](_0x198b6e);}return null;};}function patchUpdates(_0xbf80b0){return function(_0x55657b){try{jsonpatch[_0x6f8c('0x28')](_0x55657b,_0xbf80b0,!![]);}catch(_0x34c6d1){return BPromise[_0x6f8c('0x29')](_0x34c6d1);}return _0x55657b[_0x6f8c('0x2a')]();};}function saveUpdates(_0x3b555c,_0x22faba){return function(_0x41bb5e){if(_0x41bb5e){return _0x41bb5e[_0x6f8c('0x2b')](_0x3b555c)[_0x6f8c('0x2c')](function(_0x52015a){return _0x52015a;});}return null;};}function removeEntity(_0x2638fd,_0x5d7db3){return function(_0x2c9a58){if(_0x2c9a58){return _0x2c9a58[_0x6f8c('0x2d')]()[_0x6f8c('0x2c')](function(){var _0x4337db=_0x2c9a58[_0x6f8c('0x2e')]({'plain':!![]});var _0x8aa055=_0x6f8c('0x2f');return db[_0x6f8c('0x30')][_0x6f8c('0x2d')]({'where':{'type':_0x8aa055,'resourceId':_0x4337db['id']}})[_0x6f8c('0x2c')](function(){return _0x2c9a58;});})[_0x6f8c('0x2c')](function(){_0x2638fd[_0x6f8c('0x1f')](0xcc)[_0x6f8c('0x20')]();});}};}function handleEntityNotFound(_0x291fcc,_0x204aed){return function(_0x5faf2b){if(!_0x5faf2b){_0x291fcc[_0x6f8c('0x1e')](0x194);}return _0x5faf2b;};}function handleError(_0x2d6de9,_0x582d8f){_0x582d8f=_0x582d8f||0x1f4;return function(_0x45c24b){logger[_0x6f8c('0x31')](_0x45c24b[_0x6f8c('0x32')]);if(_0x45c24b[_0x6f8c('0x33')]){delete _0x45c24b['name'];}_0x2d6de9[_0x6f8c('0x1f')](_0x582d8f)[_0x6f8c('0x34')](_0x45c24b);};}exports[_0x6f8c('0x35')]=function(_0x4ed854,_0xaeb404){var _0x1269b5={},_0x3759d9={},_0x4f4494={'count':0x0,'rows':[]};var _0x38b896=_[_0x6f8c('0x36')](db[_0x6f8c('0x37')][_0x6f8c('0x38')],function(_0x461d81){return{'name':_0x461d81['fieldName'],'type':_0x461d81[_0x6f8c('0x39')][_0x6f8c('0x3a')]};});_0x3759d9[_0x6f8c('0x3b')]=_[_0x6f8c('0x36')](_0x38b896,_0x6f8c('0x33'));_0x3759d9['query']=_[_0x6f8c('0x3c')](_0x4ed854[_0x6f8c('0x3d')]);_0x3759d9[_0x6f8c('0x3e')]=_[_0x6f8c('0x3f')](_0x3759d9[_0x6f8c('0x3b')],_0x3759d9[_0x6f8c('0x3d')]);_0x1269b5[_0x6f8c('0x40')]=_[_0x6f8c('0x3f')](_0x3759d9[_0x6f8c('0x3b')],qs[_0x6f8c('0x41')](_0x4ed854[_0x6f8c('0x3d')][_0x6f8c('0x41')]));_0x1269b5['attributes']=_0x1269b5[_0x6f8c('0x40')][_0x6f8c('0x42')]?_0x1269b5[_0x6f8c('0x40')]:_0x3759d9[_0x6f8c('0x3b')];if(!_0x4ed854[_0x6f8c('0x3d')]['hasOwnProperty']('nolimit')){_0x1269b5['limit']=qs[_0x6f8c('0x24')](_0x4ed854[_0x6f8c('0x3d')][_0x6f8c('0x24')]);_0x1269b5[_0x6f8c('0x22')]=qs[_0x6f8c('0x22')](_0x4ed854[_0x6f8c('0x3d')][_0x6f8c('0x22')]);}_0x1269b5[_0x6f8c('0x43')]=qs[_0x6f8c('0x44')](_0x4ed854[_0x6f8c('0x3d')]['sort']);_0x1269b5['where']=qs[_0x6f8c('0x3e')](_['pick'](_0x4ed854[_0x6f8c('0x3d')],_0x3759d9[_0x6f8c('0x3e')]),_0x38b896);if(_0x4ed854[_0x6f8c('0x3d')][_0x6f8c('0x45')]){_0x1269b5['where']=_[_0x6f8c('0x46')](_0x1269b5[_0x6f8c('0x47')],{'$or':_['map'](_0x38b896,function(_0x96ce35){if(_0x96ce35[_0x6f8c('0x39')]!=='VIRTUAL'){var _0xea6d40={};_0xea6d40[_0x96ce35[_0x6f8c('0x33')]]={'$like':'%'+_0x4ed854[_0x6f8c('0x3d')][_0x6f8c('0x45')]+'%'};return _0xea6d40;}})});}_0x1269b5=_[_0x6f8c('0x46')]({},_0x1269b5,_0x4ed854[_0x6f8c('0x48')]);var _0x4a96e5={'where':_0x1269b5[_0x6f8c('0x47')]};return db[_0x6f8c('0x37')][_0x6f8c('0x25')](_0x4a96e5)['then'](function(_0x5eac81){_0x4f4494[_0x6f8c('0x25')]=_0x5eac81;if(_0x4ed854[_0x6f8c('0x3d')][_0x6f8c('0x49')]){_0x1269b5[_0x6f8c('0x4a')]=[{'all':!![]}];}return db[_0x6f8c('0x37')]['findAll'](_0x1269b5);})[_0x6f8c('0x2c')](function(_0x2c3881){_0x4f4494['rows']=_0x2c3881;return _0x4f4494;})[_0x6f8c('0x2c')](respondWithFilteredResult(_0xaeb404,_0x1269b5))['catch'](handleError(_0xaeb404,null));};exports[_0x6f8c('0x4b')]=function(_0x18ec76,_0x239cf1){var _0x25e0cb={'raw':![],'where':{'id':_0x18ec76[_0x6f8c('0x4c')]['id']}},_0xba4c3c={};_0xba4c3c[_0x6f8c('0x3b')]=_[_0x6f8c('0x3c')](db['Dashboard'][_0x6f8c('0x38')]);_0xba4c3c[_0x6f8c('0x3d')]=_[_0x6f8c('0x3c')](_0x18ec76[_0x6f8c('0x3d')]);_0xba4c3c[_0x6f8c('0x3e')]=_['intersection'](_0xba4c3c[_0x6f8c('0x3b')],_0xba4c3c[_0x6f8c('0x3d')]);_0x25e0cb[_0x6f8c('0x40')]=_['intersection'](_0xba4c3c[_0x6f8c('0x3b')],qs['fields'](_0x18ec76['query'][_0x6f8c('0x41')]));_0x25e0cb[_0x6f8c('0x40')]=_0x25e0cb[_0x6f8c('0x40')][_0x6f8c('0x42')]?_0x25e0cb[_0x6f8c('0x40')]:_0xba4c3c[_0x6f8c('0x3b')];if(_0x18ec76[_0x6f8c('0x3d')][_0x6f8c('0x49')]){_0x25e0cb['include']=[{'all':!![]}];}_0x25e0cb=_[_0x6f8c('0x46')]({},_0x25e0cb,_0x18ec76['options']);return db[_0x6f8c('0x37')][_0x6f8c('0x4d')](_0x25e0cb)[_0x6f8c('0x2c')](handleEntityNotFound(_0x239cf1,null))[_0x6f8c('0x2c')](respondWithResult(_0x239cf1,null))['catch'](handleError(_0x239cf1,null));};exports[_0x6f8c('0x4e')]=function(_0x3f0d8a,_0x11d26a){return db['Dashboard'][_0x6f8c('0x4e')](_0x3f0d8a[_0x6f8c('0x4f')],{})[_0x6f8c('0x2c')](function(_0x54a08b){var _0x3ed610=_0x3f0d8a[_0x6f8c('0x50')][_0x6f8c('0x2e')]({'plain':!![]});if(!_0x3ed610)throw new Error(_0x6f8c('0x51'));if(_0x3ed610[_0x6f8c('0x52')]===_0x6f8c('0x50')){var _0x83adf3=_0x54a08b[_0x6f8c('0x2e')]({'plain':!![]});var _0x3320f6=_0x6f8c('0x2f');return db[_0x6f8c('0x53')][_0x6f8c('0x4d')]({'where':{'name':_0x3320f6,'userProfileId':_0x3ed610[_0x6f8c('0x54')]},'raw':!![]})[_0x6f8c('0x2c')](function(_0x5bf31a){if(_0x5bf31a&&_0x5bf31a[_0x6f8c('0x55')]===0x0){return db[_0x6f8c('0x30')][_0x6f8c('0x4e')]({'name':_0x83adf3[_0x6f8c('0x33')],'resourceId':_0x83adf3['id'],'type':_0x5bf31a[_0x6f8c('0x33')],'sectionId':_0x5bf31a['id']},{})[_0x6f8c('0x2c')](function(){return _0x54a08b;});}else{return _0x54a08b;}})[_0x6f8c('0x56')](function(_0x43b739){logger[_0x6f8c('0x31')](_0x6f8c('0x57'),_0x43b739);throw _0x43b739;});}return _0x54a08b;})['then'](respondWithResult(_0x11d26a,0xc9))['catch'](handleError(_0x11d26a,null));};exports['clone']=function(_0x2c0886,_0x53481f){var _0x144252={'where':{'id':_0x2c0886[_0x6f8c('0x4c')]['id']}},_0x532841={};_0x532841[_0x6f8c('0x3b')]=_[_0x6f8c('0x3c')](db['Dashboard'][_0x6f8c('0x38')]);_0x144252[_0x6f8c('0x40')]=_[_0x6f8c('0x3f')](_0x532841[_0x6f8c('0x3b')],qs[_0x6f8c('0x41')](_0x2c0886[_0x6f8c('0x3d')][_0x6f8c('0x41')]));_0x144252[_0x6f8c('0x40')]=_0x144252[_0x6f8c('0x40')][_0x6f8c('0x42')]?_0x144252['attributes']:_0x532841[_0x6f8c('0x3b')];if(_0x2c0886[_0x6f8c('0x3d')][_0x6f8c('0x49')]){_0x144252[_0x6f8c('0x4a')]=[{'all':!![]}];}_0x144252=_[_0x6f8c('0x46')]({},_0x144252,_0x2c0886[_0x6f8c('0x48')]);return db['Dashboard'][_0x6f8c('0x4d')](_0x144252)[_0x6f8c('0x2c')](handleEntityNotFound(_0x53481f,null))[_0x6f8c('0x2c')](function(_0xa62c99){if(_0xa62c99){var _0x205fc5=_0xa62c99[_0x6f8c('0x2e')]({'plain':!![]});_0x205fc5=qs['omit'](_0x205fc5,['id',_0x6f8c('0x58'),'updatedAt']);_0x2c0886['body']=_[_0x6f8c('0x59')](_0x2c0886['body'],['id',_0x6f8c('0x58'),'updatedAt']);return db[_0x6f8c('0x37')][_0x6f8c('0x4e')](_[_0x6f8c('0x46')](_0x205fc5,_0x2c0886['body']),{'include':_0x2c0886['query'][_0x6f8c('0x49')]?[{'all':!![]}]:undefined})[_0x6f8c('0x2c')](function(_0x52f6b3){var _0x395d1a=_0x2c0886[_0x6f8c('0x50')][_0x6f8c('0x2e')]({'plain':!![]});if(!_0x395d1a)throw new Error(_0x6f8c('0x51'));if(_0x395d1a[_0x6f8c('0x52')]===_0x6f8c('0x50')){var _0xbb6af3=_0x52f6b3[_0x6f8c('0x2e')]({'plain':!![]});var _0x28e37c='CustomDashboards';return db[_0x6f8c('0x53')][_0x6f8c('0x4d')]({'where':{'name':_0x28e37c,'userProfileId':_0x395d1a['userProfileId']},'raw':!![]})[_0x6f8c('0x2c')](function(_0x27dcae){if(_0x27dcae&&_0x27dcae[_0x6f8c('0x55')]===0x0){return db[_0x6f8c('0x30')]['create']({'name':_0xbb6af3[_0x6f8c('0x33')],'resourceId':_0xbb6af3['id'],'type':_0x27dcae[_0x6f8c('0x33')],'sectionId':_0x27dcae['id']},{})[_0x6f8c('0x2c')](function(){return _0x52f6b3;});}else{return _0x52f6b3;}})[_0x6f8c('0x56')](function(_0x6485c5){logger[_0x6f8c('0x31')](_0x6f8c('0x57'),_0x6485c5);throw _0x6485c5;});}return _0x52f6b3;});}})[_0x6f8c('0x2c')](respondWithResult(_0x53481f,0xc9))[_0x6f8c('0x56')](handleError(_0x53481f,null));};exports[_0x6f8c('0x2b')]=function(_0x374513,_0xdc4b3a){if(_0x374513['body']['id']){delete _0x374513[_0x6f8c('0x4f')]['id'];}return db[_0x6f8c('0x37')][_0x6f8c('0x4d')]({'where':{'id':_0x374513[_0x6f8c('0x4c')]['id']}})[_0x6f8c('0x2c')](handleEntityNotFound(_0xdc4b3a,null))[_0x6f8c('0x2c')](saveUpdates(_0x374513[_0x6f8c('0x4f')],null))[_0x6f8c('0x2c')](respondWithResult(_0xdc4b3a,null))['catch'](handleError(_0xdc4b3a,null));};exports[_0x6f8c('0x2d')]=function(_0x530ac3,_0x4157a4){return db['Dashboard'][_0x6f8c('0x4d')]({'where':{'id':_0x530ac3[_0x6f8c('0x4c')]['id']}})['then'](handleEntityNotFound(_0x4157a4,null))['then'](removeEntity(_0x4157a4,null))[_0x6f8c('0x56')](handleError(_0x4157a4,null));};function widgetAttributes(_0x5a24e8){try{switch(_0x5a24e8[_0x6f8c('0x39')]){case _0x6f8c('0x5a'):return[{'name':'attrUrl','value':_0x5a24e8[_0x6f8c('0x5b')]||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x0]?_0x5a24e8[_0x6f8c('0x5c')][0x0]['value']:undefined)||_0x6f8c('0x5d')}];case _0x6f8c('0x5e'):return[{'name':'attrPath','value':_0x5a24e8[_0x6f8c('0x5f')]||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x0]?_0x5a24e8['attrs'][0x0][_0x6f8c('0x60')]:undefined)||''}];case _0x6f8c('0x61'):return[{'name':'attrHourFormat','value':_0x5a24e8[_0x6f8c('0x62')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x0]?_0x5a24e8[_0x6f8c('0x5c')][0x0][_0x6f8c('0x60')]:undefined)||_0x6f8c('0x63')},{'name':_0x6f8c('0x64'),'value':_0x5a24e8['attrTimezone']||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x1]?_0x5a24e8[_0x6f8c('0x5c')][0x1]['value']:undefined)||'0.00'},{'name':_0x6f8c('0x65'),'value':_0x5a24e8[_0x6f8c('0x65')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x2]?_0x5a24e8[_0x6f8c('0x5c')][0x2][_0x6f8c('0x60')]:undefined)||0xc}];case _0x6f8c('0x66'):return[{'name':_0x6f8c('0x67'),'value':_0x5a24e8[_0x6f8c('0x67')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x0]?_0x5a24e8[_0x6f8c('0x5c')][0x0][_0x6f8c('0x60')]:undefined)||_0x6f8c('0x68')},{'name':_0x6f8c('0x69'),'value':_0x5a24e8[_0x6f8c('0x69')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x1]?_0x5a24e8[_0x6f8c('0x5c')][0x1]['value']:undefined)||[]},{'name':_0x6f8c('0x65'),'value':_0x5a24e8['attrFontSize']||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x2]?_0x5a24e8[_0x6f8c('0x5c')][0x2][_0x6f8c('0x60')]:undefined)||0x14},{'name':_0x6f8c('0x6a'),'value':_0x5a24e8[_0x6f8c('0x6a')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x3]?_0x5a24e8['attrs'][0x3][_0x6f8c('0x60')]:undefined)||_0x6f8c('0x6b')},{'name':_0x6f8c('0x6c'),'value':_0x5a24e8[_0x6f8c('0x6c')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x4]?_0x5a24e8[_0x6f8c('0x5c')][0x4][_0x6f8c('0x60')]:undefined)||''},{'name':_0x6f8c('0x6d'),'value':_0x5a24e8[_0x6f8c('0x6d')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x5]?_0x5a24e8[_0x6f8c('0x5c')][0x5][_0x6f8c('0x60')]:undefined)||''},{'name':'attrSmsAccounts','value':_0x5a24e8['attrSmsAccounts']||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x6]?_0x5a24e8[_0x6f8c('0x5c')][0x6][_0x6f8c('0x60')]:undefined)||''},{'name':_0x6f8c('0x6e'),'value':_0x5a24e8[_0x6f8c('0x6e')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x7]?_0x5a24e8[_0x6f8c('0x5c')][0x7]['value']:undefined)||''},{'name':_0x6f8c('0x6f'),'value':_0x5a24e8[_0x6f8c('0x6f')]||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x8]?_0x5a24e8[_0x6f8c('0x5c')][0x8][_0x6f8c('0x60')]:undefined)||''},{'name':_0x6f8c('0x70'),'value':_0x5a24e8[_0x6f8c('0x70')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x9]?_0x5a24e8['attrs'][0x9][_0x6f8c('0x60')]:undefined)||''}];case _0x6f8c('0x71'):case _0x6f8c('0x72'):return[{'name':_0x6f8c('0x73'),'value':_0x5a24e8[_0x6f8c('0x73')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x0]?_0x5a24e8[_0x6f8c('0x5c')][0x0][_0x6f8c('0x60')]:undefined)||'total'},{'name':_0x6f8c('0x74'),'value':_0x5a24e8[_0x6f8c('0x74')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x1]?_0x5a24e8[_0x6f8c('0x5c')][0x1][_0x6f8c('0x60')]:undefined)||null},{'name':_0x6f8c('0x75'),'value':_0x5a24e8[_0x6f8c('0x75')]||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x2]?_0x5a24e8['attrs'][0x2][_0x6f8c('0x60')]:undefined)||null},{'name':_0x6f8c('0x69'),'value':_0x5a24e8[_0x6f8c('0x69')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x3]?_0x5a24e8[_0x6f8c('0x5c')][0x3][_0x6f8c('0x60')]:undefined)||[]},{'name':_0x6f8c('0x6a'),'value':_0x5a24e8[_0x6f8c('0x6a')]||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x4]?_0x5a24e8[_0x6f8c('0x5c')][0x4][_0x6f8c('0x60')]:undefined)||'voice'},{'name':'attrEmailAccounts','value':_0x5a24e8[_0x6f8c('0x6c')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x5]?_0x5a24e8[_0x6f8c('0x5c')][0x5][_0x6f8c('0x60')]:undefined)||''},{'name':'attrFaxAccounts','value':_0x5a24e8['attrFaxAccounts']||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x6]?_0x5a24e8['attrs'][0x6][_0x6f8c('0x60')]:undefined)||''},{'name':'attrSmsAccounts','value':_0x5a24e8[_0x6f8c('0x76')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x7]?_0x5a24e8[_0x6f8c('0x5c')][0x7][_0x6f8c('0x60')]:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x5a24e8['attrOpenchannelAccounts']||(_0x5a24e8['attrs']&&_0x5a24e8[_0x6f8c('0x5c')][0x8]?_0x5a24e8[_0x6f8c('0x5c')][0x8][_0x6f8c('0x60')]:undefined)||''},{'name':_0x6f8c('0x6f'),'value':_0x5a24e8['attrWhatsappAccounts']||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x9]?_0x5a24e8[_0x6f8c('0x5c')][0x9]['value']:undefined)||''},{'name':_0x6f8c('0x70'),'value':_0x5a24e8[_0x6f8c('0x70')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0xa]?_0x5a24e8[_0x6f8c('0x5c')][0xa][_0x6f8c('0x60')]:undefined)||''}];case _0x6f8c('0x77'):return[{'name':_0x6f8c('0x78'),'type':_0x5a24e8[_0x6f8c('0x79')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8[_0x6f8c('0x5c')][0x0]?_0x5a24e8['attrs'][0x0][_0x6f8c('0x39')]:undefined)||null,'value':_0x5a24e8[_0x6f8c('0x78')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x0]?_0x5a24e8['attrs'][0x0][_0x6f8c('0x60')]:undefined)||null},{'name':_0x6f8c('0x7a'),'value':_0x5a24e8[_0x6f8c('0x7a')]||(_0x5a24e8[_0x6f8c('0x5c')]&&_0x5a24e8['attrs'][0x1]?_0x5a24e8[_0x6f8c('0x5c')][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0x58f9f8){logger['error'](_0x6f8c('0x7b'),JSON[_0x6f8c('0x7c')](_0x58f9f8));return[];}}exports[_0x6f8c('0x7d')]=function(_0x5e86cb,_0x5b92da,_0x4c63bb){if(_0x5e86cb[_0x6f8c('0x4f')]['id']){delete _0x5e86cb[_0x6f8c('0x4f')]['id'];}return db[_0x6f8c('0x37')][_0x6f8c('0x4d')]({'where':{'id':_0x5e86cb[_0x6f8c('0x4c')]['id']}})[_0x6f8c('0x2c')](handleEntityNotFound(_0x5b92da,null))[_0x6f8c('0x2c')](function(_0x9918a0){if(_0x9918a0){_0x5e86cb[_0x6f8c('0x4f')]['DashboardId']=_0x9918a0['id'];_0x5e86cb[_0x6f8c('0x4f')][_0x6f8c('0x5c')]=widgetAttributes(_0x5e86cb[_0x6f8c('0x4f')]);return db[_0x6f8c('0x7e')][_0x6f8c('0x4e')](_0x5e86cb[_0x6f8c('0x4f')]);}})[_0x6f8c('0x2c')](respondWithResult(_0x5b92da,null))[_0x6f8c('0x56')](handleError(_0x5b92da,null));};exports[_0x6f8c('0x7f')]=function(_0x517d56,_0x2f0e04,_0x41237a){var _0x42a127={};var _0x48b4bb={};var _0x1f6f4c;var _0x2ddeb7;return db[_0x6f8c('0x37')][_0x6f8c('0x80')]({'where':{'id':_0x517d56[_0x6f8c('0x4c')]['id']}})['then'](handleEntityNotFound(_0x2f0e04,null))[_0x6f8c('0x2c')](function(_0x1c7c56){if(_0x1c7c56){_0x1f6f4c=_0x1c7c56;_0x48b4bb[_0x6f8c('0x3b')]=_[_0x6f8c('0x3c')](db['DashboardItem']['rawAttributes']);_0x48b4bb[_0x6f8c('0x3d')]=_['keys'](_0x517d56[_0x6f8c('0x3d')]);_0x48b4bb[_0x6f8c('0x3e')]=_['intersection'](_0x48b4bb[_0x6f8c('0x3b')],_0x48b4bb[_0x6f8c('0x3d')]);_0x42a127[_0x6f8c('0x40')]=_[_0x6f8c('0x3f')](_0x48b4bb['model'],qs['fields'](_0x517d56['query'][_0x6f8c('0x41')]));_0x42a127[_0x6f8c('0x40')]=_0x42a127['attributes'][_0x6f8c('0x42')]?_0x42a127[_0x6f8c('0x40')]:_0x48b4bb[_0x6f8c('0x3b')];_0x42a127['order']=qs[_0x6f8c('0x44')](_0x517d56[_0x6f8c('0x3d')]['sort']);_0x42a127[_0x6f8c('0x47')]=qs[_0x6f8c('0x3e')](_[_0x6f8c('0x81')](_0x517d56[_0x6f8c('0x3d')],_0x48b4bb[_0x6f8c('0x3e')]));if(_0x517d56[_0x6f8c('0x3d')][_0x6f8c('0x45')]){_0x42a127[_0x6f8c('0x47')]=_[_0x6f8c('0x46')](_0x42a127[_0x6f8c('0x47')],{'$or':_[_0x6f8c('0x36')](_0x42a127['attributes'],function(_0x45cadd){var _0x1af39e={};_0x1af39e[_0x45cadd]={'$like':'%'+_0x517d56[_0x6f8c('0x3d')][_0x6f8c('0x45')]+'%'};return _0x1af39e;})});}_0x42a127=_[_0x6f8c('0x46')]({},_0x42a127,_0x517d56[_0x6f8c('0x48')]);return _0x1f6f4c['getItems'](_0x42a127);}})[_0x6f8c('0x2c')](function(_0xd08e26){if(_0xd08e26){_0x2ddeb7=_0xd08e26['length'];if(!_0x517d56[_0x6f8c('0x3d')][_0x6f8c('0x82')](_0x6f8c('0x83'))){_0x42a127[_0x6f8c('0x24')]=qs[_0x6f8c('0x24')](_0x517d56[_0x6f8c('0x3d')][_0x6f8c('0x24')]);_0x42a127['offset']=qs[_0x6f8c('0x22')](_0x517d56[_0x6f8c('0x3d')][_0x6f8c('0x22')]);}return _0x1f6f4c[_0x6f8c('0x7f')](_0x42a127);}})['then'](function(_0x38fe38){if(_0x38fe38){return _0x38fe38?{'count':_0x2ddeb7,'rows':_0x38fe38}:null;}})['then'](respondWithResult(_0x2f0e04,null))[_0x6f8c('0x56')](handleError(_0x2f0e04,null));};