Built motion from commit (unavailable).|2.6.0
[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 _0x5c5f=['getItems','findOne','order','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./dashboard.socket','register','sendStatus','status','offset','limit','undefined','count','set','Content-Range','json','apply','reject','save','update','destroy','UserProfileResource','then','end','error','stack','name','send','index','map','Dashboard','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','params','rawAttributes','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','omit','updatedAt','createdAt','CustomDashboards','userProfileId','attrUrl','attrs','value','https://','custom','attrPath','clock','attrHourFormat','HH:mm:ss','attrTimezone','0.00','attrFontSize','counter','attrMetric','total','attrVoiceQueues','multibar-chart','pie-chart','attrSerie1','attrSerie2','attrSerie3','web-report','attrReport','reportType','widgetAttributes:\x20%s','stringify','DashboardId'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0x5c5f,0x183));var _0xf5c5=function(_0x28edda,_0xbd447a){_0x28edda=_0x28edda-0x0;var _0x21f4a4=_0x5c5f[_0x28edda];return _0x21f4a4;};'use strict';var emlformat=require(_0xf5c5('0x0'));var rimraf=require(_0xf5c5('0x1'));var zipdir=require(_0xf5c5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xf5c5('0x3'));var BPromise=require(_0xf5c5('0x4'));var Mustache=require(_0xf5c5('0x5'));var util=require(_0xf5c5('0x6'));var path=require(_0xf5c5('0x7'));var sox=require(_0xf5c5('0x8'));var csv=require(_0xf5c5('0x9'));var ejs=require(_0xf5c5('0xa'));var fs=require('fs');var fs_extra=require(_0xf5c5('0xb'));var _=require(_0xf5c5('0xc'));var squel=require(_0xf5c5('0xd'));var crypto=require(_0xf5c5('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xf5c5('0xf'));var toCsv=require('to-csv');var querystring=require(_0xf5c5('0x10'));var Papa=require(_0xf5c5('0x11'));var Redis=require(_0xf5c5('0x12'));var authService=require(_0xf5c5('0x13'));var qs=require(_0xf5c5('0x14'));var as=require(_0xf5c5('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf5c5('0x16'))(_0xf5c5('0x17'));var utils=require(_0xf5c5('0x18'));var config=require(_0xf5c5('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xf5c5('0x1a'))['db'];config[_0xf5c5('0x1b')]=_[_0xf5c5('0x1c')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xf5c5('0x1d'))(new Redis(config[_0xf5c5('0x1b')]));require(_0xf5c5('0x1e'))[_0xf5c5('0x1f')](socket);function respondWithStatusCode(_0x2ab5b0,_0x1681a3){_0x1681a3=_0x1681a3||0xcc;return function(_0x8e7752){if(_0x8e7752){return _0x2ab5b0[_0xf5c5('0x20')](_0x1681a3);}return _0x2ab5b0[_0xf5c5('0x21')](_0x1681a3)['end']();};}function respondWithResult(_0x19bb5c,_0x32c795){_0x32c795=_0x32c795||0xc8;return function(_0x4a143a){if(_0x4a143a){return _0x19bb5c[_0xf5c5('0x21')](_0x32c795)['json'](_0x4a143a);}};}function respondWithFilteredResult(_0x239d61,_0x41dae5){return function(_0x21134b){if(_0x21134b){var _0x4cc437=typeof _0x41dae5[_0xf5c5('0x22')]==='undefined'&&typeof _0x41dae5[_0xf5c5('0x23')]===_0xf5c5('0x24');var _0x165e5a=_0x21134b[_0xf5c5('0x25')];var _0x2ab2ca=_0x4cc437?0x0:_0x41dae5[_0xf5c5('0x22')];var _0x4c009a=_0x4cc437?_0x21134b[_0xf5c5('0x25')]:_0x41dae5['offset']+_0x41dae5[_0xf5c5('0x23')];var _0x1bc042;if(_0x4c009a>=_0x165e5a){_0x4c009a=_0x165e5a;_0x1bc042=0xc8;}else{_0x1bc042=0xce;}_0x239d61[_0xf5c5('0x21')](_0x1bc042);return _0x239d61[_0xf5c5('0x26')](_0xf5c5('0x27'),_0x2ab2ca+'-'+_0x4c009a+'/'+_0x165e5a)[_0xf5c5('0x28')](_0x21134b);}return null;};}function patchUpdates(_0x2705f0){return function(_0x1188b9){try{jsonpatch[_0xf5c5('0x29')](_0x1188b9,_0x2705f0,!![]);}catch(_0x43ef2b){return BPromise[_0xf5c5('0x2a')](_0x43ef2b);}return _0x1188b9[_0xf5c5('0x2b')]();};}function saveUpdates(_0x53715d,_0x7f83fe){return function(_0x233ef4){if(_0x233ef4){return _0x233ef4[_0xf5c5('0x2c')](_0x53715d)['then'](function(_0x13898b){return _0x13898b;});}return null;};}function removeEntity(_0x468be4,_0x154e1f){return function(_0x2e3778){if(_0x2e3778){return _0x2e3778[_0xf5c5('0x2d')]()['then'](function(){var _0x1536ee=_0x2e3778['get']({'plain':!![]});var _0x539918='CustomDashboards';return db[_0xf5c5('0x2e')][_0xf5c5('0x2d')]({'where':{'type':_0x539918,'resourceId':_0x1536ee['id']}})[_0xf5c5('0x2f')](function(){return _0x2e3778;});})['then'](function(){_0x468be4[_0xf5c5('0x21')](0xcc)[_0xf5c5('0x30')]();});}};}function handleEntityNotFound(_0x5c3c6f,_0x358932){return function(_0x546f18){if(!_0x546f18){_0x5c3c6f['sendStatus'](0x194);}return _0x546f18;};}function handleError(_0x4f0c04,_0x3f37d8){_0x3f37d8=_0x3f37d8||0x1f4;return function(_0x59b00e){logger[_0xf5c5('0x31')](_0x59b00e[_0xf5c5('0x32')]);if(_0x59b00e['name']){delete _0x59b00e[_0xf5c5('0x33')];}_0x4f0c04[_0xf5c5('0x21')](_0x3f37d8)[_0xf5c5('0x34')](_0x59b00e);};}exports[_0xf5c5('0x35')]=function(_0x3df0d3,_0x3037ba){var _0x35d997={},_0x3581f0={},_0x30e242={'count':0x0,'rows':[]};var _0xe0c4f0=_[_0xf5c5('0x36')](db[_0xf5c5('0x37')]['rawAttributes'],function(_0x1ecbb8){return{'name':_0x1ecbb8[_0xf5c5('0x38')],'type':_0x1ecbb8[_0xf5c5('0x39')][_0xf5c5('0x3a')]};});_0x3581f0[_0xf5c5('0x3b')]=_[_0xf5c5('0x36')](_0xe0c4f0,_0xf5c5('0x33'));_0x3581f0[_0xf5c5('0x3c')]=_[_0xf5c5('0x3d')](_0x3df0d3[_0xf5c5('0x3c')]);_0x3581f0[_0xf5c5('0x3e')]=_[_0xf5c5('0x3f')](_0x3581f0[_0xf5c5('0x3b')],_0x3581f0['query']);_0x35d997[_0xf5c5('0x40')]=_[_0xf5c5('0x3f')](_0x3581f0[_0xf5c5('0x3b')],qs[_0xf5c5('0x41')](_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x41')]));_0x35d997[_0xf5c5('0x40')]=_0x35d997[_0xf5c5('0x40')][_0xf5c5('0x42')]?_0x35d997[_0xf5c5('0x40')]:_0x3581f0[_0xf5c5('0x3b')];if(!_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x43')](_0xf5c5('0x44'))){_0x35d997[_0xf5c5('0x23')]=qs[_0xf5c5('0x23')](_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x23')]);_0x35d997['offset']=qs[_0xf5c5('0x22')](_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x22')]);}_0x35d997['order']=qs[_0xf5c5('0x45')](_0x3df0d3[_0xf5c5('0x3c')]['sort']);_0x35d997[_0xf5c5('0x46')]=qs['filters'](_[_0xf5c5('0x47')](_0x3df0d3['query'],_0x3581f0[_0xf5c5('0x3e')]),_0xe0c4f0);if(_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x48')]){_0x35d997[_0xf5c5('0x46')]=_[_0xf5c5('0x49')](_0x35d997[_0xf5c5('0x46')],{'$or':_[_0xf5c5('0x36')](_0xe0c4f0,function(_0x39d4d4){if(_0x39d4d4[_0xf5c5('0x39')]!==_0xf5c5('0x4a')){var _0x45ead0={};_0x45ead0[_0x39d4d4['name']]={'$like':'%'+_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x48')]+'%'};return _0x45ead0;}})});}_0x35d997=_[_0xf5c5('0x49')]({},_0x35d997,_0x3df0d3[_0xf5c5('0x4b')]);var _0x3fe852={'where':_0x35d997[_0xf5c5('0x46')]};return db[_0xf5c5('0x37')][_0xf5c5('0x25')](_0x3fe852)[_0xf5c5('0x2f')](function(_0xbcff43){_0x30e242[_0xf5c5('0x25')]=_0xbcff43;if(_0x3df0d3[_0xf5c5('0x3c')][_0xf5c5('0x4c')]){_0x35d997[_0xf5c5('0x4d')]=[{'all':!![]}];}return db['Dashboard'][_0xf5c5('0x4e')](_0x35d997);})['then'](function(_0x78aca1){_0x30e242[_0xf5c5('0x4f')]=_0x78aca1;return _0x30e242;})[_0xf5c5('0x2f')](respondWithFilteredResult(_0x3037ba,_0x35d997))[_0xf5c5('0x50')](handleError(_0x3037ba,null));};exports['show']=function(_0x4915f1,_0x32bc91){var _0xd40282={'raw':![],'where':{'id':_0x4915f1[_0xf5c5('0x51')]['id']}},_0x23af4f={};_0x23af4f[_0xf5c5('0x3b')]=_['keys'](db[_0xf5c5('0x37')][_0xf5c5('0x52')]);_0x23af4f[_0xf5c5('0x3c')]=_['keys'](_0x4915f1[_0xf5c5('0x3c')]);_0x23af4f['filters']=_[_0xf5c5('0x3f')](_0x23af4f['model'],_0x23af4f['query']);_0xd40282[_0xf5c5('0x40')]=_[_0xf5c5('0x3f')](_0x23af4f['model'],qs[_0xf5c5('0x41')](_0x4915f1['query'][_0xf5c5('0x41')]));_0xd40282[_0xf5c5('0x40')]=_0xd40282['attributes'][_0xf5c5('0x42')]?_0xd40282[_0xf5c5('0x40')]:_0x23af4f[_0xf5c5('0x3b')];if(_0x4915f1[_0xf5c5('0x3c')][_0xf5c5('0x4c')]){_0xd40282['include']=[{'all':!![]}];}_0xd40282=_[_0xf5c5('0x49')]({},_0xd40282,_0x4915f1[_0xf5c5('0x4b')]);return db['Dashboard'][_0xf5c5('0x53')](_0xd40282)[_0xf5c5('0x2f')](handleEntityNotFound(_0x32bc91,null))[_0xf5c5('0x2f')](respondWithResult(_0x32bc91,null))[_0xf5c5('0x50')](handleError(_0x32bc91,null));};exports[_0xf5c5('0x54')]=function(_0x3df746,_0x19fc6f){return db[_0xf5c5('0x37')][_0xf5c5('0x54')](_0x3df746[_0xf5c5('0x55')],{})['then'](function(_0x121cad){var _0x2ec8d4=_0x3df746[_0xf5c5('0x56')][_0xf5c5('0x57')]({'plain':!![]});if(!_0x2ec8d4)throw new Error(_0xf5c5('0x58'));if(_0x2ec8d4[_0xf5c5('0x59')]===_0xf5c5('0x56')){var _0x4531a9=_0x121cad[_0xf5c5('0x57')]({'plain':!![]});var _0x308f4d='CustomDashboards';return db[_0xf5c5('0x5a')][_0xf5c5('0x53')]({'where':{'name':_0x308f4d,'userProfileId':_0x2ec8d4['userProfileId']},'raw':!![]})[_0xf5c5('0x2f')](function(_0x48bda1){if(_0x48bda1&&_0x48bda1[_0xf5c5('0x5b')]===0x0){return db['UserProfileResource'][_0xf5c5('0x54')]({'name':_0x4531a9[_0xf5c5('0x33')],'resourceId':_0x4531a9['id'],'type':_0x48bda1['name'],'sectionId':_0x48bda1['id']},{})[_0xf5c5('0x2f')](function(){return _0x121cad;});}else{return _0x121cad;}})[_0xf5c5('0x50')](function(_0x268983){logger[_0xf5c5('0x31')](_0xf5c5('0x5c'),_0x268983);throw _0x268983;});}return _0x121cad;})[_0xf5c5('0x2f')](respondWithResult(_0x19fc6f,0xc9))[_0xf5c5('0x50')](handleError(_0x19fc6f,null));};exports['clone']=function(_0x4d05c6,_0x437fc7){var _0x1dd735={'where':{'id':_0x4d05c6['params']['id']}},_0x3a015b={};_0x3a015b['model']=_[_0xf5c5('0x3d')](db['Dashboard'][_0xf5c5('0x52')]);_0x1dd735[_0xf5c5('0x40')]=_['intersection'](_0x3a015b['model'],qs[_0xf5c5('0x41')](_0x4d05c6[_0xf5c5('0x3c')][_0xf5c5('0x41')]));_0x1dd735['attributes']=_0x1dd735[_0xf5c5('0x40')]['length']?_0x1dd735['attributes']:_0x3a015b[_0xf5c5('0x3b')];if(_0x4d05c6[_0xf5c5('0x3c')]['includeAll']){_0x1dd735[_0xf5c5('0x4d')]=[{'all':!![]}];}_0x1dd735=_['merge']({},_0x1dd735,_0x4d05c6[_0xf5c5('0x4b')]);return db[_0xf5c5('0x37')]['find'](_0x1dd735)[_0xf5c5('0x2f')](handleEntityNotFound(_0x437fc7,null))[_0xf5c5('0x2f')](function(_0x114e65){if(_0x114e65){var _0x579a7f=_0x114e65[_0xf5c5('0x57')]({'plain':!![]});_0x579a7f=qs[_0xf5c5('0x5d')](_0x579a7f,['id','createdAt',_0xf5c5('0x5e')]);_0x4d05c6[_0xf5c5('0x55')]=_['omit'](_0x4d05c6['body'],['id',_0xf5c5('0x5f'),'updatedAt']);return db['Dashboard'][_0xf5c5('0x54')](_['merge'](_0x579a7f,_0x4d05c6[_0xf5c5('0x55')]),{'include':_0x4d05c6['query'][_0xf5c5('0x4c')]?[{'all':!![]}]:undefined})[_0xf5c5('0x2f')](function(_0xf0742f){var _0x12bf5c=_0x4d05c6[_0xf5c5('0x56')][_0xf5c5('0x57')]({'plain':!![]});if(!_0x12bf5c)throw new Error(_0xf5c5('0x58'));if(_0x12bf5c[_0xf5c5('0x59')]===_0xf5c5('0x56')){var _0x2706a9=_0xf0742f[_0xf5c5('0x57')]({'plain':!![]});var _0x482e55=_0xf5c5('0x60');return db[_0xf5c5('0x5a')][_0xf5c5('0x53')]({'where':{'name':_0x482e55,'userProfileId':_0x12bf5c[_0xf5c5('0x61')]},'raw':!![]})[_0xf5c5('0x2f')](function(_0x340cb9){if(_0x340cb9&&_0x340cb9[_0xf5c5('0x5b')]===0x0){return db[_0xf5c5('0x2e')][_0xf5c5('0x54')]({'name':_0x2706a9['name'],'resourceId':_0x2706a9['id'],'type':_0x340cb9[_0xf5c5('0x33')],'sectionId':_0x340cb9['id']},{})[_0xf5c5('0x2f')](function(){return _0xf0742f;});}else{return _0xf0742f;}})[_0xf5c5('0x50')](function(_0x480864){logger[_0xf5c5('0x31')](_0xf5c5('0x5c'),_0x480864);throw _0x480864;});}return _0xf0742f;});}})['then'](respondWithResult(_0x437fc7,0xc9))[_0xf5c5('0x50')](handleError(_0x437fc7,null));};exports[_0xf5c5('0x2c')]=function(_0x560ccd,_0x49323d){if(_0x560ccd[_0xf5c5('0x55')]['id']){delete _0x560ccd[_0xf5c5('0x55')]['id'];}return db['Dashboard'][_0xf5c5('0x53')]({'where':{'id':_0x560ccd['params']['id']}})['then'](handleEntityNotFound(_0x49323d,null))[_0xf5c5('0x2f')](saveUpdates(_0x560ccd[_0xf5c5('0x55')],null))[_0xf5c5('0x2f')](respondWithResult(_0x49323d,null))[_0xf5c5('0x50')](handleError(_0x49323d,null));};exports[_0xf5c5('0x2d')]=function(_0x5ec482,_0x1d8cc8){return db[_0xf5c5('0x37')]['find']({'where':{'id':_0x5ec482[_0xf5c5('0x51')]['id']}})['then'](handleEntityNotFound(_0x1d8cc8,null))[_0xf5c5('0x2f')](removeEntity(_0x1d8cc8,null))[_0xf5c5('0x50')](handleError(_0x1d8cc8,null));};function widgetAttributes(_0x6d12be){try{switch(_0x6d12be['type']){case'iframe':return[{'name':_0xf5c5('0x62'),'value':_0x6d12be[_0xf5c5('0x62')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0][_0xf5c5('0x64')]:undefined)||_0xf5c5('0x65')}];case _0xf5c5('0x66'):return[{'name':_0xf5c5('0x67'),'value':_0x6d12be['attrPath']||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0][_0xf5c5('0x64')]:undefined)||''}];case _0xf5c5('0x68'):return[{'name':_0xf5c5('0x69'),'value':_0x6d12be['attrHourFormat']||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0][_0xf5c5('0x64')]:undefined)||_0xf5c5('0x6a')},{'name':_0xf5c5('0x6b'),'value':_0x6d12be[_0xf5c5('0x6b')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x1]?_0x6d12be['attrs'][0x1][_0xf5c5('0x64')]:undefined)||_0xf5c5('0x6c')},{'name':_0xf5c5('0x6d'),'value':_0x6d12be[_0xf5c5('0x6d')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x2]?_0x6d12be['attrs'][0x2]['value']:undefined)||0xc}];case _0xf5c5('0x6e'):return[{'name':_0xf5c5('0x6f'),'value':_0x6d12be[_0xf5c5('0x6f')]||(_0x6d12be['attrs']&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0][_0xf5c5('0x64')]:undefined)||_0xf5c5('0x70')},{'name':_0xf5c5('0x71'),'value':_0x6d12be[_0xf5c5('0x71')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x1]?_0x6d12be[_0xf5c5('0x63')][0x1]['value']:undefined)||[]},{'name':_0xf5c5('0x6d'),'value':_0x6d12be[_0xf5c5('0x6d')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x2]?_0x6d12be[_0xf5c5('0x63')][0x2][_0xf5c5('0x64')]:undefined)||0x14}];case _0xf5c5('0x72'):case _0xf5c5('0x73'):return[{'name':_0xf5c5('0x74'),'value':_0x6d12be[_0xf5c5('0x74')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0][_0xf5c5('0x64')]:undefined)||'total'},{'name':'attrSerie2','value':_0x6d12be[_0xf5c5('0x75')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x1]?_0x6d12be['attrs'][0x1][_0xf5c5('0x64')]:undefined)||null},{'name':_0xf5c5('0x76'),'value':_0x6d12be['attrSerie3']||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be['attrs'][0x2]?_0x6d12be['attrs'][0x2]['value']:undefined)||null},{'name':_0xf5c5('0x71'),'value':_0x6d12be[_0xf5c5('0x71')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x3]?_0x6d12be[_0xf5c5('0x63')][0x3][_0xf5c5('0x64')]:undefined)||[]}];case _0xf5c5('0x77'):return[{'name':_0xf5c5('0x78'),'type':_0x6d12be[_0xf5c5('0x79')]||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0]['type']:undefined)||null,'value':_0x6d12be['attrReport']||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x0]?_0x6d12be[_0xf5c5('0x63')][0x0][_0xf5c5('0x64')]:undefined)||null},{'name':'attrRefresh','value':_0x6d12be['attrRefresh']||(_0x6d12be[_0xf5c5('0x63')]&&_0x6d12be[_0xf5c5('0x63')][0x1]?_0x6d12be[_0xf5c5('0x63')][0x1][_0xf5c5('0x64')]:undefined)||0x0}];default:return[];}}catch(_0x1faae0){logger['error'](_0xf5c5('0x7a'),JSON[_0xf5c5('0x7b')](_0x1faae0));return[];}}exports['addItem']=function(_0x50c170,_0x1e2adf,_0x47bfa8){if(_0x50c170[_0xf5c5('0x55')]['id']){delete _0x50c170[_0xf5c5('0x55')]['id'];}return db[_0xf5c5('0x37')][_0xf5c5('0x53')]({'where':{'id':_0x50c170[_0xf5c5('0x51')]['id']}})[_0xf5c5('0x2f')](handleEntityNotFound(_0x1e2adf,null))['then'](function(_0x10acea){if(_0x10acea){_0x50c170[_0xf5c5('0x55')][_0xf5c5('0x7c')]=_0x10acea['id'];_0x50c170[_0xf5c5('0x55')][_0xf5c5('0x63')]=widgetAttributes(_0x50c170['body']);return db['DashboardItem'][_0xf5c5('0x54')](_0x50c170[_0xf5c5('0x55')]);}})[_0xf5c5('0x2f')](respondWithResult(_0x1e2adf,null))['catch'](handleError(_0x1e2adf,null));};exports[_0xf5c5('0x7d')]=function(_0x26533f,_0x1415e6,_0x237dc5){var _0x4f3e0e={};var _0x4a9994={};var _0x585ba6;var _0x50ce09;return db[_0xf5c5('0x37')][_0xf5c5('0x7e')]({'where':{'id':_0x26533f['params']['id']}})[_0xf5c5('0x2f')](handleEntityNotFound(_0x1415e6,null))[_0xf5c5('0x2f')](function(_0x55c47c){if(_0x55c47c){_0x585ba6=_0x55c47c;_0x4a9994['model']=_['keys'](db['DashboardItem'][_0xf5c5('0x52')]);_0x4a9994[_0xf5c5('0x3c')]=_[_0xf5c5('0x3d')](_0x26533f[_0xf5c5('0x3c')]);_0x4a9994[_0xf5c5('0x3e')]=_[_0xf5c5('0x3f')](_0x4a9994[_0xf5c5('0x3b')],_0x4a9994['query']);_0x4f3e0e[_0xf5c5('0x40')]=_[_0xf5c5('0x3f')](_0x4a9994[_0xf5c5('0x3b')],qs[_0xf5c5('0x41')](_0x26533f[_0xf5c5('0x3c')][_0xf5c5('0x41')]));_0x4f3e0e[_0xf5c5('0x40')]=_0x4f3e0e[_0xf5c5('0x40')][_0xf5c5('0x42')]?_0x4f3e0e[_0xf5c5('0x40')]:_0x4a9994[_0xf5c5('0x3b')];_0x4f3e0e[_0xf5c5('0x7f')]=qs[_0xf5c5('0x45')](_0x26533f[_0xf5c5('0x3c')][_0xf5c5('0x45')]);_0x4f3e0e[_0xf5c5('0x46')]=qs['filters'](_[_0xf5c5('0x47')](_0x26533f[_0xf5c5('0x3c')],_0x4a9994[_0xf5c5('0x3e')]));if(_0x26533f[_0xf5c5('0x3c')][_0xf5c5('0x48')]){_0x4f3e0e['where']=_[_0xf5c5('0x49')](_0x4f3e0e['where'],{'$or':_[_0xf5c5('0x36')](_0x4f3e0e[_0xf5c5('0x40')],function(_0x14e5c1){var _0x289454={};_0x289454[_0x14e5c1]={'$like':'%'+_0x26533f[_0xf5c5('0x3c')][_0xf5c5('0x48')]+'%'};return _0x289454;})});}_0x4f3e0e=_['merge']({},_0x4f3e0e,_0x26533f[_0xf5c5('0x4b')]);return _0x585ba6[_0xf5c5('0x7d')](_0x4f3e0e);}})[_0xf5c5('0x2f')](function(_0x41f9b4){if(_0x41f9b4){_0x50ce09=_0x41f9b4[_0xf5c5('0x42')];if(!_0x26533f['query'][_0xf5c5('0x43')]('nolimit')){_0x4f3e0e[_0xf5c5('0x23')]=qs['limit'](_0x26533f[_0xf5c5('0x3c')][_0xf5c5('0x23')]);_0x4f3e0e[_0xf5c5('0x22')]=qs[_0xf5c5('0x22')](_0x26533f[_0xf5c5('0x3c')]['offset']);}return _0x585ba6[_0xf5c5('0x7d')](_0x4f3e0e);}})[_0xf5c5('0x2f')](function(_0x2d635f){if(_0x2d635f){return _0x2d635f?{'count':_0x50ce09,'rows':_0x2d635f}:null;}})[_0xf5c5('0x2f')](respondWithResult(_0x1415e6,null))[_0xf5c5('0x50')](handleError(_0x1415e6,null));};