Commit ee1289b3b6be75403d2b7241337a33b3fe921c27
- Diff rendering mode:
- inline
- side by side
dss-setup-interface/dSS/data/DeviceStore.js
(1 / 1)
|   | |||
| 6 | 6 | var deviceRecord = Ext.data.Record.create([ | |
| 7 | 7 | {name:"name"}, | |
| 8 | 8 | {name:"dsid", mapping: "id"}, | |
| 9 | {name:"on"}, | ||
| 9 | {name:"blink", defaultValue: false}, | ||
| 10 | 10 | {name:"modulatorDsid"}, | |
| 11 | 11 | {name:"modulatorName"}, | |
| 12 | 12 | {name:"zoneId"}, |
dss-setup-interface/dSS/grid/DevicePanel.js
(41 / 44)
|   | |||
| 12 | 12 | dSS.grid.DevicePanel = Ext.extend(Ext.grid.GridPanel, { | |
| 13 | 13 | initComponent: function() { | |
| 14 | 14 | ||
| 15 | var stateRenderer = function(value, metaData, record, rowIndex, colIndex, store) { | ||
| 15 | var blinkRenderer = function(value, metaData, record, rowIndex, colIndex, store) { | ||
| 16 | 16 | if(record.get('isPresent') === false) { | |
| 17 | 17 | metaData.css = 'isDisabled'; | |
| 18 | 18 | } | |
| 19 | 19 | else { | |
| 20 | if(record.get('on')) { | ||
| 21 | metaData.css = 'isOn'; | ||
| 20 | if(record.get('blink') === true) { | ||
| 21 | metaData.css = 'blinkActive'; | ||
| 22 | 22 | } else { | |
| 23 | metaData.css = 'isOff'; | ||
| 23 | metaData.css = 'blink'; | ||
| 24 | 24 | } | |
| 25 | 25 | } | |
| 26 | 26 | return String.format('<img class="padding-img" src="{0}"/>',Ext.BLANK_IMAGE_URL); | |
| … | … | ||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 | var deviceCols = [ | |
| 45 | {header: _("on"), width: 30, resizable: false, sortable: true, dataIndex: 'on', renderer: stateRenderer, id: 'on'}, | ||
| 45 | {header: _("blink"), width: 25, resizable: false, sortable: false, dataIndex: 'blink', renderer: blinkRenderer, id: 'blink'}, | ||
| 46 | 46 | {header: "dsid", width: 150, sortable: true, dataIndex: 'dsid', id: 'dsid'}, | |
| 47 | 47 | {header: _("name"), width: 150, sortable: true, dataIndex: 'name', id: 'name'}, | |
| 48 | 48 | {header: _("meter name"), width: 100, sortable: true, dataIndex: 'modulatorName', id: 'modulatorName' }, | |
| … | … | ||
| 234 | 234 | return; | |
| 235 | 235 | } | |
| 236 | 236 | ||
| 237 | if (dataIndex === 'on') { | ||
| 238 | Ext.Ajax.request({ | ||
| 239 | url: record.get('on') ? '/json/device/turnOff' : '/json/device/turnOn', | ||
| 240 | disableCaching: true, | ||
| 241 | method: "GET", | ||
| 242 | params: { dsid: record.get('dsid') }, | ||
| 243 | success: function(result, request) { | ||
| 244 | try { | ||
| 245 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 246 | if(jsonData.ok) { | ||
| 247 | record.set('on', record.get('on') ? false : true ); | ||
| 248 | record.commit(); | ||
| 249 | } | ||
| 250 | } catch(err) { | ||
| 251 | Ext.MessageBox.alert('Error', err); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | }); | ||
| 237 | if (dataIndex === 'blink') { | ||
| 238 | this.sendBlinkRequest(record); | ||
| 255 | 239 | } else if (dataIndex === 'locked') { | |
| 256 | 240 | Ext.Ajax.request({ | |
| 257 | 241 | url: record.get('locked') ? '/json/device/unlock' : '/json/device/lock', | |
| … | … | ||
| 544 | 544 | }); | |
| 545 | 545 | }, | |
| 546 | 546 | ||
| 547 | sendBlinkRequest: function(record) { | ||
| 548 | record.set('blink', true); | ||
| 549 | var unblink = function(record) { | ||
| 550 | record.set('blink', false); | ||
| 551 | } | ||
| 552 | |||
| 553 | Ext.Ajax.request({ | ||
| 554 | url: '/json/device/blink', | ||
| 555 | disableCaching: true, | ||
| 556 | method: "GET", | ||
| 557 | scope: this, | ||
| 558 | params: { dsid : record.get('dsid') }, | ||
| 559 | success: function(result, request) { | ||
| 560 | try { | ||
| 561 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 562 | if (!jsonData.ok) { | ||
| 563 | Ext.MessageBox.alert(_("Could not blink"), jsonData.message); | ||
| 564 | } | ||
| 565 | } catch (err) { | ||
| 566 | Ext.MessageBox.alert(_("Error"), | ||
| 567 | _("Could send blink device command to dSS") + ": " + err); | ||
| 568 | } | ||
| 569 | unblink.defer(2000, this, [ record ]); | ||
| 570 | }, | ||
| 571 | failure: function(result, request) { | ||
| 572 | Ext.MessageBox.alert(_("Error"), | ||
| 573 | _("Could send blink device command to dSS")); | ||
| 574 | unblink.defer(2000, this, [ record ]); | ||
| 575 | } | ||
| 576 | }); | ||
| 577 | }, | ||
| 578 | |||
| 547 | 579 | blinkDevice: function(item, event, rowIndex) { | |
| 548 | 580 | var records; | |
| 549 | 581 | var store = this.getStore(); | |
| … | … | ||
| 595 | 595 | continue; | |
| 596 | 596 | } | |
| 597 | 597 | ||
| 598 | Ext.Ajax.request({ | ||
| 599 | url: '/json/device/blink', | ||
| 600 | disableCaching: true, | ||
| 601 | method: "GET", | ||
| 602 | scope: this, | ||
| 603 | params: { dsid : records[i].get('dsid') }, | ||
| 604 | success: function(result, request) { | ||
| 605 | try { | ||
| 606 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 607 | if(!jsonData.ok) { | ||
| 608 | Ext.MessageBox.alert(_("Could not blink"), jsonData.message); | ||
| 609 | } | ||
| 610 | } | ||
| 611 | catch (err) { | ||
| 612 | Ext.MessageBox.alert(_("Error"), _("Could send blink device command to dSS") + ": " + err); | ||
| 613 | } | ||
| 614 | }, | ||
| 615 | failure: function(result, request) { | ||
| 616 | Ext.MessageBox.alert(_("Error"), _("Could send blink device command to dSS")); | ||
| 617 | } | ||
| 618 | }); | ||
| 598 | this.sendBlinkRequest(records[i]); | ||
| 599 | |||
| 619 | 600 | } | |
| 620 | 601 | }, | |
| 621 | 602 |

