Built motion from commit 85328c08.|2.5.50
[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 _0x2cf2=['moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','end','status','json','offset','undefined','limit','count','Content-Range','reject','update','then','get','CustomDashboards','destroy','sendStatus','error','stack','name','send','index','rawAttributes','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','Dashboard','findAll','rows','catch','show','params','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','Unable\x20to\x20retrieve\x20the\x20current\x20user','attrUrl','attrs','value','https://','custom','attrPath','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','multibar-chart','pie-chart','attrSerie1','total','attrSerie2','web-report','attrReport','attrRefresh','widgetAttributes:\x20%s','stringify','addItem','DashboardId','DashboardItem','getItems','findOne','eml-format','rimraf','zip-dir','request-promise'];(function(_0x5e17e7,_0x551ed9){var _0x19a417=function(_0x10c981){while(--_0x10c981){_0x5e17e7['push'](_0x5e17e7['shift']());}};_0x19a417(++_0x551ed9);}(_0x2cf2,0x102));var _0x22cf=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2cf2[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0x22cf('0x0'));var rimraf=require(_0x22cf('0x1'));var zipdir=require(_0x22cf('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x22cf('0x3'));var moment=require(_0x22cf('0x4'));var BPromise=require(_0x22cf('0x5'));var Mustache=require(_0x22cf('0x6'));var util=require(_0x22cf('0x7'));var path=require(_0x22cf('0x8'));var sox=require(_0x22cf('0x9'));var csv=require(_0x22cf('0xa'));var ejs=require(_0x22cf('0xb'));var fs=require('fs');var fs_extra=require(_0x22cf('0xc'));var _=require(_0x22cf('0xd'));var squel=require('squel');var crypto=require(_0x22cf('0xe'));var jsforce=require(_0x22cf('0xf'));var deskjs=require(_0x22cf('0x10'));var toCsv=require('to-csv');var querystring=require(_0x22cf('0x11'));var Papa=require(_0x22cf('0x12'));var Redis=require('ioredis');var authService=require(_0x22cf('0x13'));var qs=require(_0x22cf('0x14'));var as=require(_0x22cf('0x15'));var hardwareService=require(_0x22cf('0x16'));var logger=require(_0x22cf('0x17'))('api');var utils=require(_0x22cf('0x18'));var config=require(_0x22cf('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x22cf('0x1a'))['db'];config[_0x22cf('0x1b')]=_[_0x22cf('0x1c')](config['redis'],{'host':_0x22cf('0x1d'),'port':0x18eb});var socket=require(_0x22cf('0x1e'))(new Redis(config[_0x22cf('0x1b')]));require('./dashboard.socket')[_0x22cf('0x1f')](socket);function respondWithStatusCode(_0x228146,_0x8cc58d){_0x8cc58d=_0x8cc58d||0xcc;return function(_0x12c29a){if(_0x12c29a){return _0x228146['sendStatus'](_0x8cc58d);}return _0x228146['status'](_0x8cc58d)[_0x22cf('0x20')]();};}function respondWithResult(_0x531159,_0x4d0aae){_0x4d0aae=_0x4d0aae||0xc8;return function(_0x53dc03){if(_0x53dc03){return _0x531159[_0x22cf('0x21')](_0x4d0aae)[_0x22cf('0x22')](_0x53dc03);}};}function respondWithFilteredResult(_0x57f6dd,_0x2707da){return function(_0x355275){if(_0x355275){var _0x314aad=typeof _0x2707da[_0x22cf('0x23')]===_0x22cf('0x24')&&typeof _0x2707da[_0x22cf('0x25')]===_0x22cf('0x24');var _0x2268eb=_0x355275[_0x22cf('0x26')];var _0x2fee6b=_0x314aad?0x0:_0x2707da['offset'];var _0x2bf1de=_0x314aad?_0x355275['count']:_0x2707da['offset']+_0x2707da['limit'];var _0x4857e7;if(_0x2bf1de>=_0x2268eb){_0x2bf1de=_0x2268eb;_0x4857e7=0xc8;}else{_0x4857e7=0xce;}_0x57f6dd[_0x22cf('0x21')](_0x4857e7);return _0x57f6dd['set'](_0x22cf('0x27'),_0x2fee6b+'-'+_0x2bf1de+'/'+_0x2268eb)['json'](_0x355275);}return null;};}function patchUpdates(_0x1d4fb3){return function(_0x596b8c){try{jsonpatch['apply'](_0x596b8c,_0x1d4fb3,!![]);}catch(_0x380bb5){return BPromise[_0x22cf('0x28')](_0x380bb5);}return _0x596b8c['save']();};}function saveUpdates(_0x1fcaca,_0x4dec09){return function(_0xea9d20){if(_0xea9d20){return _0xea9d20[_0x22cf('0x29')](_0x1fcaca)[_0x22cf('0x2a')](function(_0x4a9844){return _0x4a9844;});}return null;};}function removeEntity(_0x2787f7,_0x54392e){return function(_0x11790e){if(_0x11790e){return _0x11790e['destroy']()[_0x22cf('0x2a')](function(){var _0x314a51=_0x11790e[_0x22cf('0x2b')]({'plain':!![]});var _0x18750d=_0x22cf('0x2c');return db['UserProfileResource'][_0x22cf('0x2d')]({'where':{'type':_0x18750d,'resourceId':_0x314a51['id']}})[_0x22cf('0x2a')](function(){return _0x11790e;});})[_0x22cf('0x2a')](function(){_0x2787f7[_0x22cf('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2e1247,_0x490389){return function(_0x558d75){if(!_0x558d75){_0x2e1247[_0x22cf('0x2e')](0x194);}return _0x558d75;};}function handleError(_0x5734bb,_0x6caeca){_0x6caeca=_0x6caeca||0x1f4;return function(_0x2b4cce){logger[_0x22cf('0x2f')](_0x2b4cce[_0x22cf('0x30')]);if(_0x2b4cce[_0x22cf('0x31')]){delete _0x2b4cce['name'];}_0x5734bb['status'](_0x6caeca)[_0x22cf('0x32')](_0x2b4cce);};}exports[_0x22cf('0x33')]=function(_0x318ee6,_0x326655){var _0x3e7d9b={},_0x40498e={},_0x15265b={'count':0x0,'rows':[]};var _0x467e95=_['map'](db['Dashboard'][_0x22cf('0x34')],function(_0x4530e5){return{'name':_0x4530e5['fieldName'],'type':_0x4530e5[_0x22cf('0x35')][_0x22cf('0x36')]};});_0x40498e[_0x22cf('0x37')]=_[_0x22cf('0x38')](_0x467e95,_0x22cf('0x31'));_0x40498e[_0x22cf('0x39')]=_[_0x22cf('0x3a')](_0x318ee6[_0x22cf('0x39')]);_0x40498e[_0x22cf('0x3b')]=_[_0x22cf('0x3c')](_0x40498e[_0x22cf('0x37')],_0x40498e['query']);_0x3e7d9b[_0x22cf('0x3d')]=_[_0x22cf('0x3c')](_0x40498e[_0x22cf('0x37')],qs[_0x22cf('0x3e')](_0x318ee6[_0x22cf('0x39')][_0x22cf('0x3e')]));_0x3e7d9b[_0x22cf('0x3d')]=_0x3e7d9b[_0x22cf('0x3d')][_0x22cf('0x3f')]?_0x3e7d9b[_0x22cf('0x3d')]:_0x40498e['model'];if(!_0x318ee6[_0x22cf('0x39')][_0x22cf('0x40')]('nolimit')){_0x3e7d9b[_0x22cf('0x25')]=qs['limit'](_0x318ee6['query'][_0x22cf('0x25')]);_0x3e7d9b[_0x22cf('0x23')]=qs[_0x22cf('0x23')](_0x318ee6[_0x22cf('0x39')][_0x22cf('0x23')]);}_0x3e7d9b[_0x22cf('0x41')]=qs[_0x22cf('0x42')](_0x318ee6[_0x22cf('0x39')][_0x22cf('0x42')]);_0x3e7d9b[_0x22cf('0x43')]=qs[_0x22cf('0x3b')](_[_0x22cf('0x44')](_0x318ee6[_0x22cf('0x39')],_0x40498e[_0x22cf('0x3b')]),_0x467e95);if(_0x318ee6[_0x22cf('0x39')]['filter']){_0x3e7d9b[_0x22cf('0x43')]=_[_0x22cf('0x45')](_0x3e7d9b['where'],{'$or':_['map'](_0x467e95,function(_0x5cf9a2){if(_0x5cf9a2[_0x22cf('0x35')]!==_0x22cf('0x46')){var _0x17eeb0={};_0x17eeb0[_0x5cf9a2[_0x22cf('0x31')]]={'$like':'%'+_0x318ee6[_0x22cf('0x39')][_0x22cf('0x47')]+'%'};return _0x17eeb0;}})});}_0x3e7d9b=_[_0x22cf('0x45')]({},_0x3e7d9b,_0x318ee6[_0x22cf('0x48')]);var _0x27a672={'where':_0x3e7d9b['where']};return db['Dashboard']['count'](_0x27a672)[_0x22cf('0x2a')](function(_0x3ce04d){_0x15265b[_0x22cf('0x26')]=_0x3ce04d;if(_0x318ee6[_0x22cf('0x39')][_0x22cf('0x49')]){_0x3e7d9b[_0x22cf('0x4a')]=[{'all':!![]}];}return db[_0x22cf('0x4b')][_0x22cf('0x4c')](_0x3e7d9b);})[_0x22cf('0x2a')](function(_0xa7e36f){_0x15265b[_0x22cf('0x4d')]=_0xa7e36f;return _0x15265b;})[_0x22cf('0x2a')](respondWithFilteredResult(_0x326655,_0x3e7d9b))[_0x22cf('0x4e')](handleError(_0x326655,null));};exports[_0x22cf('0x4f')]=function(_0x9997c8,_0x2c60f0){var _0x49964f={'raw':![],'where':{'id':_0x9997c8[_0x22cf('0x50')]['id']}},_0x5516c7={};_0x5516c7['model']=_[_0x22cf('0x3a')](db[_0x22cf('0x4b')]['rawAttributes']);_0x5516c7['query']=_[_0x22cf('0x3a')](_0x9997c8[_0x22cf('0x39')]);_0x5516c7[_0x22cf('0x3b')]=_[_0x22cf('0x3c')](_0x5516c7[_0x22cf('0x37')],_0x5516c7[_0x22cf('0x39')]);_0x49964f[_0x22cf('0x3d')]=_[_0x22cf('0x3c')](_0x5516c7['model'],qs[_0x22cf('0x3e')](_0x9997c8['query'][_0x22cf('0x3e')]));_0x49964f[_0x22cf('0x3d')]=_0x49964f['attributes'][_0x22cf('0x3f')]?_0x49964f[_0x22cf('0x3d')]:_0x5516c7['model'];if(_0x9997c8[_0x22cf('0x39')][_0x22cf('0x49')]){_0x49964f[_0x22cf('0x4a')]=[{'all':!![]}];}_0x49964f=_[_0x22cf('0x45')]({},_0x49964f,_0x9997c8[_0x22cf('0x48')]);return db['Dashboard'][_0x22cf('0x51')](_0x49964f)[_0x22cf('0x2a')](handleEntityNotFound(_0x2c60f0,null))[_0x22cf('0x2a')](respondWithResult(_0x2c60f0,null))['catch'](handleError(_0x2c60f0,null));};exports[_0x22cf('0x52')]=function(_0x325a5e,_0x273df9){return db[_0x22cf('0x4b')][_0x22cf('0x52')](_0x325a5e[_0x22cf('0x53')],{})[_0x22cf('0x2a')](function(_0x2487c1){var _0x4f4374=_0x325a5e[_0x22cf('0x54')][_0x22cf('0x2b')]({'plain':!![]});if(!_0x4f4374)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4f4374[_0x22cf('0x55')]===_0x22cf('0x54')){var _0x39efce=_0x2487c1[_0x22cf('0x2b')]({'plain':!![]});var _0x29b3b6=_0x22cf('0x2c');return db[_0x22cf('0x56')][_0x22cf('0x51')]({'where':{'name':_0x29b3b6,'userProfileId':_0x4f4374[_0x22cf('0x57')]},'raw':!![]})['then'](function(_0x4e510){if(_0x4e510&&_0x4e510[_0x22cf('0x58')]===0x0){return db[_0x22cf('0x59')]['create']({'name':_0x39efce['name'],'resourceId':_0x39efce['id'],'type':_0x4e510[_0x22cf('0x31')],'sectionId':_0x4e510['id']},{})[_0x22cf('0x2a')](function(){return _0x2487c1;});}else{return _0x2487c1;}})[_0x22cf('0x4e')](function(_0x510f50){logger[_0x22cf('0x2f')](_0x22cf('0x5a'),_0x510f50);throw _0x510f50;});}return _0x2487c1;})[_0x22cf('0x2a')](respondWithResult(_0x273df9,0xc9))[_0x22cf('0x4e')](handleError(_0x273df9,null));};exports[_0x22cf('0x5b')]=function(_0x64da9d,_0x55df79){var _0x5306de={'where':{'id':_0x64da9d[_0x22cf('0x50')]['id']}},_0x32599d={};_0x32599d['model']=_['keys'](db[_0x22cf('0x4b')][_0x22cf('0x34')]);_0x5306de['attributes']=_[_0x22cf('0x3c')](_0x32599d[_0x22cf('0x37')],qs[_0x22cf('0x3e')](_0x64da9d[_0x22cf('0x39')][_0x22cf('0x3e')]));_0x5306de['attributes']=_0x5306de['attributes'][_0x22cf('0x3f')]?_0x5306de['attributes']:_0x32599d['model'];if(_0x64da9d[_0x22cf('0x39')][_0x22cf('0x49')]){_0x5306de['include']=[{'all':!![]}];}_0x5306de=_['merge']({},_0x5306de,_0x64da9d['options']);return db[_0x22cf('0x4b')][_0x22cf('0x51')](_0x5306de)[_0x22cf('0x2a')](handleEntityNotFound(_0x55df79,null))[_0x22cf('0x2a')](function(_0xc8e42c){if(_0xc8e42c){var _0x58dc22=_0xc8e42c[_0x22cf('0x2b')]({'plain':!![]});_0x58dc22=qs[_0x22cf('0x5c')](_0x58dc22,['id',_0x22cf('0x5d'),'updatedAt']);_0x64da9d[_0x22cf('0x53')]=_[_0x22cf('0x5c')](_0x64da9d[_0x22cf('0x53')],['id',_0x22cf('0x5d'),_0x22cf('0x5e')]);return db[_0x22cf('0x4b')][_0x22cf('0x52')](_['merge'](_0x58dc22,_0x64da9d['body']),{'include':_0x64da9d[_0x22cf('0x39')][_0x22cf('0x49')]?[{'all':!![]}]:undefined})['then'](function(_0x36cbeb){var _0x9b6db3=_0x64da9d[_0x22cf('0x54')][_0x22cf('0x2b')]({'plain':!![]});if(!_0x9b6db3)throw new Error(_0x22cf('0x5f'));if(_0x9b6db3['role']===_0x22cf('0x54')){var _0x2788ff=_0x36cbeb[_0x22cf('0x2b')]({'plain':!![]});var _0x22ef22=_0x22cf('0x2c');return db['UserProfileSection'][_0x22cf('0x51')]({'where':{'name':_0x22ef22,'userProfileId':_0x9b6db3[_0x22cf('0x57')]},'raw':!![]})[_0x22cf('0x2a')](function(_0x5592f0){if(_0x5592f0&&_0x5592f0[_0x22cf('0x58')]===0x0){return db[_0x22cf('0x59')][_0x22cf('0x52')]({'name':_0x2788ff[_0x22cf('0x31')],'resourceId':_0x2788ff['id'],'type':_0x5592f0['name'],'sectionId':_0x5592f0['id']},{})[_0x22cf('0x2a')](function(){return _0x36cbeb;});}else{return _0x36cbeb;}})[_0x22cf('0x4e')](function(_0x248518){logger[_0x22cf('0x2f')](_0x22cf('0x5a'),_0x248518);throw _0x248518;});}return _0x36cbeb;});}})[_0x22cf('0x2a')](respondWithResult(_0x55df79,0xc9))['catch'](handleError(_0x55df79,null));};exports[_0x22cf('0x29')]=function(_0x2c9168,_0x33bfe2){if(_0x2c9168[_0x22cf('0x53')]['id']){delete _0x2c9168[_0x22cf('0x53')]['id'];}return db[_0x22cf('0x4b')][_0x22cf('0x51')]({'where':{'id':_0x2c9168[_0x22cf('0x50')]['id']}})[_0x22cf('0x2a')](handleEntityNotFound(_0x33bfe2,null))[_0x22cf('0x2a')](saveUpdates(_0x2c9168[_0x22cf('0x53')],null))[_0x22cf('0x2a')](respondWithResult(_0x33bfe2,null))[_0x22cf('0x4e')](handleError(_0x33bfe2,null));};exports[_0x22cf('0x2d')]=function(_0x149be4,_0x379995){return db[_0x22cf('0x4b')][_0x22cf('0x51')]({'where':{'id':_0x149be4[_0x22cf('0x50')]['id']}})[_0x22cf('0x2a')](handleEntityNotFound(_0x379995,null))[_0x22cf('0x2a')](removeEntity(_0x379995,null))['catch'](handleError(_0x379995,null));};function widgetAttributes(_0xe3f29b){try{switch(_0xe3f29b[_0x22cf('0x35')]){case'iframe':return[{'name':_0x22cf('0x60'),'value':_0xe3f29b['attrUrl']||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b['attrs'][0x0][_0x22cf('0x62')]:undefined)||_0x22cf('0x63')}];case _0x22cf('0x64'):return[{'name':_0x22cf('0x65'),'value':_0xe3f29b[_0x22cf('0x65')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||''}];case'clock':return[{'name':_0x22cf('0x66'),'value':_0xe3f29b[_0x22cf('0x66')]||(_0xe3f29b['attrs']&&_0xe3f29b['attrs'][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||_0x22cf('0x67')},{'name':'attrTimezone','value':_0xe3f29b[_0x22cf('0x68')]||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x1]?_0xe3f29b[_0x22cf('0x61')][0x1][_0x22cf('0x62')]:undefined)||_0x22cf('0x69')},{'name':'attrFontSize','value':_0xe3f29b[_0x22cf('0x6a')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x2]?_0xe3f29b['attrs'][0x2][_0x22cf('0x62')]:undefined)||0xc}];case'counter':return[{'name':'attrMetric','value':_0xe3f29b['attrMetric']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||'total'},{'name':_0x22cf('0x6b'),'value':_0xe3f29b[_0x22cf('0x6b')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x1]?_0xe3f29b[_0x22cf('0x61')][0x1][_0x22cf('0x62')]:undefined)||[]},{'name':_0x22cf('0x6a'),'value':_0xe3f29b[_0x22cf('0x6a')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x2]?_0xe3f29b[_0x22cf('0x61')][0x2][_0x22cf('0x62')]:undefined)||0x14},{'name':'attrChannel','value':_0xe3f29b[_0x22cf('0x6c')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x3]?_0xe3f29b[_0x22cf('0x61')][0x3][_0x22cf('0x62')]:undefined)||_0x22cf('0x6d')},{'name':_0x22cf('0x6e'),'value':_0xe3f29b[_0x22cf('0x6e')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x4]?_0xe3f29b[_0x22cf('0x61')][0x4][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x6f'),'value':_0xe3f29b[_0x22cf('0x6f')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x5]?_0xe3f29b[_0x22cf('0x61')][0x5][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x70'),'value':_0xe3f29b['attrSmsAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x6]?_0xe3f29b[_0x22cf('0x61')][0x6][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x71'),'value':_0xe3f29b[_0x22cf('0x71')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x7]?_0xe3f29b['attrs'][0x7]['value']:undefined)||''},{'name':_0x22cf('0x72'),'value':_0xe3f29b['attrWhatsappAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x8]?_0xe3f29b[_0x22cf('0x61')][0x8][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x73'),'value':_0xe3f29b['attrChatWebsites']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x9]?_0xe3f29b[_0x22cf('0x61')][0x9]['value']:undefined)||''}];case _0x22cf('0x74'):case _0x22cf('0x75'):return[{'name':_0x22cf('0x76'),'value':_0xe3f29b['attrSerie1']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||_0x22cf('0x77')},{'name':_0x22cf('0x78'),'value':_0xe3f29b[_0x22cf('0x78')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x1]?_0xe3f29b['attrs'][0x1]['value']:undefined)||null},{'name':'attrSerie3','value':_0xe3f29b['attrSerie3']||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x2]?_0xe3f29b[_0x22cf('0x61')][0x2][_0x22cf('0x62')]:undefined)||null},{'name':_0x22cf('0x6b'),'value':_0xe3f29b[_0x22cf('0x6b')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x3]?_0xe3f29b['attrs'][0x3][_0x22cf('0x62')]:undefined)||[]},{'name':_0x22cf('0x6c'),'value':_0xe3f29b[_0x22cf('0x6c')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x4]?_0xe3f29b['attrs'][0x4][_0x22cf('0x62')]:undefined)||_0x22cf('0x6d')},{'name':_0x22cf('0x6e'),'value':_0xe3f29b['attrEmailAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x5]?_0xe3f29b[_0x22cf('0x61')][0x5][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x6f'),'value':_0xe3f29b['attrFaxAccounts']||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x6]?_0xe3f29b[_0x22cf('0x61')][0x6][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x70'),'value':_0xe3f29b[_0x22cf('0x70')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x7]?_0xe3f29b[_0x22cf('0x61')][0x7][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x71'),'value':_0xe3f29b[_0x22cf('0x71')]||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x8]?_0xe3f29b['attrs'][0x8]['value']:undefined)||''},{'name':_0x22cf('0x72'),'value':_0xe3f29b[_0x22cf('0x72')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0x9]?_0xe3f29b['attrs'][0x9][_0x22cf('0x62')]:undefined)||''},{'name':_0x22cf('0x73'),'value':_0xe3f29b[_0x22cf('0x73')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b[_0x22cf('0x61')][0xa]?_0xe3f29b['attrs'][0xa][_0x22cf('0x62')]:undefined)||''}];case _0x22cf('0x79'):return[{'name':_0x22cf('0x7a'),'type':_0xe3f29b['reportType']||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x35')]:undefined)||null,'value':_0xe3f29b[_0x22cf('0x7a')]||(_0xe3f29b['attrs']&&_0xe3f29b[_0x22cf('0x61')][0x0]?_0xe3f29b[_0x22cf('0x61')][0x0][_0x22cf('0x62')]:undefined)||null},{'name':_0x22cf('0x7b'),'value':_0xe3f29b[_0x22cf('0x7b')]||(_0xe3f29b[_0x22cf('0x61')]&&_0xe3f29b['attrs'][0x1]?_0xe3f29b['attrs'][0x1]['value']:undefined)||0x0}];default:return[];}}catch(_0x980153){logger[_0x22cf('0x2f')](_0x22cf('0x7c'),JSON[_0x22cf('0x7d')](_0x980153));return[];}}exports[_0x22cf('0x7e')]=function(_0x5a4174,_0x3d4ae2,_0x74dca1){if(_0x5a4174[_0x22cf('0x53')]['id']){delete _0x5a4174[_0x22cf('0x53')]['id'];}return db[_0x22cf('0x4b')][_0x22cf('0x51')]({'where':{'id':_0x5a4174[_0x22cf('0x50')]['id']}})['then'](handleEntityNotFound(_0x3d4ae2,null))[_0x22cf('0x2a')](function(_0x8fdf62){if(_0x8fdf62){_0x5a4174[_0x22cf('0x53')][_0x22cf('0x7f')]=_0x8fdf62['id'];_0x5a4174[_0x22cf('0x53')][_0x22cf('0x61')]=widgetAttributes(_0x5a4174[_0x22cf('0x53')]);return db[_0x22cf('0x80')][_0x22cf('0x52')](_0x5a4174[_0x22cf('0x53')]);}})[_0x22cf('0x2a')](respondWithResult(_0x3d4ae2,null))[_0x22cf('0x4e')](handleError(_0x3d4ae2,null));};exports[_0x22cf('0x81')]=function(_0x48e629,_0x3fcb39,_0x2cd54b){var _0x30a94d={};var _0xcf8394={};var _0x5b626d;var _0x1f04cb;return db[_0x22cf('0x4b')][_0x22cf('0x82')]({'where':{'id':_0x48e629[_0x22cf('0x50')]['id']}})[_0x22cf('0x2a')](handleEntityNotFound(_0x3fcb39,null))[_0x22cf('0x2a')](function(_0x434b30){if(_0x434b30){_0x5b626d=_0x434b30;_0xcf8394['model']=_[_0x22cf('0x3a')](db['DashboardItem']['rawAttributes']);_0xcf8394['query']=_[_0x22cf('0x3a')](_0x48e629[_0x22cf('0x39')]);_0xcf8394['filters']=_[_0x22cf('0x3c')](_0xcf8394[_0x22cf('0x37')],_0xcf8394[_0x22cf('0x39')]);_0x30a94d['attributes']=_[_0x22cf('0x3c')](_0xcf8394[_0x22cf('0x37')],qs[_0x22cf('0x3e')](_0x48e629[_0x22cf('0x39')][_0x22cf('0x3e')]));_0x30a94d[_0x22cf('0x3d')]=_0x30a94d[_0x22cf('0x3d')][_0x22cf('0x3f')]?_0x30a94d[_0x22cf('0x3d')]:_0xcf8394['model'];_0x30a94d[_0x22cf('0x41')]=qs[_0x22cf('0x42')](_0x48e629['query'][_0x22cf('0x42')]);_0x30a94d[_0x22cf('0x43')]=qs[_0x22cf('0x3b')](_[_0x22cf('0x44')](_0x48e629['query'],_0xcf8394[_0x22cf('0x3b')]));if(_0x48e629['query'][_0x22cf('0x47')]){_0x30a94d['where']=_[_0x22cf('0x45')](_0x30a94d[_0x22cf('0x43')],{'$or':_[_0x22cf('0x38')](_0x30a94d['attributes'],function(_0x3914e2){var _0x2e3b41={};_0x2e3b41[_0x3914e2]={'$like':'%'+_0x48e629[_0x22cf('0x39')][_0x22cf('0x47')]+'%'};return _0x2e3b41;})});}_0x30a94d=_[_0x22cf('0x45')]({},_0x30a94d,_0x48e629[_0x22cf('0x48')]);return _0x5b626d[_0x22cf('0x81')](_0x30a94d);}})[_0x22cf('0x2a')](function(_0x140b6c){if(_0x140b6c){_0x1f04cb=_0x140b6c[_0x22cf('0x3f')];if(!_0x48e629['query'][_0x22cf('0x40')]('nolimit')){_0x30a94d['limit']=qs[_0x22cf('0x25')](_0x48e629[_0x22cf('0x39')][_0x22cf('0x25')]);_0x30a94d['offset']=qs[_0x22cf('0x23')](_0x48e629[_0x22cf('0x39')][_0x22cf('0x23')]);}return _0x5b626d[_0x22cf('0x81')](_0x30a94d);}})['then'](function(_0x5c101e){if(_0x5c101e){return _0x5c101e?{'count':_0x1f04cb,'rows':_0x5c101e}:null;}})[_0x22cf('0x2a')](respondWithResult(_0x3fcb39,null))[_0x22cf('0x4e')](handleError(_0x3fcb39,null));};