Built motion from commit b517aaa2a6638133380e4d135c64a80893061362. Version 3.0.0...
[motion-next.git] / server / api / dashboardItem / dashboardItem.controller.js
1 const a175_0x4ee6=['pie-chart','attrSerie2','attrs','../../components/parsers/qs','catch','lodash','params','length','custom','name','update','include','intersection','attrMetric','fields','register','sendStatus','attrTimezone','https://','./dashboardItem.socket','stringify','attributes','value','attrRefresh','merge','counter','keys','DashboardItem','clock','0.00','reportType','model','total','end','api','attrSerie1','then','attrHourFormat','body','multibar-chart','destroy','../../rediscache','attrSerie3','send','web-report','error','rawAttributes','attrVoiceQueues','attrFontSize','type','attrUrl','status','attrReport','query','../../config/logger','json','show','findOne'];(function(_0x3d84fb,_0x4ee6ed){const _0x1412d3=function(_0x245c5f){while(--_0x245c5f){_0x3d84fb['push'](_0x3d84fb['shift']());}};_0x1412d3(++_0x4ee6ed);}(a175_0x4ee6,0x1d2));const a175_0x1412=function(_0x3d84fb,_0x4ee6ed){_0x3d84fb=_0x3d84fb-0x0;let _0x1412d3=a175_0x4ee6[_0x3d84fb];return _0x1412d3;};const _0x13e1d5=a175_0x1412;'use strict';const _=require(_0x13e1d5('0x3')),qs=require(_0x13e1d5('0x1')),logger=require(_0x13e1d5('0x34'))(_0x13e1d5('0x20')),{getSocket}=require(_0x13e1d5('0x27')),socket=getSocket(),db=require('../../mysqldb')['db'];require(_0x13e1d5('0x11'))[_0x13e1d5('0xd')](socket);function respondWithResult(_0x245c5f,_0x4a862d){return _0x4a862d=_0x4a862d||0xc8,function(_0x4bd023){const _0x58877d=a175_0x1412;if(_0x4bd023)return _0x245c5f[_0x58877d('0x31')](_0x4a862d)[_0x58877d('0x35')](_0x4bd023);};}function saveUpdates(_0x292c80){return function(_0xf41205){const _0x489079=a175_0x1412;if(_0xf41205)return _0xf41205[_0x489079('0x8')](_0x292c80)[_0x489079('0x22')](function(_0x1e9180){return _0x1e9180;});return null;};}function removeEntity(_0x33d5dc){return function(_0x26373f){if(_0x26373f)return _0x26373f['destroy']()['then'](function(){const _0x540d28=a175_0x1412;_0x33d5dc[_0x540d28('0x31')](0xcc)[_0x540d28('0x1f')]();});};}function handleEntityNotFound(_0x45b69f){return function(_0x4b7598){const _0x3e9c9b=a175_0x1412;return!_0x4b7598&&_0x45b69f[_0x3e9c9b('0xe')](0x194),_0x4b7598;};}function handleError(_0x38c274,_0x3a211d){return _0x3a211d=_0x3a211d||0x1f4,function(_0x3c03f2){const _0x3604dc=a175_0x1412;logger[_0x3604dc('0x2b')](_0x3c03f2['stack']),_0x3c03f2[_0x3604dc('0x7')]&&delete _0x3c03f2[_0x3604dc('0x7')],_0x38c274[_0x3604dc('0x31')](_0x3a211d)[_0x3604dc('0x29')](_0x3c03f2);};}exports[_0x13e1d5('0x36')]=function(_0x443314,_0x13755b){const _0x3d6a33=_0x13e1d5;let _0x126a13={'raw':![],'where':{'id':_0x443314[_0x3d6a33('0x4')]['id']}};const _0x289cdd={};return _0x289cdd[_0x3d6a33('0x1d')]=_[_0x3d6a33('0x18')](db[_0x3d6a33('0x19')][_0x3d6a33('0x2c')]),_0x289cdd[_0x3d6a33('0x33')]=_[_0x3d6a33('0x18')](_0x443314['query']),_0x289cdd['filters']=_[_0x3d6a33('0xa')](_0x289cdd[_0x3d6a33('0x1d')],_0x289cdd['query']),_0x126a13[_0x3d6a33('0x13')]=_['intersection'](_0x289cdd[_0x3d6a33('0x1d')],qs['fields'](_0x443314[_0x3d6a33('0x33')][_0x3d6a33('0xc')])),_0x126a13[_0x3d6a33('0x13')]=_0x126a13[_0x3d6a33('0x13')][_0x3d6a33('0x5')]?_0x126a13[_0x3d6a33('0x13')]:_0x289cdd['model'],_0x443314['query']['includeAll']&&(_0x126a13[_0x3d6a33('0x9')]=[{'all':!![]}]),_0x126a13=_[_0x3d6a33('0x16')]({},_0x126a13,_0x443314['options']),db['DashboardItem'][_0x3d6a33('0x37')](_0x126a13)['then'](handleEntityNotFound(_0x13755b,null))[_0x3d6a33('0x22')](respondWithResult(_0x13755b,null))['catch'](handleError(_0x13755b,null));},exports[_0x13e1d5('0x26')]=function(_0xaf5b5,_0x272dde){const _0x20dbcd=_0x13e1d5;return db[_0x20dbcd('0x19')][_0x20dbcd('0x37')]({'where':{'id':_0xaf5b5[_0x20dbcd('0x4')]['id']}})[_0x20dbcd('0x22')](handleEntityNotFound(_0x272dde,null))[_0x20dbcd('0x22')](removeEntity(_0x272dde,null))[_0x20dbcd('0x2')](handleError(_0x272dde,null));};function widgetAttributes(_0x228cce){const _0x40868f=_0x13e1d5;try{switch(_0x228cce['type']){case'iframe':return[{'name':_0x40868f('0x30'),'value':_0x228cce[_0x40868f('0x30')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce[_0x40868f('0x0')][0x0]?_0x228cce[_0x40868f('0x0')][0x0][_0x40868f('0x14')]:undefined)||_0x40868f('0x10')}];case _0x40868f('0x6'):return[{'name':'attrPath','value':_0x228cce['attrPath']||(_0x228cce['attrs']&&_0x228cce[_0x40868f('0x0')][0x0]?_0x228cce['attrs'][0x0][_0x40868f('0x14')]:undefined)||''}];case _0x40868f('0x1a'):return[{'name':_0x40868f('0x23'),'value':_0x228cce[_0x40868f('0x23')]||(_0x228cce['attrs']&&_0x228cce[_0x40868f('0x0')][0x0]?_0x228cce[_0x40868f('0x0')][0x0][_0x40868f('0x14')]:undefined)||'HH:mm:ss'},{'name':_0x40868f('0xf'),'value':_0x228cce[_0x40868f('0xf')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce[_0x40868f('0x0')][0x1]?_0x228cce[_0x40868f('0x0')][0x1][_0x40868f('0x14')]:undefined)||_0x40868f('0x1b')},{'name':'attrFontSize','value':_0x228cce['attrFontSize']||(_0x228cce['attrs']&&_0x228cce[_0x40868f('0x0')][0x2]?_0x228cce[_0x40868f('0x0')][0x2][_0x40868f('0x14')]:undefined)||0xc}];case _0x40868f('0x17'):return[{'name':'attrMetric','value':_0x228cce[_0x40868f('0xb')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce['attrs'][0x0]?_0x228cce['attrs'][0x0][_0x40868f('0x14')]:undefined)||_0x40868f('0x1e')},{'name':_0x40868f('0x2d'),'value':_0x228cce[_0x40868f('0x2d')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce['attrs'][0x1]?_0x228cce[_0x40868f('0x0')][0x1][_0x40868f('0x14')]:undefined)||[]},{'name':'attrFontSize','value':_0x228cce[_0x40868f('0x2e')]||(_0x228cce['attrs']&&_0x228cce[_0x40868f('0x0')][0x2]?_0x228cce[_0x40868f('0x0')][0x2]['value']:undefined)||0x14}];case _0x40868f('0x25'):case _0x40868f('0x38'):return[{'name':_0x40868f('0x21'),'value':_0x228cce[_0x40868f('0x21')]||(_0x228cce['attrs']&&_0x228cce['attrs'][0x0]?_0x228cce[_0x40868f('0x0')][0x0][_0x40868f('0x14')]:undefined)||_0x40868f('0x1e')},{'name':_0x40868f('0x39'),'value':_0x228cce[_0x40868f('0x39')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce['attrs'][0x1]?_0x228cce[_0x40868f('0x0')][0x1][_0x40868f('0x14')]:undefined)||null},{'name':_0x40868f('0x28'),'value':_0x228cce[_0x40868f('0x28')]||(_0x228cce['attrs']&&_0x228cce[_0x40868f('0x0')][0x2]?_0x228cce[_0x40868f('0x0')][0x2][_0x40868f('0x14')]:undefined)||null},{'name':_0x40868f('0x2d'),'value':_0x228cce[_0x40868f('0x2d')]||(_0x228cce['attrs']&&_0x228cce[_0x40868f('0x0')][0x3]?_0x228cce['attrs'][0x3][_0x40868f('0x14')]:undefined)||[]}];case _0x40868f('0x2a'):return[{'name':_0x40868f('0x32'),'type':_0x228cce[_0x40868f('0x1c')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce[_0x40868f('0x0')][0x0]?_0x228cce[_0x40868f('0x0')][0x0][_0x40868f('0x2f')]:undefined)||null,'value':_0x228cce['attrReport']||(_0x228cce[_0x40868f('0x0')]&&_0x228cce[_0x40868f('0x0')][0x0]?_0x228cce['attrs'][0x0][_0x40868f('0x14')]:undefined)||null},{'name':'attrRefresh','value':_0x228cce[_0x40868f('0x15')]||(_0x228cce[_0x40868f('0x0')]&&_0x228cce[_0x40868f('0x0')][0x1]?_0x228cce['attrs'][0x1][_0x40868f('0x14')]:undefined)||0x0}];default:return[];}}catch(_0x1cc47b){return logger[_0x40868f('0x2b')]('widgetAttributes:\x20%s',JSON[_0x40868f('0x12')](_0x1cc47b)),[];}}exports['create']=function(_0x317ca1,_0x1d4b25){const _0x5d4906=_0x13e1d5;return _0x317ca1[_0x5d4906('0x24')]&&(_0x317ca1[_0x5d4906('0x24')]['attrs']=widgetAttributes(_0x317ca1[_0x5d4906('0x24')])),db['DashboardItem']['create'](_0x317ca1[_0x5d4906('0x24')],{})[_0x5d4906('0x22')](respondWithResult(_0x1d4b25,0xc9))[_0x5d4906('0x2')](handleError(_0x1d4b25,null));},exports['update']=function(_0x15ff47,_0x240d1e){const _0x4b5748=_0x13e1d5;return _0x15ff47['body']['id']&&delete _0x15ff47[_0x4b5748('0x24')]['id'],_0x15ff47['body']['attrs']=widgetAttributes(_0x15ff47[_0x4b5748('0x24')]),db['DashboardItem'][_0x4b5748('0x37')]({'where':{'id':_0x15ff47['params']['id']}})[_0x4b5748('0x22')](handleEntityNotFound(_0x240d1e,null))[_0x4b5748('0x22')](saveUpdates(_0x15ff47['body'],null))['then'](respondWithResult(_0x240d1e,null))[_0x4b5748('0x2')](handleError(_0x240d1e,null));};