Built motion from commit e0fa946e.|2.6.5
[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 _0x58ae=['voice','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','attrVoiceQueues','attrEmailAccounts','web-report','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardItem','getItems','findOne','hasOwnProperty','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./dashboard.socket','register','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','save','then','get','CustomDashboards','destroy','error','stack','name','send','index','map','Dashboard','fieldName','key','model','query','keys','intersection','attributes','fields','length','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','options','includeAll','include','rows','catch','params','rawAttributes','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','UserProfileSection','update','iframe','attrs','value','https://','attrPath','clock','attrHourFormat','HH:mm:ss','0.00','attrFontSize','counter','attrMetric','total','attrChannel'];(function(_0x255a27,_0x217a93){var _0x2f4eac=function(_0x58238f){while(--_0x58238f){_0x255a27['push'](_0x255a27['shift']());}};_0x2f4eac(++_0x217a93);}(_0x58ae,0x1a4));var _0xe58a=function(_0x578275,_0xe7ae46){_0x578275=_0x578275-0x0;var _0xf78041=_0x58ae[_0x578275];return _0xf78041;};'use strict';var emlformat=require(_0xe58a('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe58a('0x1'));var jsonpatch=require(_0xe58a('0x2'));var rp=require(_0xe58a('0x3'));var moment=require(_0xe58a('0x4'));var BPromise=require(_0xe58a('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xe58a('0x6'));var sox=require(_0xe58a('0x7'));var csv=require(_0xe58a('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xe58a('0x9'));var _=require(_0xe58a('0xa'));var squel=require(_0xe58a('0xb'));var crypto=require(_0xe58a('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xe58a('0xd'));var toCsv=require(_0xe58a('0x8'));var querystring=require(_0xe58a('0xe'));var Papa=require(_0xe58a('0xf'));var Redis=require('ioredis');var authService=require(_0xe58a('0x10'));var qs=require(_0xe58a('0x11'));var as=require(_0xe58a('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xe58a('0x13'));var utils=require(_0xe58a('0x14'));var config=require(_0xe58a('0x15'));var licenseUtil=require(_0xe58a('0x16'));var db=require(_0xe58a('0x17'))['db'];config[_0xe58a('0x18')]=_[_0xe58a('0x19')](config[_0xe58a('0x18')],{'host':_0xe58a('0x1a'),'port':0x18eb});var socket=require(_0xe58a('0x1b'))(new Redis(config['redis']));require(_0xe58a('0x1c'))[_0xe58a('0x1d')](socket);function respondWithStatusCode(_0x5ca6fd,_0x237ed7){_0x237ed7=_0x237ed7||0xcc;return function(_0x56a2b2){if(_0x56a2b2){return _0x5ca6fd[_0xe58a('0x1e')](_0x237ed7);}return _0x5ca6fd[_0xe58a('0x1f')](_0x237ed7)[_0xe58a('0x20')]();};}function respondWithResult(_0x3f854f,_0x370c50){_0x370c50=_0x370c50||0xc8;return function(_0x4f8296){if(_0x4f8296){return _0x3f854f[_0xe58a('0x1f')](_0x370c50)[_0xe58a('0x21')](_0x4f8296);}};}function respondWithFilteredResult(_0x23f185,_0xc864d4){return function(_0x364b71){if(_0x364b71){var _0x557819=typeof _0xc864d4[_0xe58a('0x22')]==='undefined'&&typeof _0xc864d4[_0xe58a('0x23')]===_0xe58a('0x24');var _0x27b547=_0x364b71[_0xe58a('0x25')];var _0x5644d3=_0x557819?0x0:_0xc864d4[_0xe58a('0x22')];var _0x2d0aea=_0x557819?_0x364b71[_0xe58a('0x25')]:_0xc864d4[_0xe58a('0x22')]+_0xc864d4[_0xe58a('0x23')];var _0x37d58a;if(_0x2d0aea>=_0x27b547){_0x2d0aea=_0x27b547;_0x37d58a=0xc8;}else{_0x37d58a=0xce;}_0x23f185[_0xe58a('0x1f')](_0x37d58a);return _0x23f185[_0xe58a('0x26')](_0xe58a('0x27'),_0x5644d3+'-'+_0x2d0aea+'/'+_0x27b547)[_0xe58a('0x21')](_0x364b71);}return null;};}function patchUpdates(_0x1482aa){return function(_0x528a1a){try{jsonpatch[_0xe58a('0x28')](_0x528a1a,_0x1482aa,!![]);}catch(_0x5e7f55){return BPromise['reject'](_0x5e7f55);}return _0x528a1a[_0xe58a('0x29')]();};}function saveUpdates(_0x207f7c,_0x1d9a0f){return function(_0x1ff29a){if(_0x1ff29a){return _0x1ff29a['update'](_0x207f7c)['then'](function(_0x5cbff3){return _0x5cbff3;});}return null;};}function removeEntity(_0x592cdc,_0x3e8714){return function(_0x8268f8){if(_0x8268f8){return _0x8268f8['destroy']()[_0xe58a('0x2a')](function(){var _0x128b67=_0x8268f8[_0xe58a('0x2b')]({'plain':!![]});var _0x1764d6=_0xe58a('0x2c');return db['UserProfileResource'][_0xe58a('0x2d')]({'where':{'type':_0x1764d6,'resourceId':_0x128b67['id']}})['then'](function(){return _0x8268f8;});})[_0xe58a('0x2a')](function(){_0x592cdc[_0xe58a('0x1f')](0xcc)[_0xe58a('0x20')]();});}};}function handleEntityNotFound(_0x1bf28b,_0xacde92){return function(_0x3adddc){if(!_0x3adddc){_0x1bf28b[_0xe58a('0x1e')](0x194);}return _0x3adddc;};}function handleError(_0x4b9ac5,_0x2ac035){_0x2ac035=_0x2ac035||0x1f4;return function(_0x5f0a60){logger[_0xe58a('0x2e')](_0x5f0a60[_0xe58a('0x2f')]);if(_0x5f0a60[_0xe58a('0x30')]){delete _0x5f0a60[_0xe58a('0x30')];}_0x4b9ac5['status'](_0x2ac035)[_0xe58a('0x31')](_0x5f0a60);};}exports[_0xe58a('0x32')]=function(_0x55f73e,_0x5ec12b){var _0x594b1e={},_0x30812e={},_0x4badcb={'count':0x0,'rows':[]};var _0x3543b4=_[_0xe58a('0x33')](db[_0xe58a('0x34')]['rawAttributes'],function(_0x11fbed){return{'name':_0x11fbed[_0xe58a('0x35')],'type':_0x11fbed['type'][_0xe58a('0x36')]};});_0x30812e[_0xe58a('0x37')]=_['map'](_0x3543b4,_0xe58a('0x30'));_0x30812e[_0xe58a('0x38')]=_[_0xe58a('0x39')](_0x55f73e[_0xe58a('0x38')]);_0x30812e['filters']=_[_0xe58a('0x3a')](_0x30812e[_0xe58a('0x37')],_0x30812e['query']);_0x594b1e[_0xe58a('0x3b')]=_[_0xe58a('0x3a')](_0x30812e[_0xe58a('0x37')],qs[_0xe58a('0x3c')](_0x55f73e[_0xe58a('0x38')][_0xe58a('0x3c')]));_0x594b1e[_0xe58a('0x3b')]=_0x594b1e[_0xe58a('0x3b')][_0xe58a('0x3d')]?_0x594b1e[_0xe58a('0x3b')]:_0x30812e['model'];if(!_0x55f73e[_0xe58a('0x38')]['hasOwnProperty']('nolimit')){_0x594b1e['limit']=qs[_0xe58a('0x23')](_0x55f73e['query'][_0xe58a('0x23')]);_0x594b1e[_0xe58a('0x22')]=qs[_0xe58a('0x22')](_0x55f73e[_0xe58a('0x38')][_0xe58a('0x22')]);}_0x594b1e[_0xe58a('0x3e')]=qs[_0xe58a('0x3f')](_0x55f73e[_0xe58a('0x38')][_0xe58a('0x3f')]);_0x594b1e[_0xe58a('0x40')]=qs[_0xe58a('0x41')](_[_0xe58a('0x42')](_0x55f73e[_0xe58a('0x38')],_0x30812e[_0xe58a('0x41')]),_0x3543b4);if(_0x55f73e[_0xe58a('0x38')][_0xe58a('0x43')]){_0x594b1e[_0xe58a('0x40')]=_[_0xe58a('0x44')](_0x594b1e['where'],{'$or':_['map'](_0x3543b4,function(_0x32027f){if(_0x32027f[_0xe58a('0x45')]!==_0xe58a('0x46')){var _0x2c1658={};_0x2c1658[_0x32027f[_0xe58a('0x30')]]={'$like':'%'+_0x55f73e[_0xe58a('0x38')]['filter']+'%'};return _0x2c1658;}})});}_0x594b1e=_['merge']({},_0x594b1e,_0x55f73e[_0xe58a('0x47')]);var _0x18ae3d={'where':_0x594b1e['where']};return db['Dashboard'][_0xe58a('0x25')](_0x18ae3d)[_0xe58a('0x2a')](function(_0x32b0db){_0x4badcb[_0xe58a('0x25')]=_0x32b0db;if(_0x55f73e[_0xe58a('0x38')][_0xe58a('0x48')]){_0x594b1e[_0xe58a('0x49')]=[{'all':!![]}];}return db['Dashboard']['findAll'](_0x594b1e);})['then'](function(_0xa49c18){_0x4badcb[_0xe58a('0x4a')]=_0xa49c18;return _0x4badcb;})[_0xe58a('0x2a')](respondWithFilteredResult(_0x5ec12b,_0x594b1e))[_0xe58a('0x4b')](handleError(_0x5ec12b,null));};exports['show']=function(_0x571854,_0x3bc3ea){var _0x700ff1={'raw':![],'where':{'id':_0x571854[_0xe58a('0x4c')]['id']}},_0x27bff2={};_0x27bff2['model']=_['keys'](db[_0xe58a('0x34')][_0xe58a('0x4d')]);_0x27bff2[_0xe58a('0x38')]=_[_0xe58a('0x39')](_0x571854[_0xe58a('0x38')]);_0x27bff2['filters']=_[_0xe58a('0x3a')](_0x27bff2[_0xe58a('0x37')],_0x27bff2['query']);_0x700ff1[_0xe58a('0x3b')]=_[_0xe58a('0x3a')](_0x27bff2[_0xe58a('0x37')],qs[_0xe58a('0x3c')](_0x571854[_0xe58a('0x38')][_0xe58a('0x3c')]));_0x700ff1[_0xe58a('0x3b')]=_0x700ff1[_0xe58a('0x3b')][_0xe58a('0x3d')]?_0x700ff1['attributes']:_0x27bff2[_0xe58a('0x37')];if(_0x571854[_0xe58a('0x38')][_0xe58a('0x48')]){_0x700ff1['include']=[{'all':!![]}];}_0x700ff1=_[_0xe58a('0x44')]({},_0x700ff1,_0x571854[_0xe58a('0x47')]);return db[_0xe58a('0x34')][_0xe58a('0x4e')](_0x700ff1)[_0xe58a('0x2a')](handleEntityNotFound(_0x3bc3ea,null))[_0xe58a('0x2a')](respondWithResult(_0x3bc3ea,null))[_0xe58a('0x4b')](handleError(_0x3bc3ea,null));};exports[_0xe58a('0x4f')]=function(_0x350cd0,_0x567bac){return db[_0xe58a('0x34')][_0xe58a('0x4f')](_0x350cd0[_0xe58a('0x50')],{})[_0xe58a('0x2a')](function(_0x21a4ea){var _0x49a7fd=_0x350cd0[_0xe58a('0x51')]['get']({'plain':!![]});if(!_0x49a7fd)throw new Error(_0xe58a('0x52'));if(_0x49a7fd[_0xe58a('0x53')]===_0xe58a('0x51')){var _0x485819=_0x21a4ea['get']({'plain':!![]});var _0x5d9be6=_0xe58a('0x2c');return db['UserProfileSection'][_0xe58a('0x4e')]({'where':{'name':_0x5d9be6,'userProfileId':_0x49a7fd[_0xe58a('0x54')]},'raw':!![]})['then'](function(_0x4b96d9){if(_0x4b96d9&&_0x4b96d9[_0xe58a('0x55')]===0x0){return db[_0xe58a('0x56')][_0xe58a('0x4f')]({'name':_0x485819['name'],'resourceId':_0x485819['id'],'type':_0x4b96d9[_0xe58a('0x30')],'sectionId':_0x4b96d9['id']},{})[_0xe58a('0x2a')](function(){return _0x21a4ea;});}else{return _0x21a4ea;}})[_0xe58a('0x4b')](function(_0x13bc3d){logger[_0xe58a('0x2e')](_0xe58a('0x57'),_0x13bc3d);throw _0x13bc3d;});}return _0x21a4ea;})[_0xe58a('0x2a')](respondWithResult(_0x567bac,0xc9))[_0xe58a('0x4b')](handleError(_0x567bac,null));};exports[_0xe58a('0x58')]=function(_0x5c36e0,_0x1767ef){var _0x2bd7ab={'where':{'id':_0x5c36e0[_0xe58a('0x4c')]['id']}},_0x161fcd={};_0x161fcd['model']=_['keys'](db[_0xe58a('0x34')][_0xe58a('0x4d')]);_0x2bd7ab[_0xe58a('0x3b')]=_[_0xe58a('0x3a')](_0x161fcd['model'],qs['fields'](_0x5c36e0[_0xe58a('0x38')]['fields']));_0x2bd7ab[_0xe58a('0x3b')]=_0x2bd7ab[_0xe58a('0x3b')][_0xe58a('0x3d')]?_0x2bd7ab[_0xe58a('0x3b')]:_0x161fcd[_0xe58a('0x37')];if(_0x5c36e0[_0xe58a('0x38')]['includeAll']){_0x2bd7ab[_0xe58a('0x49')]=[{'all':!![]}];}_0x2bd7ab=_[_0xe58a('0x44')]({},_0x2bd7ab,_0x5c36e0['options']);return db['Dashboard'][_0xe58a('0x4e')](_0x2bd7ab)[_0xe58a('0x2a')](handleEntityNotFound(_0x1767ef,null))[_0xe58a('0x2a')](function(_0x3a5f13){if(_0x3a5f13){var _0x3c37dc=_0x3a5f13[_0xe58a('0x2b')]({'plain':!![]});_0x3c37dc=qs[_0xe58a('0x59')](_0x3c37dc,['id',_0xe58a('0x5a'),_0xe58a('0x5b')]);_0x5c36e0[_0xe58a('0x50')]=_['omit'](_0x5c36e0['body'],['id',_0xe58a('0x5a'),'updatedAt']);return db[_0xe58a('0x34')][_0xe58a('0x4f')](_[_0xe58a('0x44')](_0x3c37dc,_0x5c36e0[_0xe58a('0x50')]),{'include':_0x5c36e0[_0xe58a('0x38')][_0xe58a('0x48')]?[{'all':!![]}]:undefined})['then'](function(_0x5ae504){var _0x59354a=_0x5c36e0[_0xe58a('0x51')][_0xe58a('0x2b')]({'plain':!![]});if(!_0x59354a)throw new Error(_0xe58a('0x52'));if(_0x59354a[_0xe58a('0x53')]===_0xe58a('0x51')){var _0x52f196=_0x5ae504['get']({'plain':!![]});var _0xcb1b9a=_0xe58a('0x2c');return db[_0xe58a('0x5c')][_0xe58a('0x4e')]({'where':{'name':_0xcb1b9a,'userProfileId':_0x59354a[_0xe58a('0x54')]},'raw':!![]})[_0xe58a('0x2a')](function(_0x2a89bf){if(_0x2a89bf&&_0x2a89bf[_0xe58a('0x55')]===0x0){return db['UserProfileResource'][_0xe58a('0x4f')]({'name':_0x52f196[_0xe58a('0x30')],'resourceId':_0x52f196['id'],'type':_0x2a89bf['name'],'sectionId':_0x2a89bf['id']},{})[_0xe58a('0x2a')](function(){return _0x5ae504;});}else{return _0x5ae504;}})[_0xe58a('0x4b')](function(_0xd72462){logger[_0xe58a('0x2e')](_0xe58a('0x57'),_0xd72462);throw _0xd72462;});}return _0x5ae504;});}})[_0xe58a('0x2a')](respondWithResult(_0x1767ef,0xc9))[_0xe58a('0x4b')](handleError(_0x1767ef,null));};exports[_0xe58a('0x5d')]=function(_0x5f37d5,_0xd74f7f){if(_0x5f37d5[_0xe58a('0x50')]['id']){delete _0x5f37d5[_0xe58a('0x50')]['id'];}return db[_0xe58a('0x34')][_0xe58a('0x4e')]({'where':{'id':_0x5f37d5[_0xe58a('0x4c')]['id']}})[_0xe58a('0x2a')](handleEntityNotFound(_0xd74f7f,null))[_0xe58a('0x2a')](saveUpdates(_0x5f37d5[_0xe58a('0x50')],null))[_0xe58a('0x2a')](respondWithResult(_0xd74f7f,null))[_0xe58a('0x4b')](handleError(_0xd74f7f,null));};exports[_0xe58a('0x2d')]=function(_0xcb7ba9,_0x7e988e){return db['Dashboard']['find']({'where':{'id':_0xcb7ba9[_0xe58a('0x4c')]['id']}})[_0xe58a('0x2a')](handleEntityNotFound(_0x7e988e,null))['then'](removeEntity(_0x7e988e,null))['catch'](handleError(_0x7e988e,null));};function widgetAttributes(_0x12a239){try{switch(_0x12a239['type']){case _0xe58a('0x5e'):return[{'name':'attrUrl','value':_0x12a239['attrUrl']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x0]?_0x12a239[_0xe58a('0x5f')][0x0][_0xe58a('0x60')]:undefined)||_0xe58a('0x61')}];case'custom':return[{'name':'attrPath','value':_0x12a239[_0xe58a('0x62')]||(_0x12a239['attrs']&&_0x12a239['attrs'][0x0]?_0x12a239['attrs'][0x0]['value']:undefined)||''}];case _0xe58a('0x63'):return[{'name':_0xe58a('0x64'),'value':_0x12a239['attrHourFormat']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x0]?_0x12a239[_0xe58a('0x5f')][0x0][_0xe58a('0x60')]:undefined)||_0xe58a('0x65')},{'name':'attrTimezone','value':_0x12a239['attrTimezone']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x1]?_0x12a239[_0xe58a('0x5f')][0x1][_0xe58a('0x60')]:undefined)||_0xe58a('0x66')},{'name':'attrFontSize','value':_0x12a239[_0xe58a('0x67')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239['attrs'][0x2]?_0x12a239[_0xe58a('0x5f')][0x2][_0xe58a('0x60')]:undefined)||0xc}];case _0xe58a('0x68'):return[{'name':_0xe58a('0x69'),'value':_0x12a239[_0xe58a('0x69')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x0]?_0x12a239[_0xe58a('0x5f')][0x0]['value']:undefined)||_0xe58a('0x6a')},{'name':'attrVoiceQueues','value':_0x12a239['attrVoiceQueues']||(_0x12a239['attrs']&&_0x12a239[_0xe58a('0x5f')][0x1]?_0x12a239[_0xe58a('0x5f')][0x1]['value']:undefined)||[]},{'name':_0xe58a('0x67'),'value':_0x12a239[_0xe58a('0x67')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x2]?_0x12a239[_0xe58a('0x5f')][0x2]['value']:undefined)||0x14},{'name':_0xe58a('0x6b'),'value':_0x12a239[_0xe58a('0x6b')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x3]?_0x12a239[_0xe58a('0x5f')][0x3][_0xe58a('0x60')]:undefined)||_0xe58a('0x6c')},{'name':'attrEmailAccounts','value':_0x12a239['attrEmailAccounts']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239['attrs'][0x4]?_0x12a239[_0xe58a('0x5f')][0x4][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x6d'),'value':_0x12a239[_0xe58a('0x6d')]||(_0x12a239['attrs']&&_0x12a239['attrs'][0x5]?_0x12a239[_0xe58a('0x5f')][0x5]['value']:undefined)||''},{'name':_0xe58a('0x6e'),'value':_0x12a239[_0xe58a('0x6e')]||(_0x12a239['attrs']&&_0x12a239['attrs'][0x6]?_0x12a239['attrs'][0x6][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x6f'),'value':_0x12a239[_0xe58a('0x6f')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x7]?_0x12a239[_0xe58a('0x5f')][0x7][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x70'),'value':_0x12a239[_0xe58a('0x70')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x8]?_0x12a239[_0xe58a('0x5f')][0x8][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x71'),'value':_0x12a239[_0xe58a('0x71')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239['attrs'][0x9]?_0x12a239['attrs'][0x9][_0xe58a('0x60')]:undefined)||''}];case _0xe58a('0x72'):case _0xe58a('0x73'):return[{'name':'attrSerie1','value':_0x12a239[_0xe58a('0x74')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x0]?_0x12a239[_0xe58a('0x5f')][0x0]['value']:undefined)||_0xe58a('0x6a')},{'name':'attrSerie2','value':_0x12a239[_0xe58a('0x75')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x1]?_0x12a239[_0xe58a('0x5f')][0x1]['value']:undefined)||null},{'name':_0xe58a('0x76'),'value':_0x12a239['attrSerie3']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x2]?_0x12a239[_0xe58a('0x5f')][0x2][_0xe58a('0x60')]:undefined)||null},{'name':_0xe58a('0x77'),'value':_0x12a239[_0xe58a('0x77')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x3]?_0x12a239[_0xe58a('0x5f')][0x3]['value']:undefined)||[]},{'name':'attrChannel','value':_0x12a239[_0xe58a('0x6b')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x4]?_0x12a239[_0xe58a('0x5f')][0x4][_0xe58a('0x60')]:undefined)||_0xe58a('0x6c')},{'name':'attrEmailAccounts','value':_0x12a239[_0xe58a('0x78')]||(_0x12a239['attrs']&&_0x12a239[_0xe58a('0x5f')][0x5]?_0x12a239[_0xe58a('0x5f')][0x5][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x6d'),'value':_0x12a239[_0xe58a('0x6d')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x6]?_0x12a239[_0xe58a('0x5f')][0x6][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x6e'),'value':_0x12a239['attrSmsAccounts']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x7]?_0x12a239[_0xe58a('0x5f')][0x7][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x6f'),'value':_0x12a239[_0xe58a('0x6f')]||(_0x12a239['attrs']&&_0x12a239[_0xe58a('0x5f')][0x8]?_0x12a239[_0xe58a('0x5f')][0x8][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x70'),'value':_0x12a239[_0xe58a('0x70')]||(_0x12a239['attrs']&&_0x12a239[_0xe58a('0x5f')][0x9]?_0x12a239[_0xe58a('0x5f')][0x9][_0xe58a('0x60')]:undefined)||''},{'name':_0xe58a('0x71'),'value':_0x12a239[_0xe58a('0x71')]||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0xa]?_0x12a239[_0xe58a('0x5f')][0xa][_0xe58a('0x60')]:undefined)||''}];case _0xe58a('0x79'):return[{'name':_0xe58a('0x7a'),'type':_0x12a239[_0xe58a('0x7b')]||(_0x12a239['attrs']&&_0x12a239[_0xe58a('0x5f')][0x0]?_0x12a239[_0xe58a('0x5f')][0x0][_0xe58a('0x45')]:undefined)||null,'value':_0x12a239['attrReport']||(_0x12a239[_0xe58a('0x5f')]&&_0x12a239[_0xe58a('0x5f')][0x0]?_0x12a239['attrs'][0x0][_0xe58a('0x60')]:undefined)||null},{'name':_0xe58a('0x7c'),'value':_0x12a239['attrRefresh']||(_0x12a239['attrs']&&_0x12a239[_0xe58a('0x5f')][0x1]?_0x12a239[_0xe58a('0x5f')][0x1][_0xe58a('0x60')]:undefined)||0x0}];default:return[];}}catch(_0x3f1416){logger[_0xe58a('0x2e')](_0xe58a('0x7d'),JSON[_0xe58a('0x7e')](_0x3f1416));return[];}}exports[_0xe58a('0x7f')]=function(_0x26bbe0,_0x5adf07,_0x49ccf4){if(_0x26bbe0[_0xe58a('0x50')]['id']){delete _0x26bbe0[_0xe58a('0x50')]['id'];}return db[_0xe58a('0x34')][_0xe58a('0x4e')]({'where':{'id':_0x26bbe0[_0xe58a('0x4c')]['id']}})[_0xe58a('0x2a')](handleEntityNotFound(_0x5adf07,null))[_0xe58a('0x2a')](function(_0x36d7c0){if(_0x36d7c0){_0x26bbe0[_0xe58a('0x50')]['DashboardId']=_0x36d7c0['id'];_0x26bbe0[_0xe58a('0x50')][_0xe58a('0x5f')]=widgetAttributes(_0x26bbe0['body']);return db[_0xe58a('0x80')][_0xe58a('0x4f')](_0x26bbe0[_0xe58a('0x50')]);}})[_0xe58a('0x2a')](respondWithResult(_0x5adf07,null))[_0xe58a('0x4b')](handleError(_0x5adf07,null));};exports[_0xe58a('0x81')]=function(_0x3af598,_0xe8adfc,_0x29d5ae){var _0x3ef871={};var _0x25704b={};var _0x517385;var _0x55b6b5;return db[_0xe58a('0x34')][_0xe58a('0x82')]({'where':{'id':_0x3af598[_0xe58a('0x4c')]['id']}})['then'](handleEntityNotFound(_0xe8adfc,null))[_0xe58a('0x2a')](function(_0x1fd5fc){if(_0x1fd5fc){_0x517385=_0x1fd5fc;_0x25704b[_0xe58a('0x37')]=_[_0xe58a('0x39')](db[_0xe58a('0x80')][_0xe58a('0x4d')]);_0x25704b[_0xe58a('0x38')]=_[_0xe58a('0x39')](_0x3af598['query']);_0x25704b[_0xe58a('0x41')]=_[_0xe58a('0x3a')](_0x25704b[_0xe58a('0x37')],_0x25704b[_0xe58a('0x38')]);_0x3ef871[_0xe58a('0x3b')]=_[_0xe58a('0x3a')](_0x25704b[_0xe58a('0x37')],qs[_0xe58a('0x3c')](_0x3af598[_0xe58a('0x38')][_0xe58a('0x3c')]));_0x3ef871[_0xe58a('0x3b')]=_0x3ef871[_0xe58a('0x3b')]['length']?_0x3ef871[_0xe58a('0x3b')]:_0x25704b[_0xe58a('0x37')];_0x3ef871[_0xe58a('0x3e')]=qs[_0xe58a('0x3f')](_0x3af598['query']['sort']);_0x3ef871['where']=qs[_0xe58a('0x41')](_[_0xe58a('0x42')](_0x3af598['query'],_0x25704b[_0xe58a('0x41')]));if(_0x3af598['query'][_0xe58a('0x43')]){_0x3ef871[_0xe58a('0x40')]=_[_0xe58a('0x44')](_0x3ef871['where'],{'$or':_[_0xe58a('0x33')](_0x3ef871[_0xe58a('0x3b')],function(_0x50b73d){var _0x36220f={};_0x36220f[_0x50b73d]={'$like':'%'+_0x3af598['query']['filter']+'%'};return _0x36220f;})});}_0x3ef871=_[_0xe58a('0x44')]({},_0x3ef871,_0x3af598['options']);return _0x517385[_0xe58a('0x81')](_0x3ef871);}})[_0xe58a('0x2a')](function(_0x188d45){if(_0x188d45){_0x55b6b5=_0x188d45['length'];if(!_0x3af598[_0xe58a('0x38')][_0xe58a('0x83')]('nolimit')){_0x3ef871[_0xe58a('0x23')]=qs[_0xe58a('0x23')](_0x3af598[_0xe58a('0x38')][_0xe58a('0x23')]);_0x3ef871['offset']=qs[_0xe58a('0x22')](_0x3af598[_0xe58a('0x38')]['offset']);}return _0x517385['getItems'](_0x3ef871);}})[_0xe58a('0x2a')](function(_0x2438dc){if(_0x2438dc){return _0x2438dc?{'count':_0x55b6b5,'rows':_0x2438dc}:null;}})[_0xe58a('0x2a')](respondWithResult(_0xe8adfc,null))['catch'](handleError(_0xe8adfc,null));};