Built motion from commit cafec4f3.|2.6.31
[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 _0x241c=['update','then','get','end','stack','name','map','Dashboard','rawAttributes','type','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','options','includeAll','include','rows','catch','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','CustomDashboards','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','omit','updatedAt','createdAt','userProfileId','UserProfileResource','error','destroy','iframe','attrUrl','attrs','https://','custom','attrPath','value','clock','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','counter','attrMetric','total','attrVoiceQueues','attrChannel','voice','attrEmailAccounts','attrFaxAccounts','attrSmsAccounts','attrOpenchannelAccounts','attrWhatsappAccounts','attrChatWebsites','pie-chart','attrSerie1','attrSerie2','attrSerie3','web-report','attrReport','reportType','attrRefresh','widgetAttributes:\x20%s','stringify','DashboardItem','getItems','findOne','nolimit','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/license/util','defaults','redis','socket.io-emitter','./dashboard.socket','register','status','json','offset','limit','count','set','Content-Range','save'];(function(_0x16c42c,_0x17a056){var _0x42618e=function(_0x564309){while(--_0x564309){_0x16c42c['push'](_0x16c42c['shift']());}};_0x42618e(++_0x17a056);}(_0x241c,0x14d));var _0xc241=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0x241c[_0xa464c9];return _0x3d73c4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xc241('0x0'));var zipdir=require(_0xc241('0x1'));var jsonpatch=require(_0xc241('0x2'));var rp=require(_0xc241('0x3'));var moment=require(_0xc241('0x4'));var BPromise=require(_0xc241('0x5'));var Mustache=require(_0xc241('0x6'));var util=require(_0xc241('0x7'));var path=require(_0xc241('0x8'));var sox=require(_0xc241('0x9'));var csv=require(_0xc241('0xa'));var ejs=require(_0xc241('0xb'));var fs=require('fs');var fs_extra=require(_0xc241('0xc'));var _=require(_0xc241('0xd'));var squel=require('squel');var crypto=require(_0xc241('0xe'));var jsforce=require(_0xc241('0xf'));var deskjs=require('desk.js');var toCsv=require(_0xc241('0xa'));var querystring=require(_0xc241('0x10'));var Papa=require(_0xc241('0x11'));var Redis=require(_0xc241('0x12'));var authService=require(_0xc241('0x13'));var qs=require(_0xc241('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc241('0x15'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xc241('0x16'));var db=require('../../mysqldb')['db'];config['redis']=_[_0xc241('0x17')](config[_0xc241('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0xc241('0x19'))(new Redis(config[_0xc241('0x18')]));require(_0xc241('0x1a'))[_0xc241('0x1b')](socket);function respondWithStatusCode(_0x40cf54,_0x1d5db5){_0x1d5db5=_0x1d5db5||0xcc;return function(_0x26d7f9){if(_0x26d7f9){return _0x40cf54['sendStatus'](_0x1d5db5);}return _0x40cf54[_0xc241('0x1c')](_0x1d5db5)['end']();};}function respondWithResult(_0xd0b9fb,_0x17ce7e){_0x17ce7e=_0x17ce7e||0xc8;return function(_0x5446d7){if(_0x5446d7){return _0xd0b9fb['status'](_0x17ce7e)[_0xc241('0x1d')](_0x5446d7);}};}function respondWithFilteredResult(_0x4fed67,_0x262a98){return function(_0x4cb4f6){if(_0x4cb4f6){var _0x4e62b5=typeof _0x262a98[_0xc241('0x1e')]==='undefined'&&typeof _0x262a98[_0xc241('0x1f')]==='undefined';var _0x16d2a7=_0x4cb4f6[_0xc241('0x20')];var _0x5730fe=_0x4e62b5?0x0:_0x262a98[_0xc241('0x1e')];var _0x468757=_0x4e62b5?_0x4cb4f6['count']:_0x262a98['offset']+_0x262a98[_0xc241('0x1f')];var _0x50d317;if(_0x468757>=_0x16d2a7){_0x468757=_0x16d2a7;_0x50d317=0xc8;}else{_0x50d317=0xce;}_0x4fed67[_0xc241('0x1c')](_0x50d317);return _0x4fed67[_0xc241('0x21')](_0xc241('0x22'),_0x5730fe+'-'+_0x468757+'/'+_0x16d2a7)[_0xc241('0x1d')](_0x4cb4f6);}return null;};}function patchUpdates(_0x174158){return function(_0x184f4d){try{jsonpatch['apply'](_0x184f4d,_0x174158,!![]);}catch(_0x30b2bc){return BPromise['reject'](_0x30b2bc);}return _0x184f4d[_0xc241('0x23')]();};}function saveUpdates(_0xfe54d2,_0x18bf1d){return function(_0x34248f){if(_0x34248f){return _0x34248f[_0xc241('0x24')](_0xfe54d2)[_0xc241('0x25')](function(_0x2b9063){return _0x2b9063;});}return null;};}function removeEntity(_0xffc885,_0x445e65){return function(_0x202bd0){if(_0x202bd0){return _0x202bd0['destroy']()[_0xc241('0x25')](function(){var _0x26fa3d=_0x202bd0[_0xc241('0x26')]({'plain':!![]});var _0xd9ccdd='CustomDashboards';return db['UserProfileResource']['destroy']({'where':{'type':_0xd9ccdd,'resourceId':_0x26fa3d['id']}})[_0xc241('0x25')](function(){return _0x202bd0;});})[_0xc241('0x25')](function(){_0xffc885[_0xc241('0x1c')](0xcc)[_0xc241('0x27')]();});}};}function handleEntityNotFound(_0x8f489,_0x1740a7){return function(_0x5a5415){if(!_0x5a5415){_0x8f489['sendStatus'](0x194);}return _0x5a5415;};}function handleError(_0x306e6a,_0x58db11){_0x58db11=_0x58db11||0x1f4;return function(_0x2d5977){logger['error'](_0x2d5977[_0xc241('0x28')]);if(_0x2d5977[_0xc241('0x29')]){delete _0x2d5977['name'];}_0x306e6a[_0xc241('0x1c')](_0x58db11)['send'](_0x2d5977);};}exports['index']=function(_0x29578c,_0x572c77){var _0x3a3482={},_0x41089e={},_0x53c4eb={'count':0x0,'rows':[]};var _0x235bb4=_[_0xc241('0x2a')](db[_0xc241('0x2b')][_0xc241('0x2c')],function(_0x270313){return{'name':_0x270313['fieldName'],'type':_0x270313[_0xc241('0x2d')]['key']};});_0x41089e[_0xc241('0x2e')]=_[_0xc241('0x2a')](_0x235bb4,_0xc241('0x29'));_0x41089e[_0xc241('0x2f')]=_[_0xc241('0x30')](_0x29578c[_0xc241('0x2f')]);_0x41089e[_0xc241('0x31')]=_['intersection'](_0x41089e[_0xc241('0x2e')],_0x41089e[_0xc241('0x2f')]);_0x3a3482[_0xc241('0x32')]=_[_0xc241('0x33')](_0x41089e[_0xc241('0x2e')],qs[_0xc241('0x34')](_0x29578c['query'][_0xc241('0x34')]));_0x3a3482[_0xc241('0x32')]=_0x3a3482['attributes'][_0xc241('0x35')]?_0x3a3482[_0xc241('0x32')]:_0x41089e[_0xc241('0x2e')];if(!_0x29578c[_0xc241('0x2f')][_0xc241('0x36')]('nolimit')){_0x3a3482[_0xc241('0x1f')]=qs['limit'](_0x29578c[_0xc241('0x2f')][_0xc241('0x1f')]);_0x3a3482['offset']=qs[_0xc241('0x1e')](_0x29578c[_0xc241('0x2f')][_0xc241('0x1e')]);}_0x3a3482[_0xc241('0x37')]=qs[_0xc241('0x38')](_0x29578c['query']['sort']);_0x3a3482[_0xc241('0x39')]=qs['filters'](_[_0xc241('0x3a')](_0x29578c[_0xc241('0x2f')],_0x41089e[_0xc241('0x31')]),_0x235bb4);if(_0x29578c[_0xc241('0x2f')][_0xc241('0x3b')]){_0x3a3482['where']=_[_0xc241('0x3c')](_0x3a3482[_0xc241('0x39')],{'$or':_[_0xc241('0x2a')](_0x235bb4,function(_0x3abf22){if(_0x3abf22[_0xc241('0x2d')]!=='VIRTUAL'){var _0x1c934c={};_0x1c934c[_0x3abf22['name']]={'$like':'%'+_0x29578c['query']['filter']+'%'};return _0x1c934c;}})});}_0x3a3482=_[_0xc241('0x3c')]({},_0x3a3482,_0x29578c[_0xc241('0x3d')]);var _0x5c4287={'where':_0x3a3482[_0xc241('0x39')]};return db[_0xc241('0x2b')]['count'](_0x5c4287)['then'](function(_0x15b975){_0x53c4eb[_0xc241('0x20')]=_0x15b975;if(_0x29578c[_0xc241('0x2f')][_0xc241('0x3e')]){_0x3a3482[_0xc241('0x3f')]=[{'all':!![]}];}return db[_0xc241('0x2b')]['findAll'](_0x3a3482);})[_0xc241('0x25')](function(_0x5cc0a2){_0x53c4eb[_0xc241('0x40')]=_0x5cc0a2;return _0x53c4eb;})[_0xc241('0x25')](respondWithFilteredResult(_0x572c77,_0x3a3482))[_0xc241('0x41')](handleError(_0x572c77,null));};exports['show']=function(_0xd9ff88,_0x2ae243){var _0x525280={'raw':![],'where':{'id':_0xd9ff88[_0xc241('0x42')]['id']}},_0x107eaa={};_0x107eaa[_0xc241('0x2e')]=_['keys'](db['Dashboard'][_0xc241('0x2c')]);_0x107eaa['query']=_['keys'](_0xd9ff88[_0xc241('0x2f')]);_0x107eaa[_0xc241('0x31')]=_[_0xc241('0x33')](_0x107eaa[_0xc241('0x2e')],_0x107eaa[_0xc241('0x2f')]);_0x525280['attributes']=_[_0xc241('0x33')](_0x107eaa['model'],qs[_0xc241('0x34')](_0xd9ff88[_0xc241('0x2f')][_0xc241('0x34')]));_0x525280[_0xc241('0x32')]=_0x525280['attributes']['length']?_0x525280['attributes']:_0x107eaa[_0xc241('0x2e')];if(_0xd9ff88['query'][_0xc241('0x3e')]){_0x525280[_0xc241('0x3f')]=[{'all':!![]}];}_0x525280=_[_0xc241('0x3c')]({},_0x525280,_0xd9ff88['options']);return db[_0xc241('0x2b')][_0xc241('0x43')](_0x525280)[_0xc241('0x25')](handleEntityNotFound(_0x2ae243,null))[_0xc241('0x25')](respondWithResult(_0x2ae243,null))[_0xc241('0x41')](handleError(_0x2ae243,null));};exports[_0xc241('0x44')]=function(_0x12de83,_0x3253fc){return db['Dashboard'][_0xc241('0x44')](_0x12de83[_0xc241('0x45')],{})[_0xc241('0x25')](function(_0x453628){var _0x3f1eed=_0x12de83[_0xc241('0x46')][_0xc241('0x26')]({'plain':!![]});if(!_0x3f1eed)throw new Error(_0xc241('0x47'));if(_0x3f1eed[_0xc241('0x48')]===_0xc241('0x46')){var _0xbeafe5=_0x453628[_0xc241('0x26')]({'plain':!![]});var _0x4c238a=_0xc241('0x49');return db[_0xc241('0x4a')]['find']({'where':{'name':_0x4c238a,'userProfileId':_0x3f1eed['userProfileId']},'raw':!![]})[_0xc241('0x25')](function(_0x2d61a3){if(_0x2d61a3&&_0x2d61a3[_0xc241('0x4b')]===0x0){return db['UserProfileResource']['create']({'name':_0xbeafe5[_0xc241('0x29')],'resourceId':_0xbeafe5['id'],'type':_0x2d61a3[_0xc241('0x29')],'sectionId':_0x2d61a3['id']},{})[_0xc241('0x25')](function(){return _0x453628;});}else{return _0x453628;}})['catch'](function(_0x8fa89){logger['error'](_0xc241('0x4c'),_0x8fa89);throw _0x8fa89;});}return _0x453628;})[_0xc241('0x25')](respondWithResult(_0x3253fc,0xc9))[_0xc241('0x41')](handleError(_0x3253fc,null));};exports['clone']=function(_0x5cdb34,_0x48954b){var _0x16838b={'where':{'id':_0x5cdb34[_0xc241('0x42')]['id']}},_0x26576e={};_0x26576e[_0xc241('0x2e')]=_[_0xc241('0x30')](db[_0xc241('0x2b')][_0xc241('0x2c')]);_0x16838b[_0xc241('0x32')]=_['intersection'](_0x26576e[_0xc241('0x2e')],qs['fields'](_0x5cdb34[_0xc241('0x2f')][_0xc241('0x34')]));_0x16838b[_0xc241('0x32')]=_0x16838b['attributes']['length']?_0x16838b[_0xc241('0x32')]:_0x26576e[_0xc241('0x2e')];if(_0x5cdb34[_0xc241('0x2f')]['includeAll']){_0x16838b[_0xc241('0x3f')]=[{'all':!![]}];}_0x16838b=_[_0xc241('0x3c')]({},_0x16838b,_0x5cdb34[_0xc241('0x3d')]);return db[_0xc241('0x2b')]['find'](_0x16838b)[_0xc241('0x25')](handleEntityNotFound(_0x48954b,null))['then'](function(_0x3ef51e){if(_0x3ef51e){var _0x1387eb=_0x3ef51e['get']({'plain':!![]});_0x1387eb=qs[_0xc241('0x4d')](_0x1387eb,['id','createdAt',_0xc241('0x4e')]);_0x5cdb34[_0xc241('0x45')]=_[_0xc241('0x4d')](_0x5cdb34[_0xc241('0x45')],['id',_0xc241('0x4f'),'updatedAt']);return db[_0xc241('0x2b')][_0xc241('0x44')](_[_0xc241('0x3c')](_0x1387eb,_0x5cdb34['body']),{'include':_0x5cdb34['query'][_0xc241('0x3e')]?[{'all':!![]}]:undefined})['then'](function(_0x1c0d37){var _0x4be38b=_0x5cdb34[_0xc241('0x46')][_0xc241('0x26')]({'plain':!![]});if(!_0x4be38b)throw new Error(_0xc241('0x47'));if(_0x4be38b[_0xc241('0x48')]===_0xc241('0x46')){var _0x12f8da=_0x1c0d37[_0xc241('0x26')]({'plain':!![]});var _0x4db103=_0xc241('0x49');return db[_0xc241('0x4a')][_0xc241('0x43')]({'where':{'name':_0x4db103,'userProfileId':_0x4be38b[_0xc241('0x50')]},'raw':!![]})[_0xc241('0x25')](function(_0x5561e3){if(_0x5561e3&&_0x5561e3['autoAssociation']===0x0){return db[_0xc241('0x51')][_0xc241('0x44')]({'name':_0x12f8da[_0xc241('0x29')],'resourceId':_0x12f8da['id'],'type':_0x5561e3[_0xc241('0x29')],'sectionId':_0x5561e3['id']},{})[_0xc241('0x25')](function(){return _0x1c0d37;});}else{return _0x1c0d37;}})[_0xc241('0x41')](function(_0x4eb7ab){logger[_0xc241('0x52')](_0xc241('0x4c'),_0x4eb7ab);throw _0x4eb7ab;});}return _0x1c0d37;});}})[_0xc241('0x25')](respondWithResult(_0x48954b,0xc9))[_0xc241('0x41')](handleError(_0x48954b,null));};exports[_0xc241('0x24')]=function(_0x303ebe,_0x449699){if(_0x303ebe[_0xc241('0x45')]['id']){delete _0x303ebe[_0xc241('0x45')]['id'];}return db[_0xc241('0x2b')]['find']({'where':{'id':_0x303ebe[_0xc241('0x42')]['id']}})['then'](handleEntityNotFound(_0x449699,null))[_0xc241('0x25')](saveUpdates(_0x303ebe['body'],null))[_0xc241('0x25')](respondWithResult(_0x449699,null))[_0xc241('0x41')](handleError(_0x449699,null));};exports[_0xc241('0x53')]=function(_0x2b86d8,_0x4750d8){return db[_0xc241('0x2b')]['find']({'where':{'id':_0x2b86d8[_0xc241('0x42')]['id']}})['then'](handleEntityNotFound(_0x4750d8,null))[_0xc241('0x25')](removeEntity(_0x4750d8,null))[_0xc241('0x41')](handleError(_0x4750d8,null));};function widgetAttributes(_0x14a9bf){try{switch(_0x14a9bf[_0xc241('0x2d')]){case _0xc241('0x54'):return[{'name':_0xc241('0x55'),'value':_0x14a9bf['attrUrl']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x0]?_0x14a9bf['attrs'][0x0]['value']:undefined)||_0xc241('0x57')}];case _0xc241('0x58'):return[{'name':_0xc241('0x59'),'value':_0x14a9bf['attrPath']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x0]?_0x14a9bf[_0xc241('0x56')][0x0][_0xc241('0x5a')]:undefined)||''}];case _0xc241('0x5b'):return[{'name':_0xc241('0x5c'),'value':_0x14a9bf['attrHourFormat']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x0]?_0x14a9bf[_0xc241('0x56')][0x0]['value']:undefined)||_0xc241('0x5d')},{'name':'attrTimezone','value':_0x14a9bf[_0xc241('0x5e')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x1]?_0x14a9bf['attrs'][0x1][_0xc241('0x5a')]:undefined)||_0xc241('0x5f')},{'name':_0xc241('0x60'),'value':_0x14a9bf[_0xc241('0x60')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x2]?_0x14a9bf[_0xc241('0x56')][0x2]['value']:undefined)||0xc}];case _0xc241('0x61'):return[{'name':'attrMetric','value':_0x14a9bf[_0xc241('0x62')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x0]?_0x14a9bf[_0xc241('0x56')][0x0]['value']:undefined)||_0xc241('0x63')},{'name':_0xc241('0x64'),'value':_0x14a9bf[_0xc241('0x64')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x1]?_0x14a9bf[_0xc241('0x56')][0x1]['value']:undefined)||[]},{'name':_0xc241('0x60'),'value':_0x14a9bf[_0xc241('0x60')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x2]?_0x14a9bf[_0xc241('0x56')][0x2][_0xc241('0x5a')]:undefined)||0x14},{'name':_0xc241('0x65'),'value':_0x14a9bf['attrChannel']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x3]?_0x14a9bf['attrs'][0x3][_0xc241('0x5a')]:undefined)||_0xc241('0x66')},{'name':_0xc241('0x67'),'value':_0x14a9bf[_0xc241('0x67')]||(_0x14a9bf['attrs']&&_0x14a9bf[_0xc241('0x56')][0x4]?_0x14a9bf[_0xc241('0x56')][0x4]['value']:undefined)||''},{'name':_0xc241('0x68'),'value':_0x14a9bf[_0xc241('0x68')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x5]?_0x14a9bf[_0xc241('0x56')][0x5][_0xc241('0x5a')]:undefined)||''},{'name':_0xc241('0x69'),'value':_0x14a9bf[_0xc241('0x69')]||(_0x14a9bf['attrs']&&_0x14a9bf[_0xc241('0x56')][0x6]?_0x14a9bf[_0xc241('0x56')][0x6][_0xc241('0x5a')]:undefined)||''},{'name':_0xc241('0x6a'),'value':_0x14a9bf[_0xc241('0x6a')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x7]?_0x14a9bf[_0xc241('0x56')][0x7][_0xc241('0x5a')]:undefined)||''},{'name':_0xc241('0x6b'),'value':_0x14a9bf['attrWhatsappAccounts']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x8]?_0x14a9bf[_0xc241('0x56')][0x8][_0xc241('0x5a')]:undefined)||''},{'name':_0xc241('0x6c'),'value':_0x14a9bf[_0xc241('0x6c')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x9]?_0x14a9bf[_0xc241('0x56')][0x9]['value']:undefined)||''}];case'multibar-chart':case _0xc241('0x6d'):return[{'name':_0xc241('0x6e'),'value':_0x14a9bf[_0xc241('0x6e')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x0]?_0x14a9bf['attrs'][0x0][_0xc241('0x5a')]:undefined)||'total'},{'name':_0xc241('0x6f'),'value':_0x14a9bf['attrSerie2']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x1]?_0x14a9bf[_0xc241('0x56')][0x1][_0xc241('0x5a')]:undefined)||null},{'name':_0xc241('0x70'),'value':_0x14a9bf[_0xc241('0x70')]||(_0x14a9bf['attrs']&&_0x14a9bf['attrs'][0x2]?_0x14a9bf[_0xc241('0x56')][0x2][_0xc241('0x5a')]:undefined)||null},{'name':'attrVoiceQueues','value':_0x14a9bf[_0xc241('0x64')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x3]?_0x14a9bf[_0xc241('0x56')][0x3][_0xc241('0x5a')]:undefined)||[]},{'name':'attrChannel','value':_0x14a9bf[_0xc241('0x65')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x4]?_0x14a9bf[_0xc241('0x56')][0x4][_0xc241('0x5a')]:undefined)||_0xc241('0x66')},{'name':'attrEmailAccounts','value':_0x14a9bf['attrEmailAccounts']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x5]?_0x14a9bf[_0xc241('0x56')][0x5]['value']:undefined)||''},{'name':_0xc241('0x68'),'value':_0x14a9bf[_0xc241('0x68')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x6]?_0x14a9bf[_0xc241('0x56')][0x6][_0xc241('0x5a')]:undefined)||''},{'name':_0xc241('0x69'),'value':_0x14a9bf['attrSmsAccounts']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x7]?_0x14a9bf['attrs'][0x7]['value']:undefined)||''},{'name':_0xc241('0x6a'),'value':_0x14a9bf['attrOpenchannelAccounts']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x8]?_0x14a9bf[_0xc241('0x56')][0x8][_0xc241('0x5a')]:undefined)||''},{'name':_0xc241('0x6b'),'value':_0x14a9bf['attrWhatsappAccounts']||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x9]?_0x14a9bf['attrs'][0x9]['value']:undefined)||''},{'name':'attrChatWebsites','value':_0x14a9bf[_0xc241('0x6c')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0xa]?_0x14a9bf[_0xc241('0x56')][0xa]['value']:undefined)||''}];case _0xc241('0x71'):return[{'name':_0xc241('0x72'),'type':_0x14a9bf[_0xc241('0x73')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf[_0xc241('0x56')][0x0]?_0x14a9bf[_0xc241('0x56')][0x0][_0xc241('0x2d')]:undefined)||null,'value':_0x14a9bf[_0xc241('0x72')]||(_0x14a9bf[_0xc241('0x56')]&&_0x14a9bf['attrs'][0x0]?_0x14a9bf[_0xc241('0x56')][0x0]['value']:undefined)||null},{'name':'attrRefresh','value':_0x14a9bf[_0xc241('0x74')]||(_0x14a9bf['attrs']&&_0x14a9bf[_0xc241('0x56')][0x1]?_0x14a9bf['attrs'][0x1][_0xc241('0x5a')]:undefined)||0x0}];default:return[];}}catch(_0xb3e7e2){logger[_0xc241('0x52')](_0xc241('0x75'),JSON[_0xc241('0x76')](_0xb3e7e2));return[];}}exports['addItem']=function(_0x4f01a9,_0x8700f9,_0x3cbf14){if(_0x4f01a9[_0xc241('0x45')]['id']){delete _0x4f01a9[_0xc241('0x45')]['id'];}return db[_0xc241('0x2b')][_0xc241('0x43')]({'where':{'id':_0x4f01a9['params']['id']}})['then'](handleEntityNotFound(_0x8700f9,null))[_0xc241('0x25')](function(_0x97ce7){if(_0x97ce7){_0x4f01a9[_0xc241('0x45')]['DashboardId']=_0x97ce7['id'];_0x4f01a9[_0xc241('0x45')][_0xc241('0x56')]=widgetAttributes(_0x4f01a9[_0xc241('0x45')]);return db[_0xc241('0x77')]['create'](_0x4f01a9[_0xc241('0x45')]);}})[_0xc241('0x25')](respondWithResult(_0x8700f9,null))[_0xc241('0x41')](handleError(_0x8700f9,null));};exports[_0xc241('0x78')]=function(_0x211abf,_0x307ad6,_0x51b60b){var _0x44af63={};var _0x53ea14={};var _0x4b4727;var _0x5f3358;return db[_0xc241('0x2b')][_0xc241('0x79')]({'where':{'id':_0x211abf[_0xc241('0x42')]['id']}})['then'](handleEntityNotFound(_0x307ad6,null))['then'](function(_0x3e8466){if(_0x3e8466){_0x4b4727=_0x3e8466;_0x53ea14[_0xc241('0x2e')]=_['keys'](db[_0xc241('0x77')][_0xc241('0x2c')]);_0x53ea14[_0xc241('0x2f')]=_[_0xc241('0x30')](_0x211abf[_0xc241('0x2f')]);_0x53ea14[_0xc241('0x31')]=_[_0xc241('0x33')](_0x53ea14[_0xc241('0x2e')],_0x53ea14[_0xc241('0x2f')]);_0x44af63[_0xc241('0x32')]=_[_0xc241('0x33')](_0x53ea14[_0xc241('0x2e')],qs[_0xc241('0x34')](_0x211abf[_0xc241('0x2f')]['fields']));_0x44af63[_0xc241('0x32')]=_0x44af63['attributes'][_0xc241('0x35')]?_0x44af63['attributes']:_0x53ea14['model'];_0x44af63[_0xc241('0x37')]=qs[_0xc241('0x38')](_0x211abf['query'][_0xc241('0x38')]);_0x44af63['where']=qs[_0xc241('0x31')](_['pick'](_0x211abf[_0xc241('0x2f')],_0x53ea14[_0xc241('0x31')]));if(_0x211abf[_0xc241('0x2f')][_0xc241('0x3b')]){_0x44af63[_0xc241('0x39')]=_['merge'](_0x44af63[_0xc241('0x39')],{'$or':_[_0xc241('0x2a')](_0x44af63[_0xc241('0x32')],function(_0x35a7e7){var _0x153765={};_0x153765[_0x35a7e7]={'$like':'%'+_0x211abf['query'][_0xc241('0x3b')]+'%'};return _0x153765;})});}_0x44af63=_[_0xc241('0x3c')]({},_0x44af63,_0x211abf[_0xc241('0x3d')]);return _0x4b4727[_0xc241('0x78')](_0x44af63);}})['then'](function(_0x1ff815){if(_0x1ff815){_0x5f3358=_0x1ff815[_0xc241('0x35')];if(!_0x211abf[_0xc241('0x2f')][_0xc241('0x36')](_0xc241('0x7a'))){_0x44af63[_0xc241('0x1f')]=qs['limit'](_0x211abf[_0xc241('0x2f')][_0xc241('0x1f')]);_0x44af63[_0xc241('0x1e')]=qs[_0xc241('0x1e')](_0x211abf[_0xc241('0x2f')][_0xc241('0x1e')]);}return _0x4b4727['getItems'](_0x44af63);}})[_0xc241('0x25')](function(_0x68619c){if(_0x68619c){return _0x68619c?{'count':_0x5f3358,'rows':_0x68619c}:null;}})['then'](respondWithResult(_0x307ad6,null))[_0xc241('0x41')](handleError(_0x307ad6,null));};