diff --git a/ui/js/main.js b/ui/js/main.js index 7a1f11e3bbb39652236af37c1d79caa07a6b99e7..5cd158dd72242b615d882de806a293db376e14bf 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -1,18 +1,18 @@ -var fActive=false; -var fChangedCallback=[]; +/* globals Ext, dss, _, Gettext */ + +var fActive = false; +var fChangedCallback = []; var iSubscriptDemo; -var lastUpdate=0; -var lastValue=0; +var lastUpdate = 0; +var lastValue = 0; var fStepperBound; -var oGrid=null; +var oGrid = null; var selecterObject; -function initializeConsole() { + +function initializeConsole () { var method; - var noop = function () {}; - var methods = [ - 'info', 'log', 'time', 'timeEnd', - 'debug', 'trace', 'warn' - ]; + var noop = function () {}; // eslint-disable-line no-empty-function + var methods = [ 'info', 'log', 'time', 'timeEnd', 'debug', 'trace', 'warn' ]; var length = methods.length; var console = (window.console = window.console || {}); @@ -26,128 +26,133 @@ function initializeConsole() { } } -function changeListener(sValue) { - - var oValue=JSON.parse(sValue); - var fActiveTemp=false; - if (oValue!=null) - if (oValue.result!=null) - if (oValue.result.value!=null) { - if (oValue.result.value) - fActiveTemp=true; - } - fActive=fActiveTemp; - for (var iIndex=0;iIndex<fChangedCallback.length;iIndex++) - fChangedCallback[iIndex](); +function changeListener (sValue) { + var oValue = JSON.parse(sValue); + var fActiveTemp = false; + if (oValue && oValue.result && oValue.result.value) { + fActiveTemp = true; + } + fActive = fActiveTemp; + for (var iIndex = 0; iIndex < fChangedCallback.length; iIndex++) { + fChangedCallback[iIndex](); + } } -function requestAndUpdateDatabase() { - dss.raiseEvent('led-wizard.startImport',{}); -} +function requestAndUpdateDatabase () { + dss.raiseEvent('led-wizard.startImport', {}); +} -function startListener() { - dss.ajaxAssyncRequestWithoutAnswer('/json/property/getBoolean',{path:'/scripts/led-wizard/demo/state'},changeListener); +function startListener () { + dss.ajaxAssyncRequestWithoutAnswer('/json/property/getBoolean', { path: '/scripts/led-wizard/demo/state' }, changeListener); - iSubscriptDemo = Math.floor(Math.random() * 100000000000); - dss.ajaxSyncRequest('/json/event/subscribe', { - subscriptionID : iSubscriptDemo, - name : 'led-wizard.answer' - }); - refreshListener(); + iSubscriptDemo = Math.floor(Math.random() * 100000000000); + dss.ajaxSyncRequest('/json/event/subscribe', { + subscriptionID: iSubscriptDemo, + name: 'led-wizard.answer' + }); + refreshListener(); } -function refreshListener() { - dss.ajaxAssyncRequestWithoutAnswer('/json/event/get', { - subscriptionID : iSubscriptDemo, - timeout : 5 * 1000 - }, function(answer) { +function refreshListener () { + dss.ajaxAssyncRequestWithoutAnswer('/json/event/get', { + subscriptionID: iSubscriptDemo, + timeout: 5 * 1000 + }, function (answer) { try { var result = Ext.JSON.decode(answer); - if (result.ok==false) { - iSubscriptDemo = Math.floor(Math.random() * 100000000000); - dss.ajaxSyncRequest('/json/event/subscribe', { - subscriptionID : iSubscriptDemo, - name : 'led-wizard.answer' - }); - refreshListener(); - return; + if (!result.ok) { + iSubscriptDemo = Math.floor(Math.random() * 100000000000); + dss.ajaxSyncRequest('/json/event/subscribe', { + subscriptionID: iSubscriptDemo, + name: 'led-wizard.answer' + }); + refreshListener(); + return; } - if (result.result == null) { - dss.ajaxAssyncRequestWithoutAnswer('/json/property/getBoolean',{path:'/scripts/led-wizard/demo/state'},changeListener); - } else { - for (var iIndex=0;iIndex<result.result.events.length;iIndex++) { - var oItem=result.result.events[iIndex].properties; - switch (oItem.type) { - case'step':{ - if (fStepperBound!=null) - fStepperBound(answer); - } - break; - case 'demo':{ - if (oItem.state!=null) { - fActive=(oItem.state=="true"); - } - if (oItem.step!=null) { - lastValue=Math.floor(parseInt(oItem.step,10)/2.56); - } - for (var jIndex=0;jIndex<fChangedCallback.length;jIndex++) - fChangedCallback[jIndex](); - } - break; - case 'saveDB':{ - oGrid.setStatus(_('Loading ...')); - refreshIlluminantDB(); - } - break; - case 'curves': { - //illuminateTypeStore - - var IllminatID=oItem.illumant; - var curveValues=Ext.JSON.decode(oItem.data); - - for (var iIndex=0;iIndex<curveValues.length;iIndex++) { - curveValues[iIndex]._id=curveValues[iIndex].pos; - curveValues[iIndex].value=curveValues[iIndex].val; - } - curveValues.sort(function(a,b){return a._id-b._id;}); - var oRecord=Ext.data.StoreManager.lookup('illuminateTypeStore').findRecord('_id',IllminatID,0,false,false,true); - var fCurve=false; - var dimmMax=0; - var fMin=false; - var dimmMinimum=oRecord.get('dimmMinimum'); - for (kIndex=0;kIndex<curveValues.length;kIndex++) { - if (curveValues[kIndex]!=null) { - if (!fMin) - if (curveValues[kIndex]._id<=dimmMinimum) - if (dimmMinimum<curveValues[kIndex+1]._id) { - var oTempMinDim=curveValues[kIndex].value; - dimmMinimum=Math.round(oTempMinDim/100); - fMin=true; - fCurve=true; - } - if (curveValues[kIndex].value==9999) - fCurve=false; - - if (fCurve) - curveValues[kIndex].window=9999; - else - curveValues[kIndex].window=0; - } - } - oRecord.set('curveValues',curveValues); - oRecord.set('dimmMinimum',dimmMinimum); - selecterObject.refreshSelection(); - } - break; - } - - } - } - } catch (e) {console.log("exception " + e.message+ " in refreshListener(): " + answer);} - refreshListener(); - }); + if (result.result == null) { + dss.ajaxAssyncRequestWithoutAnswer('/json/property/getBoolean', { path: '/scripts/led-wizard/demo/state' }, changeListener); + } else { + for (var iIndex = 0; iIndex < result.result.events.length; iIndex++) { + var oItem = result.result.events[iIndex].properties; + switch (oItem.type) { + case 'step': { + if (fStepperBound != null) { + fStepperBound(answer); + } + break; + } + case 'demo': { + if (oItem.state != null) { + fActive = oItem.state === 'true'; + } + if (oItem.step != null) { + lastValue = Math.floor(parseInt(oItem.step, 10) / 2.56); + } + for (var jIndex = 0; jIndex < fChangedCallback.length; jIndex++) { + fChangedCallback[jIndex](); + } + break; + } + case 'saveDB': { + oGrid.setStatus(_('Loading ...')); + refreshIlluminantDB(); + break; + } + case 'curves': { + // illuminateTypeStore + + var IllminatID = oItem.illumant; + var curveValues = Ext.JSON.decode(oItem.data); + + for (var lIndex = 0; lIndex < curveValues.length; lIndex++) { + curveValues[lIndex]._id = curveValues[lIndex].pos; + curveValues[lIndex].value = curveValues[lIndex].val; + } + curveValues.sort(function (a, b) { + return a._id - b._id; + }); + var oRecord = Ext.data.StoreManager.lookup('illuminateTypeStore').findRecord('_id', IllminatID, 0, false, false, true); + var fCurve = false; + var fMin = false; + var dimmMinimum = oRecord.get('dimmMinimum'); + for (var kIndex = 0; kIndex < curveValues.length; kIndex++) { + if (curveValues[kIndex] == null) { + continue; + } + if ( + !fMin && + curveValues[kIndex]._id <= dimmMinimum && + dimmMinimum < curveValues[kIndex + 1]._id + ) { + var oTempMinDim = curveValues[kIndex].value; + dimmMinimum = Math.round(oTempMinDim / 100); + fMin = true; + fCurve = true; + } + if (curveValues[kIndex].value == 9999) { + fCurve = false; + } + if (fCurve) { + curveValues[kIndex].window = 9999; + } else { + curveValues[kIndex].window = 0; + } + } + oRecord.set('curveValues', curveValues); + oRecord.set('dimmMinimum', dimmMinimum); + selecterObject.refreshSelection(); + break; + } + } + } + } + } catch (e) { + console.log('exception ' + e.message + ' in refreshListener(): ' + answer); + } + refreshListener(); + }); } - + Ext.define('DSS.addon.Lizard', { extend: 'DSS.addon.Framework', @@ -156,14 +161,14 @@ Ext.define('DSS.addon.Lizard', { appName: _('LED Wizard'), appId: 'led-wizard', appVersion: '1.1.5', - dSSVersion : '1.9.0', + dSSVersion: '1.9.0', appIcon: 'default_icon.png' }, - getHelp: function() { + getHelp: function () { return Ext.create('Ext.Component', { - whiteSpace : 'normal', - padding : '0 20 0 0', //top right bottom left + whiteSpace: 'normal', + padding: '0 20 0 0', // top right bottom left loader: { url: 'locale/' + dss.staticDataModel.activeLanguage + '/help.html', autoLoad: true, @@ -171,964 +176,996 @@ Ext.define('DSS.addon.Lizard', { } }); }, - myGrid:null, + myGrid: null, setTestButtons: function () { - if (this.myGrid==null) - return; + if (this.myGrid == null) { + return; + } if (fActive) { - this.myGrid.btnDelete.setDisabled(true); - this.myGrid.btnCustom[0].setDisabled(true); - this.myGrid.btnCustom[1].setDisabled(false); + this.myGrid.btnDelete.setDisabled(true); + this.myGrid.btnCustom[0].setDisabled(true); + this.myGrid.btnCustom[1].setDisabled(false); } else { - this.myGrid.btnDelete.setDisabled((this.myGrid.curSelectedEvent==null)); - this.myGrid.btnCustom[0].setDisabled(false); - this.myGrid.btnCustom[1].setDisabled(true); + this.myGrid.btnDelete.setDisabled((this.myGrid.curSelectedEvent == null)); + this.myGrid.btnCustom[0].setDisabled(false); + this.myGrid.btnCustom[1].setDisabled(true); } }, - isSupportedDevice: function (device) { - return ((((device.functionID & 0xf000) >> 12) === 1) && - (([ - 200, // GE-KM200 - 6344, // GE-SDS200-CW - 6345, // GE-SDS200-CS - 1234, // GE-TKM210 - 2248, // GE-SDM200 - 2249, // GE-SDM200-JS - 2250, // GE-SDM200-CS - 6364, // GE-SDS220-CT - 300, // GE-KM300 - 1324, // GE-TKM300 - 15660, // GE-ZWD300 - 2348, // GE-SDM300-W - 2349 // GE-SDM300-S - ].indexOf(device.productID) !== -1) && (device.outputMode !== 0))); - }, - startWizard: function() { - var me=this; - if (this.wizardDialog!=null) { - return; - } - - var DeviceSelector; - var DefaultDimmingProcessor= Ext.create('DSS.addon.Lizard.DefaultDimmingProcessor',{}); - var ModeControl= Ext.create('DSS.addon.Lizard.ModeControl',{}); - var MinValueControl= Ext.create('DSS.addon.Lizard.MinValueControl',{}); - var MaxValueControl= Ext.create('DSS.addon.Lizard.MaxValueControl',{}); - var TransmitControl= Ext.create('DSS.addon.Lizard.TransmitControl',{}); - var TestControl= Ext.create('DSS.addon.Lizard.TestControl',{}); - - this.wizardDialog=Ext.create('DSS.component.Wizard', { - height:400, - width:750, - title:_('LED configuration wizard'), - pages:[{ - shortTitle:_('Select device'), - longTitle:_('Step 1: Device selection'), - longDescription: _('Select a dimming device'), - controls:[{ - type : 'deviceSelection', - id : 'dsuid', - multiselect : true, - width:600, - filterFunc: this.isSupportedDevice, - specialDeviceRenderer: function(val, metadata, record, colIdx, store, view) { - var sReturn='<table style="height:16px;"><tr>'; - sReturn+='<td><img src="' + record.get('icon') + '" style="margin-right: 5px;"></td>'; - sReturn+='<td width="100%">' + record.get('name') + '</td><td>'; - sReturn+=dss.staticDataModel.getProductNameForDevice(dss.staticDataModel.getDevice(record.get('dSUID')))+'</td>'; - switch (dss.staticDataModel.getDevice(record.get('dSUID')).outputMode) { - case 22: - sReturn+='<td style="padding-left:5px;">' + _('dimmed (trailing edge)') + '</td>'; - break; - case 20: - sReturn+='<td style="padding-left:5px;">' + _('dimmed (leading edge)') + '</td>'; - break; - case 31: - sReturn+='<td style="padding-left:5px;">' + _('dimmed (automatic)') + '</td>'; - break; - default: - sReturn+='<td style="padding-left:5px;">' + _('switched') + '</td>'; - break; - - } - return sReturn +'</tr></table>'; - }, - constrainFunc: function (id,values) { - if (values.prepared!=null) - return false; - return true; - } }] - },{ - shortTitle:_('Prepare device'), - longTitle:_('Step 2: Preparing the device'), - longDescription: _('A universal dimming curve is transmitted to the selected device to allow the full phase angle dimming spectrum. Please wait until the process is finished. Step 3 will start automatically.'), - controls:[{ - id:'prepared', - type:'custom', - control:DefaultDimmingProcessor - }], - hideBack:true, - constrainFunc: function (id,values) { - if (values.prepared!=null) - if (values.prepared) - return false; - if (values.minDimm!=null) - return false; - - if (values.dsuid!=null) - if (values.dsuid.length>0) - return true; - return false; - } - },{ - shortTitle:_('Dimming Mode'), - longTitle:_('Step 3: Determine the dimming mode'), - longDescription: _('Dimming Mode must be set.'), - controls:[{ - id:'mode', - type:'custom', - control:ModeControl - }], - hideBack:true, - constrainFunc: function (id,values) { - if (values.prepared!=null) - if (values.prepared) - if (values.dsuid!=null) - if (values.dsuid.length>0) - return true; - return false; - } - },{ - shortTitle:_('Min value'), - longTitle:_('Step 4: Determine the minimum brightness value'), - longDescription: _('Now we need to determinate the minimum brightness value of the light bulb.<br>'+ - 'Light bulbs tend to flicker at very low brightness. Also dimming them on from an off-state normally requires a higher '+ - 'brightness than it may be possible by dimming them down in an on-state. The minimum value needs to ensure a save start '+ - 'start of the light bulb from an off state.<br>Therefore it is important to set the light bulb into an off-state and then ' + - 'start dimming it up slowly to find the value where the lamp gets on and doesn\'t flicker. You are allowed to dim a step '+ - 'down, but then the wizard will automatically turn the light bulb off, waits 2 seconds and then turns it on to the desired value.<br>'+ - 'After that, click \"Continue\".'), - controls:[{ - id:'minDimm', - type:'custom', - control:MinValueControl - }], - hideBack:true, - constrainFunc: function (id,values) { - if (values.prepared!=null) - if (values.prepared) - if (values.dsuid!=null) - if (values.dsuid.length>0) - return true; - return false; - } - },{ - shortTitle:_('Max value'), - longTitle:_('Step 5: Determine the maximum brightness value'), - longDescription: _('It\'s important to fine the correct maximum brightness value to ensure getting the maximum brightness out of the light bulb ' + - 'and additionally havein a perfect dimming behavior.<br><b>Important:</b> To protect your eyes, please look onto a wall instead of looking ' + - 'directly into the loght blub!<br><br>Please start by moving the selector repeatedly to find the lowest value which already delivers ' + - 'the highest possible brightness. You can finetune the value by using the up/down buttons. You can compare your selected value ' + - 'with the maximum value by selecting \"max value\" which returns automatically to your selected value after 5 seconds.<br>' + - 'After that, click \"Continue\".'), - controls:[{ - id:'maxDimm', - type:'custom', - control:MaxValueControl - }], - constrainFunc: function (id,values) { - if (values.prepared!=null) - if (values.prepared) - if (values.dsuid!=null) - if (values.dsuid.length>0) - if (values.minDimm!=null) - return true; - return false; - } - },{ - shortTitle:_('Generate curve'), - longTitle:_('Step 6: Generate dimming curve and transmit to device'), - longDescription: _('A dimming curve is generated using your selected minimum and maximum values. After that the dimming curve is transmitted to the selected device Please wait until the process is finished. Step 6 will start automatically.'), - controls:[{ - id:'finishedValue', - type:'custom', - control:TransmitControl - }], - constrainFunc: function (id,values) { - if (values.prepared!=null) - if (values.prepared) - if (values.dsuid!=null) - if (values.dsuid.length>0) - if (values.minDimm!=null) - if (values.maxDimm!=null) - return true; - return false; - } - },{ - shortTitle:_('Test curve'), - longTitle:_('Step 7: Test your dimming curve'), - longDescription: _('Here you can test your new dimming curve. After that, please finish the wizard.'), - controls:[{ - id:'_alsoSkip', - type:'custom', - control:TestControl - }], - hideBack:true, - constrainFunc: function (id,values) { - if (values.finishedValue!=null) - return values.finishedValue; - return false; - } - }], - startLongTitle:_('LED Dimming wizard - longer title'), - hideLeftFinish:true, - startDescription:_('This wizard will help you for manually determinate a dimming curve'), - finishFunc: function (values) { - me.loadParameter(me.myGrid); - } - }); - this.wizardDialog.addListener("hide",function () { - me.wizardDialog=null; - }); - this.wizardDialog.startWizard(); + isSupportedDevice: function (device) { + return ( + (((device.functionID & 0xf000) >> 12) === 1) && + [ + 200, // GE-KM200 + 6344, // GE-SDS200-CW + 6345, // GE-SDS200-CS + 1234, // GE-TKM210 + 2248, // GE-SDM200 + 2249, // GE-SDM200-JS + 2250, // GE-SDM200-CS + 6364, // GE-SDS220-CT + 300, // GE-KM300 + 1324, // GE-TKM300 + 15660, // GE-ZWD300 + 2348, // GE-SDM300-W + 2349 // GE-SDM300-S + ].indexOf(device.productID) !== -1 && + device.outputMode !== 0 + ); }, - illuminantTestControl:null, - illuminantManualControl:null, - illuminantTypeControl:null, - getContent: function() { - var me=this; - this.illuminantTypeControl= Ext.create('DSS.addon.IlluminantType' ,{}); - this.illuminantTestControl= Ext.create('DSS.addon.IlluminantTest' ,{}); - this.illuminantManualControl= Ext.create('DSS.addon.IlluminantManual' ,{}); - this.illuminantTypeControl.parent = this; - - var oConfig={ - defaultSortCol:'name', - grouperField: 'grouping', - multiselect: true, - storeConfig: { - storeId : 'lizardStore', - fields : [ {name:'id'}, - {name:'dsid', sortType:'asUCText'}, - {name:'dsuid', sortType:'asUCText'}, - {name:'devicename', sortType:'asUCText'}, - {name:'catalogeID', sortType:'asUCText'}, - {name:'ts'}, - {name:'aaa'}, - {name:'present'}, - {name: 'grouping', sortType: 'asUCText'}] - }, - columns: [ { - header : _('Device name'), - dataIndex : 'devicename', - renderer: function (val, metadata, record, rowIdx, colIdx, store, view) { - var oDevice = dss.staticDataModel.getDevice(record.get('dsuid')); - if (record.get('present') === '') { - //device is not known to dSS - metadata.css='grid-cell-completly-wrong'; - } - if (record.get('present') === false) { - //device is currently not connected to dSS - metadata.css='grid-cell-temporary-wrong'; + startWizard: function () { + var me = this; + if (this.wizardDialog != null) { + return; + } + + var DefaultDimmingProcessor = Ext.create('DSS.addon.Lizard.DefaultDimmingProcessor', {}); + var ModeControl = Ext.create('DSS.addon.Lizard.ModeControl', {}); + var MinValueControl = Ext.create('DSS.addon.Lizard.MinValueControl', {}); + var MaxValueControl = Ext.create('DSS.addon.Lizard.MaxValueControl', {}); + var TransmitControl = Ext.create('DSS.addon.Lizard.TransmitControl', {}); + var TestControl = Ext.create('DSS.addon.Lizard.TestControl', {}); + + this.wizardDialog = Ext.create('DSS.component.Wizard', { + height: 446, + width: 750, + title: _('LED configuration wizard'), + pages: [ { + shortTitle: _('Select device'), + longTitle: _('Step 1: Device selection'), + longDescription: _('Select a dimming device'), + controls: [ { + type: 'deviceSelection', + id: 'dsuid', + multiselect: true, + width: 600, + margin: '6px 0 0', + filterFunc: this.isSupportedDevice, + specialDeviceRenderer: function (val, metadata, record) { // , colIdx, store, view + var sReturn = '<table style="height:16px;"><tr>'; + sReturn += '<td><img src="' + record.get('icon') + '" style="margin-right: 5px;"></td>'; + sReturn += '<td width="100%">' + record.get('name') + '</td><td>'; + sReturn += dss.staticDataModel.getProductNameForDevice(dss.staticDataModel.getDevice(record.get('dSUID'))) + '</td>'; + switch (dss.staticDataModel.getDevice(record.get('dSUID')).outputMode) { + case 22: + sReturn += '<td style="padding-left:5px;">' + _('dimmed (trailing edge)') + '</td>'; + break; + case 20: + sReturn += '<td style="padding-left:5px;">' + _('dimmed (leading edge)') + '</td>'; + break; + case 31: + sReturn += '<td style="padding-left:5px;">' + _('dimmed (automatic)') + '</td>'; + break; + default: + sReturn += '<td style="padding-left:5px;">' + _('switched') + '</td>'; + break; + } - var sString = '<table><tr><td style="padding-right:5px;"><img src="' + dss.staticDataModel.getImageForDevice(oDevice) + '"></td>'; - sString += '<td>' + oDevice.name + _(" in "); - sString += dss.staticDataModel.getNameForZone(oDevice.ZoneID) + '</td></tr></table>'; - - return sString; + return sReturn + '</tr></table>'; }, - flex : 3 - }, { - header: _('dSUID'), - dataIndex: 'dsuid', - xtype: 'devicedsidcolumn', - width: 70, - customColumnRenderer: function (val, metadata, record, rowIdx, colIdx, store, view) { - if (record.get('present') === '') { - //device is not known to dSS - metadata.css='grid-cell-completly-wrong'; - } - if (record.get('present') === false) { - //device is currently not connected to dSS - metadata.css='grid-cell-temporary-wrong'; - } - return val.slice(val.length-10, val.length-2); - } - },{ - header: _('led type'), - dataIndex: 'catalogeID', - xtype: 'textcolumn', - customColumnRenderer: function (val, metadata, record, rowIdx, colIdx, store, view) { - if (record.get('present') === '') { - //device is not known to dSS - metadata.css='grid-cell-completly-wrong'; - } - if (record.get('present') === false) { - //device is currently not connected to dSS - metadata.css='grid-cell-temporary-wrong'; - } - val = parseInt("" + val,10); - if ((val & 0xf000) == 0xf000) { - var min=val & 0x3f; - var max=(val>>6) & 0x3f; - - var mode=dss.staticDataModel.getDevice(record.get('dsuid')).outputMode; - return Ext.String.format2(_('Manual determinated curve (type: {mode}/ min value: {minDimm}/ max value: {maxDimm})'), - {maxDimm:max,minDimm:min,mode:modeNameForValue(mode)}); - } else { - var oRecord=Ext.data.StoreManager.lookup('illuminateTypeStore').findRecord('_id',val,0,false,false,true); - if (oRecord==null) { - return _('led type is not found in database'); - } else { - return oRecord.get('socket') + ' ' + oRecord.get('name') + ' ' + oRecord.get('watt') + 'W ' + oRecord.get('colortemp'); - } + constrainFunc: function (id, values) { + if (values.prepared != null) { + return false; } - }, - flex :3 - }, { - header: _('manufacturer'), - dataIndex: 'catalogeID', - xtype: 'textcolumn', - customColumnRenderer: function (val, metadata, record, rowIdx, colIdx, store, view) { - if (record.get('present') === '') { - //device is not known to dSS - metadata.css='grid-cell-completly-wrong'; + return true; + } + } ] + }, { + shortTitle: _('Prepare device'), + longTitle: _('Step 2: Preparing the device'), + longDescription: _('A universal dimming curve is transmitted to the selected device to allow the full phase angle dimming spectrum. ' + + 'Please wait until the process is finished. Step 3 will start automatically.'), + controls: [{ + id: 'prepared', + type: 'custom', + control: DefaultDimmingProcessor + }], + hideBack: true, + constrainFunc: function (id, values) { + if (values.prepared) { + return false; + } + if (values.minDimm != null) { + return false; + } + if (values.dsuid && values.dsuid.length) { + return true; + } + return false; + } + }, { + shortTitle: _('Dimming Mode'), + longTitle: _('Step 3: Determine the dimming mode'), + longDescription: _('Dimming Mode must be set.'), + controls: [ { + id: 'mode', + type: 'custom', + control: ModeControl + } ], + hideBack: true, + constrainFunc: function (id, values) { + if (values.prepared) { + if (values.dsuid && values.dsuid.length) { + return true; } - if (record.get('present') === false) { - //device is currently not connected to dSS - metadata.css='grid-cell-temporary-wrong'; + } + return false; + } + }, { + shortTitle: _('Min value'), + longTitle: _('Step 4: Determine the minimum brightness value'), + longDescription: _('Now we need to determinate the minimum brightness value of the light bulb.<br>' + + 'Light bulbs tend to flicker at very low brightness. Also dimming them on from an off-state normally requires a higher ' + + 'brightness than it may be possible by dimming them down in an on-state. The minimum value needs to ensure a save start ' + + 'start of the light bulb from an off state.<br>Therefore it is important to set the light bulb into an off-state and then ' + + 'start dimming it up slowly to find the value where the lamp gets on and doesn\'t flicker. You are allowed to dim a step ' + + 'down, but then the wizard will automatically turn the light bulb off, waits 2 seconds and then turns it on to the desired value.<br>' + + 'After that, click "Continue".'), + controls: [ { + id: 'minDimm', + type: 'custom', + control: MinValueControl + } ], + hideBack: true, + constrainFunc: function (id, values) { + if (values.prepared) { + if (values.dsuid && values.dsuid.length) { + return true; } - var oRecord=Ext.data.StoreManager.lookup('illuminateTypeStore').findRecord('_id',val,0,false,false,true); - if (oRecord==null) { - return _('-'); - } else { - var manuID=oRecord.get('manufactureID'); - var oVendorRecord=Ext.data.StoreManager.lookup('illuminateVendorStore').findRecord('_id',manuID,0,false,false,true); - if (oVendorRecord!=null) { - return oVendorRecord.get('vendor').substr(1); - } else { - return _('-'); + } + return false; + } + }, { + shortTitle: _('Max value'), + longTitle: _('Step 5: Determine the maximum brightness value'), + longDescription: _('It\'s important to fine the correct maximum brightness value to ensure getting the maximum brightness out of the light bulb ' + + 'and additionally havein a perfect dimming behavior.<br><b>Important:</b> To protect your eyes, please look onto a wall instead of looking ' + + 'directly into the loght blub!<br><br>Please start by moving the selector repeatedly to find the lowest value which already delivers ' + + 'the highest possible brightness. You can finetune the value by using the up/down buttons. You can compare your selected value ' + + 'with the maximum value by selecting "max value" which returns automatically to your selected value after 5 seconds.<br>' + + 'After that, click "Continue".'), + controls: [ { + id: 'maxDimm', + type: 'custom', + control: MaxValueControl + } ], + constrainFunc: function (id, values) { + if (values.prepared) { + if (values.dsuid && values.dsuid.length) { + if (values.minDimm != null) { + return true; } } - }, - flex :3 - }, { - header: _('modified at'), - dataIndex: 'ts', - xtype: 'timestampcolumn', - width: 160, - customColumnRenderer: function (val, metadata, record, rowIdx, colIdx, store, view) { - if (record.get('present') === '') { - //device is not known to dSS - metadata.css='grid-cell-completly-wrong'; - } - if (record.get('present') === false) { - //device is currently not connected to dSS - metadata.css='grid-cell-temporary-wrong'; + } + return false; + } + }, { + shortTitle: _('Generate curve'), + longTitle: _('Step 6: Generate dimming curve and transmit to device'), + longDescription: _('A dimming curve is generated using your selected minimum and maximum values. ' + + 'After that the dimming curve is transmitted to the selected device Please wait until the process is finished. Step 6 will start automatically.'), + controls: [ { + id: 'finishedValue', + type: 'custom', + control: TransmitControl + } ], + constrainFunc: function (id, values) { + if (values.prepared) { + if (values.dsuid && values.dsuid.length) { + if (values.minDimm != null && values.maxDimm != null) { + return true; + } } } - }], - buttonText: { - newButton: _('New device'), - editButton: _('Edit device'), - deleteButton: _('Reset device') - }, - customButtons:[{ - text:_('Make a Demo'), - iconCls:'icon-demo-start-action', - handler:function(grid,entry){ - dss.raiseEvent('led-wizard.demo',{actions:'startDemoModus', dsuid:entry.get('dsuid')}); - + return false; + } + }, { + shortTitle: _('Test curve'), + longTitle: _('Step 7: Test your dimming curve'), + longDescription: _('Here you can test your new dimming curve. After that, please finish the wizard.'), + controls: [ { + id: '_alsoSkip', + type: 'custom', + control: TestControl + } ], + hideBack: true, + constrainFunc: function (id, values) { + if (values.finishedValue != null) { + return values.finishedValue; } - }, - { - text:_('Stop Demo'), - iconCls:'icon-demo-stop-action', - handler:function(grid,entry){ - dss.raiseEvent('led-wizard.demo',{actions:'stopDemoModus'}); + return false; + } + }], + startLongTitle: _('LED Dimming wizard - longer title'), + hideLeftFinish: true, + startDescription: _('This wizard will help you for manually determinate a dimming curve'), + finishFunc: function () { + me.loadParameter(me.myGrid); + } + }); + this.wizardDialog.addListener('hide', function () { + me.wizardDialog = null; + }); + this.wizardDialog.startWizard(); + }, + illuminantTestControl: null, + illuminantManualControl: null, + illuminantTypeControl: null, + getContent: function () { + var me = this; + this.illuminantTypeControl = Ext.create('DSS.addon.IlluminantType', {}); + this.illuminantTestControl = Ext.create('DSS.addon.IlluminantTest', {}); + this.illuminantManualControl = Ext.create('DSS.addon.IlluminantManual', {}); + this.illuminantTypeControl.parent = this; + + var oConfig = { + defaultSortCol: 'name', + grouperField: 'grouping', + multiselect: true, + storeConfig: { + storeId: 'lizardStore', + fields: [ + { name: 'id' }, + { name: 'dsid', sortType: 'asUCText' }, + { name: 'dsuid', sortType: 'asUCText' }, + { name: 'devicename', sortType: 'asUCText' }, + { name: 'catalogeID', sortType: 'asUCText' }, + { name: 'ts' }, + { name: 'aaa' }, + { name: 'present' }, + { name: 'grouping', sortType: 'asUCText' } + ] + }, + columns: [ { + header: _('Device name'), + dataIndex: 'devicename', + renderer: function (val, metadata, record) { // , rowIdx, colIdx, store, view + var oDevice = dss.staticDataModel.getDevice(record.get('dsuid')); + if (record.get('present') === '') { + // device is not known to dSS + metadata.css = 'grid-cell-completly-wrong'; + } + if (!record.get('present')) { + // device is currently not connected to dSS + metadata.css = 'grid-cell-temporary-wrong'; } + var sString = '<table><tr><td style="padding-right:5px;"><img src="' + dss.staticDataModel.getImageForDevice(oDevice) + '"></td>'; + sString += '<td>' + oDevice.name + _(' in '); + sString += dss.staticDataModel.getNameForZone(oDevice.ZoneID) + '</td></tr></table>'; + + return sString; }, - { - text:_('Request DB Refresh'), - iconCls:'', - handler:function(grid,entry){ - dss.raiseEvent('led-wizard.db',{actions:'syncOnline'}); + flex: 3 + }, { + header: _('dSUID'), + dataIndex: 'dsuid', + xtype: 'devicedsidcolumn', + width: 70, + customColumnRenderer: function (val, metadata, record) { // , rowIdx, colIdx, store, view + if (record.get('present') === '') { + // device is not known to dSS + metadata.css = 'grid-cell-completly-wrong'; } - },{ - text : _('Start configuration wizard'), - iconCls : 'icon-edit-action', - handler : function () { - me.startWizard(); - } + if (!record.get('present')) { + // device is currently not connected to dSS + metadata.css = 'grid-cell-temporary-wrong'; + } + return val.slice(val.length - 10, val.length - 2); } - ], - customButtonsRAlign:[{ - text:_('refresh led database'), - iconCls: 'led-refresh', - handler:function(grid,entry){ - requestAndUpdateDatabase(); - grid.setStatus(_('refreshing database in background is in progress ...')); + }, { + header: _('led type'), + dataIndex: 'catalogeID', + xtype: 'textcolumn', + customColumnRenderer: function (val, metadata, record) { // , rowIdx, colIdx, store, view + if (record.get('present') === '') { + // device is not known to dSS + metadata.css = 'grid-cell-completly-wrong'; + } + if (!record.get('present')) { + // device is currently not connected to dSS + metadata.css = 'grid-cell-temporary-wrong'; + } + val = parseInt('' + val, 10); + if ((val & 0xf000) == 0xf000) { + var min = val & 0x3f; + var max = (val >> 6) & 0x3f; + + var mode = dss.staticDataModel.getDevice(record.get('dsuid')).outputMode; + return Ext.String.format2( + _('Manual determinated curve (type: {mode}/ min value: {minDimm}/ max value: {maxDimm})'), + { maxDimm: max, minDimm: min, mode: modeNameForValue(mode) } + ); + } else { + var oRecord = Ext.data.StoreManager.lookup('illuminateTypeStore').findRecord('_id', val, 0, false, false, true); + if (oRecord == null) { + return _('led type is not found in database'); + } else { + return oRecord.get('socket') + ' ' + oRecord.get('name') + ' ' + oRecord.get('watt') + 'W ' + oRecord.get('colortemp'); + } } - }], - editorConfig:{ - title : _('Edit Deviceconfig'), - hideSave: true, - cancelTitle: _('Close'), - staticControls : [ { - type: 'hidden', - label: 'id', - id: 'id' - }], - tabControls : [{ - tabLabel : _('Deviceselection'), - tabDescription : _('Choose the device, on which the dimmingcurve should be optimized'), - content : [{ - type : 'deviceSelection', - id : 'dsuid', - multiselect : true, - filterFunc: this.isSupportedDevice, - specialDeviceRenderer: function(val, metadata, record, colIdx, store, view) { - var sReturn='<table style="height:16px;"><tr>'; - sReturn+='<td><img src="' + record.get('icon') + '" style="margin-right: 5px;"></td>'; - sReturn+='<td width="100%">' + record.get('name') + '</td><td>'; - sReturn+=dss.staticDataModel.getProductNameForDevice(dss.staticDataModel.getDevice(record.get('dSUID')))+'</td>'; - switch (dss.staticDataModel.getDevice(record.get('dSUID')).outputMode) { - case 22: - sReturn+='<td style="padding-left:5px;">' + _('dimmed (trailing edge)') + '</td>'; - break; - case 20: - sReturn+='<td style="padding-left:5px;">' + _('dimmed (leading edge)') + '</td>'; - break; - case 31: - sReturn+='<td style="padding-left:5px;">' + _('dimmed (automatic)') + '</td>'; - break; - default: - sReturn+='<td style="padding-left:5px;">' + _('switched') + '</td>'; - break; - - } - return sReturn +'</tr></table>'; - }, - flex : true - }] - }, { - tabLabel : _('illuminant'), - tabDescription : _('Choose the type of the illuminant'), - content : [{ - type : 'custom', - id : 'catalogeID', - control: this.illuminantTypeControl, - flex : true - }] - }, { - tabLabel : _('Test'), - tabDescription : _('Send the dimmingcurve to the device and test the result'), - content : [{ - type : 'custom', - id : 'aaa', - control: this.illuminantTestControl, - flex : true - }] - }, { - tabLabel : _('Manual'), - tabDescription : _('Send the dimmingcurve to the device and test the result'), - content : [{ - type : 'custom', - id : 'bbb', - control: this.illuminantManualControl, - flex : true - }] - }] }, - listeners: { - 'loadDataStore':function (grid){ - me.loadParameter(grid); - }, - 'saveEntry':function (grid,values){ - me.loadParameter(grid); - }, - 'deleteEntry':function (grid,entry){ - var sWarningPermanentDeleted = _('This device was deleted from the system. Schould it be removed from the list whithout reseting the dimming curve?'); - var sWarningNotConnected = _('This device is currently not connected to the system. Schould it be removed from the list whithout reseting the dimming curve?'); - var messageBox = Ext.create('Ext.window.MessageBox', { - buttonText: { - yes: _('Yes'), - no: _('No') - } - }); - var bPresentState=[]; - var deviceID=[]; - var iIndex, jIndex; - if (entry.length) { - for (iIndex=0;iIndex<entry.length;iIndex++) { - if (entry[iIndex]!=null) { - bPresentState.push(entry[iIndex].get('present')); - deviceID.push(entry[iIndex].get('dsuid')); - } - } + flex: 3 + }, { + header: _('manufacturer'), + dataIndex: 'catalogeID', + xtype: 'textcolumn', + customColumnRenderer: function (val, metadata, record) { // , rowIdx, colIdx, store, view + if (record.get('present') === '') { + // device is not known to dSS + metadata.css = 'grid-cell-completly-wrong'; + } + if (!record.get('present')) { + // device is currently not connected to dSS + metadata.css = 'grid-cell-temporary-wrong'; + } + var oRecord = Ext.data.StoreManager.lookup('illuminateTypeStore').findRecord('_id', val, 0, false, false, true); + if (oRecord == null) { + return _('-'); + } else { + var manuID = oRecord.get('manufactureID'); + var oVendorRecord = Ext.data.StoreManager.lookup('illuminateVendorStore').findRecord('_id', manuID, 0, false, false, true); + if (oVendorRecord != null) { + return oVendorRecord.get('vendor').substr(1); } else { - bPresentState.push(entry.get('present')); - deviceID.push(entry.get('dsuid')); + return _('-'); + } + } + }, + flex: 3 + }, { + header: _('modified at'), + dataIndex: 'ts', + xtype: 'timestampcolumn', + width: 160, + customColumnRenderer: function (val, metadata, record) { // , rowIdx, colIdx, store, view + if (record.get('present') === '') { + // device is not known to dSS + metadata.css = 'grid-cell-completly-wrong'; + } + if (!record.get('present')) { + // device is currently not connected to dSS + metadata.css = 'grid-cell-temporary-wrong'; + } + } + }], + buttonText: { + newButton: _('New device'), + editButton: _('Edit device'), + deleteButton: _('Reset device') + }, + customButtons: [ { + text: _('Make a Demo'), + iconCls: 'icon-demo-start-action', + handler: function (grid, entry) { + dss.raiseEvent('led-wizard.demo', { actions: 'startDemoModus', dsuid: entry.get('dsuid') }); + } + }, + { + text: _('Stop Demo'), + iconCls: 'icon-demo-stop-action', + handler: function () { // grid, entry + dss.raiseEvent('led-wizard.demo', { actions: 'stopDemoModus' }); + } + }, + { + text: _('Request DB Refresh'), + iconCls: '', + handler: function () { // grid, entry + dss.raiseEvent('led-wizard.db', { actions: 'syncOnline' }); + } + }, { + text: _('Start configuration wizard'), + iconCls: 'icon-edit-action', + handler: function () { + me.startWizard(); + } + } ], + customButtonsRAlign: [ { + text: _('refresh led database'), + iconCls: 'led-refresh', + handler: function (grid) { // , entry + requestAndUpdateDatabase(); + grid.setStatus(_('refreshing database in background is in progress ...')); + } + } ], + editorConfig: { + title: _('Edit Deviceconfig'), + hideSave: true, + cancelTitle: _('Close'), + staticControls: [ { + type: 'hidden', + label: 'id', + id: 'id' + } ], + tabControls: [ { + tabLabel: _('Deviceselection'), + tabDescription: _('Choose the device, on which the dimmingcurve should be optimized'), + content: [ { + type: 'deviceSelection', + id: 'dsuid', + multiselect: true, + filterFunc: this.isSupportedDevice, + specialDeviceRenderer: function (val, metadata, record) { // , colIdx, store, view + var sReturn = '<table style="height:16px;"><tr>'; + sReturn += '<td><img src="' + record.get('icon') + '" style="margin-right: 5px;"></td>'; + sReturn += '<td width="100%">' + record.get('name') + '</td><td>'; + sReturn += dss.staticDataModel.getProductNameForDevice(dss.staticDataModel.getDevice(record.get('dSUID'))) + '</td>'; + switch (dss.staticDataModel.getDevice(record.get('dSUID')).outputMode) { + case 22: + sReturn += '<td style="padding-left:5px;">' + _('dimmed (trailing edge)') + '</td>'; + break; + case 20: + sReturn += '<td style="padding-left:5px;">' + _('dimmed (leading edge)') + '</td>'; + break; + case 31: + sReturn += '<td style="padding-left:5px;">' + _('dimmed (automatic)') + '</td>'; + break; + default: + sReturn += '<td style="padding-left:5px;">' + _('switched') + '</td>'; + break; + } + return sReturn + '</tr></table>'; + }, + flex: true + } ] + }, { + tabLabel: _('illuminant'), + tabDescription: _('Choose the type of the illuminant'), + content: [ { + type: 'custom', + id: 'catalogeID', + control: this.illuminantTypeControl, + flex: true + } ] + }, { + tabLabel: _('Test'), + tabDescription: _('Send the dimmingcurve to the device and test the result'), + content: [ { + type: 'custom', + id: 'aaa', + control: this.illuminantTestControl, + flex: true + } ] + }, { + tabLabel: _('Manual'), + tabDescription: _('Send the dimmingcurve to the device and test the result'), + content: [ { + type: 'custom', + id: 'bbb', + control: this.illuminantManualControl, + flex: true + } ] + } ] + }, + listeners: { + loadDataStore: function (grid) { + me.loadParameter(grid); + }, + saveEntry: function (grid) { // , values + me.loadParameter(grid); + }, + deleteEntry: function (grid, entry) { + // var sWarningPermanentDeleted = _('This device was deleted from the system. Schould it be removed from the list whithout reseting the dimming curve?'); + // var sWarningNotConnected = _('This device is currently not connected to the system. ' + + // ' Schould it be removed from the list whithout reseting the dimming curve?'); + var messageBox = Ext.create('Ext.window.MessageBox', { + buttonText: { + yes: _('Yes'), + no: _('No') } - var bAsk = false; - for (jIndex = 0; jIndex<deviceID.length; jIndex++) { - if ((bPresentState[jIndex] === '') || (bPresentState[jIndex] === false)) { - bAsk = true; + }); + var bPresentState = []; + var deviceID = []; + var iIndex; var jIndex; + if (entry.length) { + for (iIndex = 0; iIndex < entry.length; iIndex++) { + if (entry[iIndex]) { + bPresentState.push(entry[iIndex].get('present')); + deviceID.push(entry[iIndex].get('dsuid')); } } - if (bAsk) { - messageBox.show({ - title:_('Remove Entry?'), - msg: _('At least one device not connected to the system. They will be removed from the list whithout reseting the dimming curve?'), - buttons:Ext.MessageBox.OKCANCEL, - buttonText : - { - ok : _('OK'), - cancel : _('Cancel') - }, - icon: Ext.Msg.QUESTION, - fn: function (buttonID) { - if (buttonID=='ok') { - me.myGrid.editorWindow.editControls.aaa.winWait.start({actions:'programmCurve',dsuid:Ext.JSON.encode(deviceID), curve_id:-1},0, deviceID.length); - } + } else { + bPresentState.push(entry.get('present')); + deviceID.push(entry.get('dsuid')); + } + var bAsk = false; + for (jIndex = 0; jIndex < deviceID.length; jIndex++) { + if (bPresentState[jIndex] === '' || bPresentState[jIndex] === false) { + bAsk = true; + } + } + if (bAsk) { + messageBox.show({ + title: _('Remove Entry?'), + msg: _('At least one device not connected to the system. They will be removed from the list whithout reseting the dimming curve?'), + buttons: Ext.MessageBox.OKCANCEL, + buttonText: { + ok: _('OK'), + cancel: _('Cancel') + }, + icon: Ext.Msg.QUESTION, + fn: function (buttonID) { + if (buttonID === 'ok') { + me.myGrid.editorWindow.editControls.aaa.winWait.start( + { actions: 'programmCurve', dsuid: Ext.JSON.encode(deviceID), curve_id: -1 }, 0, deviceID.length + ); } - }); + } + }); + } else { + me.myGrid.editorWindow.editControls.aaa.winWait.start( + { actions: 'programmCurve', dsuid: Ext.JSON.encode(deviceID), curve_id: -1 }, 0, deviceID.length + ); + } + }, + selectionChanged: function (grid, selections) { + if (selections.length === 1) { + var entry = selections[0]; + if (entry.get('present') === '' || entry.get('present') === false) { + // disable edit button if device is currently not connected or deleted + grid.btnEdit.setDisabled(true); } else { - me.myGrid.editorWindow.editControls.aaa.winWait.start({actions:'programmCurve', dsuid:Ext.JSON.encode(deviceID), curve_id:-1},0, deviceID.length); - } - }, - 'selectionChanged': function(grid, selections) { - if (selections.length==1) { - var entry = selections[0]; - if ((entry.get('present') === '') || (entry.get('present') === false)) { - //disable edit button if device is currently not connected or deleted - grid.btnEdit.setDisabled(true); + var val = parseInt('' + entry.get('catalogeID'), 10); + if ((val & 0xf000) == 0xf000) { + grid.btnEdit.setDisabled(true); } else { - var val = parseInt("" + entry.get('catalogeID'),10); - if ((val & 0xf000) == 0xf000) - grid.btnEdit.setDisabled(true); - else - grid.btnEdit.setDisabled(false); + grid.btnEdit.setDisabled(false); } } } } - }; + } + }; - fChangedCallback.push(function () {me.setTestButtons();}); - this.myGrid=Ext.create('DSS.gridPanel', oConfig); - var oEditor=this.myGrid.editorWindow; - oGrid=this.myGrid; - oEditor.editControls.dsuid.addListener('change',function() { - oEditor.editControls.catalogeID.typeGrid.getView().refresh(); - oEditor.editControls.catalogeID.macPanel.doLayout(); - oEditor.editControls.aaa.updateLabels(); + fChangedCallback.push(function () { me.setTestButtons(); }); + this.myGrid = Ext.create('DSS.gridPanel', oConfig); + var oEditor = this.myGrid.editorWindow; + oGrid = this.myGrid; + oEditor.editControls.dsuid.addListener('change', function () { + oEditor.editControls.catalogeID.typeGrid.getView().refresh(); + oEditor.editControls.catalogeID.macPanel.doLayout(); + oEditor.editControls.aaa.updateLabels(); }); - + oEditor.oTabPanelParent.items.items[2].tab.show(); - oEditor.oTabPanelParent.items.items[3].tab.hide(); - - this.myGrid.editorWindow.buttonCancel.setHandler(function (){ - var oDev=oEditor.editControls.dsuid.getValue(); - var oIllu=oEditor.editControls.catalogeID.getValue(); - if (oDev!=null) - if (oIllu!=null) - if (!oEditor.editControls.aaa.fHasActionDone) { - - var messageBox = Ext.create('Ext.window.MessageBox', { - buttonText: { - yes: _('Yes'), - no: _('No') - } - }); - - messageBox.show({ - title:_('Transmit curve?'), - msg: _('A device and a valid curve has been selected but not yet been transmitted. Should it be done now ?'), - buttons:Ext.MessageBox.YESNO, - icon: Ext.Msg.QUESTION, - fn: function (buttonID) { - if (buttonID=='yes') { - oEditor.editControls.aaa.winWait.start({actions:'programmCurve', dsuid:Ext.JSON.encode(oDev), curve_id:oEditor.editControls.catalogeID.getValue()}); - } - } - }); - } - oEditor.fireEvent('cancel'); - oEditor.hide(); + oEditor.oTabPanelParent.items.items[3].tab.hide(); + + this.myGrid.editorWindow.buttonCancel.setHandler(function () { + var oDev = oEditor.editControls.dsuid.getValue(); + var oIllu = oEditor.editControls.catalogeID.getValue(); + if (oDev != null) { + if (oIllu != null) { + if (!oEditor.editControls.aaa.fHasActionDone) { + + var messageBox = Ext.create('Ext.window.MessageBox', { + buttonText: { + yes: _('Yes'), + no: _('No') + } + }); + + messageBox.show({ + title: _('Transmit curve?'), + msg: _('A device and a valid curve has been selected but not yet been transmitted. Should it be done now ?'), + buttons: Ext.MessageBox.YESNO, + icon: Ext.Msg.QUESTION, + fn: function (buttonID) { + if (buttonID === 'yes') { + oEditor.editControls.aaa.winWait.start( + { actions: 'programmCurve', dsuid: Ext.JSON.encode(oDev), curve_id: oEditor.editControls.catalogeID.getValue() } + ); + } + } + }); + } + } + } + oEditor.fireEvent('cancel'); + oEditor.hide(); }); - Ext.data.StoreManager.on('clear',function () { - refreshIlluminantDB(); - me.myGrid.editorWindow.editControls.catalogeID.initStores(); - me.myGrid.editorWindow.editControls.catalogeID.updateGridStores(); - me.loadParameter(me.myGrid); - }); - + Ext.data.StoreManager.on('clear', function () { + refreshIlluminantDB(); + me.myGrid.editorWindow.editControls.catalogeID.initStores(); + me.myGrid.editorWindow.editControls.catalogeID.updateGridStores(); + me.loadParameter(me.myGrid); + }); + return this.myGrid; - }, - loadParameter : function(grid) { - grid.setStatus(_('Loading ...')); - this.myGrid=grid; - oEdit=grid.editorWindow; - this.myGrid.btnCustom[0].setVisible(false); - this.myGrid.btnCustom[1].setVisible(false); - this.myGrid.btnCustom[2].setVisible(false); - if (oEdit!=null) - if (oEdit.displayBottomText!=null) - oEdit.displayBottomText.setValue(_('illuminant database updated on: ')+Ext.Date.format(lastUpdate, "d.m.Y H:i")); + }, + loadParameter: function (grid) { + grid.setStatus(_('Loading ...')); + this.myGrid = grid; + oEdit = grid.editorWindow; + this.myGrid.btnCustom[0].setVisible(false); + this.myGrid.btnCustom[1].setVisible(false); + this.myGrid.btnCustom[2].setVisible(false); + if (oEdit != null) { + if (oEdit.displayBottomText != null) { + oEdit.displayBottomText.setValue(_('illuminant database updated on: ') + Ext.Date.format(lastUpdate, 'd.m.Y H:i')); + } + } var sString = dss.ajaxSyncRequest('/json/property/query', { - 'query' : '/scripts/led-wizard/devices/*(*)' + query: '/scripts/led-wizard/devices/*(*)' }); try { var result = Ext.JSON.decode(sString); - var oResultObject=dss.parsePropertyQueryAnswer(result,[{name:'dsid',type:'simple'}, - {name:'dsuid',type:'simple'}, - {name:'catalogeID',type:'simple'}, - {name: 'ts',type:'simple'}]); - if (oResultObject!=null) { - for (var iIndex=0;iIndex<oResultObject.length;iIndex++){ - var oDevice = dss.staticDataModel.getDevice(oResultObject[iIndex].dsuid); - oResultObject[iIndex].aaa="aaa"; - oResultObject[iIndex].devicename= oDevice.name; - oResultObject[iIndex].present = oDevice.present; - var Room = dss.staticDataModel.getNameForZone(oDevice.ZoneID); - oResultObject[iIndex].grouping = unescape(Room); - } + var oResultObject = dss.parsePropertyQueryAnswer(result, [ + { name: 'dsid', type: 'simple' }, + { name: 'dsuid', type: 'simple' }, + { name: 'catalogeID', type: 'simple' }, + { name: 'ts', type: 'simple' } + ]); + if (oResultObject) { + for (var iIndex = 0; iIndex < oResultObject.length; iIndex++) { + var oDevice = dss.staticDataModel.getDevice(oResultObject[iIndex].dsuid); + oResultObject[iIndex].aaa = 'aaa'; + oResultObject[iIndex].devicename = oDevice.name; + oResultObject[iIndex].present = oDevice.present; + var Room = dss.staticDataModel.getNameForZone(oDevice.ZoneID); + oResultObject[iIndex].grouping = unescape(Room); + } grid.loadParameter(oResultObject); } grid.setStatus(_('Ready')); } catch (e) { grid.setStatus(_('Error')); - console.log("exception " + e.message+ " in loadParameter(): " + sString); + console.log('exception ' + e.message + ' in loadParameter(): ' + sString); } } }); -Ext.onReady(function() { +Ext.onReady(function () { initializeConsole(); dss.buildUpLang(['locale/{languageSuffix}/led-wizard.po']); - + refreshIlluminantDB(); - //requestAndUpdateDatabase(); - var ledwizard = Ext.create('DSS.addon.Lizard'); - ledwizard.initPage(); + // requestAndUpdateDatabase(); + var ledWizard = Ext.create('DSS.addon.Lizard'); + ledWizard.initPage(); startListener(); }); -function refreshIlluminantDB (){ - if (Ext.data.StoreManager.lookup('illuminateTypeStore') == null) { - Ext.create('Ext.data.Store', { - storeId : 'illuminateTypeStore', - fields : [ {name:'name', sortType: 'asUCText'}, - '_id', - 'ability', - 'abilityDetail', - 'colortemp', - 'curveValues', - 'dimmMinimum', - 'ean', - 'illuminateCount', - 'lumen', - 'manufactureID', - 'mount', - 'winkel', - {name:'socket', sortType: 'asUCText'}, - {name:'watt',sortType:'asCommaFloat'}, - 'dimming_type'], - proxy : { - type : 'memory', - reader : { - type : 'json', - root : 'items' - } - } - }); - } - if (Ext.data.StoreManager.lookup('illuminateTypeControlStore') == null) { - Ext.create('Ext.data.Store', { - storeId : 'illuminateTypeControlStore', - fields : [ {name:'name', sortType: 'asUCText'}, - '_id', - 'ability', - 'abilityDetail', - 'colortemp', - 'curveValues', - 'dimmMinimum', - 'ean', - 'illuminateCount', - 'lumen', - 'manufactureID', - 'mount', - 'winkel', - {name:'socket', sortType: 'asUCText'}, - {name:'watt',sortType:'asCommaFloat'}, - 'dimming_type'], - proxy : { - type : 'memory', - reader : { - type : 'json', - root : 'items' - } - } - }); - } - if (Ext.data.StoreManager.lookup('illuminateVendorStore') == null) { - Ext.create('Ext.data.Store', { - storeId : 'illuminateVendorStore', - fields : [ '_id', {name:'vendor', sortType: 'asUCText'}, 'passive' ], - proxy : { - type : 'memory', - reader : { - type : 'json', - root : 'items' - } - } - }); - } - Ext.data.StoreManager.lookup('illuminateVendorStore').suspendEvents(); - Ext.data.StoreManager.lookup('illuminateTypeStore').suspendEvents(); - Ext.data.StoreManager.lookup('illuminateTypeControlStore').suspendEvents(); - - Ext.data.StoreManager.lookup('illuminateVendorStore').removeAll(); - Ext.data.StoreManager.lookup('illuminateTypeStore').removeAll(); - Ext.data.StoreManager.lookup('illuminateTypeControlStore').removeAll(); - +function refreshIlluminantDB () { + if (Ext.data.StoreManager.lookup('illuminateTypeStore') == null) { + Ext.create('Ext.data.Store', { + storeId: 'illuminateTypeStore', + fields: [ + { name: 'name', sortType: 'asUCText' }, + '_id', + 'ability', + 'abilityDetail', + 'colortemp', + 'curveValues', + 'dimmMinimum', + 'ean', + 'illuminateCount', + 'lumen', + 'manufactureID', + 'mount', + 'winkel', + { name: 'socket', sortType: 'asUCText' }, + { name: 'watt', sortType: 'asCommaFloat' }, + 'dimming_type' + ], + proxy: { + type: 'memory', + reader: { + type: 'json', + root: 'items' + } + } + }); + } + if (Ext.data.StoreManager.lookup('illuminateTypeControlStore') == null) { + Ext.create('Ext.data.Store', { + storeId: 'illuminateTypeControlStore', + fields: [ + { name: 'name', sortType: 'asUCText' }, + '_id', + 'ability', + 'abilityDetail', + 'colortemp', + 'curveValues', + 'dimmMinimum', + 'ean', + 'illuminateCount', + 'lumen', + 'manufactureID', + 'mount', + 'winkel', + { name: 'socket', sortType: 'asUCText' }, + { name: 'watt', sortType: 'asCommaFloat' }, + 'dimming_type' + ], + proxy: { + type: 'memory', + reader: { + type: 'json', + root: 'items' + } + } + }); + } + if (Ext.data.StoreManager.lookup('illuminateVendorStore') == null) { + Ext.create('Ext.data.Store', { + storeId: 'illuminateVendorStore', + fields: [ '_id', { name: 'vendor', sortType: 'asUCText' }, 'passive' ], + proxy: { + type: 'memory', + reader: { + type: 'json', + root: 'items' + } + } + }); + } + Ext.data.StoreManager.lookup('illuminateVendorStore').suspendEvents(); + Ext.data.StoreManager.lookup('illuminateTypeStore').suspendEvents(); + Ext.data.StoreManager.lookup('illuminateTypeControlStore').suspendEvents(); + + Ext.data.StoreManager.lookup('illuminateVendorStore').removeAll(); + Ext.data.StoreManager.lookup('illuminateTypeStore').removeAll(); + Ext.data.StoreManager.lookup('illuminateTypeControlStore').removeAll(); + + try { + var sString = dss.ajaxSyncRequest('/json/database/query', { + sql: 'select * from mounting_form', + database: 'led-wizard' + }); + var result = Ext.JSON.decode(sString); + var mountingForm = []; + var iIndex; + for (iIndex = 0; iIndex < result.result.data.length; iIndex++) { + mountingForm.push({ id: parseInt('' + result.result.data[iIndex].id, 10), name: result.result.data[iIndex].name }); + } + + sString = dss.ajaxSyncRequest('/json/database/query', { + sql: 'select * from socket', + database: 'led-wizard' + }); + result = Ext.JSON.decode(sString); + var socket = []; + for (iIndex = 0; iIndex < result.result.data.length; iIndex++) { + socket.push({ id: parseInt('' + result.result.data[iIndex].id, 10), name: Ext.String.htmlEncode(result.result.data[iIndex].name) }); + } - try { - - var sString = dss.ajaxSyncRequest('/json/database/query', { - 'sql' : 'select * from mounting_form', - 'database' : 'led-wizard' - }); - var result = Ext.JSON.decode(sString); - var mountingForm=[]; - for (var iIndex=0;iIndex<result.result.data.length;iIndex++) { - mountingForm.push({id:parseInt('' + result.result.data[iIndex].id,10),name:result.result.data[iIndex].name}) - } - - sString = dss.ajaxSyncRequest('/json/database/query', { - 'sql' : 'select * from socket', - 'database' : 'led-wizard' - }); - result = Ext.JSON.decode(sString); - var socket =[]; - for (var iIndex=0;iIndex<result.result.data.length;iIndex++) { - socket.push({id:parseInt('' + result.result.data[iIndex].id,10),name:Ext.String.htmlEncode(result.result.data[iIndex].name)}); - } - - sString = dss.ajaxSyncRequest('/json/database/query', { - 'sql' : 'select * from ability_detail', - 'database' : 'led-wizard' - }); - result = Ext.JSON.decode(sString); - var choosenLanguage=dss.staticDataModel.activeLanguage; - var abilityDetail =[]; - for (var iIndex=0;iIndex<result.result.data.length;iIndex++) { - var sAbiString=result.result.data[iIndex].name; - if (sAbiString.indexOf('{')==0) { - var oAbiObject=Ext.JSON.decode(sAbiString); - if (oAbiObject[choosenLanguage]!=null) - Gettext._locale_data['dss-addon-framework'].msgs[oAbiObject['en_US']]=[null,oAbiObject[choosenLanguage]]; - abilityDetail.push({name:Ext.String.htmlEncode(oAbiObject['en_US']),id:parseInt('' + result.result.data[iIndex].id,10)}); - } - } + sString = dss.ajaxSyncRequest('/json/database/query', { + sql: 'select * from ability_detail', + database: 'led-wizard' + }); + result = Ext.JSON.decode(sString); + var choosenLanguage = dss.staticDataModel.activeLanguage; + var abilityDetail = []; + for (iIndex = 0; iIndex < result.result.data.length; iIndex++) { + var sAbiString = result.result.data[iIndex].name; + if (sAbiString.indexOf('{') === 0) { + var oAbiObject = Ext.JSON.decode(sAbiString); + if (oAbiObject[choosenLanguage] != null) { + Gettext._locale_data['dss-addon-framework'].msgs[oAbiObject.en_US] = [ null, oAbiObject[choosenLanguage] ]; + } + abilityDetail.push({ name: Ext.String.htmlEncode(oAbiObject.en_US), id: parseInt('' + result.result.data[iIndex].id, 10) }); + } + } - - sString = dss.ajaxSyncRequest('/json/database/query', { - 'sql' : 'select * from manufacture', - 'database' : 'led-wizard' - }); - result = Ext.JSON.decode(sString); - var manufactureID=[]; - for (var iIndex=0;iIndex<result.result.data.length;iIndex++) { - var priority=9; - if (result.result.data[iIndex].id==-1) - priority=1; - manufactureID.push(result.result.data[iIndex].id); - Ext.data.StoreManager.lookup('illuminateVendorStore').add({_id:parseInt('' + result.result.data[iIndex].id,10),vendor:""+priority+Ext.String.htmlEncode(result.result.data[iIndex].name)}); - } -/* Ext.data.StoreManager.lookup('illuminateVendorStore').add({_id:-10,vendor:'2'+_('Manual')}); - - var oItemManualLeading={ - _id:-11, - lumen:"0", - ean:'-', - colortemp:"0", - manufactureID:-10, - watt:0, - name:_("Manual linear leading Edge"), - winkel:"0", - dimmMinimum:"4", - dimming_type:"0", - illuminateCount:"1", - ability:1, - curveValues:[] - }; + sString = dss.ajaxSyncRequest('/json/database/query', { + sql: 'select * from manufacture', + database: 'led-wizard' + }); + result = Ext.JSON.decode(sString); + var manufactureID = []; + for (iIndex = 0; iIndex < result.result.data.length; iIndex++) { + var priority = 9; + if (result.result.data[iIndex].id == -1) { + priority = 1; + } + manufactureID.push(result.result.data[iIndex].id); + Ext.data.StoreManager.lookup('illuminateVendorStore').add({ + _id: parseInt('' + result.result.data[iIndex].id, 10), + vendor: '' + priority + Ext.String.htmlEncode(result.result.data[iIndex].name) + }); + } + /* Ext.data.StoreManager.lookup('illuminateVendorStore').add({_id:-10,vendor:'2'+_('Manual')}); + + var oItemManualLeading={ + _id:-11, + lumen:"0", + ean:'-', + colortemp:"0", + manufactureID:-10, + watt:0, + name:_("Manual linear leading Edge"), + winkel:"0", + dimmMinimum:"4", + dimming_type:"0", + illuminateCount:"1", + ability:1, + curveValues:[] + }; + + oItemManualLeading.curveValues.push({_id:0,value:0,window:0}); + for (var index=4;index<252;index+=8) { + oItemManualLeading.curveValues.push({_id:index,value:Math.floor((9999*index)/256),window:9999}); + } + oItemManualLeading.curveValues.push({_id:252,value:9999,window:0}); + + for (kIndex=0;kIndex<mountingForm.length;kIndex++) + if (mountingForm[kIndex].id==8) + oItemManualLeading.mount=mountingForm[kIndex].name; + + for (kIndex=0;kIndex<socket.length;kIndex++) + if (socket[kIndex].id==11) + oItemManualLeading.socket=socket[kIndex].name; + + for (kIndex=0;kIndex<abilityDetail.length;kIndex++) + if (abilityDetail[kIndex].id==2) + oItemManualLeading.abilityDetail=abilityDetail[kIndex].name; + + Ext.data.StoreManager.lookup('illuminateTypeStore').add(oItemManualLeading); + Ext.data.StoreManager.lookup('illuminateTypeControlStore').add(oItemManualLeading); + + var oItemManualTrailing={ + _id:-12, + lumen:"0", + ean:'-', + colortemp:"0", + manufactureID:-10, + watt:"0", + name:_("Manual linear trailing Edge"), + winkel:"0", + dimmMinimum:"4", + illuminateCount:"1", + ability:1, + dimming_type:"1", + curveValues:[] + }; + + oItemManualTrailing.curveValues.push({_id:0,value:0,window:0}); + for (var index=4;index<252;index+=8) { + oItemManualTrailing.curveValues.push({_id:index,value:Math.floor((9999*index)/256),window:9999}); + } + oItemManualTrailing.curveValues.push({_id:252,value:9999,window:0}); - oItemManualLeading.curveValues.push({_id:0,value:0,window:0}); - for (var index=4;index<252;index+=8) { - oItemManualLeading.curveValues.push({_id:index,value:Math.floor((9999*index)/256),window:9999}); - } - oItemManualLeading.curveValues.push({_id:252,value:9999,window:0}); + for (kIndex=0;kIndex<mountingForm.length;kIndex++) + if (mountingForm[kIndex].id=="8") + oItemManualTrailing.mount=mountingForm[kIndex].name; - for (kIndex=0;kIndex<mountingForm.length;kIndex++) - if (mountingForm[kIndex].id==8) - oItemManualLeading.mount=mountingForm[kIndex].name; - - for (kIndex=0;kIndex<socket.length;kIndex++) - if (socket[kIndex].id==11) - oItemManualLeading.socket=socket[kIndex].name; - - for (kIndex=0;kIndex<abilityDetail.length;kIndex++) - if (abilityDetail[kIndex].id==2) - oItemManualLeading.abilityDetail=abilityDetail[kIndex].name; - - Ext.data.StoreManager.lookup('illuminateTypeStore').add(oItemManualLeading); - Ext.data.StoreManager.lookup('illuminateTypeControlStore').add(oItemManualLeading); - - var oItemManualTrailing={ - _id:-12, - lumen:"0", - ean:'-', - colortemp:"0", - manufactureID:-10, - watt:"0", - name:_("Manual linear trailing Edge"), - winkel:"0", - dimmMinimum:"4", - illuminateCount:"1", - ability:1, - dimming_type:"1", - curveValues:[] - }; + for (kIndex=0;kIndex<socket.length;kIndex++) + if (socket[kIndex].id=="11") + oItemManualTrailing.socket=socket[kIndex].name; - oItemManualTrailing.curveValues.push({_id:0,value:0,window:0}); - for (var index=4;index<252;index+=8) { - oItemManualTrailing.curveValues.push({_id:index,value:Math.floor((9999*index)/256),window:9999}); - } - oItemManualTrailing.curveValues.push({_id:252,value:9999,window:0}); + for (kIndex=0;kIndex<abilityDetail.length;kIndex++) + if (abilityDetail[kIndex].id=="2") + oItemManualTrailing.abilityDetail=abilityDetail[kIndex].name; - for (kIndex=0;kIndex<mountingForm.length;kIndex++) - if (mountingForm[kIndex].id=="8") - oItemManualTrailing.mount=mountingForm[kIndex].name; - - for (kIndex=0;kIndex<socket.length;kIndex++) - if (socket[kIndex].id=="11") - oItemManualTrailing.socket=socket[kIndex].name; - - for (kIndex=0;kIndex<abilityDetail.length;kIndex++) - if (abilityDetail[kIndex].id=="2") - oItemManualTrailing.abilityDetail=abilityDetail[kIndex].name; - - Ext.data.StoreManager.lookup('illuminateTypeStore').add(oItemManualTrailing); - Ext.data.StoreManager.lookup('illuminateTypeControlStore').add(oItemManualTrailing); - */ - - Ext.data.StoreManager.lookup('illuminateVendorStore').add({_id:-20,vendor:'3-'}); - - Ext.data.StoreManager.lookup('illuminateVendorStore').add({_id:0,vendor:'8'+_('All vendors')}); - Ext.data.StoreManager.lookup('illuminateVendorStore').sort('vendor','ASC'); + Ext.data.StoreManager.lookup('illuminateTypeStore').add(oItemManualTrailing); + Ext.data.StoreManager.lookup('illuminateTypeControlStore').add(oItemManualTrailing); + */ + Ext.data.StoreManager.lookup('illuminateVendorStore').add({ _id: -20, vendor: '3-' }); - sString = dss.ajaxSyncRequest('/json/database/query', { - 'sql' : 'select illuminant_technical_parameter.id, illuminant.lumen, illuminant.ean, illuminant.color_temperature, illuminant.manufacture_id, illuminant.watt, illuminant.name, illuminant.mounting_form_id, illuminant.socket_id, illuminant.abstrahlwinkel, ' + - 'illuminant_technical_parameter.dimming_minimal_range, illuminant_technical_parameter.illuminant_count, illuminant_technical_parameter.ds_ability, illuminant_technical_parameter.ability_detail_id,illuminant_technical_parameter.dimming_type ' + - 'from illuminant_technical_parameter inner join illuminant on illuminant_technical_parameter.illuminant_id=illuminant.id', - 'database' : 'led-wizard' - }); - result = Ext.JSON.decode(sString); - for (var iIndex=0;iIndex<result.result.data.length;iIndex++) { - var oObject=result.result.data[iIndex]; - - var oItem={ - _id:parseInt('' + oObject.id,10), - lumen:oObject.lumen, - ean:oObject.ean, - colortemp:oObject.color_temperature, - manufactureID:parseInt('' + oObject.manufacture_id,10), - watt:(Math.round(parseFloat(('' + oObject.watt).replace(',','.'))*10))/10.0, - name:Ext.String.htmlEncode(oObject.name), - winkel:oObject.abstrahlwinkel, - dimmMinimum:oObject.dimming_minimal_range, - illuminateCount:oObject.illuminant_count, - ability:parseInt('' +oObject.ds_ability,10), - dimming_type:oObject.dimming_type - }; - - for (kIndex=0;kIndex<mountingForm.length;kIndex++) - if (mountingForm[kIndex].id==oObject.mounting_form_id) - oItem.mount=mountingForm[kIndex].name; - - for (kIndex=0;kIndex<socket.length;kIndex++) - if (socket[kIndex].id==oObject.socket_id) - oItem.socket=socket[kIndex].name; - - for (kIndex=0;kIndex<abilityDetail.length;kIndex++) - if (abilityDetail[kIndex].id==oObject.ability_detail_id) - oItem.abilityDetail=abilityDetail[kIndex].name; - - Ext.data.StoreManager.lookup('illuminateTypeStore').add(oItem); - if (oItem._id !== -1) { - Ext.data.StoreManager.lookup('illuminateTypeControlStore').add(oItem); - } - - } - - Ext.data.StoreManager.lookup('illuminateTypeControlStore').sort('socket','ASC'); - - var sRefreshString = dss.ajaxSyncRequest('/json/property/getString', { - 'path' : '/scripts/led-wizard/dbrefresh' - }); - var refreshResult = Ext.JSON.decode(sRefreshString); - if (refreshResult.ok) { - lastUpdate=new Date(); - lastUpdate.setTime(parseInt(refreshResult.result.value,10)); - if (oEdit!=null) - if (oEdit.displayBottomText!=null) - oEdit.displayBottomText.setValue(_('illuminant database updated on: ')+Ext.Date.format(lastUpdate, "d.m.Y H:i")); - } - - Ext.data.StoreManager.lookup('illuminateVendorStore').resumeEvents(); - Ext.data.StoreManager.lookup('illuminateTypeStore').resumeEvents(); - Ext.data.StoreManager.lookup('illuminateTypeControlStore').resumeEvents(); - - if (oGrid!=null) { - oGrid.setStatus(_('Ready')); - } + Ext.data.StoreManager.lookup('illuminateVendorStore').add({ _id: 0, vendor: '8' + _('All vendors') }); + Ext.data.StoreManager.lookup('illuminateVendorStore').sort('vendor', 'ASC'); - } - catch (e) { - - } - return; - + sString = dss.ajaxSyncRequest('/json/database/query', { + sql: 'select illuminant_technical_parameter.id, illuminant.lumen, illuminant.ean, illuminant.color_temperature, illuminant.manufacture_id, ' + + 'illuminant.watt, illuminant.name, illuminant.mounting_form_id, illuminant.socket_id, illuminant.abstrahlwinkel, ' + + 'illuminant_technical_parameter.dimming_minimal_range, illuminant_technical_parameter.illuminant_count, illuminant_technical_parameter.ds_ability, ' + + 'illuminant_technical_parameter.ability_detail_id,illuminant_technical_parameter.dimming_type ' + + 'from illuminant_technical_parameter inner join illuminant on illuminant_technical_parameter.illuminant_id=illuminant.id', + database: 'led-wizard' + }); + result = Ext.JSON.decode(sString); + for (iIndex = 0; iIndex < result.result.data.length; iIndex++) { + var oObject = result.result.data[iIndex]; + + var oItem = { + _id: parseInt('' + oObject.id, 10), + lumen: oObject.lumen, + ean: oObject.ean, + colortemp: oObject.color_temperature, + manufactureID: parseInt('' + oObject.manufacture_id, 10), + watt: (Math.round(parseFloat(('' + oObject.watt).replace(',', '.')) * 10)) / 10.0, + name: Ext.String.htmlEncode(oObject.name), + winkel: oObject.abstrahlwinkel, + dimmMinimum: oObject.dimming_minimal_range, + illuminateCount: oObject.illuminant_count, + ability: parseInt('' + oObject.ds_ability, 10), + dimming_type: oObject.dimming_type + }; + + var kIndex; + for (kIndex = 0; kIndex < mountingForm.length; kIndex++) { + if (mountingForm[kIndex].id == oObject.mounting_form_id) { + oItem.mount = mountingForm[kIndex].name; + } + } + + for (kIndex = 0; kIndex < socket.length; kIndex++) { + if (socket[kIndex].id == oObject.socket_id) { + oItem.socket = socket[kIndex].name; + } + } + + for (kIndex = 0; kIndex < abilityDetail.length; kIndex++) { + if (abilityDetail[kIndex].id == oObject.ability_detail_id) { + oItem.abilityDetail = abilityDetail[kIndex].name; + } + } + + Ext.data.StoreManager.lookup('illuminateTypeStore').add(oItem); + if (oItem._id !== -1) { + Ext.data.StoreManager.lookup('illuminateTypeControlStore').add(oItem); + } + } + + Ext.data.StoreManager.lookup('illuminateTypeControlStore').sort('socket', 'ASC'); + + var sRefreshString = dss.ajaxSyncRequest('/json/property/getString', { + path: '/scripts/led-wizard/dbrefresh' + }); + var refreshResult = Ext.JSON.decode(sRefreshString); + if (refreshResult.ok) { + lastUpdate = new Date(); + lastUpdate.setTime(parseInt(refreshResult.result.value, 10)); + if (oEdit && oEdit.displayBottomText) { + oEdit.displayBottomText.setValue(_('illuminant database updated on: ') + Ext.Date.format(lastUpdate, 'd.m.Y H:i')); + } + } + + Ext.data.StoreManager.lookup('illuminateVendorStore').resumeEvents(); + Ext.data.StoreManager.lookup('illuminateTypeStore').resumeEvents(); + Ext.data.StoreManager.lookup('illuminateTypeControlStore').resumeEvents(); + + if (oGrid != null) { + oGrid.setStatus(_('Ready')); + } + } catch (e) { + // silence error + } } Ext.apply(Ext.data.SortTypes, { - asCommaFloat: function(oValue) { - var sString=""+oValue; - sString=sString.replace(',','.'); - return parseFloat(sString,10); - } + asCommaFloat: function (oValue) { + var sString = '' + oValue; + sString = sString.replace(',', '.'); + return parseFloat(sString, 10); } - ); - +}); -var oEdit=null; +var oEdit = null; -function modeNameForValue(mode) { - switch (mode) { - case 31: - return _('dimmed (automatic)'); - case 16: - return _('switched'); - case 19: - case 20: - return _('dimmed (leading edge)'); - case 21: - case 22: - return _('dimmed (trailing edge)'); - default: - return '-'; - } +function modeNameForValue (mode) { + switch (mode) { + case 31: + return _('dimmed (automatic)'); + case 16: + return _('switched'); + case 19: + case 20: + return _('dimmed (leading edge)'); + case 21: + case 22: + return _('dimmed (trailing edge)'); + default: + return '-'; + } }