Built motion from commit 377f727e.|2.6.28
[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 _0x097f=['attrSerie2','attrSerie3','web-report','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify','DashboardItem','getItems','findOne','pick','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','redis','socket.io-emitter','./dashboard.socket','sendStatus','status','json','undefined','limit','count','offset','set','Content-Range','reject','save','update','then','destroy','get','CustomDashboards','UserProfileResource','end','stack','name','send','index','map','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','type','VIRTUAL','options','Dashboard','includeAll','findAll','rows','show','params','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','rawAttributes','omit','createdAt','UserProfileSection','iframe','attrUrl','attrs','value','custom','attrPath','clock','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','counter','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1'];(function(_0x5e32ce,_0x53dace){var _0x2a6398=function(_0x104469){while(--_0x104469){_0x5e32ce['push'](_0x5e32ce['shift']());}};_0x2a6398(++_0x53dace);}(_0x097f,0x8c));var _0xf097=function(_0x529a0f,_0x328763){_0x529a0f=_0x529a0f-0x0;var _0x187a88=_0x097f[_0x529a0f];return _0x187a88;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf097('0x0'));var jsonpatch=require(_0xf097('0x1'));var rp=require(_0xf097('0x2'));var moment=require(_0xf097('0x3'));var BPromise=require(_0xf097('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf097('0x5'));var sox=require(_0xf097('0x6'));var csv=require(_0xf097('0x7'));var ejs=require(_0xf097('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf097('0x9'));var squel=require('squel');var crypto=require(_0xf097('0xa'));var jsforce=require(_0xf097('0xb'));var deskjs=require(_0xf097('0xc'));var toCsv=require(_0xf097('0x7'));var querystring=require(_0xf097('0xd'));var Papa=require(_0xf097('0xe'));var Redis=require(_0xf097('0xf'));var authService=require(_0xf097('0x10'));var qs=require(_0xf097('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf097('0x12'));var logger=require(_0xf097('0x13'))(_0xf097('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xf097('0x15'));var db=require(_0xf097('0x16'))['db'];config[_0xf097('0x17')]=_['defaults'](config[_0xf097('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0xf097('0x18'))(new Redis(config[_0xf097('0x17')]));require(_0xf097('0x19'))['register'](socket);function respondWithStatusCode(_0x483f59,_0x47de66){_0x47de66=_0x47de66||0xcc;return function(_0x267e3b){if(_0x267e3b){return _0x483f59[_0xf097('0x1a')](_0x47de66);}return _0x483f59[_0xf097('0x1b')](_0x47de66)['end']();};}function respondWithResult(_0x3de6a1,_0x37d9b3){_0x37d9b3=_0x37d9b3||0xc8;return function(_0xf34a05){if(_0xf34a05){return _0x3de6a1[_0xf097('0x1b')](_0x37d9b3)[_0xf097('0x1c')](_0xf34a05);}};}function respondWithFilteredResult(_0xdd5109,_0x34abd0){return function(_0x2aa5e2){if(_0x2aa5e2){var _0x1e24cc=typeof _0x34abd0['offset']===_0xf097('0x1d')&&typeof _0x34abd0[_0xf097('0x1e')]===_0xf097('0x1d');var _0x46ec72=_0x2aa5e2[_0xf097('0x1f')];var _0x303811=_0x1e24cc?0x0:_0x34abd0[_0xf097('0x20')];var _0x419003=_0x1e24cc?_0x2aa5e2[_0xf097('0x1f')]:_0x34abd0[_0xf097('0x20')]+_0x34abd0[_0xf097('0x1e')];var _0x37dd71;if(_0x419003>=_0x46ec72){_0x419003=_0x46ec72;_0x37dd71=0xc8;}else{_0x37dd71=0xce;}_0xdd5109[_0xf097('0x1b')](_0x37dd71);return _0xdd5109[_0xf097('0x21')](_0xf097('0x22'),_0x303811+'-'+_0x419003+'/'+_0x46ec72)[_0xf097('0x1c')](_0x2aa5e2);}return null;};}function patchUpdates(_0x3a3ec5){return function(_0x31b621){try{jsonpatch['apply'](_0x31b621,_0x3a3ec5,!![]);}catch(_0x1509fb){return BPromise[_0xf097('0x23')](_0x1509fb);}return _0x31b621[_0xf097('0x24')]();};}function saveUpdates(_0x13efe9,_0x271526){return function(_0x4d234a){if(_0x4d234a){return _0x4d234a[_0xf097('0x25')](_0x13efe9)[_0xf097('0x26')](function(_0x1e608c){return _0x1e608c;});}return null;};}function removeEntity(_0x41ba9e,_0x5ef9a4){return function(_0x56f84c){if(_0x56f84c){return _0x56f84c[_0xf097('0x27')]()[_0xf097('0x26')](function(){var _0x9f80b7=_0x56f84c[_0xf097('0x28')]({'plain':!![]});var _0xce8f42=_0xf097('0x29');return db[_0xf097('0x2a')]['destroy']({'where':{'type':_0xce8f42,'resourceId':_0x9f80b7['id']}})[_0xf097('0x26')](function(){return _0x56f84c;});})[_0xf097('0x26')](function(){_0x41ba9e[_0xf097('0x1b')](0xcc)[_0xf097('0x2b')]();});}};}function handleEntityNotFound(_0x4ca677,_0x4f3adf){return function(_0x4c3ae9){if(!_0x4c3ae9){_0x4ca677['sendStatus'](0x194);}return _0x4c3ae9;};}function handleError(_0x525a2d,_0x919960){_0x919960=_0x919960||0x1f4;return function(_0x3af0c6){logger['error'](_0x3af0c6[_0xf097('0x2c')]);if(_0x3af0c6['name']){delete _0x3af0c6[_0xf097('0x2d')];}_0x525a2d[_0xf097('0x1b')](_0x919960)[_0xf097('0x2e')](_0x3af0c6);};}exports[_0xf097('0x2f')]=function(_0x5c466f,_0x12e6d4){var _0x2faac6={},_0x2ea780={},_0x4cbb46={'count':0x0,'rows':[]};var _0x3c3d9a=_[_0xf097('0x30')](db['Dashboard']['rawAttributes'],function(_0x5bdc36){return{'name':_0x5bdc36['fieldName'],'type':_0x5bdc36['type'][_0xf097('0x31')]};});_0x2ea780[_0xf097('0x32')]=_[_0xf097('0x30')](_0x3c3d9a,_0xf097('0x2d'));_0x2ea780[_0xf097('0x33')]=_[_0xf097('0x34')](_0x5c466f['query']);_0x2ea780['filters']=_[_0xf097('0x35')](_0x2ea780[_0xf097('0x32')],_0x2ea780[_0xf097('0x33')]);_0x2faac6[_0xf097('0x36')]=_[_0xf097('0x35')](_0x2ea780[_0xf097('0x32')],qs[_0xf097('0x37')](_0x5c466f[_0xf097('0x33')][_0xf097('0x37')]));_0x2faac6['attributes']=_0x2faac6[_0xf097('0x36')][_0xf097('0x38')]?_0x2faac6[_0xf097('0x36')]:_0x2ea780[_0xf097('0x32')];if(!_0x5c466f[_0xf097('0x33')][_0xf097('0x39')](_0xf097('0x3a'))){_0x2faac6[_0xf097('0x1e')]=qs[_0xf097('0x1e')](_0x5c466f['query'][_0xf097('0x1e')]);_0x2faac6[_0xf097('0x20')]=qs['offset'](_0x5c466f[_0xf097('0x33')][_0xf097('0x20')]);}_0x2faac6[_0xf097('0x3b')]=qs[_0xf097('0x3c')](_0x5c466f[_0xf097('0x33')][_0xf097('0x3c')]);_0x2faac6[_0xf097('0x3d')]=qs[_0xf097('0x3e')](_['pick'](_0x5c466f[_0xf097('0x33')],_0x2ea780['filters']),_0x3c3d9a);if(_0x5c466f[_0xf097('0x33')][_0xf097('0x3f')]){_0x2faac6['where']=_[_0xf097('0x40')](_0x2faac6[_0xf097('0x3d')],{'$or':_[_0xf097('0x30')](_0x3c3d9a,function(_0x17867d){if(_0x17867d[_0xf097('0x41')]!==_0xf097('0x42')){var _0x22b2ed={};_0x22b2ed[_0x17867d[_0xf097('0x2d')]]={'$like':'%'+_0x5c466f[_0xf097('0x33')]['filter']+'%'};return _0x22b2ed;}})});}_0x2faac6=_[_0xf097('0x40')]({},_0x2faac6,_0x5c466f[_0xf097('0x43')]);var _0x3e1508={'where':_0x2faac6[_0xf097('0x3d')]};return db[_0xf097('0x44')][_0xf097('0x1f')](_0x3e1508)[_0xf097('0x26')](function(_0x193268){_0x4cbb46[_0xf097('0x1f')]=_0x193268;if(_0x5c466f[_0xf097('0x33')][_0xf097('0x45')]){_0x2faac6['include']=[{'all':!![]}];}return db[_0xf097('0x44')][_0xf097('0x46')](_0x2faac6);})['then'](function(_0x4f14ae){_0x4cbb46[_0xf097('0x47')]=_0x4f14ae;return _0x4cbb46;})['then'](respondWithFilteredResult(_0x12e6d4,_0x2faac6))['catch'](handleError(_0x12e6d4,null));};exports[_0xf097('0x48')]=function(_0x116fdb,_0x59648f){var _0x47d2f8={'raw':![],'where':{'id':_0x116fdb[_0xf097('0x49')]['id']}},_0x397b76={};_0x397b76[_0xf097('0x32')]=_[_0xf097('0x34')](db[_0xf097('0x44')]['rawAttributes']);_0x397b76[_0xf097('0x33')]=_['keys'](_0x116fdb[_0xf097('0x33')]);_0x397b76[_0xf097('0x3e')]=_[_0xf097('0x35')](_0x397b76[_0xf097('0x32')],_0x397b76['query']);_0x47d2f8[_0xf097('0x36')]=_[_0xf097('0x35')](_0x397b76[_0xf097('0x32')],qs[_0xf097('0x37')](_0x116fdb[_0xf097('0x33')][_0xf097('0x37')]));_0x47d2f8[_0xf097('0x36')]=_0x47d2f8['attributes'][_0xf097('0x38')]?_0x47d2f8['attributes']:_0x397b76[_0xf097('0x32')];if(_0x116fdb[_0xf097('0x33')]['includeAll']){_0x47d2f8['include']=[{'all':!![]}];}_0x47d2f8=_[_0xf097('0x40')]({},_0x47d2f8,_0x116fdb['options']);return db[_0xf097('0x44')][_0xf097('0x4a')](_0x47d2f8)[_0xf097('0x26')](handleEntityNotFound(_0x59648f,null))[_0xf097('0x26')](respondWithResult(_0x59648f,null))[_0xf097('0x4b')](handleError(_0x59648f,null));};exports['create']=function(_0x394eb5,_0x37b2ce){return db[_0xf097('0x44')][_0xf097('0x4c')](_0x394eb5[_0xf097('0x4d')],{})[_0xf097('0x26')](function(_0x3bc968){var _0x4e18e0=_0x394eb5[_0xf097('0x4e')][_0xf097('0x28')]({'plain':!![]});if(!_0x4e18e0)throw new Error(_0xf097('0x4f'));if(_0x4e18e0[_0xf097('0x50')]===_0xf097('0x4e')){var _0xe42c45=_0x3bc968['get']({'plain':!![]});var _0x5e7195=_0xf097('0x29');return db['UserProfileSection']['find']({'where':{'name':_0x5e7195,'userProfileId':_0x4e18e0[_0xf097('0x51')]},'raw':!![]})['then'](function(_0x337f41){if(_0x337f41&&_0x337f41[_0xf097('0x52')]===0x0){return db[_0xf097('0x2a')][_0xf097('0x4c')]({'name':_0xe42c45[_0xf097('0x2d')],'resourceId':_0xe42c45['id'],'type':_0x337f41[_0xf097('0x2d')],'sectionId':_0x337f41['id']},{})[_0xf097('0x26')](function(){return _0x3bc968;});}else{return _0x3bc968;}})[_0xf097('0x4b')](function(_0x4da2c7){logger[_0xf097('0x53')](_0xf097('0x54'),_0x4da2c7);throw _0x4da2c7;});}return _0x3bc968;})[_0xf097('0x26')](respondWithResult(_0x37b2ce,0xc9))[_0xf097('0x4b')](handleError(_0x37b2ce,null));};exports[_0xf097('0x55')]=function(_0x50aed1,_0x55b7a8){var _0x45b800={'where':{'id':_0x50aed1['params']['id']}},_0x3abc89={};_0x3abc89['model']=_[_0xf097('0x34')](db['Dashboard'][_0xf097('0x56')]);_0x45b800[_0xf097('0x36')]=_[_0xf097('0x35')](_0x3abc89['model'],qs[_0xf097('0x37')](_0x50aed1[_0xf097('0x33')]['fields']));_0x45b800['attributes']=_0x45b800[_0xf097('0x36')][_0xf097('0x38')]?_0x45b800[_0xf097('0x36')]:_0x3abc89[_0xf097('0x32')];if(_0x50aed1[_0xf097('0x33')][_0xf097('0x45')]){_0x45b800['include']=[{'all':!![]}];}_0x45b800=_[_0xf097('0x40')]({},_0x45b800,_0x50aed1[_0xf097('0x43')]);return db[_0xf097('0x44')]['find'](_0x45b800)[_0xf097('0x26')](handleEntityNotFound(_0x55b7a8,null))[_0xf097('0x26')](function(_0x3e4f16){if(_0x3e4f16){var _0x4e54ed=_0x3e4f16[_0xf097('0x28')]({'plain':!![]});_0x4e54ed=qs[_0xf097('0x57')](_0x4e54ed,['id',_0xf097('0x58'),'updatedAt']);_0x50aed1[_0xf097('0x4d')]=_['omit'](_0x50aed1[_0xf097('0x4d')],['id','createdAt','updatedAt']);return db[_0xf097('0x44')][_0xf097('0x4c')](_[_0xf097('0x40')](_0x4e54ed,_0x50aed1['body']),{'include':_0x50aed1['query'][_0xf097('0x45')]?[{'all':!![]}]:undefined})['then'](function(_0x15c286){var _0x49071=_0x50aed1[_0xf097('0x4e')][_0xf097('0x28')]({'plain':!![]});if(!_0x49071)throw new Error(_0xf097('0x4f'));if(_0x49071[_0xf097('0x50')]===_0xf097('0x4e')){var _0x263f28=_0x15c286[_0xf097('0x28')]({'plain':!![]});var _0x3de6ee=_0xf097('0x29');return db[_0xf097('0x59')][_0xf097('0x4a')]({'where':{'name':_0x3de6ee,'userProfileId':_0x49071[_0xf097('0x51')]},'raw':!![]})[_0xf097('0x26')](function(_0x4ca052){if(_0x4ca052&&_0x4ca052[_0xf097('0x52')]===0x0){return db[_0xf097('0x2a')][_0xf097('0x4c')]({'name':_0x263f28[_0xf097('0x2d')],'resourceId':_0x263f28['id'],'type':_0x4ca052[_0xf097('0x2d')],'sectionId':_0x4ca052['id']},{})[_0xf097('0x26')](function(){return _0x15c286;});}else{return _0x15c286;}})[_0xf097('0x4b')](function(_0x2042cc){logger[_0xf097('0x53')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2042cc);throw _0x2042cc;});}return _0x15c286;});}})[_0xf097('0x26')](respondWithResult(_0x55b7a8,0xc9))[_0xf097('0x4b')](handleError(_0x55b7a8,null));};exports['update']=function(_0x28d53,_0x49e9fe){if(_0x28d53[_0xf097('0x4d')]['id']){delete _0x28d53[_0xf097('0x4d')]['id'];}return db[_0xf097('0x44')][_0xf097('0x4a')]({'where':{'id':_0x28d53['params']['id']}})[_0xf097('0x26')](handleEntityNotFound(_0x49e9fe,null))['then'](saveUpdates(_0x28d53['body'],null))[_0xf097('0x26')](respondWithResult(_0x49e9fe,null))[_0xf097('0x4b')](handleError(_0x49e9fe,null));};exports[_0xf097('0x27')]=function(_0x5a75af,_0x3ec6a8){return db[_0xf097('0x44')]['find']({'where':{'id':_0x5a75af[_0xf097('0x49')]['id']}})[_0xf097('0x26')](handleEntityNotFound(_0x3ec6a8,null))[_0xf097('0x26')](removeEntity(_0x3ec6a8,null))[_0xf097('0x4b')](handleError(_0x3ec6a8,null));};function widgetAttributes(_0x4c80ae){try{switch(_0x4c80ae[_0xf097('0x41')]){case _0xf097('0x5a'):return[{'name':'attrUrl','value':_0x4c80ae[_0xf097('0x5b')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x5d')]:undefined)||'https://'}];case _0xf097('0x5e'):return[{'name':_0xf097('0x5f'),'value':_0x4c80ae[_0xf097('0x5f')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x5d')]:undefined)||''}];case _0xf097('0x60'):return[{'name':_0xf097('0x61'),'value':_0x4c80ae[_0xf097('0x61')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x5d')]:undefined)||_0xf097('0x62')},{'name':_0xf097('0x63'),'value':_0x4c80ae[_0xf097('0x63')]||(_0x4c80ae['attrs']&&_0x4c80ae[_0xf097('0x5c')][0x1]?_0x4c80ae['attrs'][0x1]['value']:undefined)||_0xf097('0x64')},{'name':_0xf097('0x65'),'value':_0x4c80ae[_0xf097('0x65')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x2]?_0x4c80ae[_0xf097('0x5c')][0x2][_0xf097('0x5d')]:undefined)||0xc}];case _0xf097('0x66'):return[{'name':'attrMetric','value':_0x4c80ae['attrMetric']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x5d')]:undefined)||_0xf097('0x67')},{'name':_0xf097('0x68'),'value':_0x4c80ae['attrVoiceQueues']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x1]?_0x4c80ae[_0xf097('0x5c')][0x1][_0xf097('0x5d')]:undefined)||[]},{'name':_0xf097('0x65'),'value':_0x4c80ae[_0xf097('0x65')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x2]?_0x4c80ae['attrs'][0x2]['value']:undefined)||0x14},{'name':_0xf097('0x69'),'value':_0x4c80ae[_0xf097('0x69')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x3]?_0x4c80ae[_0xf097('0x5c')][0x3][_0xf097('0x5d')]:undefined)||_0xf097('0x6a')},{'name':_0xf097('0x6b'),'value':_0x4c80ae['attrEmailAccounts']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x4]?_0x4c80ae[_0xf097('0x5c')][0x4][_0xf097('0x5d')]:undefined)||''},{'name':_0xf097('0x6c'),'value':_0x4c80ae['attrFaxAccounts']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x5]?_0x4c80ae[_0xf097('0x5c')][0x5][_0xf097('0x5d')]:undefined)||''},{'name':_0xf097('0x6d'),'value':_0x4c80ae[_0xf097('0x6d')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x6]?_0x4c80ae[_0xf097('0x5c')][0x6][_0xf097('0x5d')]:undefined)||''},{'name':'attrOpenchannelAccounts','value':_0x4c80ae[_0xf097('0x6e')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x7]?_0x4c80ae['attrs'][0x7][_0xf097('0x5d')]:undefined)||''},{'name':'attrWhatsappAccounts','value':_0x4c80ae[_0xf097('0x6f')]||(_0x4c80ae['attrs']&&_0x4c80ae[_0xf097('0x5c')][0x8]?_0x4c80ae['attrs'][0x8]['value']:undefined)||''},{'name':_0xf097('0x70'),'value':_0x4c80ae[_0xf097('0x70')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x9]?_0x4c80ae[_0xf097('0x5c')][0x9]['value']:undefined)||''}];case _0xf097('0x71'):case _0xf097('0x72'):return[{'name':_0xf097('0x73'),'value':_0x4c80ae[_0xf097('0x73')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x5d')]:undefined)||_0xf097('0x67')},{'name':_0xf097('0x74'),'value':_0x4c80ae[_0xf097('0x74')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x1]?_0x4c80ae[_0xf097('0x5c')][0x1]['value']:undefined)||null},{'name':_0xf097('0x75'),'value':_0x4c80ae['attrSerie3']||(_0x4c80ae['attrs']&&_0x4c80ae[_0xf097('0x5c')][0x2]?_0x4c80ae[_0xf097('0x5c')][0x2][_0xf097('0x5d')]:undefined)||null},{'name':'attrVoiceQueues','value':_0x4c80ae['attrVoiceQueues']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x3]?_0x4c80ae[_0xf097('0x5c')][0x3][_0xf097('0x5d')]:undefined)||[]},{'name':'attrChannel','value':_0x4c80ae[_0xf097('0x69')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x4]?_0x4c80ae['attrs'][0x4][_0xf097('0x5d')]:undefined)||_0xf097('0x6a')},{'name':_0xf097('0x6b'),'value':_0x4c80ae['attrEmailAccounts']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x5]?_0x4c80ae[_0xf097('0x5c')][0x5][_0xf097('0x5d')]:undefined)||''},{'name':'attrFaxAccounts','value':_0x4c80ae['attrFaxAccounts']||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x6]?_0x4c80ae['attrs'][0x6][_0xf097('0x5d')]:undefined)||''},{'name':_0xf097('0x6d'),'value':_0x4c80ae[_0xf097('0x6d')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae['attrs'][0x7]?_0x4c80ae[_0xf097('0x5c')][0x7][_0xf097('0x5d')]:undefined)||''},{'name':_0xf097('0x6e'),'value':_0x4c80ae[_0xf097('0x6e')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x8]?_0x4c80ae[_0xf097('0x5c')][0x8][_0xf097('0x5d')]:undefined)||''},{'name':'attrWhatsappAccounts','value':_0x4c80ae[_0xf097('0x6f')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x9]?_0x4c80ae['attrs'][0x9]['value']:undefined)||''},{'name':_0xf097('0x70'),'value':_0x4c80ae[_0xf097('0x70')]||(_0x4c80ae['attrs']&&_0x4c80ae[_0xf097('0x5c')][0xa]?_0x4c80ae[_0xf097('0x5c')][0xa][_0xf097('0x5d')]:undefined)||''}];case _0xf097('0x76'):return[{'name':_0xf097('0x77'),'type':_0x4c80ae[_0xf097('0x78')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x41')]:undefined)||null,'value':_0x4c80ae[_0xf097('0x77')]||(_0x4c80ae['attrs']&&_0x4c80ae[_0xf097('0x5c')][0x0]?_0x4c80ae[_0xf097('0x5c')][0x0][_0xf097('0x5d')]:undefined)||null},{'name':_0xf097('0x79'),'value':_0x4c80ae[_0xf097('0x79')]||(_0x4c80ae[_0xf097('0x5c')]&&_0x4c80ae[_0xf097('0x5c')][0x1]?_0x4c80ae['attrs'][0x1][_0xf097('0x5d')]:undefined)||0x0}];default:return[];}}catch(_0x5d0a34){logger['error'](_0xf097('0x7a'),JSON[_0xf097('0x7b')](_0x5d0a34));return[];}}exports['addItem']=function(_0x5ef72e,_0x163e23,_0x12a1fe){if(_0x5ef72e[_0xf097('0x4d')]['id']){delete _0x5ef72e['body']['id'];}return db['Dashboard'][_0xf097('0x4a')]({'where':{'id':_0x5ef72e['params']['id']}})['then'](handleEntityNotFound(_0x163e23,null))[_0xf097('0x26')](function(_0x1d091e){if(_0x1d091e){_0x5ef72e[_0xf097('0x4d')]['DashboardId']=_0x1d091e['id'];_0x5ef72e[_0xf097('0x4d')][_0xf097('0x5c')]=widgetAttributes(_0x5ef72e[_0xf097('0x4d')]);return db[_0xf097('0x7c')][_0xf097('0x4c')](_0x5ef72e[_0xf097('0x4d')]);}})['then'](respondWithResult(_0x163e23,null))[_0xf097('0x4b')](handleError(_0x163e23,null));};exports[_0xf097('0x7d')]=function(_0x6a20fa,_0x3ed77b,_0x17a9ad){var _0x188355={};var _0x314017={};var _0x1a7ff5;var _0x21e9cb;return db['Dashboard'][_0xf097('0x7e')]({'where':{'id':_0x6a20fa[_0xf097('0x49')]['id']}})[_0xf097('0x26')](handleEntityNotFound(_0x3ed77b,null))[_0xf097('0x26')](function(_0x35edb3){if(_0x35edb3){_0x1a7ff5=_0x35edb3;_0x314017[_0xf097('0x32')]=_[_0xf097('0x34')](db['DashboardItem']['rawAttributes']);_0x314017['query']=_['keys'](_0x6a20fa['query']);_0x314017[_0xf097('0x3e')]=_[_0xf097('0x35')](_0x314017['model'],_0x314017['query']);_0x188355[_0xf097('0x36')]=_[_0xf097('0x35')](_0x314017[_0xf097('0x32')],qs[_0xf097('0x37')](_0x6a20fa['query'][_0xf097('0x37')]));_0x188355[_0xf097('0x36')]=_0x188355[_0xf097('0x36')]['length']?_0x188355['attributes']:_0x314017[_0xf097('0x32')];_0x188355['order']=qs[_0xf097('0x3c')](_0x6a20fa[_0xf097('0x33')][_0xf097('0x3c')]);_0x188355['where']=qs[_0xf097('0x3e')](_[_0xf097('0x7f')](_0x6a20fa[_0xf097('0x33')],_0x314017[_0xf097('0x3e')]));if(_0x6a20fa[_0xf097('0x33')][_0xf097('0x3f')]){_0x188355[_0xf097('0x3d')]=_[_0xf097('0x40')](_0x188355['where'],{'$or':_['map'](_0x188355['attributes'],function(_0x426732){var _0x23beb1={};_0x23beb1[_0x426732]={'$like':'%'+_0x6a20fa[_0xf097('0x33')]['filter']+'%'};return _0x23beb1;})});}_0x188355=_[_0xf097('0x40')]({},_0x188355,_0x6a20fa[_0xf097('0x43')]);return _0x1a7ff5['getItems'](_0x188355);}})['then'](function(_0x355f54){if(_0x355f54){_0x21e9cb=_0x355f54['length'];if(!_0x6a20fa[_0xf097('0x33')][_0xf097('0x39')]('nolimit')){_0x188355[_0xf097('0x1e')]=qs[_0xf097('0x1e')](_0x6a20fa[_0xf097('0x33')][_0xf097('0x1e')]);_0x188355['offset']=qs['offset'](_0x6a20fa['query']['offset']);}return _0x1a7ff5[_0xf097('0x7d')](_0x188355);}})[_0xf097('0x26')](function(_0x3eb4d2){if(_0x3eb4d2){return _0x3eb4d2?{'count':_0x21e9cb,'rows':_0x3eb4d2}:null;}})[_0xf097('0x26')](respondWithResult(_0x3ed77b,null))[_0xf097('0x4b')](handleError(_0x3ed77b,null));};