Built motion from commit fe909640.|2.6.8
[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 _0x49ba=['order','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','./dashboard.socket','register','sendStatus','end','status','json','offset','undefined','count','limit','set','Content-Range','save','then','destroy','CustomDashboards','UserProfileResource','error','stack','name','send','index','map','rawAttributes','fieldName','type','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','VIRTUAL','options','Dashboard','includeAll','include','rows','catch','show','keys','create','body','get','user','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','createdAt','updatedAt','omit','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','update','params','iframe','attrUrl','attrs','value','custom','attrPath','clock','attrHourFormat','HH:mm:ss','0.00','attrFontSize','counter','attrMetric','total','attrVoiceQueues','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','attrChannel','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','getItems','DashboardItem'];(function(_0x16cff9,_0xf24ff4){var _0x4f048c=function(_0x14c8bc){while(--_0x14c8bc){_0x16cff9['push'](_0x16cff9['shift']());}};_0x4f048c(++_0xf24ff4);}(_0x49ba,0x82));var _0xa49b=function(_0x3d6069,_0x5afca8){_0x3d6069=_0x3d6069-0x0;var _0x35f0d3=_0x49ba[_0x3d6069];return _0x35f0d3;};'use strict';var emlformat=require(_0xa49b('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa49b('0x1'));var jsonpatch=require(_0xa49b('0x2'));var rp=require(_0xa49b('0x3'));var moment=require(_0xa49b('0x4'));var BPromise=require(_0xa49b('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xa49b('0x6'));var sox=require(_0xa49b('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa49b('0x8'));var squel=require(_0xa49b('0x9'));var crypto=require('crypto');var jsforce=require(_0xa49b('0xa'));var deskjs=require(_0xa49b('0xb'));var toCsv=require(_0xa49b('0xc'));var querystring=require(_0xa49b('0xd'));var Papa=require(_0xa49b('0xe'));var Redis=require(_0xa49b('0xf'));var authService=require(_0xa49b('0x10'));var qs=require(_0xa49b('0x11'));var as=require(_0xa49b('0x12'));var hardwareService=require(_0xa49b('0x13'));var logger=require(_0xa49b('0x14'))(_0xa49b('0x15'));var utils=require(_0xa49b('0x16'));var config=require(_0xa49b('0x17'));var licenseUtil=require(_0xa49b('0x18'));var db=require(_0xa49b('0x19'))['db'];config[_0xa49b('0x1a')]=_['defaults'](config['redis'],{'host':_0xa49b('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xa49b('0x1c'))[_0xa49b('0x1d')](socket);function respondWithStatusCode(_0x4bc226,_0x231315){_0x231315=_0x231315||0xcc;return function(_0x3276e1){if(_0x3276e1){return _0x4bc226[_0xa49b('0x1e')](_0x231315);}return _0x4bc226['status'](_0x231315)[_0xa49b('0x1f')]();};}function respondWithResult(_0x9a1ff9,_0x383cb3){_0x383cb3=_0x383cb3||0xc8;return function(_0xefdfe8){if(_0xefdfe8){return _0x9a1ff9[_0xa49b('0x20')](_0x383cb3)[_0xa49b('0x21')](_0xefdfe8);}};}function respondWithFilteredResult(_0x2a7efd,_0x3ebe0d){return function(_0x52c9d1){if(_0x52c9d1){var _0x94c0f9=typeof _0x3ebe0d[_0xa49b('0x22')]===_0xa49b('0x23')&&typeof _0x3ebe0d['limit']===_0xa49b('0x23');var _0x3b5766=_0x52c9d1['count'];var _0x15e6cb=_0x94c0f9?0x0:_0x3ebe0d[_0xa49b('0x22')];var _0x5807f9=_0x94c0f9?_0x52c9d1[_0xa49b('0x24')]:_0x3ebe0d[_0xa49b('0x22')]+_0x3ebe0d[_0xa49b('0x25')];var _0x437b4a;if(_0x5807f9>=_0x3b5766){_0x5807f9=_0x3b5766;_0x437b4a=0xc8;}else{_0x437b4a=0xce;}_0x2a7efd[_0xa49b('0x20')](_0x437b4a);return _0x2a7efd[_0xa49b('0x26')](_0xa49b('0x27'),_0x15e6cb+'-'+_0x5807f9+'/'+_0x3b5766)['json'](_0x52c9d1);}return null;};}function patchUpdates(_0x4d101b){return function(_0xded164){try{jsonpatch['apply'](_0xded164,_0x4d101b,!![]);}catch(_0x1062c3){return BPromise['reject'](_0x1062c3);}return _0xded164[_0xa49b('0x28')]();};}function saveUpdates(_0x58c09c,_0x4c7eb3){return function(_0xfd3cb2){if(_0xfd3cb2){return _0xfd3cb2['update'](_0x58c09c)[_0xa49b('0x29')](function(_0x1eb449){return _0x1eb449;});}return null;};}function removeEntity(_0xfd39f1,_0x3c541b){return function(_0x3c54c2){if(_0x3c54c2){return _0x3c54c2[_0xa49b('0x2a')]()[_0xa49b('0x29')](function(){var _0x3c0f44=_0x3c54c2['get']({'plain':!![]});var _0x4c73ad=_0xa49b('0x2b');return db[_0xa49b('0x2c')]['destroy']({'where':{'type':_0x4c73ad,'resourceId':_0x3c0f44['id']}})[_0xa49b('0x29')](function(){return _0x3c54c2;});})['then'](function(){_0xfd39f1[_0xa49b('0x20')](0xcc)[_0xa49b('0x1f')]();});}};}function handleEntityNotFound(_0x4a6e2e,_0x569f8c){return function(_0x375b91){if(!_0x375b91){_0x4a6e2e['sendStatus'](0x194);}return _0x375b91;};}function handleError(_0x43ce86,_0x5d236a){_0x5d236a=_0x5d236a||0x1f4;return function(_0x4114a6){logger[_0xa49b('0x2d')](_0x4114a6[_0xa49b('0x2e')]);if(_0x4114a6[_0xa49b('0x2f')]){delete _0x4114a6[_0xa49b('0x2f')];}_0x43ce86['status'](_0x5d236a)[_0xa49b('0x30')](_0x4114a6);};}exports[_0xa49b('0x31')]=function(_0x1b9ede,_0x82d723){var _0x29af25={},_0x3bb348={},_0x28d876={'count':0x0,'rows':[]};var _0x4384ce=_[_0xa49b('0x32')](db['Dashboard'][_0xa49b('0x33')],function(_0x51927c){return{'name':_0x51927c[_0xa49b('0x34')],'type':_0x51927c[_0xa49b('0x35')]['key']};});_0x3bb348['model']=_[_0xa49b('0x32')](_0x4384ce,_0xa49b('0x2f'));_0x3bb348[_0xa49b('0x36')]=_['keys'](_0x1b9ede[_0xa49b('0x36')]);_0x3bb348[_0xa49b('0x37')]=_[_0xa49b('0x38')](_0x3bb348['model'],_0x3bb348[_0xa49b('0x36')]);_0x29af25['attributes']=_[_0xa49b('0x38')](_0x3bb348[_0xa49b('0x39')],qs[_0xa49b('0x3a')](_0x1b9ede[_0xa49b('0x36')][_0xa49b('0x3a')]));_0x29af25[_0xa49b('0x3b')]=_0x29af25[_0xa49b('0x3b')][_0xa49b('0x3c')]?_0x29af25[_0xa49b('0x3b')]:_0x3bb348[_0xa49b('0x39')];if(!_0x1b9ede[_0xa49b('0x36')][_0xa49b('0x3d')](_0xa49b('0x3e'))){_0x29af25[_0xa49b('0x25')]=qs[_0xa49b('0x25')](_0x1b9ede[_0xa49b('0x36')][_0xa49b('0x25')]);_0x29af25[_0xa49b('0x22')]=qs[_0xa49b('0x22')](_0x1b9ede[_0xa49b('0x36')][_0xa49b('0x22')]);}_0x29af25['order']=qs[_0xa49b('0x3f')](_0x1b9ede['query'][_0xa49b('0x3f')]);_0x29af25['where']=qs[_0xa49b('0x37')](_[_0xa49b('0x40')](_0x1b9ede[_0xa49b('0x36')],_0x3bb348[_0xa49b('0x37')]),_0x4384ce);if(_0x1b9ede[_0xa49b('0x36')][_0xa49b('0x41')]){_0x29af25[_0xa49b('0x42')]=_[_0xa49b('0x43')](_0x29af25['where'],{'$or':_[_0xa49b('0x32')](_0x4384ce,function(_0x47a17b){if(_0x47a17b['type']!==_0xa49b('0x44')){var _0x52181b={};_0x52181b[_0x47a17b[_0xa49b('0x2f')]]={'$like':'%'+_0x1b9ede[_0xa49b('0x36')][_0xa49b('0x41')]+'%'};return _0x52181b;}})});}_0x29af25=_['merge']({},_0x29af25,_0x1b9ede[_0xa49b('0x45')]);var _0x268f61={'where':_0x29af25[_0xa49b('0x42')]};return db[_0xa49b('0x46')][_0xa49b('0x24')](_0x268f61)['then'](function(_0x37eb9a){_0x28d876[_0xa49b('0x24')]=_0x37eb9a;if(_0x1b9ede['query'][_0xa49b('0x47')]){_0x29af25[_0xa49b('0x48')]=[{'all':!![]}];}return db[_0xa49b('0x46')]['findAll'](_0x29af25);})[_0xa49b('0x29')](function(_0x2c99af){_0x28d876[_0xa49b('0x49')]=_0x2c99af;return _0x28d876;})[_0xa49b('0x29')](respondWithFilteredResult(_0x82d723,_0x29af25))[_0xa49b('0x4a')](handleError(_0x82d723,null));};exports[_0xa49b('0x4b')]=function(_0x2f241b,_0x2906fc){var _0x272036={'raw':![],'where':{'id':_0x2f241b['params']['id']}},_0x5e071e={};_0x5e071e[_0xa49b('0x39')]=_[_0xa49b('0x4c')](db[_0xa49b('0x46')][_0xa49b('0x33')]);_0x5e071e[_0xa49b('0x36')]=_['keys'](_0x2f241b['query']);_0x5e071e['filters']=_['intersection'](_0x5e071e[_0xa49b('0x39')],_0x5e071e['query']);_0x272036[_0xa49b('0x3b')]=_['intersection'](_0x5e071e[_0xa49b('0x39')],qs[_0xa49b('0x3a')](_0x2f241b[_0xa49b('0x36')][_0xa49b('0x3a')]));_0x272036[_0xa49b('0x3b')]=_0x272036[_0xa49b('0x3b')][_0xa49b('0x3c')]?_0x272036[_0xa49b('0x3b')]:_0x5e071e[_0xa49b('0x39')];if(_0x2f241b[_0xa49b('0x36')][_0xa49b('0x47')]){_0x272036[_0xa49b('0x48')]=[{'all':!![]}];}_0x272036=_[_0xa49b('0x43')]({},_0x272036,_0x2f241b[_0xa49b('0x45')]);return db['Dashboard']['find'](_0x272036)[_0xa49b('0x29')](handleEntityNotFound(_0x2906fc,null))[_0xa49b('0x29')](respondWithResult(_0x2906fc,null))[_0xa49b('0x4a')](handleError(_0x2906fc,null));};exports[_0xa49b('0x4d')]=function(_0x4f6b82,_0x3bdc90){return db[_0xa49b('0x46')][_0xa49b('0x4d')](_0x4f6b82[_0xa49b('0x4e')],{})[_0xa49b('0x29')](function(_0x1fb3a6){var _0x8b3e46=_0x4f6b82['user'][_0xa49b('0x4f')]({'plain':!![]});if(!_0x8b3e46)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x8b3e46['role']===_0xa49b('0x50')){var _0x229b39=_0x1fb3a6[_0xa49b('0x4f')]({'plain':!![]});var _0x382e4f=_0xa49b('0x2b');return db['UserProfileSection'][_0xa49b('0x51')]({'where':{'name':_0x382e4f,'userProfileId':_0x8b3e46['userProfileId']},'raw':!![]})[_0xa49b('0x29')](function(_0x1be5d6){if(_0x1be5d6&&_0x1be5d6[_0xa49b('0x52')]===0x0){return db[_0xa49b('0x2c')][_0xa49b('0x4d')]({'name':_0x229b39['name'],'resourceId':_0x229b39['id'],'type':_0x1be5d6[_0xa49b('0x2f')],'sectionId':_0x1be5d6['id']},{})[_0xa49b('0x29')](function(){return _0x1fb3a6;});}else{return _0x1fb3a6;}})[_0xa49b('0x4a')](function(_0x6a9650){logger[_0xa49b('0x2d')](_0xa49b('0x53'),_0x6a9650);throw _0x6a9650;});}return _0x1fb3a6;})[_0xa49b('0x29')](respondWithResult(_0x3bdc90,0xc9))[_0xa49b('0x4a')](handleError(_0x3bdc90,null));};exports['clone']=function(_0x351eb3,_0x579e01){var _0x342c22={'where':{'id':_0x351eb3['params']['id']}},_0x3dd137={};_0x3dd137[_0xa49b('0x39')]=_[_0xa49b('0x4c')](db['Dashboard'][_0xa49b('0x33')]);_0x342c22[_0xa49b('0x3b')]=_['intersection'](_0x3dd137[_0xa49b('0x39')],qs[_0xa49b('0x3a')](_0x351eb3['query']['fields']));_0x342c22[_0xa49b('0x3b')]=_0x342c22[_0xa49b('0x3b')]['length']?_0x342c22['attributes']:_0x3dd137[_0xa49b('0x39')];if(_0x351eb3[_0xa49b('0x36')][_0xa49b('0x47')]){_0x342c22[_0xa49b('0x48')]=[{'all':!![]}];}_0x342c22=_[_0xa49b('0x43')]({},_0x342c22,_0x351eb3[_0xa49b('0x45')]);return db[_0xa49b('0x46')][_0xa49b('0x51')](_0x342c22)['then'](handleEntityNotFound(_0x579e01,null))[_0xa49b('0x29')](function(_0x4a2864){if(_0x4a2864){var _0x5b5fb9=_0x4a2864[_0xa49b('0x4f')]({'plain':!![]});_0x5b5fb9=qs['omit'](_0x5b5fb9,['id',_0xa49b('0x54'),_0xa49b('0x55')]);_0x351eb3[_0xa49b('0x4e')]=_[_0xa49b('0x56')](_0x351eb3['body'],['id',_0xa49b('0x54'),_0xa49b('0x55')]);return db[_0xa49b('0x46')]['create'](_[_0xa49b('0x43')](_0x5b5fb9,_0x351eb3[_0xa49b('0x4e')]),{'include':_0x351eb3[_0xa49b('0x36')][_0xa49b('0x47')]?[{'all':!![]}]:undefined})[_0xa49b('0x29')](function(_0x2da310){var _0x323c65=_0x351eb3['user']['get']({'plain':!![]});if(!_0x323c65)throw new Error(_0xa49b('0x57'));if(_0x323c65[_0xa49b('0x58')]==='user'){var _0xc8edb8=_0x2da310['get']({'plain':!![]});var _0x258a32=_0xa49b('0x2b');return db['UserProfileSection'][_0xa49b('0x51')]({'where':{'name':_0x258a32,'userProfileId':_0x323c65[_0xa49b('0x59')]},'raw':!![]})['then'](function(_0x12bb97){if(_0x12bb97&&_0x12bb97['autoAssociation']===0x0){return db[_0xa49b('0x2c')][_0xa49b('0x4d')]({'name':_0xc8edb8['name'],'resourceId':_0xc8edb8['id'],'type':_0x12bb97[_0xa49b('0x2f')],'sectionId':_0x12bb97['id']},{})[_0xa49b('0x29')](function(){return _0x2da310;});}else{return _0x2da310;}})[_0xa49b('0x4a')](function(_0x1c20ba){logger[_0xa49b('0x2d')](_0xa49b('0x53'),_0x1c20ba);throw _0x1c20ba;});}return _0x2da310;});}})[_0xa49b('0x29')](respondWithResult(_0x579e01,0xc9))['catch'](handleError(_0x579e01,null));};exports[_0xa49b('0x5a')]=function(_0x1aef23,_0x301724){if(_0x1aef23[_0xa49b('0x4e')]['id']){delete _0x1aef23['body']['id'];}return db[_0xa49b('0x46')][_0xa49b('0x51')]({'where':{'id':_0x1aef23[_0xa49b('0x5b')]['id']}})[_0xa49b('0x29')](handleEntityNotFound(_0x301724,null))[_0xa49b('0x29')](saveUpdates(_0x1aef23['body'],null))[_0xa49b('0x29')](respondWithResult(_0x301724,null))[_0xa49b('0x4a')](handleError(_0x301724,null));};exports[_0xa49b('0x2a')]=function(_0x282b02,_0x3f1a3c){return db[_0xa49b('0x46')][_0xa49b('0x51')]({'where':{'id':_0x282b02['params']['id']}})[_0xa49b('0x29')](handleEntityNotFound(_0x3f1a3c,null))[_0xa49b('0x29')](removeEntity(_0x3f1a3c,null))['catch'](handleError(_0x3f1a3c,null));};function widgetAttributes(_0x2cb4cc){try{switch(_0x2cb4cc[_0xa49b('0x35')]){case _0xa49b('0x5c'):return[{'name':_0xa49b('0x5d'),'value':_0x2cb4cc[_0xa49b('0x5d')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x0]?_0x2cb4cc[_0xa49b('0x5e')][0x0][_0xa49b('0x5f')]:undefined)||'https://'}];case _0xa49b('0x60'):return[{'name':_0xa49b('0x61'),'value':_0x2cb4cc[_0xa49b('0x61')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x0]?_0x2cb4cc[_0xa49b('0x5e')][0x0][_0xa49b('0x5f')]:undefined)||''}];case _0xa49b('0x62'):return[{'name':_0xa49b('0x63'),'value':_0x2cb4cc[_0xa49b('0x63')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x0]?_0x2cb4cc[_0xa49b('0x5e')][0x0][_0xa49b('0x5f')]:undefined)||_0xa49b('0x64')},{'name':'attrTimezone','value':_0x2cb4cc['attrTimezone']||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x1]?_0x2cb4cc[_0xa49b('0x5e')][0x1][_0xa49b('0x5f')]:undefined)||_0xa49b('0x65')},{'name':_0xa49b('0x66'),'value':_0x2cb4cc[_0xa49b('0x66')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x2]?_0x2cb4cc[_0xa49b('0x5e')][0x2][_0xa49b('0x5f')]:undefined)||0xc}];case _0xa49b('0x67'):return[{'name':_0xa49b('0x68'),'value':_0x2cb4cc[_0xa49b('0x68')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x0]?_0x2cb4cc[_0xa49b('0x5e')][0x0]['value']:undefined)||_0xa49b('0x69')},{'name':'attrVoiceQueues','value':_0x2cb4cc[_0xa49b('0x6a')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x1]?_0x2cb4cc['attrs'][0x1][_0xa49b('0x5f')]:undefined)||[]},{'name':_0xa49b('0x66'),'value':_0x2cb4cc['attrFontSize']||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x2]?_0x2cb4cc['attrs'][0x2][_0xa49b('0x5f')]:undefined)||0x14},{'name':'attrChannel','value':_0x2cb4cc['attrChannel']||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x3]?_0x2cb4cc[_0xa49b('0x5e')][0x3][_0xa49b('0x5f')]:undefined)||_0xa49b('0x6b')},{'name':_0xa49b('0x6c'),'value':_0x2cb4cc[_0xa49b('0x6c')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x4]?_0x2cb4cc[_0xa49b('0x5e')][0x4][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x6d'),'value':_0x2cb4cc[_0xa49b('0x6d')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x5]?_0x2cb4cc[_0xa49b('0x5e')][0x5][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x6e'),'value':_0x2cb4cc[_0xa49b('0x6e')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x6]?_0x2cb4cc[_0xa49b('0x5e')][0x6][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x6f'),'value':_0x2cb4cc[_0xa49b('0x6f')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x7]?_0x2cb4cc[_0xa49b('0x5e')][0x7][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x70'),'value':_0x2cb4cc['attrWhatsappAccounts']||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x8]?_0x2cb4cc['attrs'][0x8][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x71'),'value':_0x2cb4cc[_0xa49b('0x71')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x9]?_0x2cb4cc[_0xa49b('0x5e')][0x9][_0xa49b('0x5f')]:undefined)||''}];case _0xa49b('0x72'):case _0xa49b('0x73'):return[{'name':_0xa49b('0x74'),'value':_0x2cb4cc[_0xa49b('0x74')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x0]?_0x2cb4cc[_0xa49b('0x5e')][0x0][_0xa49b('0x5f')]:undefined)||_0xa49b('0x69')},{'name':_0xa49b('0x75'),'value':_0x2cb4cc[_0xa49b('0x75')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x1]?_0x2cb4cc[_0xa49b('0x5e')][0x1][_0xa49b('0x5f')]:undefined)||null},{'name':_0xa49b('0x76'),'value':_0x2cb4cc[_0xa49b('0x76')]||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x2]?_0x2cb4cc[_0xa49b('0x5e')][0x2]['value']:undefined)||null},{'name':'attrVoiceQueues','value':_0x2cb4cc['attrVoiceQueues']||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x3]?_0x2cb4cc[_0xa49b('0x5e')][0x3][_0xa49b('0x5f')]:undefined)||[]},{'name':_0xa49b('0x77'),'value':_0x2cb4cc[_0xa49b('0x77')]||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x4]?_0x2cb4cc['attrs'][0x4][_0xa49b('0x5f')]:undefined)||_0xa49b('0x6b')},{'name':_0xa49b('0x6c'),'value':_0x2cb4cc[_0xa49b('0x6c')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x5]?_0x2cb4cc[_0xa49b('0x5e')][0x5][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x6d'),'value':_0x2cb4cc['attrFaxAccounts']||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x6]?_0x2cb4cc[_0xa49b('0x5e')][0x6][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x6e'),'value':_0x2cb4cc[_0xa49b('0x6e')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x7]?_0x2cb4cc[_0xa49b('0x5e')][0x7][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x6f'),'value':_0x2cb4cc[_0xa49b('0x6f')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x8]?_0x2cb4cc['attrs'][0x8][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x70'),'value':_0x2cb4cc[_0xa49b('0x70')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x9]?_0x2cb4cc[_0xa49b('0x5e')][0x9][_0xa49b('0x5f')]:undefined)||''},{'name':_0xa49b('0x71'),'value':_0x2cb4cc[_0xa49b('0x71')]||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0xa]?_0x2cb4cc['attrs'][0xa][_0xa49b('0x5f')]:undefined)||''}];case'web-report':return[{'name':_0xa49b('0x78'),'type':_0x2cb4cc[_0xa49b('0x79')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc['attrs'][0x0]?_0x2cb4cc['attrs'][0x0]['type']:undefined)||null,'value':_0x2cb4cc[_0xa49b('0x78')]||(_0x2cb4cc['attrs']&&_0x2cb4cc[_0xa49b('0x5e')][0x0]?_0x2cb4cc[_0xa49b('0x5e')][0x0][_0xa49b('0x5f')]:undefined)||null},{'name':_0xa49b('0x7a'),'value':_0x2cb4cc[_0xa49b('0x7a')]||(_0x2cb4cc[_0xa49b('0x5e')]&&_0x2cb4cc[_0xa49b('0x5e')][0x1]?_0x2cb4cc[_0xa49b('0x5e')][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0x49062b){logger[_0xa49b('0x2d')](_0xa49b('0x7b'),JSON[_0xa49b('0x7c')](_0x49062b));return[];}}exports[_0xa49b('0x7d')]=function(_0x23c1d3,_0x19c164,_0x342871){if(_0x23c1d3[_0xa49b('0x4e')]['id']){delete _0x23c1d3['body']['id'];}return db['Dashboard'][_0xa49b('0x51')]({'where':{'id':_0x23c1d3[_0xa49b('0x5b')]['id']}})[_0xa49b('0x29')](handleEntityNotFound(_0x19c164,null))[_0xa49b('0x29')](function(_0x42db7b){if(_0x42db7b){_0x23c1d3['body']['DashboardId']=_0x42db7b['id'];_0x23c1d3[_0xa49b('0x4e')][_0xa49b('0x5e')]=widgetAttributes(_0x23c1d3['body']);return db['DashboardItem'][_0xa49b('0x4d')](_0x23c1d3['body']);}})[_0xa49b('0x29')](respondWithResult(_0x19c164,null))[_0xa49b('0x4a')](handleError(_0x19c164,null));};exports[_0xa49b('0x7e')]=function(_0x5a1e13,_0x2a05dc,_0x126018){var _0x416501={};var _0x5be320={};var _0x558564;var _0x525575;return db[_0xa49b('0x46')]['findOne']({'where':{'id':_0x5a1e13[_0xa49b('0x5b')]['id']}})[_0xa49b('0x29')](handleEntityNotFound(_0x2a05dc,null))[_0xa49b('0x29')](function(_0x4ea816){if(_0x4ea816){_0x558564=_0x4ea816;_0x5be320[_0xa49b('0x39')]=_[_0xa49b('0x4c')](db[_0xa49b('0x7f')][_0xa49b('0x33')]);_0x5be320[_0xa49b('0x36')]=_[_0xa49b('0x4c')](_0x5a1e13['query']);_0x5be320[_0xa49b('0x37')]=_[_0xa49b('0x38')](_0x5be320['model'],_0x5be320['query']);_0x416501[_0xa49b('0x3b')]=_[_0xa49b('0x38')](_0x5be320[_0xa49b('0x39')],qs[_0xa49b('0x3a')](_0x5a1e13[_0xa49b('0x36')][_0xa49b('0x3a')]));_0x416501[_0xa49b('0x3b')]=_0x416501[_0xa49b('0x3b')][_0xa49b('0x3c')]?_0x416501[_0xa49b('0x3b')]:_0x5be320[_0xa49b('0x39')];_0x416501[_0xa49b('0x80')]=qs[_0xa49b('0x3f')](_0x5a1e13['query'][_0xa49b('0x3f')]);_0x416501['where']=qs[_0xa49b('0x37')](_[_0xa49b('0x40')](_0x5a1e13[_0xa49b('0x36')],_0x5be320[_0xa49b('0x37')]));if(_0x5a1e13[_0xa49b('0x36')][_0xa49b('0x41')]){_0x416501[_0xa49b('0x42')]=_['merge'](_0x416501[_0xa49b('0x42')],{'$or':_[_0xa49b('0x32')](_0x416501[_0xa49b('0x3b')],function(_0x4422fe){var _0x1426c1={};_0x1426c1[_0x4422fe]={'$like':'%'+_0x5a1e13[_0xa49b('0x36')][_0xa49b('0x41')]+'%'};return _0x1426c1;})});}_0x416501=_[_0xa49b('0x43')]({},_0x416501,_0x5a1e13[_0xa49b('0x45')]);return _0x558564[_0xa49b('0x7e')](_0x416501);}})[_0xa49b('0x29')](function(_0x1bbe22){if(_0x1bbe22){_0x525575=_0x1bbe22[_0xa49b('0x3c')];if(!_0x5a1e13[_0xa49b('0x36')]['hasOwnProperty'](_0xa49b('0x3e'))){_0x416501[_0xa49b('0x25')]=qs[_0xa49b('0x25')](_0x5a1e13['query'][_0xa49b('0x25')]);_0x416501[_0xa49b('0x22')]=qs[_0xa49b('0x22')](_0x5a1e13[_0xa49b('0x36')][_0xa49b('0x22')]);}return _0x558564[_0xa49b('0x7e')](_0x416501);}})[_0xa49b('0x29')](function(_0x1d1feb){if(_0x1d1feb){return _0x1d1feb?{'count':_0x525575,'rows':_0x1d1feb}:null;}})[_0xa49b('0x29')](respondWithResult(_0x2a05dc,null))[_0xa49b('0x4a')](handleError(_0x2a05dc,null));};