Commit 7b2ae65f178833194b623eb83ed9defaf1c38ad9
- Diff rendering mode:
- inline
- side by side
webroot/js/dss/dss-setup-interface/dSS/GetTextHelper.js
(6 / 4)
|   | |||
| 1 | 1 | var params = { | |
| 2 | "domain" : "dss-installer", | ||
| 3 | "locale_data" : json_locale_data | ||
| 4 | }; | ||
| 2 | "domain": "dss-installer", | ||
| 3 | "locale_data": json_locale_data | ||
| 4 | }; | ||
| 5 | 5 | ||
| 6 | 6 | var gt = new Gettext(params); | |
| 7 | 7 | ||
| 8 | function _(msgid) { return gt.gettext(msgid); } | ||
| 8 | function _(msgid) { | ||
| 9 | return gt.gettext(msgid); | ||
| 10 | } |
webroot/js/dss/dss-setup-interface/dSS/GlossaryPanel.js
(15 / 16)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | |||
| 3 | 2 | Ext.namespace('dSS'); | |
| 4 | 3 | ||
| 5 | 4 | dSS.GlossaryPanel = Ext.extend(Ext.Panel, { | |
| 6 | initComponent: function() { | ||
| 5 | initComponent: function() { | ||
| 7 | 6 | ||
| 8 | Ext.apply(this, { | ||
| 9 | layout: 'border', | ||
| 10 | items: [{ | ||
| 11 | xtype: 'box', | ||
| 12 | region: 'center', | ||
| 13 | autoEl: { | ||
| 14 | tag: 'div', | ||
| 15 | html: '<h1>' + _("Glossary") + '</h1>' | ||
| 16 | } | ||
| 17 | } | ||
| 18 | ] | ||
| 19 | }); | ||
| 7 | Ext.apply(this, { | ||
| 8 | layout: 'border', | ||
| 9 | items: [ | ||
| 10 | { | ||
| 11 | xtype: 'box', | ||
| 12 | region: 'center', | ||
| 13 | autoEl: { | ||
| 14 | tag: 'div', | ||
| 15 | html: '<h1>' + _("Glossary") + '</h1>' | ||
| 16 | } | ||
| 17 | }] | ||
| 18 | }); | ||
| 20 | 19 | ||
| 21 | dSS.GlossaryPanel.superclass.initComponent.apply(this, arguments); | ||
| 22 | } | ||
| 20 | dSS.GlossaryPanel.superclass.initComponent.apply(this, arguments); | ||
| 21 | } | ||
| 23 | 22 | }); | |
| 24 | 23 | ||
| 25 | 24 | Ext.reg('dssglossarypanel', dSS.GlossaryPanel); |
webroot/js/dss/dss-setup-interface/dSS/MessageBus.js
(0 / 1)
|   | |||
| 1 | 1 | //= require <dSS/MessageBusImpl> | |
| 2 | |||
| 3 | 2 | Ext.namespace('dSS'); | |
| 4 | 3 | ||
| 5 | 4 | dSS.MessageBus = (function() { |
webroot/js/dss/dss-setup-interface/dSS/MessageBusImpl.js
(6 / 6)
|   | |||
| 1 | 1 | Ext.namespace('dSS'); | |
| 2 | 2 | ||
| 3 | 3 | dSS.MessageBusImpl = Ext.extend(Ext.util.Observable, { | |
| 4 | publish: function() { | ||
| 5 | dSS.MessageBusImpl.superclass.fireEvent.apply(this, arguments); | ||
| 6 | }, | ||
| 7 | subscribe: function() { | ||
| 8 | dSS.MessageBusImpl.superclass.addListener.apply(this, arguments); | ||
| 9 | } | ||
| 4 | publish: function() { | ||
| 5 | dSS.MessageBusImpl.superclass.fireEvent.apply(this, arguments); | ||
| 6 | }, | ||
| 7 | subscribe: function() { | ||
| 8 | dSS.MessageBusImpl.superclass.addListener.apply(this, arguments); | ||
| 9 | } | ||
| 10 | 10 | }); |
webroot/js/dss/dss-setup-interface/dSS/ScenesPanel.js
(165 / 193)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/Util> | |
| 3 | |||
| 4 | 3 | Ext.namespace('dSS'); | |
| 5 | 4 | ||
| 6 | 5 | dSS.ScenesPanel = Ext.extend(Ext.Panel, { | |
| 7 | initComponent: function() { | ||
| 6 | initComponent: function() { | ||
| 8 | 7 | ||
| 9 | var contentPanel = { | ||
| 10 | ref: 'contentPanel', | ||
| 11 | region: 'center', | ||
| 12 | layout: 'card', | ||
| 8 | var contentPanel = { | ||
| 9 | ref: 'contentPanel', | ||
| 10 | region: 'center', | ||
| 11 | layout: 'card', | ||
| 13 | 12 | hideBorders: true, | |
| 14 | border: true, | ||
| 15 | activeItem: 0, | ||
| 16 | items: [ | ||
| 17 | { | ||
| 18 | xtype: 'dssdevicepanel' | ||
| 19 | } | ||
| 20 | ] | ||
| 21 | }; | ||
| 13 | border: true, | ||
| 14 | activeItem: 0, | ||
| 15 | items: [ | ||
| 16 | { | ||
| 17 | xtype: 'dssdevicepanel' | ||
| 18 | }] | ||
| 19 | }; | ||
| 22 | 20 | ||
| 23 | this.treePanel = new Ext.tree.TreePanel( | ||
| 24 | { | ||
| 21 | this.treePanel = new Ext.tree.TreePanel({ | ||
| 25 | 22 | useArrows: true, | |
| 26 | 23 | autoScroll: true, | |
| 27 | 24 | animate: true, | |
| … | … | ||
| 34 | 34 | ||
| 35 | 35 | this.treePanel.getRootNode().expand(); | |
| 36 | 36 | ||
| 37 | var treeHolder = new Ext.Panel( | ||
| 38 | { | ||
| 39 | title: gt.ngettext("Scene", 2), | ||
| 40 | region: 'west', | ||
| 41 | layout: 'fit', | ||
| 42 | split: true, | ||
| 43 | width: 225, | ||
| 44 | minSize: 175, | ||
| 45 | maxSize: 400, | ||
| 46 | tbar: this.buildTopToolbar(), | ||
| 47 | items: [ this.treePanel ] | ||
| 48 | } | ||
| 49 | ); | ||
| 50 | |||
| 51 | Ext.apply(this, | ||
| 52 | { | ||
| 53 | layout: 'border', | ||
| 54 | border: false, | ||
| 55 | bodyBorder: false, | ||
| 56 | items: [ treeHolder, contentPanel ] | ||
| 57 | } | ||
| 58 | ); | ||
| 37 | var treeHolder = new Ext.Panel({ | ||
| 38 | title: gt.ngettext("Scene", 2), | ||
| 39 | region: 'west', | ||
| 40 | layout: 'fit', | ||
| 41 | split: true, | ||
| 42 | width: 225, | ||
| 43 | minSize: 175, | ||
| 44 | maxSize: 400, | ||
| 45 | tbar: this.buildTopToolbar(), | ||
| 46 | items: [this.treePanel] | ||
| 47 | }); | ||
| 59 | 48 | ||
| 49 | Ext.apply(this, { | ||
| 50 | layout: 'border', | ||
| 51 | border: false, | ||
| 52 | bodyBorder: false, | ||
| 53 | items: [treeHolder, contentPanel] | ||
| 54 | }); | ||
| 55 | |||
| 60 | 56 | this.updateTree(); | |
| 61 | 57 | ||
| 62 | dSS.data.Loader.getZoneStore().addListener('datachanged', | ||
| 63 | this.updateTree, | ||
| 64 | this, | ||
| 65 | { buffer: 1000 }); | ||
| 58 | dSS.data.Loader.getZoneStore().addListener('datachanged', this.updateTree, this, { | ||
| 59 | buffer: 1000 | ||
| 60 | }); | ||
| 66 | 61 | ||
| 67 | dSS.ScenesPanel.superclass.initComponent.apply(this, arguments); | ||
| 62 | dSS.ScenesPanel.superclass.initComponent.apply(this, arguments); | ||
| 68 | 63 | ||
| 69 | this.on( | ||
| 70 | 'activate', | ||
| 71 | function(component) { | ||
| 72 | var selModel = this.treePanel.getSelectionModel(); | ||
| 73 | var node = selModel.getSelectedNode(); | ||
| 74 | var root = this.treePanel.getRootNode(); | ||
| 75 | if ((node === null) && root.hasChildNodes()) { | ||
| 76 | root.firstChild.select(); | ||
| 77 | this.handleNodeClick(root.firstChild); | ||
| 78 | } else { | ||
| 79 | this.handleNodeClick(node); | ||
| 80 | } | ||
| 81 | }, | ||
| 82 | this | ||
| 83 | ); | ||
| 64 | this.on('activate', function(component) { | ||
| 65 | var selModel = this.treePanel.getSelectionModel(); | ||
| 66 | var node = selModel.getSelectedNode(); | ||
| 67 | var root = this.treePanel.getRootNode(); | ||
| 68 | if ((node === null) && root.hasChildNodes()) { | ||
| 69 | root.firstChild.select(); | ||
| 70 | this.handleNodeClick(root.firstChild); | ||
| 71 | } else { | ||
| 72 | this.handleNodeClick(node); | ||
| 73 | } | ||
| 74 | }, | ||
| 75 | this); | ||
| 84 | 76 | ||
| 85 | this.treePanel.on( | ||
| 86 | 'contextmenu', | ||
| 87 | function(node, event) { | ||
| 88 | event.preventDefault(); | ||
| 89 | event.stopEvent(); | ||
| 77 | this.treePanel.on('contextmenu', function(node, event) { | ||
| 78 | event.preventDefault(); | ||
| 79 | event.stopEvent(); | ||
| 90 | 80 | ||
| 91 | if (!node.isSelected()) { | ||
| 92 | node.select(); | ||
| 93 | this.handleNodeClick(node); | ||
| 94 | } | ||
| 81 | if (!node.isSelected()) { | ||
| 82 | node.select(); | ||
| 83 | this.handleNodeClick(node); | ||
| 84 | } | ||
| 95 | 85 | ||
| 96 | if (!node.isLeaf()) { | ||
| 97 | return; | ||
| 98 | } | ||
| 86 | if (!node.isLeaf()) { | ||
| 87 | return; | ||
| 88 | } | ||
| 99 | 89 | ||
| 100 | if(!this.contextMenu) { | ||
| 101 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 102 | } else { | ||
| 103 | this.contextMenu.removeAll(); | ||
| 104 | } | ||
| 90 | if (!this.contextMenu) { | ||
| 91 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 92 | } else { | ||
| 93 | this.contextMenu.removeAll(); | ||
| 94 | } | ||
| 105 | 95 | ||
| 106 | var menuItem = new Ext.menu.Item({ | ||
| 107 | text: _("Call scene"), | ||
| 108 | icon: '/images/on.png', | ||
| 109 | handler: this.callScene.createDelegate(this, [ node ]) | ||
| 110 | }); | ||
| 111 | this.contextMenu.add(menuItem) | ||
| 96 | var menuItem = new Ext.menu.Item({ | ||
| 97 | text: _("Call scene"), | ||
| 98 | icon: '/images/on.png', | ||
| 99 | handler: this.callScene.createDelegate(this, [node]) | ||
| 100 | }); | ||
| 101 | this.contextMenu.add(menuItem) | ||
| 112 | 102 | ||
| 113 | var menuItem = new Ext.menu.Item({ | ||
| 114 | text: _("Save scene"), | ||
| 115 | icon: '/images/disk.png', | ||
| 116 | handler: this.saveScene.createDelegate(this, [ node ]) | ||
| 117 | }); | ||
| 118 | this.contextMenu.add(menuItem); | ||
| 103 | var menuItem = new Ext.menu.Item({ | ||
| 104 | text: _("Save scene"), | ||
| 105 | icon: '/images/disk.png', | ||
| 106 | handler: this.saveScene.createDelegate(this, [node]) | ||
| 107 | }); | ||
| 108 | this.contextMenu.add(menuItem); | ||
| 119 | 109 | ||
| 120 | var xy = event.getXY(); | ||
| 121 | this.contextMenu.showAt(xy); | ||
| 122 | }, | ||
| 123 | this | ||
| 124 | ); | ||
| 125 | }, | ||
| 110 | var xy = event.getXY(); | ||
| 111 | this.contextMenu.showAt(xy); | ||
| 112 | }, | ||
| 113 | this); | ||
| 114 | }, | ||
| 126 | 115 | updateTree: function() { | |
| 127 | 116 | // for leafs the id is encoded as: zone id - group - scene number | |
| 128 | 117 | // when no group is desired, 0 is used | |
| 129 | 118 | function generateSubNodes(zoneId) { | |
| 130 | 119 | return [ | |
| 131 | { | ||
| 132 | text: _("Light"), | ||
| 133 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-all', | ||
| 134 | leaf: false, | ||
| 135 | children: [ | ||
| 136 | { | ||
| 137 | text: _("Light scene") + " 1", | ||
| 138 | id: zoneId + '-' + | ||
| 139 | dSS.config.groups.LIGHT + '-' + | ||
| 140 | dSS.config.scenes.T0_S1, | ||
| 141 | leaf: true | ||
| 142 | }, | ||
| 143 | { | ||
| 144 | text: _("Light scene") + " 2", | ||
| 145 | id: zoneId + '-' + | ||
| 146 | dSS.config.groups.LIGHT + '-' + | ||
| 147 | dSS.config.scenes.T0_S2, | ||
| 148 | leaf: true | ||
| 149 | }, | ||
| 150 | { | ||
| 151 | text: _("Light scene") + " 3", | ||
| 152 | id: zoneId + '-' + | ||
| 153 | dSS.config.groups.LIGHT + '-' + | ||
| 154 | dSS.config.scenes.T0_S3, | ||
| 155 | leaf: true | ||
| 156 | }, | ||
| 157 | { | ||
| 158 | text: _("Light scene") + " 4", | ||
| 159 | id: zoneId + '-' + | ||
| 160 | dSS.config.groups.LIGHT + '-' + | ||
| 161 | dSS.config.scenes.T0_S4, | ||
| 162 | leaf: true | ||
| 163 | } | ||
| 164 | ] | ||
| 165 | }, | ||
| 166 | { | ||
| 167 | text: _("Leave home"), | ||
| 168 | id: zoneId + '-all-' + dSS.config.scenes.ABSENT, | ||
| 169 | leaf: true | ||
| 170 | }, | ||
| 171 | { | ||
| 172 | text: _("Door bell"), | ||
| 173 | id: zoneId + '-all-' + dSS.config.scenes.SIG_BELL, | ||
| 174 | leaf: true | ||
| 175 | } | ||
| 176 | ]; | ||
| 120 | { | ||
| 121 | text: _("Light"), | ||
| 122 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-all', | ||
| 123 | leaf: false, | ||
| 124 | children: [ | ||
| 125 | { | ||
| 126 | text: _("Light scene") + " 1", | ||
| 127 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-' + dSS.config.scenes.T0_S1, | ||
| 128 | leaf: true | ||
| 129 | }, | ||
| 130 | { | ||
| 131 | text: _("Light scene") + " 2", | ||
| 132 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-' + dSS.config.scenes.T0_S2, | ||
| 133 | leaf: true | ||
| 134 | }, | ||
| 135 | { | ||
| 136 | text: _("Light scene") + " 3", | ||
| 137 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-' + dSS.config.scenes.T0_S3, | ||
| 138 | leaf: true | ||
| 139 | }, | ||
| 140 | { | ||
| 141 | text: _("Light scene") + " 4", | ||
| 142 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-' + dSS.config.scenes.T0_S4, | ||
| 143 | leaf: true | ||
| 144 | }] | ||
| 145 | }, | ||
| 146 | { | ||
| 147 | text: _("Leave home"), | ||
| 148 | id: zoneId + '-all-' + dSS.config.scenes.ABSENT, | ||
| 149 | leaf: true | ||
| 150 | }, | ||
| 151 | { | ||
| 152 | text: _("Door bell"), | ||
| 153 | id: zoneId + '-all-' + dSS.config.scenes.SIG_BELL, | ||
| 154 | leaf: true | ||
| 155 | }]; | ||
| 177 | 156 | } | |
| 178 | 157 | ||
| 179 | 158 | var selModel = this.treePanel.getSelectionModel(); | |
| … | … | ||
| 161 | 161 | if (selectedNode != null) { | |
| 162 | 162 | selectedPath = selectedNode.getPath(); | |
| 163 | 163 | } | |
| 164 | |||
| 164 | |||
| 165 | 165 | var zStore = dSS.data.Loader.getZoneStore(); | |
| 166 | 166 | var devStore = dSS.data.Loader.getDeviceStore(); | |
| 167 | 167 | var nodes = []; | |
| 168 | 168 | zStore.each( | |
| 169 | function(record) { | ||
| 170 | if ((record.get('id') != 0) && | ||
| 171 | (devStore.find('zoneId', record.get('id')) > 0)) { | ||
| 172 | nodes.push( | ||
| 173 | { | ||
| 174 | text: record.get('name') + " - " + record.get('id'), | ||
| 175 | id: record.get('id'), | ||
| 176 | leaf: false, | ||
| 177 | children: generateSubNodes(record.get('id')) | ||
| 178 | } | ||
| 179 | ); | ||
| 180 | } | ||
| 181 | return true; | ||
| 182 | }, | ||
| 183 | this | ||
| 184 | ); | ||
| 185 | var root = new Ext.tree.AsyncTreeNode({ children: nodes, id: 'root', leaf: false }); | ||
| 186 | this.treePanel.setRootNode(root); | ||
| 169 | function(record) { | ||
| 170 | if ((record.get('id') != 0) && (devStore.find('zoneId', record.get('id')) > 0)) { | ||
| 171 | nodes.push({ | ||
| 172 | text: record.get('name') + " - " + record.get('id'), | ||
| 173 | id: record.get('id'), | ||
| 174 | leaf: false, | ||
| 175 | children: generateSubNodes(record.get('id')) | ||
| 176 | }); | ||
| 177 | } | ||
| 178 | return true; | ||
| 179 | }, | ||
| 180 | this); | ||
| 181 | var root = new Ext.tree.AsyncTreeNode({ | ||
| 182 | children: nodes, | ||
| 183 | id: 'root', | ||
| 184 | leaf: false | ||
| 185 | }); | ||
| 186 | this.treePanel.setRootNode(root); | ||
| 187 | 187 | ||
| 188 | 188 | if (selectedPath.length > 0) { | |
| 189 | this.treePanel.selectPath(selectedPath, null, | ||
| 190 | function(result, node) { | ||
| 191 | if (result === false) { | ||
| 192 | if (root.firstChild != null) { | ||
| 193 | root.firstChild.select(); | ||
| 194 | } | ||
| 189 | this.treePanel.selectPath(selectedPath, null, function(result, node) { | ||
| 190 | if (result === false) { | ||
| 191 | if (root.firstChild != null) { | ||
| 192 | root.firstChild.select(); | ||
| 195 | 193 | } | |
| 194 | } | ||
| 196 | 195 | }); | |
| 197 | 196 | } else { | |
| 198 | 197 | if (root.firstChild != null) { | |
| 199 | 198 | root.firstChild.select(); | |
| 200 | 199 | } | |
| 201 | 200 | } | |
| 202 | |||
| 201 | |||
| 203 | 202 | if (selModel.getSelectedNode() != null) { | |
| 204 | 203 | this.handleNodeClick(selModel.getSelectedNode()); | |
| 205 | 204 | } | |
| 206 | |||
| 205 | |||
| 207 | 206 | }, | |
| 208 | 207 | handleNodeClick: function(node) { | |
| 209 | 208 | if (!this.isVisible()) { | |
| … | … | ||
| 231 | 231 | ||
| 232 | 232 | var nodeType = path[2].split('-'); | |
| 233 | 233 | // all leaf node ids will have 3 components: zone-group-scene | |
| 234 | if (nodeType.length < 3) { | ||
| 234 | if (nodeType.length < 3) { | ||
| 235 | 235 | return false; | |
| 236 | 236 | } | |
| 237 | 237 | ||
| … | … | ||
| 254 | 254 | } | |
| 255 | 255 | ||
| 256 | 256 | switch (scene) { | |
| 257 | case dSS.config.scenes.ABSENT: | ||
| 258 | case dSS.config.scenes.SIG_BELL: | ||
| 259 | return true; | ||
| 260 | default: | ||
| 261 | break; | ||
| 257 | case dSS.config.scenes.ABSENT: | ||
| 258 | case dSS.config.scenes.SIG_BELL: | ||
| 259 | return true; | ||
| 260 | default: | ||
| 261 | break; | ||
| 262 | 262 | } | |
| 263 | 263 | } | |
| 264 | 264 | return false; | |
| 265 | 265 | }); | |
| 266 | 266 | }, | |
| 267 | 267 | buildTopToolbar: function() { | |
| 268 | return [ | ||
| 269 | '->', | ||
| 268 | return ['->', { | ||
| 269 | cls: 'zonePanelMenu', | ||
| 270 | menu: [ | ||
| 270 | 271 | { | |
| 271 | cls: 'zonePanelMenu', | ||
| 272 | menu: [{ | ||
| 273 | text: _("Reload"), | ||
| 274 | handler: this.reload, | ||
| 275 | scope: this | ||
| 276 | }, | ||
| 277 | { | ||
| 278 | text: _("Rescan"), | ||
| 279 | handler: this.rescan, | ||
| 280 | scope: this | ||
| 281 | }] | ||
| 282 | } | ||
| 283 | ]; | ||
| 272 | text: _("Reload"), | ||
| 273 | handler: this.reload, | ||
| 274 | scope: this | ||
| 275 | }, | ||
| 276 | { | ||
| 277 | text: _("Rescan"), | ||
| 278 | handler: this.rescan, | ||
| 279 | scope: this | ||
| 280 | }] | ||
| 281 | }]; | ||
| 284 | 282 | }, | |
| 285 | 283 | rescan: function() { | |
| 286 | 284 | this.ownerCt.zoneBrowser.rescan(); | |
| … | … | ||
| 288 | 288 | }, | |
| 289 | 289 | ||
| 290 | 290 | getZoneSceneGroup: function(id) { | |
| 291 | var ret = | ||
| 292 | { | ||
| 293 | "zoneId": null, | ||
| 294 | "sceneNumber": null, | ||
| 295 | "groupId": null | ||
| 296 | }; | ||
| 291 | var ret = { | ||
| 292 | "zoneId": null, | ||
| 293 | "sceneNumber": null, | ||
| 294 | "groupId": null | ||
| 295 | }; | ||
| 297 | 296 | ||
| 298 | 297 | var ids = id.split('-'); | |
| 299 | 298 | if (ids.length < 3) { |
webroot/js/dss/dss-setup-interface/dSS/SystemPanel.js
(86 / 90)
|   | |||
| 2 | 2 | //= require <dSS/system/PropertyTree> | |
| 3 | 3 | //= require <dSS/system/logfiles> | |
| 4 | 4 | //= require <dSS/system/jsLogFiles> | |
| 5 | |||
| 6 | 5 | Ext.namespace('dSS'); | |
| 7 | 6 | ||
| 8 | 7 | dSS.SystemPanel = Ext.extend(Ext.Panel, { | |
| 9 | initComponent: function() { | ||
| 8 | initComponent: function() { | ||
| 10 | 9 | ||
| 11 | var tabRecord = Ext.data.Record.create([ { name:"title" } ]); | ||
| 10 | var tabRecord = Ext.data.Record.create([ | ||
| 11 | { | ||
| 12 | name: "title" | ||
| 13 | }]); | ||
| 12 | 14 | ||
| 13 | var tabStore = new Ext.data.Store({}, tabRecord); | ||
| 15 | var tabStore = new Ext.data.Store({}, | ||
| 16 | tabRecord); | ||
| 14 | 17 | ||
| 15 | var contentPanel = { | ||
| 16 | ref: 'contentPanel', | ||
| 17 | region: 'center', | ||
| 18 | layout: 'card', | ||
| 18 | var contentPanel = { | ||
| 19 | ref: 'contentPanel', | ||
| 20 | region: 'center', | ||
| 21 | layout: 'card', | ||
| 19 | 22 | hideBorders: true, | |
| 20 | border: true, | ||
| 21 | activeItem: 0, | ||
| 22 | items: [ | ||
| 23 | { | ||
| 24 | title: _("Property Tree"), | ||
| 25 | xtype: 'dsssystempropertytree', | ||
| 26 | ref: 'systemPropertyTree' | ||
| 27 | }, { | ||
| 28 | title: _("Logfiles"), | ||
| 29 | xtype: 'systemlogfiles', | ||
| 30 | ref: 'systemlogfiles' | ||
| 31 | }, { | ||
| 32 | title: _("JS Plugin Logs"), | ||
| 33 | xtype: "dsssystemjslogfiles", | ||
| 34 | ref: "systemjslogfiles" | ||
| 35 | } | ||
| 36 | ] | ||
| 37 | }; | ||
| 38 | |||
| 39 | this.listView = new Ext.list.ListView( | ||
| 23 | border: true, | ||
| 24 | activeItem: 0, | ||
| 25 | items: [ | ||
| 40 | 26 | { | |
| 41 | ref: 'listView', | ||
| 42 | store: tabStore, | ||
| 43 | singleSelect: true, | ||
| 44 | region: 'west', | ||
| 45 | hideHeaders: true, | ||
| 46 | columns: [{ header: 'name', dataIndex: 'title' }] | ||
| 47 | } | ||
| 48 | ); | ||
| 49 | |||
| 50 | var listHolder = new Ext.Panel( | ||
| 27 | title: _("Property Tree"), | ||
| 28 | xtype: 'dsssystempropertytree', | ||
| 29 | ref: 'systemPropertyTree' | ||
| 30 | }, | ||
| 51 | 31 | { | |
| 52 | title: "System", | ||
| 53 | region: 'west', | ||
| 54 | layout: 'fit', | ||
| 55 | split: true, | ||
| 56 | width: 225, | ||
| 57 | minSize: 175, | ||
| 58 | maxSize: 400, | ||
| 59 | items: [ this.listView ] | ||
| 60 | } | ||
| 61 | ); | ||
| 62 | |||
| 63 | Ext.apply(this, | ||
| 32 | title: _("Logfiles"), | ||
| 33 | xtype: 'systemlogfiles', | ||
| 34 | ref: 'systemlogfiles' | ||
| 35 | }, | ||
| 64 | 36 | { | |
| 65 | layout: 'border', | ||
| 66 | border: false, | ||
| 67 | bodyBorder: false, | ||
| 68 | items: [ listHolder, contentPanel ] | ||
| 69 | } | ||
| 70 | ); | ||
| 37 | title: _("JS Plugin Logs"), | ||
| 38 | xtype: "dsssystemjslogfiles", | ||
| 39 | ref: "systemjslogfiles" | ||
| 40 | }] | ||
| 41 | }; | ||
| 71 | 42 | ||
| 72 | dSS.SystemPanel.superclass.initComponent.apply(this, arguments); | ||
| 43 | this.listView = new Ext.list.ListView({ | ||
| 44 | ref: 'listView', | ||
| 45 | store: tabStore, | ||
| 46 | singleSelect: true, | ||
| 47 | region: 'west', | ||
| 48 | hideHeaders: true, | ||
| 49 | columns: [ | ||
| 50 | { | ||
| 51 | header: 'name', | ||
| 52 | dataIndex: 'title' | ||
| 53 | }] | ||
| 54 | }); | ||
| 73 | 55 | ||
| 74 | this.on( | ||
| 75 | 'activate', | ||
| 76 | function(component) { | ||
| 77 | if(this.initializedTabs) { | ||
| 78 | this.contentPanel.layout.activeItem.fireEvent("activate", this.contentPanel.layout.activeItem); | ||
| 79 | return; | ||
| 80 | } | ||
| 81 | // for each item in contentPanel | ||
| 82 | this.contentPanel.items.each(function(item) { | ||
| 83 | var tab = new tabRecord({title: item.title}); | ||
| 84 | tabStore.add([tab]); | ||
| 85 | }, this); | ||
| 86 | this.listView.select(0, false, true); | ||
| 87 | this.listView.on( | ||
| 88 | 'activate', | ||
| 89 | function() { | ||
| 90 | // setup new filter when panel gets reactivated | ||
| 91 | }, | ||
| 92 | this | ||
| 93 | ); | ||
| 94 | this.listView.on( | ||
| 95 | 'selectionchange', | ||
| 96 | function(listView, selections) { | ||
| 97 | this.contentPanel.layout.setActiveItem(selections[0].viewIndex); | ||
| 98 | this.contentPanel.layout.activeItem.fireEvent("activate", this.contentPanel.layout.activeItem); | ||
| 99 | }, | ||
| 100 | this | ||
| 101 | ); | ||
| 102 | this.initializedTabs = true; | ||
| 103 | }, | ||
| 104 | this | ||
| 105 | ); | ||
| 106 | }, | ||
| 56 | var listHolder = new Ext.Panel({ | ||
| 57 | title: "System", | ||
| 58 | region: 'west', | ||
| 59 | layout: 'fit', | ||
| 60 | split: true, | ||
| 61 | width: 225, | ||
| 62 | minSize: 175, | ||
| 63 | maxSize: 400, | ||
| 64 | items: [this.listView] | ||
| 65 | }); | ||
| 66 | |||
| 67 | Ext.apply(this, { | ||
| 68 | layout: 'border', | ||
| 69 | border: false, | ||
| 70 | bodyBorder: false, | ||
| 71 | items: [listHolder, contentPanel] | ||
| 72 | }); | ||
| 73 | |||
| 74 | dSS.SystemPanel.superclass.initComponent.apply(this, arguments); | ||
| 75 | |||
| 76 | this.on('activate', function(component) { | ||
| 77 | if (this.initializedTabs) { | ||
| 78 | this.contentPanel.layout.activeItem.fireEvent("activate", this.contentPanel.layout.activeItem); | ||
| 79 | return; | ||
| 80 | } | ||
| 81 | // for each item in contentPanel | ||
| 82 | this.contentPanel.items.each(function(item) { | ||
| 83 | var tab = new tabRecord({ | ||
| 84 | title: item.title | ||
| 85 | }); | ||
| 86 | tabStore.add([tab]); | ||
| 87 | }, | ||
| 88 | this); | ||
| 89 | this.listView.select(0, false, true); | ||
| 90 | this.listView.on('activate', function() { | ||
| 91 | // setup new filter when panel gets reactivated | ||
| 92 | }, | ||
| 93 | this); | ||
| 94 | this.listView.on('selectionchange', function(listView, selections) { | ||
| 95 | this.contentPanel.layout.setActiveItem(selections[0].viewIndex); | ||
| 96 | this.contentPanel.layout.activeItem.fireEvent("activate", this.contentPanel.layout.activeItem); | ||
| 97 | }, | ||
| 98 | this); | ||
| 99 | this.initializedTabs = true; | ||
| 100 | }, | ||
| 101 | this); | ||
| 102 | }, | ||
| 107 | 103 | rescan: function() { | |
| 108 | 104 | this.ownerCt.zoneBrowser.rescan(); | |
| 109 | 105 | }, |
webroot/js/dss/dss-setup-interface/dSS/ZoneBrowser.js
(51 / 57)
|   | |||
| 2 | 2 | //= require <dSS/ZonePanel> | |
| 3 | 3 | //= require <dSS/grid/DevicePanel> | |
| 4 | 4 | //= require <dSS/MessageBus> | |
| 5 | |||
| 6 | 5 | Ext.namespace('dSS'); | |
| 7 | 6 | ||
| 8 | 7 | dSS.ZoneBrowser = Ext.extend(Ext.Panel, { | |
| 9 | initComponent: function() { | ||
| 8 | initComponent: function() { | ||
| 10 | 9 | ||
| 11 | Ext.apply(this, { | ||
| 12 | layout: 'border', | ||
| 13 | items: [{ | ||
| 14 | xtype: 'dsszonepanel', | ||
| 15 | ref: 'zonePanel', | ||
| 16 | region: 'west', | ||
| 17 | width: 225, // give east and west regions a width | ||
| 18 | minSize: 175, | ||
| 19 | maxSize: 400, | ||
| 20 | split: true | ||
| 21 | },{ | ||
| 22 | xtype: 'dssdevicepanel', | ||
| 23 | ref: 'devicePanel', | ||
| 24 | minSize: 400, | ||
| 25 | region: 'center' | ||
| 26 | } | ||
| 27 | ] | ||
| 28 | }); | ||
| 10 | Ext.apply(this, { | ||
| 11 | layout: 'border', | ||
| 12 | items: [ | ||
| 13 | { | ||
| 14 | xtype: 'dsszonepanel', | ||
| 15 | ref: 'zonePanel', | ||
| 16 | region: 'west', | ||
| 17 | width: 225, | ||
| 18 | // give east and west regions a width | ||
| 19 | minSize: 175, | ||
| 20 | maxSize: 400, | ||
| 21 | split: true | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | xtype: 'dssdevicepanel', | ||
| 25 | ref: 'devicePanel', | ||
| 26 | minSize: 400, | ||
| 27 | region: 'center' | ||
| 28 | }] | ||
| 29 | }); | ||
| 29 | 30 | ||
| 30 | dSS.ZoneBrowser.superclass.initComponent.apply(this, arguments); | ||
| 31 | this.on( | ||
| 32 | 'afterrender', | ||
| 33 | this.loadData, | ||
| 34 | this | ||
| 35 | ); | ||
| 31 | dSS.ZoneBrowser.superclass.initComponent.apply(this, arguments); | ||
| 32 | this.on('afterrender', this.loadData, this); | ||
| 36 | 33 | ||
| 37 | this.on( | ||
| 38 | 'activate', | ||
| 39 | function() { | ||
| 40 | if (this.zonePanel) { | ||
| 41 | this.zonePanel.zoneView.filterDevices(); | ||
| 42 | } | ||
| 34 | this.on('activate', function() { | ||
| 35 | if (this.zonePanel) { | ||
| 36 | this.zonePanel.zoneView.filterDevices(); | ||
| 37 | } | ||
| 38 | }, | ||
| 39 | this); | ||
| 40 | |||
| 41 | }, | ||
| 42 | allDevices: undefined, | ||
| 43 | rescan: function() { | ||
| 44 | this.el.mask(_("Rescanning") + "..."); | ||
| 45 | Ext.Ajax.request({ | ||
| 46 | url: '/json/apartment/rescan', | ||
| 47 | disableCaching: true, | ||
| 48 | method: "GET", | ||
| 49 | scope: this, | ||
| 50 | success: function(result, request) { | ||
| 51 | this.el.unmask(); | ||
| 52 | this.loadData(); | ||
| 43 | 53 | }, | |
| 44 | this | ||
| 45 | ); | ||
| 54 | failure: function(result, request) { | ||
| 55 | this.el.unmask(); | ||
| 56 | Ext.MessageBox.alert(_("Error"), _("Rescan failed")); | ||
| 57 | } | ||
| 58 | }); | ||
| 59 | }, | ||
| 46 | 60 | ||
| 47 | }, | ||
| 48 | allDevices: undefined, | ||
| 49 | rescan: function() { | ||
| 50 | this.el.mask(_("Rescanning") + "..."); | ||
| 51 | Ext.Ajax.request({ | ||
| 52 | url: '/json/apartment/rescan', | ||
| 53 | disableCaching: true, | ||
| 54 | method: "GET", | ||
| 55 | scope: this, | ||
| 56 | success: function(result, request) { | ||
| 57 | this.el.unmask(); | ||
| 58 | this.loadData(); | ||
| 59 | }, | ||
| 60 | failure: function(result, request) { | ||
| 61 | this.el.unmask(); | ||
| 62 | Ext.MessageBox.alert(_("Error"), _("Rescan failed")); | ||
| 63 | } | ||
| 64 | }); | ||
| 65 | }, | ||
| 66 | |||
| 67 | loadData: function() { | ||
| 68 | dSS.data.Loader.load(); | ||
| 69 | } | ||
| 61 | loadData: function() { | ||
| 62 | dSS.data.Loader.load(); | ||
| 63 | } | ||
| 70 | 64 | ||
| 71 | 65 | }); | |
| 72 | 66 |
webroot/js/dss/dss-setup-interface/dSS/ZonePanel.js
(180 / 166)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/ZoneView> | |
| 3 | |||
| 4 | 3 | Ext.namespace('dSS'); | |
| 5 | 4 | ||
| 6 | 5 | dSS.ZonePanel = Ext.extend(Ext.Panel, { | |
| 7 | initComponent: function() { | ||
| 8 | Ext.apply(this, { | ||
| 9 | title:_("Rooms"), | ||
| 10 | layout: 'border', | ||
| 11 | items: [{ xtype: 'dsszoneview', ref: 'zoneView', region: 'center'}] | ||
| 12 | //tbar: ['->', createZoneAction, reloadAction] | ||
| 13 | }); | ||
| 6 | initComponent: function() { | ||
| 7 | Ext.apply(this, { | ||
| 8 | title: _("Rooms"), | ||
| 9 | layout: 'border', | ||
| 10 | items: [ | ||
| 11 | { | ||
| 12 | xtype: 'dsszoneview', | ||
| 13 | ref: 'zoneView', | ||
| 14 | region: 'center' | ||
| 15 | }] | ||
| 16 | //tbar: ['->', createZoneAction, reloadAction] | ||
| 17 | }); | ||
| 14 | 18 | ||
| 15 | this.tbar = this.buildTopToolbar(); | ||
| 19 | this.tbar = this.buildTopToolbar(); | ||
| 16 | 20 | ||
| 17 | this.zoneSortMode = 0; | ||
| 21 | this.zoneSortMode = 0; | ||
| 18 | 22 | ||
| 19 | dSS.ZonePanel.superclass.initComponent.apply(this, arguments); | ||
| 20 | }, | ||
| 23 | dSS.ZonePanel.superclass.initComponent.apply(this, arguments); | ||
| 24 | }, | ||
| 21 | 25 | ||
| 22 | buildTopToolbar: function() { | ||
| 23 | return [{ | ||
| 24 | //text: 'New Zone', | ||
| 25 | iconCls: 'newZoneAction', | ||
| 26 | handler: this.createNewZone, | ||
| 27 | scope: this | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | //text: 'Edit Room | ||
| 31 | iconCls: 'editZoneAction', | ||
| 32 | handler: this.editZone, | ||
| 33 | scope: this | ||
| 34 | }, | ||
| 26 | buildTopToolbar: function() { | ||
| 27 | return [ | ||
| 28 | { | ||
| 29 | //text: 'New Zone', | ||
| 30 | iconCls: 'newZoneAction', | ||
| 31 | handler: this.createNewZone, | ||
| 32 | scope: this | ||
| 33 | }, | ||
| 34 | { | ||
| 35 | //text: 'Edit Room | ||
| 36 | iconCls: 'editZoneAction', | ||
| 37 | handler: this.editZone, | ||
| 38 | scope: this | ||
| 39 | }, | ||
| 35 | 40 | ||
| 36 | '->', | ||
| 37 | { | ||
| 38 | iconCls: 'sortZoneAction', | ||
| 39 | handler: this.sortZonesCycle, | ||
| 40 | scope: this | ||
| 41 | }, | ||
| 41 | '->', { | ||
| 42 | iconCls: 'sortZoneAction', | ||
| 43 | handler: this.sortZonesCycle, | ||
| 44 | scope: this | ||
| 45 | }, | ||
| 42 | 46 | ||
| 43 | { | ||
| 44 | cls: 'zonePanelMenu', | ||
| 45 | menu: [{ | ||
| 46 | text: _("Reload"), | ||
| 47 | handler: this.reload, | ||
| 48 | scope: this | ||
| 49 | }, | ||
| 50 | { | ||
| 51 | text: _("Rescan"), | ||
| 52 | handler: this.rescan, | ||
| 53 | scope: this | ||
| 54 | }] | ||
| 55 | } | ||
| 56 | ]; | ||
| 57 | }, | ||
| 58 | rescan: function() { | ||
| 59 | this.ownerCt.rescan(); | ||
| 60 | }, | ||
| 61 | editZone: function() { | ||
| 62 | var zoneStore = this.zoneView.getStore(); | ||
| 63 | if(this.zoneView.getSelectionCount() !== 1) { | ||
| 64 | return; | ||
| 65 | } else { | ||
| 66 | var record = this.zoneView.getSelectedRecords()[0]; | ||
| 67 | Ext.Msg.prompt(_("Rename room"), _("New name for room"), function(btn, text){ | ||
| 68 | if(text !== record.get('name')) { | ||
| 69 | Ext.Ajax.request({ | ||
| 70 | url: '/json/zone/setName', | ||
| 71 | disableCaching: true, | ||
| 72 | method: "GET", | ||
| 73 | params: { id: record.get('id'), | ||
| 74 | newName: text}, | ||
| 75 | success: function(result, request) { | ||
| 76 | try { | ||
| 77 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 78 | if(jsonData.ok) { | ||
| 79 | record.set('name', text); | ||
| 80 | record.commit(); | ||
| 81 | } else { | ||
| 82 | Ext.MessageBox.alert(_("Error"), _("Could not rename room")); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | catch (err) { | ||
| 86 | Ext.MessageBox.alert(_("Error"), _("Could not rename room")); | ||
| 87 | } | ||
| 88 | }, | ||
| 89 | failure: function(result, request) { | ||
| 90 | Ext.MessageBox.alert(_("Error"), _("Could not rename room")); | ||
| 91 | } | ||
| 92 | }); | ||
| 93 | } | ||
| 94 | }, this, false, record.get('name')); | ||
| 95 | } | ||
| 96 | }, | ||
| 47 | { | ||
| 48 | cls: 'zonePanelMenu', | ||
| 49 | menu: [ | ||
| 50 | { | ||
| 51 | text: _("Reload"), | ||
| 52 | handler: this.reload, | ||
| 53 | scope: this | ||
| 54 | }, | ||
| 55 | { | ||
| 56 | text: _("Rescan"), | ||
| 57 | handler: this.rescan, | ||
| 58 | scope: this | ||
| 59 | }] | ||
| 60 | }]; | ||
| 61 | }, | ||
| 62 | rescan: function() { | ||
| 63 | this.ownerCt.rescan(); | ||
| 64 | }, | ||
| 65 | editZone: function() { | ||
| 66 | var zoneStore = this.zoneView.getStore(); | ||
| 67 | if (this.zoneView.getSelectionCount() !== 1) { | ||
| 68 | return; | ||
| 69 | } else { | ||
| 70 | var record = this.zoneView.getSelectedRecords()[0]; | ||
| 71 | Ext.Msg.prompt(_("Rename room"), _("New name for room"), function(btn, text) { | ||
| 72 | if (text !== record.get('name')) { | ||
| 73 | Ext.Ajax.request({ | ||
| 74 | url: '/json/zone/setName', | ||
| 75 | disableCaching: true, | ||
| 76 | method: "GET", | ||
| 77 | params: { | ||
| 78 | id: record.get('id'), | ||
| 79 | newName: text | ||
| 80 | }, | ||
| 81 | success: function(result, request) { | ||
| 82 | try { | ||
| 83 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 84 | if (jsonData.ok) { | ||
| 85 | record.set('name', text); | ||
| 86 | record.commit(); | ||
| 87 | } else { | ||
| 88 | Ext.MessageBox.alert(_("Error"), _("Could not rename room")); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | catch(err) { | ||
| 92 | Ext.MessageBox.alert(_("Error"), _("Could not rename room")); | ||
| 93 | } | ||
| 94 | }, | ||
| 95 | failure: function(result, request) { | ||
| 96 | Ext.MessageBox.alert(_("Error"), _("Could not rename room")); | ||
| 97 | } | ||
| 98 | }); | ||
| 99 | } | ||
| 100 | }, | ||
| 101 | this, false, record.get('name')); | ||
| 102 | } | ||
| 103 | }, | ||
| 97 | 104 | ||
| 98 | createNewZone: function() { | ||
| 99 | var zoneStore = this.zoneView.getStore(); | ||
| 100 | Ext.Msg.prompt(_("Create new room"), _("Name for new room"), function(btn, text){ | ||
| 101 | if (btn == 'ok'){ | ||
| 102 | for(var i = 0; i <= zoneStore.data.length; i++) { | ||
| 103 | if(zoneStore.findExact('id', i) === -1) { | ||
| 105 | createNewZone: function() { | ||
| 106 | var zoneStore = this.zoneView.getStore(); | ||
| 107 | Ext.Msg.prompt(_("Create new room"), _("Name for new room"), function(btn, text) { | ||
| 108 | if (btn == 'ok') { | ||
| 109 | for (var i = 0; i <= zoneStore.data.length; i++) { | ||
| 110 | if (zoneStore.findExact('id', i) === - 1) { | ||
| 104 | 111 | ||
| 105 | Ext.Ajax.request({ | ||
| 106 | url: '/json/structure/addZone', | ||
| 107 | disableCaching: true, | ||
| 108 | method: "GET", | ||
| 109 | params: { zoneID: i }, | ||
| 110 | success: function(result, request) { | ||
| 111 | try { | ||
| 112 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 113 | if(jsonData.ok) { | ||
| 112 | Ext.Ajax.request({ | ||
| 113 | url: '/json/structure/addZone', | ||
| 114 | disableCaching: true, | ||
| 115 | method: "GET", | ||
| 116 | params: { | ||
| 117 | zoneID: i | ||
| 118 | }, | ||
| 119 | success: function(result, request) { | ||
| 120 | try { | ||
| 121 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 122 | if (jsonData.ok) { | ||
| 114 | 123 | ||
| 124 | Ext.Ajax.request({ | ||
| 125 | url: '/json/zone/setName', | ||
| 126 | disableCaching: true, | ||
| 127 | method: "GET", | ||
| 128 | params: { | ||
| 129 | id: i, | ||
| 130 | newName: text | ||
| 131 | }, | ||
| 132 | success: function(result, request) { | ||
| 133 | try { | ||
| 134 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 135 | if (jsonData.ok) { | ||
| 136 | zoneStore.loadData({ | ||
| 137 | zones: [ | ||
| 138 | { | ||
| 139 | id: i, | ||
| 140 | name: text | ||
| 141 | }] | ||
| 142 | }, | ||
| 143 | true); | ||
| 144 | } else { | ||
| 145 | Ext.MessageBox.alert(_("Error"), _("Could not create zone") + ": " + json.message); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | catch(err) { | ||
| 149 | Ext.MessageBox.alert(_("Error"), _("Could not create zone") + ": " + err); | ||
| 150 | } | ||
| 151 | }, | ||
| 152 | failure: function(result, request) { | ||
| 153 | Ext.MessageBox.alert(_("Error"), _("Could not create zone")); | ||
| 154 | } | ||
| 155 | }); | ||
| 115 | 156 | ||
| 116 | |||
| 117 | Ext.Ajax.request({ | ||
| 118 | url: '/json/zone/setName', | ||
| 119 | disableCaching: true, | ||
| 120 | method: "GET", | ||
| 121 | params: { id: i, | ||
| 122 | newName: text}, | ||
| 123 | success: function(result, request) { | ||
| 124 | try { | ||
| 125 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 126 | if(jsonData.ok) { | ||
| 127 | zoneStore.loadData({zones: [{id: i, name: text}]}, true); | ||
| 128 | } else { | ||
| 129 | Ext.MessageBox.alert(_("Error"), _("Could not create zone") + ": " + json.message); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | catch (err) { | ||
| 133 | Ext.MessageBox.alert(_("Error"), _("Could not create zone") + ": " + err); | ||
| 134 | } | ||
| 135 | }, | ||
| 136 | failure: function(result, request) { | ||
| 137 | Ext.MessageBox.alert(_("Error"), _("Could not create zone")); | ||
| 138 | } | ||
| 139 | }); | ||
| 140 | |||
| 141 | |||
| 142 | } | ||
| 143 | } | ||
| 144 | catch (err) { | ||
| 145 | Ext.MessageBox.alert(_("Error"), _("Could not create zone")); | ||
| 146 | } | ||
| 147 | }, | ||
| 148 | failure: function(result, request) { | ||
| 149 | Ext.MessageBox.alert(_("Error"), _("Could not create zone")); | ||
| 150 | } | ||
| 151 | }); | ||
| 152 | return; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | } | ||
| 156 | }) | ||
| 157 | }, | ||
| 158 | reload: function() { | ||
| 159 | this.ownerCt.loadData(); | ||
| 160 | }, | ||
| 157 | } | ||
| 158 | } | ||
| 159 | catch(err) { | ||
| 160 | Ext.MessageBox.alert(_("Error"), _("Could not create zone")); | ||
| 161 | } | ||
| 162 | }, | ||
| 163 | failure: function(result, request) { | ||
| 164 | Ext.MessageBox.alert(_("Error"), _("Could not create zone")); | ||
| 165 | } | ||
| 166 | }); | ||
| 167 | return; | ||
| 168 | } | ||
| 169 | } | ||
| 170 | } | ||
| 171 | }) | ||
| 172 | }, | ||
| 173 | reload: function() { | ||
| 174 | this.ownerCt.loadData(); | ||
| 175 | }, | ||
| 161 | 176 | sortZonesCycle: function() { | |
| 162 | 177 | var zstore = dSS.data.Loader.getZoneStore(); | |
| 163 | switch (this.zoneSortMode) | ||
| 164 | { | ||
| 165 | case 0: | ||
| 166 | zstore.sort('id', 'ASC'); | ||
| 167 | this.zoneSortMode++; | ||
| 168 | break; | ||
| 169 | case 1: | ||
| 170 | zstore.sort('id', 'DESC') | ||
| 171 | this.zoneSortMode++; | ||
| 172 | break; | ||
| 173 | case 2: | ||
| 174 | zstore.sort('name', 'ASC'); | ||
| 175 | this.zoneSortMode++; | ||
| 176 | break; | ||
| 177 | case 3: | ||
| 178 | zstore.sort('name', 'DESC'); | ||
| 179 | this.zoneSortMode = 0; | ||
| 180 | break; | ||
| 181 | default: | ||
| 182 | this.zoneSortMode = 0; | ||
| 183 | break; | ||
| 178 | switch (this.zoneSortMode) { | ||
| 179 | case 0: | ||
| 180 | zstore.sort('id', 'ASC'); | ||
| 181 | this.zoneSortMode++; | ||
| 182 | break; | ||
| 183 | case 1: | ||
| 184 | zstore.sort('id', 'DESC') | ||
| 185 | this.zoneSortMode++; | ||
| 186 | break; | ||
| 187 | case 2: | ||
| 188 | zstore.sort('name', 'ASC'); | ||
| 189 | this.zoneSortMode++; | ||
| 190 | break; | ||
| 191 | case 3: | ||
| 192 | zstore.sort('name', 'DESC'); | ||
| 193 | this.zoneSortMode = 0; | ||
| 194 | break; | ||
| 195 | default: | ||
| 196 | this.zoneSortMode = 0; | ||
| 197 | break; | ||
| 184 | 198 | } | |
| 185 | 199 | } | |
| 186 | 200 | }); |
webroot/js/dss/dss-setup-interface/dSS/ZoneView.js
(184 / 194)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/data/ZoneStore> | |
| 3 | 3 | //= require <dSS/data/Loader> | |
| 4 | |||
| 5 | 4 | Ext.namespace('dSS'); | |
| 6 | 5 | ||
| 7 | 6 | dSS.ZoneView = Ext.extend(Ext.DataView, { | |
| 8 | initComponent: function() { | ||
| 7 | initComponent: function() { | ||
| 9 | 8 | ||
| 10 | var zoneTemplate = new Ext.XTemplate( | ||
| 11 | '<tpl for=".">', | ||
| 12 | '<div class="zone-wrap {css}" id="zone-{id}">', | ||
| 13 | '<span>', | ||
| 14 | '{name} - {id}', | ||
| 15 | '<tpl if="primary === true">', | ||
| 16 | ' *', | ||
| 17 | '</tpl>', | ||
| 18 | '</span>', | ||
| 19 | '</div>', | ||
| 20 | '</tpl>', | ||
| 21 | '<div class="x-clear"></div>' | ||
| 22 | ); | ||
| 9 | var zoneTemplate = new Ext.XTemplate( | ||
| 10 | '<tpl for=".">', | ||
| 11 | '<div class="zone-wrap {css}" id="zone-{id}">', | ||
| 12 | '<span>', | ||
| 13 | '{name} - {id}', | ||
| 14 | '<tpl if="primary === true">', | ||
| 15 | ' *', | ||
| 16 | '</tpl>', | ||
| 17 | '</span>', | ||
| 18 | '</div>', | ||
| 19 | '</tpl>', | ||
| 20 | '<div class="x-clear"></div>'); | ||
| 23 | 21 | ||
| 24 | Ext.apply(this, { | ||
| 25 | store: dSS.data.Loader.getZoneStore(), | ||
| 26 | tpl: zoneTemplate, | ||
| 27 | singleSelect: true, | ||
| 28 | multiSelect: false, | ||
| 29 | layout: 'fit', | ||
| 30 | style: "overflow: auto", | ||
| 31 | overClass:'x-view-over', | ||
| 32 | itemSelector:'div.zone-wrap', | ||
| 33 | emptyText: _("No rooms to display") | ||
| 34 | }); | ||
| 22 | Ext.apply(this, { | ||
| 23 | store: dSS.data.Loader.getZoneStore(), | ||
| 24 | tpl: zoneTemplate, | ||
| 25 | singleSelect: true, | ||
| 26 | multiSelect: false, | ||
| 27 | layout: 'fit', | ||
| 28 | style: "overflow: auto", | ||
| 29 | overClass: 'x-view-over', | ||
| 30 | itemSelector: 'div.zone-wrap', | ||
| 31 | emptyText: _("No rooms to display") | ||
| 32 | }); | ||
| 35 | 33 | ||
| 36 | dSS.ZoneView.superclass.initComponent.apply(this, arguments); | ||
| 34 | dSS.ZoneView.superclass.initComponent.apply(this, arguments); | ||
| 37 | 35 | ||
| 38 | dSS.data.Loader.getDeviceStore().on( | ||
| 39 | 'load', | ||
| 40 | this.updateNumDevicesHeader, | ||
| 41 | this | ||
| 42 | ); | ||
| 36 | dSS.data.Loader.getDeviceStore().on('load', this.updateNumDevicesHeader, this); | ||
| 43 | 37 | ||
| 44 | // Here you can add functionality that requires the object to | ||
| 45 | // exist, like event handling. | ||
| 46 | this.on( | ||
| 47 | 'selectionchange', | ||
| 48 | function(dv,nodes) { | ||
| 38 | // Here you can add functionality that requires the object to | ||
| 39 | // exist, like event handling. | ||
| 40 | this.on('selectionchange', function(dv, nodes) { | ||
| 49 | 41 | /* | |
| 50 | 42 | var l = nodes.length; | |
| 51 | 43 | var s = l != 1 ? 's' : ''; | |
| 52 | 44 | this.findParentByType('dsszonepanel').setTitle(gt.ngettext("Zone", "n% Zones", l)); | |
| 53 | 45 | */ | |
| 54 | this.filterDevices(); | ||
| 55 | this.updateNumDevicesHeader(); | ||
| 56 | }, | ||
| 57 | this | ||
| 58 | ); | ||
| 46 | this.filterDevices(); | ||
| 47 | this.updateNumDevicesHeader(); | ||
| 48 | }, | ||
| 49 | this); | ||
| 59 | 50 | ||
| 60 | this.on( | ||
| 61 | 'render', | ||
| 62 | function() { | ||
| 63 | var zoneView = this; | ||
| 64 | this.dropZone = new Ext.dd.DropZone(zoneView.getEl(), { | ||
| 65 | ddGroup : "zoneDeviceDD", | ||
| 66 | containerScroll : true, | ||
| 67 | getTargetFromEvent: function(e) { | ||
| 68 | return e.getTarget(zoneView.itemSelector); | ||
| 69 | }, | ||
| 70 | onNodeEnter : function(target, dd, e, data){ | ||
| 71 | Ext.fly(target).addClass('my-row-highlight-class'); | ||
| 72 | }, | ||
| 73 | onNodeOut : function(target, dd, e, data){ | ||
| 74 | Ext.fly(target).removeClass('my-row-highlight-class'); | ||
| 75 | }, | ||
| 76 | onNodeOver : function(target, dd, e, data){ | ||
| 77 | return Ext.dd.DropZone.prototype.dropAllowed; | ||
| 78 | }, | ||
| 79 | onNodeDrop : function(target, dd, e, data){ | ||
| 80 | var record = zoneView.getRecord(target); | ||
| 81 | Ext.each(data.selections, function(device) { | ||
| 82 | var currentDevice = device; | ||
| 83 | Ext.Ajax.request({ | ||
| 84 | url: '/json/structure/zoneAddDevice', | ||
| 85 | disableCaching: true, | ||
| 86 | method: "GET", | ||
| 87 | scope: zoneView, | ||
| 88 | params: { deviceID: currentDevice.get('dsid'), | ||
| 89 | zone: record.get('id') | ||
| 90 | }, | ||
| 91 | success: function(result, request) { | ||
| 92 | try { | ||
| 93 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 94 | if(jsonData.ok) { | ||
| 95 | currentDevice.set("zoneId", record.data.id); | ||
| 96 | currentDevice.store.commitChanges(); | ||
| 97 | this.filterDevices(); | ||
| 98 | this.updateNumDevicesHeader(); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | catch (err) { | ||
| 102 | Ext.MessageBox.alert(_("Error"), _("Could not move device ") + '"' + device.data.dsid + '"'); | ||
| 103 | } | ||
| 104 | }, | ||
| 105 | failure: function(result, request) { | ||
| 106 | Ext.MessageBox.alert(_("Error"), _("Could not move device ") + '"' + device.data.dsid + '"'); | ||
| 107 | } | ||
| 108 | }); | ||
| 109 | }); | ||
| 110 | return true; | ||
| 111 | } | ||
| 112 | }); | ||
| 113 | }, | ||
| 114 | this | ||
| 115 | ); | ||
| 51 | this.on('render', function() { | ||
| 52 | var zoneView = this; | ||
| 53 | this.dropZone = new Ext.dd.DropZone(zoneView.getEl(), { | ||
| 54 | ddGroup: "zoneDeviceDD", | ||
| 55 | containerScroll: true, | ||
| 56 | getTargetFromEvent: function(e) { | ||
| 57 | return e.getTarget(zoneView.itemSelector); | ||
| 58 | }, | ||
| 59 | onNodeEnter: function(target, dd, e, data) { | ||
| 60 | Ext.fly(target).addClass('my-row-highlight-class'); | ||
| 61 | }, | ||
| 62 | onNodeOut: function(target, dd, e, data) { | ||
| 63 | Ext.fly(target).removeClass('my-row-highlight-class'); | ||
| 64 | }, | ||
| 65 | onNodeOver: function(target, dd, e, data) { | ||
| 66 | return Ext.dd.DropZone.prototype.dropAllowed; | ||
| 67 | }, | ||
| 68 | onNodeDrop: function(target, dd, e, data) { | ||
| 69 | var record = zoneView.getRecord(target); | ||
| 70 | Ext.each(data.selections, function(device) { | ||
| 71 | var currentDevice = device; | ||
| 72 | Ext.Ajax.request({ | ||
| 73 | url: '/json/structure/zoneAddDevice', | ||
| 74 | disableCaching: true, | ||
| 75 | method: "GET", | ||
| 76 | scope: zoneView, | ||
| 77 | params: { | ||
| 78 | deviceID: currentDevice.get('dsid'), | ||
| 79 | zone: record.get('id') | ||
| 80 | }, | ||
| 81 | success: function(result, request) { | ||
| 82 | try { | ||
| 83 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 84 | if (jsonData.ok) { | ||
| 85 | currentDevice.set("zoneId", record.data.id); | ||
| 86 | currentDevice.store.commitChanges(); | ||
| 87 | this.filterDevices(); | ||
| 88 | this.updateNumDevicesHeader(); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | catch(err) { | ||
| 92 | Ext.MessageBox.alert(_("Error"), _("Could not move device ") + '"' + device.data.dsid + '"'); | ||
| 93 | } | ||
| 94 | }, | ||
| 95 | failure: function(result, request) { | ||
| 96 | Ext.MessageBox.alert(_("Error"), _("Could not move device ") + '"' + device.data.dsid + '"'); | ||
| 97 | } | ||
| 98 | }); | ||
| 99 | }); | ||
| 100 | return true; | ||
| 101 | } | ||
| 102 | }); | ||
| 103 | }, | ||
| 104 | this); | ||
| 116 | 105 | ||
| 117 | this.on( | ||
| 118 | 'contextmenu', | ||
| 119 | function(view, index, node, event) { | ||
| 120 | event.preventDefault(); | ||
| 121 | event.stopEvent(); | ||
| 122 | if(!this.contextMenu) { | ||
| 123 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 124 | } else { | ||
| 125 | this.contextMenu.removeAll(); | ||
| 126 | } | ||
| 106 | this.on('contextmenu', function(view, index, node, event) { | ||
| 107 | event.preventDefault(); | ||
| 108 | event.stopEvent(); | ||
| 109 | if (!this.contextMenu) { | ||
| 110 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 111 | } else { | ||
| 112 | this.contextMenu.removeAll(); | ||
| 113 | } | ||
| 127 | 114 | ||
| 128 | var menuItem = new Ext.menu.Item({ | ||
| 129 | text: _("Rename room"), | ||
| 130 | icon: '/images/page_white_edit.png', | ||
| 131 | handler: this.findParentByType('dsszonepanel').editZone.createDelegate(this.findParentByType('dsszonepanel'), index, true) | ||
| 132 | }); | ||
| 133 | this.contextMenu.add(menuItem) | ||
| 115 | var menuItem = new Ext.menu.Item({ | ||
| 116 | text: _("Rename room"), | ||
| 117 | icon: '/images/page_white_edit.png', | ||
| 118 | handler: this.findParentByType('dsszonepanel').editZone.createDelegate(this.findParentByType('dsszonepanel'), index, true) | ||
| 119 | }); | ||
| 120 | this.contextMenu.add(menuItem) | ||
| 134 | 121 | ||
| 135 | var menuItem = new Ext.menu.Item({ | ||
| 136 | text: _("Delete room"), | ||
| 137 | icon: '/images/delete.png', | ||
| 138 | handler: this.removeZone.createDelegate(this, index, true) | ||
| 139 | }); | ||
| 140 | this.contextMenu.add(menuItem) | ||
| 122 | var menuItem = new Ext.menu.Item({ | ||
| 123 | text: _("Delete room"), | ||
| 124 | icon: '/images/delete.png', | ||
| 125 | handler: this.removeZone.createDelegate(this, index, true) | ||
| 126 | }); | ||
| 127 | this.contextMenu.add(menuItem) | ||
| 141 | 128 | ||
| 142 | var menuItem = new Ext.menu.Item({ | ||
| 143 | text: _("Blink"), | ||
| 144 | icon: '/images/blink.png', | ||
| 145 | handler: this.blinkZone.createDelegate(this, index, true) | ||
| 146 | }); | ||
| 147 | this.contextMenu.add(menuItem) | ||
| 129 | var menuItem = new Ext.menu.Item({ | ||
| 130 | text: _("Blink"), | ||
| 131 | icon: '/images/blink.png', | ||
| 132 | handler: this.blinkZone.createDelegate(this, index, true) | ||
| 133 | }); | ||
| 134 | this.contextMenu.add(menuItem) | ||
| 148 | 135 | ||
| 149 | var xy = event.getXY(); | ||
| 150 | this.contextMenu.showAt(xy); | ||
| 151 | }, | ||
| 152 | this | ||
| 153 | ); | ||
| 154 | }, | ||
| 136 | var xy = event.getXY(); | ||
| 137 | this.contextMenu.showAt(xy); | ||
| 138 | }, | ||
| 139 | this); | ||
| 140 | }, | ||
| 155 | 141 | ||
| 156 | 142 | filterDevices: function() { | |
| 157 | 143 | var selectedZones = this.getSelectedRecords(); | |
| 158 | 144 | var store = dSS.data.Loader.getDeviceStore(); | |
| 159 | 145 | ||
| 160 | if(selectedZones.length === 0) { | ||
| 146 | if (selectedZones.length === 0) { | ||
| 161 | 147 | store.clearFilter(); | |
| 162 | 148 | return; | |
| 163 | 149 | } | |
| 164 | 150 | store.filterBy(function(record) { | |
| 165 | for(var i = 0; i < selectedZones.length; i++) { | ||
| 166 | if(record.get('zoneId') === selectedZones[i].get('id')) { | ||
| 151 | for (var i = 0; i < selectedZones.length; i++) { | ||
| 152 | if (record.get('zoneId') === selectedZones[i].get('id')) { | ||
| 167 | 153 | return true; | |
| 168 | 154 | } | |
| 169 | 155 | } | |
| … | … | ||
| 161 | 161 | var count = dSS.data.Loader.getDeviceStore().getRange().length; | |
| 162 | 162 | var selectedZones = this.getSelectedRecords(); | |
| 163 | 163 | var title = ''; | |
| 164 | if(selectedZones.length === 0) { | ||
| 164 | if (selectedZones.length === 0) { | ||
| 165 | 165 | title = _("Devices in all rooms"); | |
| 166 | 166 | } else { | |
| 167 | 167 | title = _("Devices in room") + " \"" + selectedZones[0].get('name') + " - " + selectedZones[0].get('id') + "\""; | |
| … | … | ||
| 169 | 169 | this.findParentByType('dsszonebrowser').devicePanel.setTitle("<span class=\"x-panel-header-text\">" + title + "</span><span style=\"float: right;\" class=\"x-panel-header-text\">" + count + " " + gt.ngettext("Device", "n% Devices", count) + "</span>"); | |
| 170 | 170 | }, | |
| 171 | 171 | ||
| 172 | removeZone: function(item, event, index) { | ||
| 173 | var record = this.getStore().getAt(index); | ||
| 174 | if(record.get('primary') == true) { | ||
| 175 | Ext.MessageBox.alert('Error', 'You cannot delete a primary room.'); | ||
| 176 | return; | ||
| 177 | } | ||
| 178 | var deviceStore = this.findParentByType('dsszonebrowser').devicePanel.getStore(); | ||
| 179 | if(deviceStore.query('zone', record.get('id')).getCount() > 0) { | ||
| 180 | Ext.MessageBox.alert('Error', 'You cannot delete a non empty room.'); | ||
| 181 | return; | ||
| 182 | } | ||
| 172 | removeZone: function(item, event, index) { | ||
| 173 | var record = this.getStore().getAt(index); | ||
| 174 | if (record.get('primary') == true) { | ||
| 175 | Ext.MessageBox.alert('Error', 'You cannot delete a primary room.'); | ||
| 176 | return; | ||
| 177 | } | ||
| 178 | var deviceStore = this.findParentByType('dsszonebrowser').devicePanel.getStore(); | ||
| 179 | if (deviceStore.query('zone', record.get('id')).getCount() > 0) { | ||
| 180 | Ext.MessageBox.alert('Error', 'You cannot delete a non empty room.'); | ||
| 181 | return; | ||
| 182 | } | ||
| 183 | 183 | ||
| 184 | Ext.Ajax.request({ | ||
| 185 | url: '/json/structure/removeZone', | ||
| 186 | disableCaching: true, | ||
| 187 | method: "GET", | ||
| 188 | scope: this, | ||
| 189 | params: { zoneID: record.get('id') }, | ||
| 190 | success: function(result, request) { | ||
| 191 | try { | ||
| 192 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 193 | if(jsonData.ok) { | ||
| 194 | this.getStore().removeAt(index); | ||
| 195 | } else { | ||
| 196 | Ext.MessageBox.alert(_("Error"), _("Could not remove room") + " \"" + record.get('name') + "\""); | ||
| 197 | } | ||
| 198 | } catch (err) { | ||
| 199 | Ext.MessageBox.alert(_("Error"), _("Could not remove room") + " \"" + record.get('name') + "\""); | ||
| 200 | } | ||
| 201 | }, | ||
| 202 | failure: function(result, request) { | ||
| 203 | Ext.MessageBox.alert(_("Error"), _("Could not remove room") + " \"" + record.get('name') + "\""); | ||
| 204 | } | ||
| 205 | }) | ||
| 206 | }, | ||
| 184 | Ext.Ajax.request({ | ||
| 185 | url: '/json/structure/removeZone', | ||
| 186 | disableCaching: true, | ||
| 187 | method: "GET", | ||
| 188 | scope: this, | ||
| 189 | params: { | ||
| 190 | zoneID: record.get('id') | ||
| 191 | }, | ||
| 192 | success: function(result, request) { | ||
| 193 | try { | ||
| 194 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 195 | if (jsonData.ok) { | ||
| 196 | this.getStore().removeAt(index); | ||
| 197 | } else { | ||
| 198 | Ext.MessageBox.alert(_("Error"), _("Could not remove room") + " \"" + record.get('name') + "\""); | ||
| 199 | } | ||
| 200 | } catch(err) { | ||
| 201 | Ext.MessageBox.alert(_("Error"), _("Could not remove room") + " \"" + record.get('name') + "\""); | ||
| 202 | } | ||
| 203 | }, | ||
| 204 | failure: function(result, request) { | ||
| 205 | Ext.MessageBox.alert(_("Error"), _("Could not remove room") + " \"" + record.get('name') + "\""); | ||
| 206 | } | ||
| 207 | }) | ||
| 208 | }, | ||
| 207 | 209 | ||
| 208 | blinkZone: function(item, event, index) { | ||
| 209 | var record = this.getStore().getAt(index); | ||
| 210 | |||
| 211 | Ext.Ajax.request({ | ||
| 212 | url: '/json/zone/blink', | ||
| 213 | disableCaching: true, | ||
| 214 | method: "GET", | ||
| 215 | scope: this, | ||
| 216 | params: { id: record.get('id') }, | ||
| 217 | success: function(result, request) { | ||
| 218 | try { | ||
| 219 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 220 | if(!jsonData.ok) { | ||
| 221 | Ext.MessageBox.alert(_("Error"), _("Could not blink room") + " \"" + record.get('name') + "\""); | ||
| 222 | } | ||
| 223 | } catch (err) { | ||
| 224 | Ext.MessageBox.alert(_("Error"), _("Could not blink room") + " \"" + record.get('name') + "\""); | ||
| 225 | } | ||
| 226 | }, | ||
| 227 | failure: function(result, request) { | ||
| 228 | Ext.MessageBox.alert(_("Error"), _("Could not blink room") + " \"" + record.get('name') + "\""); | ||
| 229 | } | ||
| 230 | }) | ||
| 231 | } | ||
| 210 | blinkZone: function(item, event, index) { | ||
| 211 | var record = this.getStore().getAt(index); | ||
| 212 | |||
| 213 | Ext.Ajax.request({ | ||
| 214 | url: '/json/zone/blink', | ||
| 215 | disableCaching: true, | ||
| 216 | method: "GET", | ||
| 217 | scope: this, | ||
| 218 | params: { | ||
| 219 | id: record.get('id') | ||
| 220 | }, | ||
| 221 | success: function(result, request) { | ||
| 222 | try { | ||
| 223 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 224 | if (!jsonData.ok) { | ||
| 225 | Ext.MessageBox.alert(_("Error"), _("Could not blink room") + " \"" + record.get('name') + "\""); | ||
| 226 | } | ||
| 227 | } catch(err) { | ||
| 228 | Ext.MessageBox.alert(_("Error"), _("Could not blink room") + " \"" + record.get('name') + "\""); | ||
| 229 | } | ||
| 230 | }, | ||
| 231 | failure: function(result, request) { | ||
| 232 | Ext.MessageBox.alert(_("Error"), _("Could not blink room") + " \"" + record.get('name') + "\""); | ||
| 233 | } | ||
| 234 | }) | ||
| 235 | } | ||
| 232 | 236 | }); | |
| 233 | 237 | ||
| 234 | 238 | Ext.reg('dsszoneview', dSS.ZoneView); |
webroot/js/dss/dss-setup-interface/dSS/dSMOverviewPanel.js
(10 / 10)
|   | |||
| 1 | 1 | //= require <dSS/grid/ModulatorPanel> | |
| 2 | 2 | //= require <dSS/ZonePanel> | |
| 3 | |||
| 4 | 3 | Ext.namespace('dSS', 'dSS.system', 'dSS.grid'); | |
| 5 | 4 | ||
| 6 | 5 | dSS.system.dSMOverview = Ext.extend(Ext.Panel, { | |
| … | … | ||
| 9 | 9 | layout: 'border', | |
| 10 | 10 | items: [ | |
| 11 | 11 | { | |
| 12 | xtype: 'dssmodulatorpanel', | ||
| 13 | ref: 'modulatorPanel', | ||
| 14 | region: 'north', | ||
| 15 | split : true | ||
| 16 | },{ | ||
| 17 | xtype: 'dssdevicepanel', | ||
| 18 | region: 'center' | ||
| 12 | xtype: 'dssmodulatorpanel', | ||
| 13 | ref: 'modulatorPanel', | ||
| 14 | region: 'north', | ||
| 15 | split: true | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | xtype: 'dssdevicepanel', | ||
| 19 | region: 'center' | ||
| 19 | 20 | }] | |
| 20 | 21 | }); | |
| 21 | |||
| 22 | |||
| 22 | 23 | dSS.system.dSMOverview.superclass.initComponent.apply(this, arguments); | |
| 23 | } | ||
| 24 | } | ||
| 24 | 25 | }); | |
| 25 | 26 | ||
| 26 | 27 | Ext.reg('dsmoverviewpanel', dSS.system.dSMOverview); |
webroot/js/dss/dss-setup-interface/dSS/data/CircuitStore.js
(38 / 22)
|   | |||
| 1 | 1 | Ext.namespace('dSS', 'dSS.data'); | |
| 2 | 2 | ||
| 3 | 3 | dSS.data.CircuitStore = Ext.extend(Ext.data.Store, { | |
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for zone records | ||
| 6 | var zoneRecord = Ext.data.Record.create([ | ||
| 7 | {name:"busid"}, | ||
| 8 | {name:"deviceType"}, | ||
| 9 | {name:"dsid"}, | ||
| 10 | {name:"hwName"}, | ||
| 11 | {name:"hwVersion"}, | ||
| 12 | {name:"isPresent"}, | ||
| 13 | {name:"name"}, | ||
| 14 | {name:"swVersion"} | ||
| 15 | ]); | ||
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for zone records | ||
| 6 | var zoneRecord = Ext.data.Record.create([ | ||
| 7 | { | ||
| 8 | name: "busid" | ||
| 9 | }, | ||
| 10 | { | ||
| 11 | name: "deviceType" | ||
| 12 | }, | ||
| 13 | { | ||
| 14 | name: "dsid" | ||
| 15 | }, | ||
| 16 | { | ||
| 17 | name: "hwName" | ||
| 18 | }, | ||
| 19 | { | ||
| 20 | name: "hwVersion" | ||
| 21 | }, | ||
| 22 | { | ||
| 23 | name: "isPresent" | ||
| 24 | }, | ||
| 25 | { | ||
| 26 | name: "name" | ||
| 27 | }, | ||
| 28 | { | ||
| 29 | name: "swVersion" | ||
| 30 | }]); | ||
| 16 | 31 | ||
| 17 | // a json reader to read the zone data | ||
| 18 | var zoneReader = new Ext.data.JsonReader( | ||
| 19 | { | ||
| 20 | root: "result.circuits" | ||
| 21 | }, | ||
| 22 | zoneRecord | ||
| 23 | ); | ||
| 32 | // a json reader to read the zone data | ||
| 33 | var zoneReader = new Ext.data.JsonReader({ | ||
| 34 | root: "result.circuits" | ||
| 35 | }, | ||
| 36 | zoneRecord); | ||
| 24 | 37 | ||
| 25 | Ext.apply(this, { reader: zoneReader, url: '/json/apartment/getCircuits' }); | ||
| 26 | dSS.data.CircuitStore.superclass.constructor.call(this, arguments); | ||
| 27 | } | ||
| 38 | Ext.apply(this, { | ||
| 39 | reader: zoneReader, | ||
| 40 | url: '/json/apartment/getCircuits' | ||
| 41 | }); | ||
| 42 | dSS.data.CircuitStore.superclass.constructor.call(this, arguments); | ||
| 43 | } | ||
| 28 | 44 | }); |
webroot/js/dss/dss-setup-interface/dSS/data/DeviceStore.js
(55 / 36)
|   | |||
| 1 | 1 | Ext.namespace('dSS', 'dSS.data'); | |
| 2 | 2 | ||
| 3 | 3 | dSS.data.DeviceStore = Ext.extend(Ext.data.Store, { | |
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for device records | ||
| 6 | var deviceRecord = Ext.data.Record.create([ | ||
| 7 | {name:"name"}, | ||
| 8 | {name:"dsid", mapping: "id"}, | ||
| 9 | {name:"blink", defaultValue: false}, | ||
| 10 | {name:"modulatorDsid"}, | ||
| 11 | {name:"modulatorName"}, | ||
| 12 | {name:"zoneId"}, | ||
| 13 | {name:"isPresent"}, | ||
| 14 | {name:"firstSeen"}, | ||
| 15 | {name:"lastDiscovered"}, | ||
| 16 | {name:"locked"}, | ||
| 17 | {name:"functionID"} | ||
| 18 | ]); | ||
| 19 | |||
| 20 | // a json reader to read the device data | ||
| 21 | var deviceReader = new Ext.data.JsonReader( | ||
| 22 | { | ||
| 23 | root:"devices" | ||
| 24 | }, | ||
| 25 | deviceRecord | ||
| 26 | ); | ||
| 27 | |||
| 28 | Ext.apply( | ||
| 29 | this, | ||
| 30 | { | ||
| 31 | reader: deviceReader, | ||
| 32 | sortInfo: { | ||
| 33 | field: 'firstSeen', | ||
| 34 | direction: 'DESC' // or 'DESC' (case sensitive for local sorting) | ||
| 35 | } | ||
| 36 | } | ||
| 37 | ); | ||
| 38 | dSS.data.DeviceStore.superclass.constructor.call(this, arguments); | ||
| 39 | } | ||
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for device records | ||
| 6 | var deviceRecord = Ext.data.Record.create([ | ||
| 7 | { | ||
| 8 | name: "name" | ||
| 9 | }, | ||
| 10 | { | ||
| 11 | name: "dsid", | ||
| 12 | mapping: "id" | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | name: "blink", | ||
| 16 | defaultValue: false | ||
| 17 | }, | ||
| 18 | { | ||
| 19 | name: "modulatorDsid" | ||
| 20 | }, | ||
| 21 | { | ||
| 22 | name: "modulatorName" | ||
| 23 | }, | ||
| 24 | { | ||
| 25 | name: "zoneId" | ||
| 26 | }, | ||
| 27 | { | ||
| 28 | name: "isPresent" | ||
| 29 | }, | ||
| 30 | { | ||
| 31 | name: "firstSeen" | ||
| 32 | }, | ||
| 33 | { | ||
| 34 | name: "lastDiscovered" | ||
| 35 | }, | ||
| 36 | { | ||
| 37 | name: "locked" | ||
| 38 | }, | ||
| 39 | { | ||
| 40 | name: "functionID" | ||
| 41 | }]); | ||
| 42 | |||
| 43 | // a json reader to read the device data | ||
| 44 | var deviceReader = new Ext.data.JsonReader({ | ||
| 45 | root: "devices" | ||
| 46 | }, | ||
| 47 | deviceRecord); | ||
| 48 | |||
| 49 | Ext.apply( | ||
| 50 | this, { | ||
| 51 | reader: deviceReader, | ||
| 52 | sortInfo: { | ||
| 53 | field: 'firstSeen', | ||
| 54 | direction: 'DESC' // or 'DESC' (case sensitive for local sorting) | ||
| 55 | } | ||
| 56 | }); | ||
| 57 | dSS.data.DeviceStore.superclass.constructor.call(this, arguments); | ||
| 58 | } | ||
| 40 | 59 | }); |
webroot/js/dss/dss-setup-interface/dSS/data/Loader.js
(0 / 1)
|   | |||
| 1 | 1 | //= require <dSS/data/LoaderImpl> | |
| 2 | |||
| 3 | 2 | Ext.namespace('dSS', 'dSS.data'); | |
| 4 | 3 | ||
| 5 | 4 | dSS.data.Loader = (function() { |
webroot/js/dss/dss-setup-interface/dSS/data/LoaderImpl.js
(82 / 77)
|   | |||
| 1 | 1 | //= require <dSS/data/ModulatorStore> | |
| 2 | 2 | //= require <dSS/data/DeviceStore> | |
| 3 | 3 | //= require <dSS/data/ZoneStore> | |
| 4 | |||
| 5 | 4 | Ext.namespace('dSS', 'dSS.data'); | |
| 6 | 5 | ||
| 7 | 6 | dSS.data.LoaderImpl = Ext.extend(Ext.util.Observable, { | |
| 8 | 7 | ||
| 9 | constructor: function() { | ||
| 10 | this.modulatorStore = new dSS.data.ModulatorStore({url: '/json/apartment/getCircuits'}); | ||
| 11 | this.deviceStore = new dSS.data.DeviceStore(); | ||
| 12 | this.zoneStore = new dSS.data.ZoneStore(); | ||
| 13 | }, | ||
| 8 | constructor: function() { | ||
| 9 | this.modulatorStore = new dSS.data.ModulatorStore({ | ||
| 10 | url: '/json/apartment/getCircuits' | ||
| 11 | }); | ||
| 12 | this.deviceStore = new dSS.data.DeviceStore(); | ||
| 13 | this.zoneStore = new dSS.data.ZoneStore(); | ||
| 14 | }, | ||
| 14 | 15 | ||
| 15 | load: function() { | ||
| 16 | this.modulatorStore.load(); | ||
| 17 | this.loadStructure(); | ||
| 18 | }, | ||
| 16 | load: function() { | ||
| 17 | this.modulatorStore.load(); | ||
| 18 | this.loadStructure(); | ||
| 19 | }, | ||
| 19 | 20 | ||
| 20 | getModulatorStore: function() { | ||
| 21 | return this.modulatorStore; | ||
| 22 | }, | ||
| 21 | getModulatorStore: function() { | ||
| 22 | return this.modulatorStore; | ||
| 23 | }, | ||
| 23 | 24 | ||
| 24 | getDeviceStore: function() { | ||
| 25 | return this.deviceStore; | ||
| 26 | }, | ||
| 25 | getDeviceStore: function() { | ||
| 26 | return this.deviceStore; | ||
| 27 | }, | ||
| 27 | 28 | ||
| 28 | getZoneStore: function() { | ||
| 29 | return this.zoneStore; | ||
| 30 | }, | ||
| 29 | getZoneStore: function() { | ||
| 30 | return this.zoneStore; | ||
| 31 | }, | ||
| 31 | 32 | ||
| 33 | loadStructure: function() { | ||
| 34 | Ext.Ajax.request({ | ||
| 35 | url: '/json/apartment/getStructure', | ||
| 36 | disableCaching: true, | ||
| 37 | timeout: 300000, | ||
| 38 | method: "GET", | ||
| 39 | scope: this, | ||
| 40 | success: function(result, request) { | ||
| 41 | try { | ||
| 42 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 43 | this.processStructure(jsonData.result); | ||
| 44 | } | ||
| 45 | catch(err) { | ||
| 46 | Ext.MessageBox.alert(_("Error"), _("Could not load appartment structure") + ": \"" + err + "\""); | ||
| 47 | } | ||
| 48 | }, | ||
| 49 | failure: function(result, request) { | ||
| 50 | Ext.MessageBox.alert(_("Error"), _("Could not load") + ": \"" + request.url + "\""); | ||
| 51 | } | ||
| 52 | }); | ||
| 53 | }, | ||
| 32 | 54 | ||
| 33 | loadStructure: function() { | ||
| 34 | Ext.Ajax.request({ | ||
| 35 | url: '/json/apartment/getStructure', | ||
| 36 | disableCaching: true, | ||
| 37 | timeout: 300000, | ||
| 38 | method: "GET", | ||
| 39 | scope: this, | ||
| 40 | success: function(result, request) { | ||
| 41 | try { | ||
| 42 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 43 | this.processStructure(jsonData.result); | ||
| 44 | } | ||
| 45 | catch (err) { | ||
| 46 | Ext.MessageBox.alert(_("Error"), _("Could not load appartment structure") + ": \"" + err + "\""); | ||
| 47 | } | ||
| 48 | }, | ||
| 49 | failure: function(result, request) { | ||
| 50 | Ext.MessageBox.alert(_("Error"), _("Could not load") + ": \"" + request.url + "\""); | ||
| 51 | } | ||
| 52 | }); | ||
| 53 | }, | ||
| 54 | |||
| 55 | processStructure: function(structure) { | ||
| 56 | var devices = [], zones = []; | ||
| 57 | var zoneStore = this.zoneStore; | ||
| 58 | var modulatorStore = this.modulatorStore; | ||
| 59 | var deviceStore = this.deviceStore; | ||
| 60 | Ext.each(structure.apartment.zones, function(zone) { | ||
| 61 | if(zone.id === 0) { | ||
| 62 | Ext.each(zone.devices, function(device) { | ||
| 63 | device.firstSeen = Date.parseDate(device.firstSeen + "+00:00", "c"); | ||
| 64 | device.lastDiscovered = Date.parseDate(device.lastDiscovered + "+00:00", "c"); | ||
| 65 | devices.push(device); | ||
| 55 | processStructure: function(structure) { | ||
| 56 | var devices = [], | ||
| 57 | zones = []; | ||
| 58 | var zoneStore = this.zoneStore; | ||
| 59 | var modulatorStore = this.modulatorStore; | ||
| 60 | var deviceStore = this.deviceStore; | ||
| 61 | Ext.each(structure.apartment.zones, function(zone) { | ||
| 62 | if (zone.id === 0) { | ||
| 63 | Ext.each(zone.devices, function(device) { | ||
| 64 | device.firstSeen = Date.parseDate(device.firstSeen + "+00:00", "c"); | ||
| 65 | device.lastDiscovered = Date.parseDate(device.lastDiscovered + "+00:00", "c"); | ||
| 66 | devices.push(device); | ||
| 67 | }); | ||
| 68 | } | ||
| 69 | zones.push({ | ||
| 70 | id: zone.id, | ||
| 71 | name: zone.name ? zone.name: _("Zone"), | ||
| 72 | primary: ('firstZoneOnDSMeter' in zone) ? true: false | ||
| 73 | }); | ||
| 74 | Ext.each(zone.devices, function(device) { | ||
| 75 | for (var i = 0; i < devices.length; i++) { | ||
| 76 | if (devices[i].id == device.id) { | ||
| 77 | devices[i].zoneId = zone.id; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | }); | ||
| 81 | zoneStore.loadData({ | ||
| 82 | zones: zones | ||
| 83 | }); | ||
| 66 | 84 | }); | |
| 67 | } | ||
| 68 | zones.push({ | ||
| 69 | id: zone.id, | ||
| 70 | name: zone.name ? zone.name : _("Zone"), | ||
| 71 | primary: ('firstZoneOnDSMeter' in zone) ? true : false | ||
| 72 | }); | ||
| 73 | Ext.each(zone.devices, function(device) { | ||
| 74 | for(var i = 0; i < devices.length; i++) { | ||
| 75 | if(devices[i].id == device.id) { | ||
| 76 | devices[i].zoneId = zone.id; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | }); | ||
| 80 | zoneStore.loadData({zones: zones}); | ||
| 81 | }); | ||
| 82 | Ext.each(devices, function(device) { | ||
| 83 | var index = modulatorStore.find("busId", new RegExp("^" + device.circuitID + "$")); | ||
| 84 | if(index > -1) { | ||
| 85 | var modulator = modulatorStore.getAt(index); | ||
| 86 | device.modulatorName = modulator.get("name"); | ||
| 87 | device.modulatorDsid = modulator.get("dsid") | ||
| 88 | } | ||
| 89 | }); | ||
| 90 | deviceStore.loadData({devices: devices}); | ||
| 91 | } | ||
| 85 | Ext.each(devices, function(device) { | ||
| 86 | var index = modulatorStore.find("busId", new RegExp("^" + device.circuitID + "$")); | ||
| 87 | if (index > - 1) { | ||
| 88 | var modulator = modulatorStore.getAt(index); | ||
| 89 | device.modulatorName = modulator.get("name"); | ||
| 90 | device.modulatorDsid = modulator.get("dsid") | ||
| 91 | } | ||
| 92 | }); | ||
| 93 | deviceStore.loadData({ | ||
| 94 | devices: devices | ||
| 95 | }); | ||
| 96 | } | ||
| 92 | 97 | ||
| 93 | 98 | }); |
webroot/js/dss/dss-setup-interface/dSS/data/ModulatorStore.js
(81 / 63)
|   | |||
| 1 | 1 | Ext.namespace('dSS', 'dSS.data'); | |
| 2 | 2 | ||
| 3 | 3 | dSS.data.ModulatorStore = Ext.extend(Ext.data.Store, { | |
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for zone records | ||
| 6 | var modulatorRecord = Ext.data.Record.create([ | ||
| 7 | {name:"busId", mapping: "busID"}, | ||
| 8 | {name:"deviceType"}, | ||
| 9 | {name:"dsid"}, | ||
| 10 | {name:"hwName"}, | ||
| 11 | {name:"hwVersion"}, | ||
| 12 | {name:"isPresent"}, | ||
| 13 | {name:"name"}, | ||
| 14 | {name:"swVersion"}, | ||
| 15 | {name:"consumption"}, | ||
| 16 | {name:"measureDate"} | ||
| 17 | ]); | ||
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for zone records | ||
| 6 | var modulatorRecord = Ext.data.Record.create([ | ||
| 7 | { | ||
| 8 | name: "busId", | ||
| 9 | mapping: "busID" | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | name: "deviceType" | ||
| 13 | }, | ||
| 14 | { | ||
| 15 | name: "dsid" | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | name: "hwName" | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | name: "hwVersion" | ||
| 22 | }, | ||
| 23 | { | ||
| 24 | name: "isPresent" | ||
| 25 | }, | ||
| 26 | { | ||
| 27 | name: "name" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | name: "swVersion" | ||
| 31 | }, | ||
| 32 | { | ||
| 33 | name: "consumption" | ||
| 34 | }, | ||
| 35 | { | ||
| 36 | name: "measureDate" | ||
| 37 | }]); | ||
| 18 | 38 | ||
| 19 | // a json reader to read the zone data | ||
| 20 | var modulatorReader = new Ext.data.JsonReader( | ||
| 21 | { | ||
| 22 | root: "result.circuits" | ||
| 23 | }, | ||
| 24 | modulatorRecord | ||
| 25 | ); | ||
| 39 | // a json reader to read the zone data | ||
| 40 | var modulatorReader = new Ext.data.JsonReader({ | ||
| 41 | root: "result.circuits" | ||
| 42 | }, | ||
| 43 | modulatorRecord); | ||
| 26 | 44 | ||
| 27 | Ext.apply(this, { reader: modulatorReader, url: '/json/apartment/getCircuits' }); | ||
| 28 | dSS.data.ModulatorStore.superclass.constructor.call(this, arguments); | ||
| 45 | Ext.apply(this, { | ||
| 46 | reader: modulatorReader, | ||
| 47 | url: '/json/apartment/getCircuits' | ||
| 48 | }); | ||
| 49 | dSS.data.ModulatorStore.superclass.constructor.call(this, arguments); | ||
| 29 | 50 | ||
| 30 | this.on( | ||
| 31 | 'load', | ||
| 32 | function(records, options) { | ||
| 33 | var store = this; | ||
| 34 | Ext.Ajax.request({ | ||
| 35 | url: '/json/metering/getLatest', | ||
| 36 | disableCaching: true, | ||
| 37 | method: 'GET', | ||
| 38 | scope: this, | ||
| 39 | params: { type : 'consumption', | ||
| 40 | from : '.meters(all)'}, | ||
| 41 | success: function(result, request) { | ||
| 42 | try { | ||
| 43 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 44 | if (jsonData.ok) { | ||
| 45 | var modified = false; | ||
| 51 | this.on('load', function(records, options) { | ||
| 52 | var store = this; | ||
| 53 | Ext.Ajax.request({ | ||
| 54 | url: '/json/metering/getLatest', | ||
| 55 | disableCaching: true, | ||
| 56 | method: 'GET', | ||
| 57 | scope: this, | ||
| 58 | params: { | ||
| 59 | type: 'consumption', | ||
| 60 | from: '.meters(all)' | ||
| 61 | }, | ||
| 62 | success: function(result, request) { | ||
| 63 | try { | ||
| 64 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 65 | if (jsonData.ok) { | ||
| 66 | var modified = false; | ||
| 46 | 67 | ||
| 47 | Ext.each(jsonData.result.values, | ||
| 48 | function(val) { | ||
| 49 | var index = store.find("dsid", new RegExp("^" + val.dsid + "$")); | ||
| 50 | if (index > -1) { | ||
| 51 | var rec = store.getAt(index); | ||
| 52 | rec.set("consumption", val.value); | ||
| 53 | rec.set("measureDate", val.date); | ||
| 54 | modified = true; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | ); | ||
| 58 | if (modified === true) { | ||
| 59 | store.commitChanges(); | ||
| 68 | Ext.each(jsonData.result.values, function(val) { | ||
| 69 | var index = store.find("dsid", new RegExp("^" + val.dsid + "$")); | ||
| 70 | if (index > - 1) { | ||
| 71 | var rec = store.getAt(index); | ||
| 72 | rec.set("consumption", val.value); | ||
| 73 | rec.set("measureDate", val.date); | ||
| 74 | modified = true; | ||
| 60 | 75 | } | |
| 61 | |||
| 62 | } else { | ||
| 63 | Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server")); | ||
| 76 | }); | ||
| 77 | if (modified === true) { | ||
| 78 | store.commitChanges(); | ||
| 64 | 79 | } | |
| 65 | } | ||
| 66 | catch (err) { | ||
| 80 | |||
| 81 | } else { | ||
| 67 | 82 | Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server")); | |
| 68 | 83 | } | |
| 69 | }, | ||
| 70 | failure: function(result, request) { | ||
| 84 | } | ||
| 85 | catch(err) { | ||
| 71 | 86 | Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server")); | |
| 72 | 87 | } | |
| 73 | }); | ||
| 74 | }, | ||
| 75 | this | ||
| 76 | ); | ||
| 88 | }, | ||
| 89 | failure: function(result, request) { | ||
| 90 | Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server")); | ||
| 91 | } | ||
| 92 | }); | ||
| 93 | }, | ||
| 94 | this); | ||
| 77 | 95 | } | |
| 78 | 96 | }); |
webroot/js/dss/dss-setup-interface/dSS/data/ZoneStore.js
(25 / 19)
|   | |||
| 1 | 1 | Ext.namespace('dSS', 'dSS.data'); | |
| 2 | 2 | ||
| 3 | 3 | dSS.data.ZoneStore = Ext.extend(Ext.data.Store, { | |
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for zone records | ||
| 6 | var zoneRecord = Ext.data.Record.create([ | ||
| 7 | {name:"name"}, | ||
| 8 | {name:"id"}, | ||
| 9 | {name:"primary", defaultValue: false} | ||
| 10 | ]); | ||
| 11 | |||
| 12 | // a json reader to read the zone data | ||
| 13 | var zoneReader = new Ext.data.JsonReader( | ||
| 14 | { | ||
| 15 | root: "zones" | ||
| 16 | }, | ||
| 17 | zoneRecord | ||
| 18 | ); | ||
| 19 | |||
| 20 | Ext.apply(this, { reader: zoneReader }); | ||
| 21 | dSS.data.ZoneStore.superclass.constructor.call(this, arguments); | ||
| 22 | } | ||
| 4 | constructor: function(config) { | ||
| 5 | // create a record constructor for zone records | ||
| 6 | var zoneRecord = Ext.data.Record.create([ | ||
| 7 | { | ||
| 8 | name: "name" | ||
| 9 | }, | ||
| 10 | { | ||
| 11 | name: "id" | ||
| 12 | }, | ||
| 13 | { | ||
| 14 | name: "primary", | ||
| 15 | defaultValue: false | ||
| 16 | }]); | ||
| 17 | |||
| 18 | // a json reader to read the zone data | ||
| 19 | var zoneReader = new Ext.data.JsonReader({ | ||
| 20 | root: "zones" | ||
| 21 | }, | ||
| 22 | zoneRecord); | ||
| 23 | |||
| 24 | Ext.apply(this, { | ||
| 25 | reader: zoneReader | ||
| 26 | }); | ||
| 27 | dSS.data.ZoneStore.superclass.constructor.call(this, arguments); | ||
| 28 | } | ||
| 23 | 29 | }); |
webroot/js/dss/dss-setup-interface/dSS/grid/DevicePanel.js
(548 / 480)
|   | |||
| 10 | 10 | //= requie <dSS/config/Config> | |
| 11 | 11 | //= require <dSS/scene/SceneWindowShadow> | |
| 12 | 12 | //= require <dSS/scene/SceneWindowLight> | |
| 13 | |||
| 14 | 13 | Ext.namespace('dSS', 'dSS.grid'); | |
| 15 | 14 | ||
| 16 | 15 | dSS.grid.DevicePanel = Ext.extend(Ext.grid.GridPanel, { | |
| 17 | initComponent: function() { | ||
| 16 | initComponent: function() { | ||
| 18 | 17 | ||
| 19 | var blinkRenderer = function(value, metaData, record, rowIndex, colIndex, store) { | ||
| 20 | if(record.get('isPresent') === false) { | ||
| 18 | var blinkRenderer = function(value, metaData, record, rowIndex, colIndex, store) { | ||
| 19 | if (record.get('isPresent') === false) { | ||
| 21 | 20 | metaData.css = 'isDisabled'; | |
| 22 | 21 | } | |
| 23 | 22 | else { | |
| 24 | if(record.get('blink') === true) { | ||
| 25 | metaData.css = 'blinkActive'; | ||
| 26 | } else { | ||
| 27 | metaData.css = 'blink'; | ||
| 28 | } | ||
| 23 | if (record.get('blink') === true) { | ||
| 24 | metaData.css = 'blinkActive'; | ||
| 25 | } else { | ||
| 26 | metaData.css = 'blink'; | ||
| 27 | } | ||
| 29 | 28 | } | |
| 30 | return String.format('<img class="padding-img" src="{0}"/>',Ext.BLANK_IMAGE_URL); | ||
| 31 | }; | ||
| 29 | return String.format('<img class="padding-img" src="{0}"/>', Ext.BLANK_IMAGE_URL); | ||
| 30 | }; | ||
| 32 | 31 | ||
| 33 | 32 | var lockRenderer = function(value, metaData, record, rowIndex, colIndex, store) { | |
| 34 | if(record.get('isPresent') === false) { | ||
| 33 | if (record.get('isPresent') === false) { | ||
| 35 | 34 | metaData.css = 'lockDisabled'; | |
| 36 | 35 | } | |
| 37 | 36 | else { | |
| 38 | if(record.get('locked')) { | ||
| 39 | metaData.css = 'isLocked'; | ||
| 40 | } else { | ||
| 41 | metaData.css = 'isUnlocked'; | ||
| 42 | } | ||
| 37 | if (record.get('locked')) { | ||
| 38 | metaData.css = 'isLocked'; | ||
| 39 | } else { | ||
| 40 | metaData.css = 'isUnlocked'; | ||
| 41 | } | ||
| 43 | 42 | } | |
| 44 | return String.format('<img class="padding-img" src="{0}"/>',Ext.BLANK_IMAGE_URL); | ||
| 45 | }; | ||
| 43 | return String.format('<img class="padding-img" src="{0}"/>', Ext.BLANK_IMAGE_URL); | ||
| 44 | }; | ||
| 46 | 45 | ||
| 47 | 46 | var devTypeRenderer = function(value, metaData, record, rowIndex, colIndex, store) { | |
| 48 | 47 | ||
| 49 | var present = record.get('isPresent'); | ||
| 48 | var present = record.get('isPresent'); | ||
| 50 | 49 | ||
| 51 | var fid = dSS.util.parseFunctionID(record.get('functionID')); | ||
| 50 | var fid = dSS.util.parseFunctionID(record.get('functionID')); | ||
| 52 | 51 | ||
| 53 | var retval = String.format('<img class="padding-img" src="{0}"/>',Ext.BLANK_IMAGE_URL); | ||
| 52 | var retval = String.format('<img class="padding-img" src="{0}"/>', Ext.BLANK_IMAGE_URL); | ||
| 54 | 53 | ||
| 55 | switch (fid[0]) { | ||
| 56 | case dSS.config.groups.LIGHT: | ||
| 57 | if (present === true) { | ||
| 58 | metaData.css = 'functionLight'; | ||
| 59 | } else { | ||
| 60 | metaData.css = 'functionLightDisabled'; | ||
| 61 | } | ||
| 62 | break; | ||
| 63 | case dSS.config.groups.SHADOW: | ||
| 64 | if (present === true) { | ||
| 65 | metaData.css = 'functionShadow'; | ||
| 66 | } else { | ||
| 67 | metaData.css = 'functionShadowDisabled'; | ||
| 68 | } | ||
| 69 | break; | ||
| 70 | case dSS.config.groups.CLIMATE: | ||
| 71 | metaData.css = 'functionClimate'; | ||
| 72 | break; | ||
| 73 | case dSS.config.groups.AUDIO: | ||
| 74 | metaData.css = 'functionAudio'; | ||
| 75 | break; | ||
| 76 | case dSS.config.groups.VIDEO: | ||
| 77 | metaData.css = 'functionVideo'; | ||
| 78 | break; | ||
| 79 | case dSS.config.groups.SECURITY: | ||
| 80 | metaData.css = 'functionSecurity'; | ||
| 81 | break; | ||
| 82 | case dSS.config.groups.ACCESS: | ||
| 83 | metaData.css = 'functionAccess'; | ||
| 84 | break; | ||
| 85 | case dSS.config.groups.JOKER: | ||
| 86 | metaData.css = 'functionJoker'; | ||
| 87 | break; | ||
| 88 | default: | ||
| 89 | retval = ""; | ||
| 90 | break; | ||
| 54 | switch (fid[0]) { | ||
| 55 | case dSS.config.groups.LIGHT: | ||
| 56 | if (present === true) { | ||
| 57 | metaData.css = 'functionLight'; | ||
| 58 | } else { | ||
| 59 | metaData.css = 'functionLightDisabled'; | ||
| 91 | 60 | } | |
| 92 | |||
| 93 | return retval; | ||
| 94 | }; | ||
| 61 | break; | ||
| 62 | case dSS.config.groups.SHADOW: | ||
| 63 | if (present === true) { | ||
| 64 | metaData.css = 'functionShadow'; | ||
| 65 | } else { | ||
| 66 | metaData.css = 'functionShadowDisabled'; | ||
| 67 | } | ||
| 68 | break; | ||
| 69 | case dSS.config.groups.CLIMATE: | ||
| 70 | metaData.css = 'functionClimate'; | ||
| 71 | break; | ||
| 72 | case dSS.config.groups.AUDIO: | ||
| 73 | metaData.css = 'functionAudio'; | ||
| 74 | break; | ||
| 75 | case dSS.config.groups.VIDEO: | ||
| 76 | metaData.css = 'functionVideo'; | ||
| 77 | break; | ||
| 78 | case dSS.config.groups.SECURITY: | ||
| 79 | metaData.css = 'functionSecurity'; | ||
| 80 | break; | ||
| 81 | case dSS.config.groups.ACCESS: | ||
| 82 | metaData.css = 'functionAccess'; | ||
| 83 | break; | ||
| 84 | case dSS.config.groups.JOKER: | ||
| 85 | metaData.css = 'functionJoker'; | ||
| 86 | break; | ||
| 87 | default: | ||
| 88 | retval = ""; | ||
| 89 | break; | ||
| 90 | } | ||
| 95 | 91 | ||
| 92 | return retval; | ||
| 93 | }; | ||
| 96 | 94 | ||
| 97 | var deviceCols = [ | ||
| 98 | {header: "", width: 17, resizable: false, sortable: false, hideable: false, menuDisabled: true, fixed: true, dataIndex: 'functionID', renderer: devTypeRenderer, id: 'functionID'}, | ||
| 99 | {header: _("blink"), width: 25, resizable: false, sortable: false, dataIndex: 'blink', renderer: blinkRenderer, id: 'blink'}, | ||
| 100 | {header: "dsid", width: 150, sortable: true, dataIndex: 'dsid', id: 'dsid'}, | ||
| 101 | {header: _("name"), width: 150, sortable: true, dataIndex: 'name', id: 'name'}, | ||
| 102 | {header: _("meter name"), width: 100, sortable: true, dataIndex: 'modulatorName', id: 'modulatorName' }, | ||
| 103 | {header: _("meter dsid"), width: 150, sortable: true, dataIndex: 'modulatorDsid', id: 'modulatorDsid'}, | ||
| 104 | {header: _("zone id"), width: 50, sortable: true, dataIndex: 'zoneId', id: 'zoneId'}, | ||
| 105 | {header: _("first seen"), width: 150, sortable: true, dataIndex: 'firstSeen', xtype: 'datecolumn', format: 'Y-m-d\\&\\n\\b\\s\\p\\;H:m:i', id: 'firstSeen'}, | ||
| 106 | {header: _("last discovered"), width: 150, sortable: true, dataIndex: 'lastDiscovered', xtype: 'datecolumn', format: 'Y-m-d\\&\\n\\b\\s\\p\\;H:m:i', id: 'lastDiscovered'}, | ||
| 107 | {header: _("locked"),width: 20, sortable: true, dataIndex: 'locked', renderer: lockRenderer} | ||
| 108 | ]; | ||
| 95 | var deviceCols = [ | ||
| 96 | { | ||
| 97 | header: "", | ||
| 98 | width: 17, | ||
| 99 | resizable: false, | ||
| 100 | sortable: false, | ||
| 101 | hideable: false, | ||
| 102 | menuDisabled: true, | ||
| 103 | fixed: true, | ||
| 104 | dataIndex: 'functionID', | ||
| 105 | renderer: devTypeRenderer, | ||
| 106 | id: 'functionID' | ||
| 107 | }, | ||
| 108 | { | ||
| 109 | header: _("blink"), | ||
| 110 | width: 25, | ||
| 111 | resizable: false, | ||
| 112 | sortable: false, | ||
| 113 | dataIndex: 'blink', | ||
| 114 | renderer: blinkRenderer, | ||
| 115 | id: 'blink' | ||
| 116 | }, | ||
| 117 | { | ||
| 118 | header: "dsid", | ||
| 119 | width: 150, | ||
| 120 | sortable: true, | ||
| 121 | dataIndex: 'dsid', | ||
| 122 | id: 'dsid' | ||
| 123 | }, | ||
| 124 | { | ||
| 125 | header: _("name"), | ||
| 126 | width: 150, | ||
| 127 | sortable: true, | ||
| 128 | dataIndex: 'name', | ||
| 129 | id: 'name' | ||
| 130 | }, | ||
| 131 | { | ||
| 132 | header: _("meter name"), | ||
| 133 | width: 100, | ||
| 134 | sortable: true, | ||
| 135 | dataIndex: 'modulatorName', | ||
| 136 | id: 'modulatorName' | ||
| 137 | }, | ||
| 138 | { | ||
| 139 | header: _("meter dsid"), | ||
| 140 | width: 150, | ||
| 141 | sortable: true, | ||
| 142 | dataIndex: 'modulatorDsid', | ||
| 143 | id: 'modulatorDsid' | ||
| 144 | }, | ||
| 145 | { | ||
| 146 | header: _("zone id"), | ||
| 147 | width: 50, | ||
| 148 | sortable: true, | ||
| 149 | dataIndex: 'zoneId', | ||
| 150 | id: 'zoneId' | ||
| 151 | }, | ||
| 152 | { | ||
| 153 | header: _("first seen"), | ||
| 154 | width: 150, | ||
| 155 | sortable: true, | ||
| 156 | dataIndex: 'firstSeen', | ||
| 157 | xtype: 'datecolumn', | ||
| 158 | format: 'Y-m-d\\&\\n\\b\\s\\p\\;H:m:i', | ||
| 159 | id: 'firstSeen' | ||
| 160 | }, | ||
| 161 | { | ||
| 162 | header: _("last discovered"), | ||
| 163 | width: 150, | ||
| 164 | sortable: true, | ||
| 165 | dataIndex: 'lastDiscovered', | ||
| 166 | xtype: 'datecolumn', | ||
| 167 | format: 'Y-m-d\\&\\n\\b\\s\\p\\;H:m:i', | ||
| 168 | id: 'lastDiscovered' | ||
| 169 | }, | ||
| 170 | { | ||
| 171 | header: _("locked"), | ||
| 172 | width: 20, | ||
| 173 | sortable: true, | ||
| 174 | dataIndex: 'locked', | ||
| 175 | renderer: lockRenderer | ||
| 176 | }]; | ||
| 109 | 177 | ||
| 110 | Ext.apply(this, { | ||
| 111 | store : dSS.data.Loader.getDeviceStore(), | ||
| 112 | columns : deviceCols, | ||
| 113 | ddGroup : "zoneDeviceDD", | ||
| 114 | enableDragDrop : true, | ||
| 115 | stripeRows : true, | ||
| 116 | forceFit : true, | ||
| 117 | title : gt.ngettext("Device", 2), | ||
| 118 | viewConfig: { | ||
| 119 | autoFill: true, | ||
| 120 | getRowClass: function(record, index) { | ||
| 121 | var c = record.get('isPresent'); | ||
| 122 | if (c === false) { | ||
| 123 | return 'nonPresentDevice'; | ||
| 124 | } | ||
| 125 | return ''; | ||
| 126 | } | ||
| 127 | } | ||
| 128 | }); | ||
| 178 | Ext.apply(this, { | ||
| 179 | store: dSS.data.Loader.getDeviceStore(), | ||
| 180 | columns: deviceCols, | ||
| 181 | ddGroup: "zoneDeviceDD", | ||
| 182 | enableDragDrop: true, | ||
| 183 | stripeRows: true, | ||
| 184 | forceFit: true, | ||
| 185 | title: gt.ngettext("Device", 2), | ||
| 186 | viewConfig: { | ||
| 187 | autoFill: true, | ||
| 188 | getRowClass: function(record, index) { | ||
| 189 | var c = record.get('isPresent'); | ||
| 190 | if (c === false) { | ||
| 191 | return 'nonPresentDevice'; | ||
| 192 | } | ||
| 193 | return ''; | ||
| 194 | } | ||
| 195 | } | ||
| 196 | }); | ||
| 129 | 197 | ||
| 130 | 198 | this.tbar = this.buildTopToolbar(); | |
| 131 | 199 | ||
| 132 | dSS.grid.DevicePanel.superclass.initComponent.apply(this, arguments); | ||
| 200 | dSS.grid.DevicePanel.superclass.initComponent.apply(this, arguments); | ||
| 133 | 201 | ||
| 134 | // Here you can add functionality that requires the object to | ||
| 135 | // exist, like event handling. | ||
| 136 | this.on( | ||
| 137 | 'rowcontextmenu', | ||
| 138 | function(grid, rowIndex, event) { | ||
| 139 | event.preventDefault(); | ||
| 140 | event.stopEvent(); | ||
| 141 | if(!this.contextMenu) { | ||
| 142 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 143 | } else { | ||
| 144 | this.contextMenu.removeAll(); | ||
| 145 | } | ||
| 202 | // Here you can add functionality that requires the object to | ||
| 203 | // exist, like event handling. | ||
| 204 | this.on('rowcontextmenu', function(grid, rowIndex, event) { | ||
| 205 | event.preventDefault(); | ||
| 206 | event.stopEvent(); | ||
| 207 | if (!this.contextMenu) { | ||
| 208 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 209 | } else { | ||
| 210 | this.contextMenu.removeAll(); | ||
| 211 | } | ||
| 146 | 212 | ||
| 147 | var sel = this.getSelectionModel(); | ||
| 148 | if (!sel.isSelected(rowIndex)) { | ||
| 149 | sel.selectRow(rowIndex, false); | ||
| 150 | } | ||
| 213 | var sel = this.getSelectionModel(); | ||
| 214 | if (!sel.isSelected(rowIndex)) { | ||
| 215 | sel.selectRow(rowIndex, false); | ||
| 216 | } | ||
| 151 | 217 | ||
| 152 | var showRemoveMenuItem = false; | ||
| 153 | var presentInSelection = false; | ||
| 218 | var showRemoveMenuItem = false; | ||
| 219 | var presentInSelection = false; | ||
| 154 | 220 | ||
| 155 | if (sel.getSelected().get("isPresent") === true) { | ||
| 156 | showPingMenuItem = true; | ||
| 157 | } | ||
| 221 | if (sel.getSelected().get("isPresent") === true) { | ||
| 222 | showPingMenuItem = true; | ||
| 223 | } | ||
| 158 | 224 | ||
| 159 | var records = sel.getSelections(); | ||
| 225 | var records = sel.getSelections(); | ||
| 160 | 226 | ||
| 161 | for (var i = 0; i < records.length; i++) | ||
| 162 | { | ||
| 163 | var record = records[i]; | ||
| 227 | for (var i = 0; i < records.length; i++) { | ||
| 228 | var record = records[i]; | ||
| 164 | 229 | ||
| 165 | // if at least one record can be removed - set the flag | ||
| 166 | // | ||
| 167 | if (record.get('isPresent') === false) { | ||
| 168 | showRemoveMenuItem = true; | ||
| 169 | } else { | ||
| 170 | presentInSelection = true; | ||
| 171 | } | ||
| 172 | |||
| 173 | if ((showRemoveMenuItem === true) && | ||
| 174 | (presentInSelection === true)) { | ||
| 175 | break; | ||
| 176 | } | ||
| 230 | // if at least one record can be removed - set the flag | ||
| 231 | // | ||
| 232 | if (record.get('isPresent') === false) { | ||
| 233 | showRemoveMenuItem = true; | ||
| 234 | } else { | ||
| 235 | presentInSelection = true; | ||
| 177 | 236 | } | |
| 178 | 237 | ||
| 179 | var menuItem = new Ext.menu.Item({ | ||
| 180 | text: _("Rename device"), | ||
| 181 | icon: '/images/page_white_edit.png', | ||
| 182 | handler: this.editDevice.createDelegate(this, rowIndex, true) | ||
| 183 | }); | ||
| 184 | this.contextMenu.add(menuItem) | ||
| 185 | |||
| 186 | if (presentInSelection === true) { | ||
| 187 | var menuItem = new Ext.menu.Item({ | ||
| 188 | text: _("Send diagnostic ping"), | ||
| 189 | icon: '/images/application_osx_terminal.png', | ||
| 190 | handler: this.pingDevice.createDelegate(this, rowIndex, true) | ||
| 191 | }); | ||
| 192 | this.contextMenu.add(menuItem) | ||
| 238 | if ((showRemoveMenuItem === true) && (presentInSelection === true)) { | ||
| 239 | break; | ||
| 193 | 240 | } | |
| 241 | } | ||
| 194 | 242 | ||
| 195 | if (dSS.config.features.extendedPing === true) { | ||
| 196 | var subMenu = new Ext.menu.Menu({}); | ||
| 243 | var menuItem = new Ext.menu.Item({ | ||
| 244 | text: _("Rename device"), | ||
| 245 | icon: '/images/page_white_edit.png', | ||
| 246 | handler: this.editDevice.createDelegate(this, rowIndex, true) | ||
| 247 | }); | ||
| 248 | this.contextMenu.add(menuItem) | ||
| 197 | 249 | ||
| 198 | if (presentInSelection === true) { | ||
| 199 | var menuItem = new Ext.menu.Item({ | ||
| 200 | text: _("Extended diagnostic ping"), | ||
| 201 | icon: '/images/application_osx_terminal.png', | ||
| 202 | handler: this.extendedPing.createDelegate(this, rowIndex, true) | ||
| 203 | }); | ||
| 204 | subMenu.add(menuItem); | ||
| 205 | } | ||
| 250 | if (presentInSelection === true) { | ||
| 251 | var menuItem = new Ext.menu.Item({ | ||
| 252 | text: _("Send diagnostic ping"), | ||
| 253 | icon: '/images/application_osx_terminal.png', | ||
| 254 | handler: this.pingDevice.createDelegate(this, rowIndex, true) | ||
| 255 | }); | ||
| 256 | this.contextMenu.add(menuItem) | ||
| 257 | } | ||
| 206 | 258 | ||
| 207 | var menuItem = new Ext.menu.Item({ | ||
| 208 | text: _("Extended diagnostic ping results"), | ||
| 209 | icon: '/images/application_osx_terminal.png', | ||
| 210 | handler: this.showExtendedPingResults.createDelegate(this, rowIndex, true) | ||
| 211 | }); | ||
| 212 | subMenu.add(menuItem); | ||
| 259 | if (dSS.config.features.extendedPing === true) { | ||
| 260 | var subMenu = new Ext.menu.Menu({}); | ||
| 213 | 261 | ||
| 262 | if (presentInSelection === true) { | ||
| 214 | 263 | var menuItem = new Ext.menu.Item({ | |
| 215 | text: _("Abort ping session"), | ||
| 216 | icon: '/images/application_osx_terminal.png', | ||
| 217 | handler: this.abortRound.createDelegate(this, ["extendedPing", _("Ping")], true) | ||
| 218 | }); | ||
| 219 | subMenu.add(menuItem); | ||
| 220 | |||
| 221 | var menuItem = new Ext.menu.Item({ | ||
| 222 | text: _("Extended ping"), | ||
| 223 | icon: '/images/application_osx_terminal.png', | ||
| 224 | menu: subMenu | ||
| 264 | text: _("Extended diagnostic ping"), | ||
| 265 | icon: '/images/application_osx_terminal.png', | ||
| 266 | handler: this.extendedPing.createDelegate(this, rowIndex, true) | ||
| 225 | 267 | }); | |
| 226 | this.contextMenu.add(menuItem); | ||
| 268 | subMenu.add(menuItem); | ||
| 227 | 269 | } | |
| 228 | 270 | ||
| 229 | if (showRemoveMenuItem === true) { | ||
| 230 | var menuItem = new Ext.menu.Item({ | ||
| 231 | text: _("Remove device"), | ||
| 232 | icon: '/images/delete.png', | ||
| 233 | handler: this.removeDevice.createDelegate(this, rowIndex, true) | ||
| 234 | }); | ||
| 235 | this.contextMenu.add(menuItem); | ||
| 236 | } | ||
| 237 | |||
| 238 | if (dSS.config.features.deviceStatistics === true) { | ||
| 239 | var subMenu = new Ext.menu.Menu({}); | ||
| 271 | var menuItem = new Ext.menu.Item({ | ||
| 272 | text: _("Extended diagnostic ping results"), | ||
| 273 | icon: '/images/application_osx_terminal.png', | ||
| 274 | handler: this.showExtendedPingResults.createDelegate(this, rowIndex, true) | ||
| 275 | }); | ||
| 276 | subMenu.add(menuItem); | ||
| 240 | 277 | ||
| 241 | if (presentInSelection === true) { | ||
| 242 | var menuItem = new Ext.menu.Item({ | ||
| 243 | text: _("Statistics"), | ||
| 244 | icon: '/images/application_osx_terminal.png', | ||
| 245 | handler: this.deviceStatistics.createDelegate(this, rowIndex, true) | ||
| 246 | }); | ||
| 247 | subMenu.add(menuItem); | ||
| 248 | } | ||
| 278 | var menuItem = new Ext.menu.Item({ | ||
| 279 | text: _("Abort ping session"), | ||
| 280 | icon: '/images/application_osx_terminal.png', | ||
| 281 | handler: this.abortRound.createDelegate(this, ["extendedPing", _("Ping")], true) | ||
| 282 | }); | ||
| 283 | subMenu.add(menuItem); | ||
| 249 | 284 | ||
| 250 | var menuItem = new Ext.menu.Item({ | ||
| 251 | text: _("Abort statistics session"), | ||
| 252 | icon: '/images/application_osx_terminal.png', | ||
| 253 | handler: this.abortRound.createDelegate(this, ["deviceStatistics", _("Device statistics")], true) | ||
| 254 | }); | ||
| 255 | subMenu.add(menuItem); | ||
| 285 | var menuItem = new Ext.menu.Item({ | ||
| 286 | text: _("Extended ping"), | ||
| 287 | icon: '/images/application_osx_terminal.png', | ||
| 288 | menu: subMenu | ||
| 289 | }); | ||
| 290 | this.contextMenu.add(menuItem); | ||
| 291 | } | ||
| 256 | 292 | ||
| 293 | if (showRemoveMenuItem === true) { | ||
| 294 | var menuItem = new Ext.menu.Item({ | ||
| 295 | text: _("Remove device"), | ||
| 296 | icon: '/images/delete.png', | ||
| 297 | handler: this.removeDevice.createDelegate(this, rowIndex, true) | ||
| 298 | }); | ||
| 299 | this.contextMenu.add(menuItem); | ||
| 300 | } | ||
| 301 | |||
| 302 | if (dSS.config.features.deviceStatistics === true) { | ||
| 303 | var subMenu = new Ext.menu.Menu({}); | ||
| 304 | |||
| 305 | if (presentInSelection === true) { | ||
| 257 | 306 | var menuItem = new Ext.menu.Item({ | |
| 258 | text: _("Device statistics"), | ||
| 259 | icon: '/images/application_osx_terminal.png', | ||
| 260 | menu: subMenu | ||
| 307 | text: _("Statistics"), | ||
| 308 | icon: '/images/application_osx_terminal.png', | ||
| 309 | handler: this.deviceStatistics.createDelegate(this, rowIndex, true) | ||
| 261 | 310 | }); | |
| 262 | this.contextMenu.add(menuItem); | ||
| 311 | subMenu.add(menuItem); | ||
| 263 | 312 | } | |
| 264 | 313 | ||
| 265 | if (presentInSelection === true) { | ||
| 266 | var menuItem = new Ext.menu.Item({ | ||
| 267 | text: _("Blink"), | ||
| 268 | icon: '/images/blink.png', | ||
| 269 | handler: this.blinkDevice.createDelegate(this, rowIndex, true) | ||
| 270 | }); | ||
| 271 | this.contextMenu.add(menuItem); | ||
| 272 | } | ||
| 314 | var menuItem = new Ext.menu.Item({ | ||
| 315 | text: _("Abort statistics session"), | ||
| 316 | icon: '/images/application_osx_terminal.png', | ||
| 317 | handler: this.abortRound.createDelegate(this, ["deviceStatistics", _("Device statistics")], true) | ||
| 318 | }); | ||
| 319 | subMenu.add(menuItem); | ||
| 273 | 320 | ||
| 274 | var xy = event.getXY(); | ||
| 275 | this.contextMenu.showAt(xy); | ||
| 276 | }, | ||
| 277 | this | ||
| 278 | ); | ||
| 321 | var menuItem = new Ext.menu.Item({ | ||
| 322 | text: _("Device statistics"), | ||
| 323 | icon: '/images/application_osx_terminal.png', | ||
| 324 | menu: subMenu | ||
| 325 | }); | ||
| 326 | this.contextMenu.add(menuItem); | ||
| 327 | } | ||
| 279 | 328 | ||
| 280 | this.on( | ||
| 281 | 'cellclick', | ||
| 282 | function (grid, rowIndex, columnIndex, event) { | ||
| 329 | if (presentInSelection === true) { | ||
| 330 | var menuItem = new Ext.menu.Item({ | ||
| 331 | text: _("Blink"), | ||
| 332 | icon: '/images/blink.png', | ||
| 333 | handler: this.blinkDevice.createDelegate(this, rowIndex, true) | ||
| 334 | }); | ||
| 335 | this.contextMenu.add(menuItem); | ||
| 336 | } | ||
| 283 | 337 | ||
| 284 | var dataIndex = grid.getColumnModel().getDataIndex(columnIndex); | ||
| 285 | |||
| 286 | var record = this.getStore().getAt(rowIndex); | ||
| 287 | if (record.get('isPresent') === false) { | ||
| 288 | return; | ||
| 289 | } | ||
| 338 | var xy = event.getXY(); | ||
| 339 | this.contextMenu.showAt(xy); | ||
| 340 | }, | ||
| 341 | this); | ||
| 290 | 342 | ||
| 291 | if (dataIndex === 'blink') { | ||
| 292 | this.sendBlinkRequest(record); | ||
| 293 | } else if (dataIndex === 'locked') { | ||
| 294 | Ext.Ajax.request({ | ||
| 295 | url: record.get('locked') ? '/json/device/unlock' : '/json/device/lock', | ||
| 296 | disableCaching: true, | ||
| 297 | method: "GET", | ||
| 298 | params: { dsid: record.get('dsid') }, | ||
| 299 | success: function(result, request) { | ||
| 300 | try { | ||
| 301 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 302 | if(jsonData.ok) { | ||
| 303 | record.set('locked', record.get('locked') ? false : true ); | ||
| 304 | record.commit(); | ||
| 305 | } | ||
| 306 | } catch(err) { | ||
| 307 | Ext.MessageBox.alert('Error', err); | ||
| 308 | } | ||
| 309 | } | ||
| 310 | }); | ||
| 311 | } else if (dataIndex === 'functionID') { | ||
| 312 | var fid = dSS.util.parseFunctionID(record.get('functionID')); | ||
| 313 | switch (fid[0]) { | ||
| 314 | case 1: | ||
| 315 | var win = new dSS.scene.SceneWindowLight({ | ||
| 316 | dsid : record.get('dsid'), | ||
| 317 | maskElement : | ||
| 318 | this.findParentByType(Ext.Viewport).el | ||
| 319 | }); | ||
| 320 | win.show(this); | ||
| 321 | break; | ||
| 322 | case 2: | ||
| 323 | var win = new dSS.scene.SceneWindowShadow({ | ||
| 324 | dsid : record.get('dsid'), | ||
| 325 | maskElement : | ||
| 326 | this.findParentByType(Ext.Viewport).el | ||
| 327 | }); | ||
| 328 | win.show(this); | ||
| 329 | break; | ||
| 330 | default: | ||
| 331 | break; | ||
| 332 | } | ||
| 343 | this.on('cellclick', function(grid, rowIndex, columnIndex, event) { | ||
| 344 | |||
| 345 | var dataIndex = grid.getColumnModel().getDataIndex(columnIndex); | ||
| 346 | |||
| 347 | var record = this.getStore().getAt(rowIndex); | ||
| 348 | if (record.get('isPresent') === false) { | ||
| 349 | return; | ||
| 350 | } | ||
| 351 | |||
| 352 | if (dataIndex === 'blink') { | ||
| 353 | this.sendBlinkRequest(record); | ||
| 354 | } else if (dataIndex === 'locked') { | ||
| 355 | Ext.Ajax.request({ | ||
| 356 | url: record.get('locked') ? '/json/device/unlock': '/json/device/lock', | ||
| 357 | disableCaching: true, | ||
| 358 | method: "GET", | ||
| 359 | params: { | ||
| 360 | dsid: record.get('dsid') | ||
| 361 | }, | ||
| 362 | success: function(result, request) { | ||
| 363 | try { | ||
| 364 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 365 | if (jsonData.ok) { | ||
| 366 | record.set('locked', record.get('locked') ? false: true); | ||
| 367 | record.commit(); | ||
| 368 | } | ||
| 369 | } catch(err) { | ||
| 370 | Ext.MessageBox.alert('Error', err); | ||
| 371 | } | ||
| 372 | } | ||
| 373 | }); | ||
| 374 | } else if (dataIndex === 'functionID') { | ||
| 375 | var fid = dSS.util.parseFunctionID(record.get('functionID')); | ||
| 376 | switch (fid[0]) { | ||
| 377 | case 1: | ||
| 378 | var win = new dSS.scene.SceneWindowLight({ | ||
| 379 | dsid: record.get('dsid'), | ||
| 380 | maskElement: this.findParentByType(Ext.Viewport).el | ||
| 381 | }); | ||
| 382 | win.show(this); | ||
| 383 | break; | ||
| 384 | case 2: | ||
| 385 | var win = new dSS.scene.SceneWindowShadow({ | ||
| 386 | dsid: record.get('dsid'), | ||
| 387 | maskElement: this.findParentByType(Ext.Viewport).el | ||
| 388 | }); | ||
| 389 | win.show(this); | ||
| 390 | break; | ||
| 391 | default: | ||
| 392 | break; | ||
| 333 | 393 | } | |
| 334 | }, | ||
| 335 | this | ||
| 336 | ); | ||
| 337 | }, | ||
| 394 | } | ||
| 395 | }, | ||
| 396 | this); | ||
| 397 | }, | ||
| 338 | 398 | ||
| 339 | 399 | buildTopToolbar: function() { | |
| 340 | 400 | return ['->', { | |
| 341 | 401 | iconCls: 'copyToClipboardToolbarIcon', | |
| 342 | 402 | handler: this.showCopyWindow, | |
| 343 | 403 | scope: this | |
| 344 | },{ | ||
| 404 | }, | ||
| 405 | { | ||
| 345 | 406 | iconCls: 'editDeviceToolbarIcon', | |
| 346 | 407 | handler: this.editDevice, | |
| 347 | 408 | scope: this | |
| 348 | },{ | ||
| 409 | }, | ||
| 410 | { | ||
| 349 | 411 | iconCls: 'pingDeviceToolbarIcon', | |
| 350 | 412 | handler: this.pingDevice, | |
| 351 | 413 | scope: this | |
| 352 | },{ | ||
| 414 | }, | ||
| 415 | { | ||
| 353 | 416 | iconCls: 'removeDeviceToolbarIcon', | |
| 354 | 417 | handler: this.removeDevice, | |
| 355 | 418 | scope: this | |
| 356 | 419 | }]; | |
| 357 | 420 | }, | |
| 358 | 421 | ||
| 359 | editDevice: function(item, event, rowIndex) { | ||
| 422 | editDevice: function(item, event, rowIndex) { | ||
| 360 | 423 | var record; | |
| 361 | 424 | // we were called from the toolbar, so its possible that there is | |
| 362 | 425 | // no device selection yet | |
| 363 | 426 | var sel = this.getSelectionModel(); | |
| 364 | if (!sel.hasSelection()) | ||
| 365 | { | ||
| 427 | if (!sel.hasSelection()) { | ||
| 366 | 428 | Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!")); | |
| 367 | 429 | return; | |
| 368 | 430 | } | |
| 369 | 431 | ||
| 370 | if (sel.getSelections().length > 1) | ||
| 371 | { | ||
| 432 | if (sel.getSelections().length > 1) { | ||
| 372 | 433 | Ext.Msg.alert(_("Multiple devices selected"), _("It is not possible to edit multiple devices simultaneously, please select only one device!")); | |
| 373 | 434 | return; | |
| 374 | 435 | } | |
| 375 | 436 | ||
| 376 | 437 | record = sel.getSelected(); | |
| 377 | 438 | ||
| 378 | Ext.Msg.prompt(_("Rename device"), _("Name") + ": ", function(btn, text){ | ||
| 379 | if(text !== record.get('name')) { | ||
| 380 | Ext.Ajax.request({ | ||
| 381 | url: '/json/device/setName', | ||
| 382 | disableCaching: true, | ||
| 383 | method: "GET", | ||
| 384 | params: { dsid: record.get('dsid'), | ||
| 385 | newName: text}, | ||
| 386 | success: function(result, request) { | ||
| 387 | try { | ||
| 388 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 389 | if(jsonData.ok) { | ||
| 390 | record.set('name', text); | ||
| 391 | record.commit(); | ||
| 392 | } else { | ||
| 393 | Ext.MessageBox.alert(_("Error"), _("Could not rename device")); | ||
| 394 | } | ||
| 395 | } | ||
| 396 | catch (err) { | ||
| 397 | Ext.MessageBox.alert(_("Error"), _("Could not rename device")); | ||
| 398 | } | ||
| 399 | }, | ||
| 400 | failure: function(result, request) { | ||
| 401 | Ext.MessageBox.alert(_("Error"), _("Could not rename device")); | ||
| 402 | } | ||
| 403 | }); | ||
| 404 | } | ||
| 405 | }, this, false, record.get('name')); | ||
| 406 | }, | ||
| 439 | Ext.Msg.prompt(_("Rename device"), _("Name") + ": ", function(btn, text) { | ||
| 440 | if (text !== record.get('name')) { | ||
| 441 | Ext.Ajax.request({ | ||
| 442 | url: '/json/device/setName', | ||
| 443 | disableCaching: true, | ||
| 444 | method: "GET", | ||
| 445 | params: { | ||
| 446 | dsid: record.get('dsid'), | ||
| 447 | newName: text | ||
| 448 | }, | ||
| 449 | success: function(result, request) { | ||
| 450 | try { | ||
| 451 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 452 | if (jsonData.ok) { | ||
| 453 | record.set('name', text); | ||
| 454 | record.commit(); | ||
| 455 | } else { | ||
| 456 | Ext.MessageBox.alert(_("Error"), _("Could not rename device")); | ||
| 457 | } | ||
| 458 | } | ||
| 459 | catch(err) { | ||
| 460 | Ext.MessageBox.alert(_("Error"), _("Could not rename device")); | ||
| 461 | } | ||
| 462 | }, | ||
| 463 | failure: function(result, request) { | ||
| 464 | Ext.MessageBox.alert(_("Error"), _("Could not rename device")); | ||
| 465 | } | ||
| 466 | }); | ||
| 467 | } | ||
| 468 | }, | ||
| 469 | this, false, record.get('name')); | ||
| 470 | }, | ||
| 407 | 471 | ||
| 408 | pingDevice: function(item, event, rowIndex) { | ||
| 472 | pingDevice: function(item, event, rowIndex) { | ||
| 409 | 473 | var record; | |
| 410 | 474 | // we were called from the toolbar, so its possible that there is | |
| 411 | 475 | // no device selection yet | |
| 412 | 476 | var sel = this.getSelectionModel(); | |
| 413 | if (!sel.hasSelection()) | ||
| 414 | { | ||
| 477 | if (!sel.hasSelection()) { | ||
| 415 | 478 | Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!")); | |
| 416 | 479 | return; | |
| 417 | 480 | } | |
| 418 | 481 | ||
| 419 | if (sel.getSelections().length > 1) | ||
| 420 | { | ||
| 482 | if (sel.getSelections().length > 1) { | ||
| 421 | 483 | Ext.Msg.alert(_("Multiple devices selected"), _("It is not possible to ping multiple devices simultaneously, please select only one device or use extended ping!")); | |
| 422 | 484 | return; | |
| 423 | 485 | } | |
| … | … | ||
| 491 | 491 | return; | |
| 492 | 492 | } | |
| 493 | 493 | ||
| 494 | Ext.Ajax.request({ | ||
| 495 | url: '/json/debug/pingDevice', | ||
| 496 | disableCaching: true, | ||
| 497 | method: "GET", | ||
| 498 | params: { dsid: record.get('dsid') }, | ||
| 499 | success: function(result, request) { | ||
| 500 | try { | ||
| 501 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 502 | if(jsonData.ok) { | ||
| 503 | var title = _("Ping") + " " + record.get('dsid'); | ||
| 504 | var message = _("SC") + ": " + jsonData.result.qualityHK + "<br/>" + _("RC") + ": " + jsonData.result.qualityRK; | ||
| 505 | Ext.MessageBox.show({ | ||
| 506 | title: title, | ||
| 507 | msg: message, | ||
| 508 | buttons: Ext.Msg.OK, | ||
| 509 | minWidth: 300 | ||
| 510 | }); | ||
| 511 | } else { | ||
| 512 | Ext.MessageBox.alert(_("Ping error"), jsonData.message); | ||
| 513 | } | ||
| 514 | } | ||
| 515 | catch (err) { | ||
| 516 | Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS") + ": " + err); | ||
| 517 | } | ||
| 518 | }, | ||
| 519 | failure: function(result, request) { | ||
| 520 | Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS")); | ||
| 521 | } | ||
| 522 | }); | ||
| 523 | }, | ||
| 494 | Ext.Ajax.request({ | ||
| 495 | url: '/json/debug/pingDevice', | ||
| 496 | disableCaching: true, | ||
| 497 | method: "GET", | ||
| 498 | params: { | ||
| 499 | dsid: record.get('dsid') | ||
| 500 | }, | ||
| 501 | success: function(result, request) { | ||
| 502 | try { | ||
| 503 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 504 | if (jsonData.ok) { | ||
| 505 | var title = _("Ping") + " " + record.get('dsid'); | ||
| 506 | var message = _("SC") + ": " + jsonData.result.qualityHK + "<br/>" + _("RC") + ": " + jsonData.result.qualityRK; | ||
| 507 | Ext.MessageBox.show({ | ||
| 508 | title: title, | ||
| 509 | msg: message, | ||
| 510 | buttons: Ext.Msg.OK, | ||
| 511 | minWidth: 300 | ||
| 512 | }); | ||
| 513 | } else { | ||
| 514 | Ext.MessageBox.alert(_("Ping error"), jsonData.message); | ||
| 515 | } | ||
| 516 | } | ||
| 517 | catch(err) { | ||
| 518 | Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS") + ": " + err); | ||
| 519 | } | ||
| 520 | }, | ||
| 521 | failure: function(result, request) { | ||
| 522 | Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS")); | ||
| 523 | } | ||
| 524 | }); | ||
| 525 | }, | ||
| 524 | 526 | ||
| 525 | extendedPing: function(item, event, rowIndex) { | ||
| 527 | extendedPing: function(item, event, rowIndex) { | ||
| 526 | 528 | var record; | |
| 527 | 529 | // we were called from the toolbar, so its possible that there is | |
| 528 | 530 | // no device selection yet | |
| 529 | 531 | var sel = this.getSelectionModel(); | |
| 530 | if (!sel.hasSelection()) | ||
| 531 | { | ||
| 532 | if (!sel.hasSelection()) { | ||
| 532 | 533 | Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!")); | |
| 533 | 534 | return; | |
| 534 | 535 | } | |
| … | … | ||
| 538 | 538 | ||
| 539 | 539 | var dsids = ""; | |
| 540 | 540 | var deviceArray = []; | |
| 541 | for (var i = 0; i < records.length; i++) | ||
| 542 | { | ||
| 541 | for (var i = 0; i < records.length; i++) { | ||
| 543 | 542 | if (records[i].get("isPresent") === false) { | |
| 544 | 543 | continue; | |
| 545 | 544 | } | |
| … | … | ||
| 547 | 547 | device.name = records[i].get("name"); | |
| 548 | 548 | deviceArray.push(device); | |
| 549 | 549 | dsids += device.dsid; | |
| 550 | if (i < records.length - 1) | ||
| 551 | dsids += ","; | ||
| 550 | if (i < records.length - 1) dsids += ","; | ||
| 552 | 551 | } | |
| 553 | |||
| 552 | |||
| 554 | 553 | if (deviceArray.length === 0) { | |
| 555 | 554 | Ext.Msg.alert(_("No devices present"), _("Your selection contained only non present devices which can not be pinged!")); | |
| 556 | 555 | return; | |
| 557 | 556 | } | |
| 558 | 557 | ||
| 559 | 558 | var deviceRecord = Ext.data.Record.create([ | |
| 560 | { name: "dsid", mapping: "dsid"}, | ||
| 561 | { name: "name", mapping: "name"} | ||
| 562 | ]); | ||
| 559 | { | ||
| 560 | name: "dsid", | ||
| 561 | mapping: "dsid" | ||
| 562 | }, | ||
| 563 | { | ||
| 564 | name: "name", | ||
| 565 | mapping: "name" | ||
| 566 | }]); | ||
| 563 | 567 | ||
| 564 | 568 | var pingStore = new Ext.data.ArrayStore({ | |
| 565 | autoDestroy : true, | ||
| 566 | storeId : "pingStore", | ||
| 567 | idIndex : 0, | ||
| 568 | fields : deviceRecord, | ||
| 569 | autoDestroy: true, | ||
| 570 | storeId: "pingStore", | ||
| 571 | idIndex: 0, | ||
| 572 | fields: deviceRecord, | ||
| 569 | 573 | data: deviceArray | |
| 570 | 574 | }); | |
| 571 | 575 | ||
| … | … | ||
| 578 | 578 | var m_now = now.getMinutes(); | |
| 579 | 579 | ||
| 580 | 580 | m_now += 5; | |
| 581 | if (m_now >= 60) | ||
| 582 | { | ||
| 581 | if (m_now >= 60) { | ||
| 583 | 582 | h_now++; | |
| 584 | 583 | m_now = m_now - 60; | |
| 585 | 584 | } | |
| 586 | 585 | ||
| 587 | if (h_now >= 24) | ||
| 588 | h_now = 0; | ||
| 586 | if (h_now >= 24) h_now = 0; | ||
| 589 | 587 | ||
| 590 | 588 | var sep = ":"; | |
| 591 | 589 | ||
| 592 | if (m_now < 10) | ||
| 593 | sep = sep + "0"; | ||
| 590 | if (m_now < 10) sep = sep + "0"; | ||
| 594 | 591 | ||
| 595 | var pingForm = new dSS.util.ExtendedPingForm({ | ||
| 592 | var pingForm = new dSS.util.ExtendedPingForm({ | ||
| 596 | 593 | pingStore: pingStore, | |
| 597 | 594 | sep: sep, | |
| 598 | 595 | h_now: h_now, | |
| 599 | 596 | m_now: m_now | |
| 600 | 597 | }); | |
| 601 | 598 | ||
| 602 | var win = new dSS.util.ExtendedPingWindow({ | ||
| 603 | form : pingForm, | ||
| 604 | dsids : dsids, | ||
| 605 | maskElement : this.findParentByType(Ext.Viewport).el | ||
| 599 | var win = new dSS.util.ExtendedPingWindow({ | ||
| 600 | form: pingForm, | ||
| 601 | dsids: dsids, | ||
| 602 | maskElement: this.findParentByType(Ext.Viewport).el | ||
| 606 | 603 | }); | |
| 607 | 604 | ||
| 608 | 605 | win.show(this); | |
| 609 | }, | ||
| 606 | }, | ||
| 610 | 607 | ||
| 611 | removeDevice: function(item, event, rowIndex) { | ||
| 612 | var records; | ||
| 613 | var store = this.getStore(); | ||
| 608 | removeDevice: function(item, event, rowIndex) { | ||
| 609 | var records; | ||
| 610 | var store = this.getStore(); | ||
| 614 | 611 | ||
| 615 | // we were called from the toolbar, so its possible that there is | ||
| 616 | // no device selection yet | ||
| 617 | var sel = this.getSelectionModel(); | ||
| 618 | if (!sel.hasSelection()) | ||
| 619 | { | ||
| 620 | Ext.MessageBox.alert(_("No device selected"), _("Please select a device from the list!")); | ||
| 621 | return; | ||
| 622 | } | ||
| 623 | records = sel.getSelections(); | ||
| 612 | // we were called from the toolbar, so its possible that there is | ||
| 613 | // no device selection yet | ||
| 614 | var sel = this.getSelectionModel(); | ||
| 615 | if (!sel.hasSelection()) { | ||
| 616 | Ext.MessageBox.alert(_("No device selected"), _("Please select a device from the list!")); | ||
| 617 | return; | ||
| 618 | } | ||
| 619 | records = sel.getSelections(); | ||
| 624 | 620 | ||
| 625 | var skippedPresent = false; | ||
| 621 | var skippedPresent = false; | ||
| 626 | 622 | var notPresent = new Array(); | |
| 627 | 623 | ||
| 628 | for (var i = 0; i < records.length; i++) | ||
| 629 | { | ||
| 630 | var record = records[i]; | ||
| 624 | for (var i = 0; i < records.length; i++) { | ||
| 625 | var record = records[i]; | ||
| 631 | 626 | ||
| 632 | // do not issue the ajax request if we know that it will fail | ||
| 633 | if (record.get('isPresent') === true) { | ||
| 627 | // do not issue the ajax request if we know that it will fail | ||
| 628 | if (record.get('isPresent') === true) { | ||
| 634 | 629 | skippedPresent = true; | |
| 635 | continue; | ||
| 636 | } | ||
| 630 | continue; | ||
| 631 | } | ||
| 637 | 632 | ||
| 638 | 633 | notPresent.push(record); | |
| 639 | } | ||
| 634 | } | ||
| 640 | 635 | ||
| 641 | if (notPresent.length > 0) | ||
| 642 | this.deleteDevice(notPresent); | ||
| 636 | if (notPresent.length > 0) this.deleteDevice(notPresent); | ||
| 643 | 637 | else { | |
| 644 | 638 | if (skippedPresent === true) { | |
| 645 | 639 | Ext.MessageBox.alert(_("Warning"), _("Present devices can not be removed!")); | |
| 646 | 640 | } | |
| 647 | 641 | } | |
| 648 | }, | ||
| 642 | }, | ||
| 649 | 643 | ||
| 650 | deleteDevice : function(records) { | ||
| 651 | var store = this.getStore(); | ||
| 644 | deleteDevice: function(records) { | ||
| 645 | var store = this.getStore(); | ||
| 652 | 646 | if (records.length < 1) { | |
| 653 | 647 | this.el.unmask(); | |
| 654 | 648 | return; | |
| … | … | ||
| 650 | 650 | ||
| 651 | 651 | var record = records.shift(); | |
| 652 | 652 | ||
| 653 | this.el.mask(_("Deleting device") + ": " + record.get("dsid")); | ||
| 654 | Ext.Ajax.request({ | ||
| 655 | url: '/json/structure/removeDevice', | ||
| 656 | disableCaching: true, | ||
| 657 | method: "GET", | ||
| 658 | scope: this, | ||
| 659 | params: { deviceID : record.get('dsid') }, | ||
| 660 | success: function(result, request) { | ||
| 661 | try { | ||
| 662 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 663 | if(jsonData.ok) { | ||
| 664 | store.remove(record); | ||
| 653 | this.el.mask(_("Deleting device") + ": " + record.get("dsid")); | ||
| 654 | Ext.Ajax.request({ | ||
| 655 | url: '/json/structure/removeDevice', | ||
| 656 | disableCaching: true, | ||
| 657 | method: "GET", | ||
| 658 | scope: this, | ||
| 659 | params: { | ||
| 660 | deviceID: record.get('dsid') | ||
| 661 | }, | ||
| 662 | success: function(result, request) { | ||
| 663 | try { | ||
| 664 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 665 | if (jsonData.ok) { | ||
| 666 | store.remove(record); | ||
| 665 | 667 | this.deleteDevice(records); | |
| 666 | } else { | ||
| 668 | } else { | ||
| 667 | 669 | this.el.unmask(); | |
| 668 | Ext.MessageBox.alert(_("Could not remove"), jsonData.message); | ||
| 669 | } | ||
| 670 | } | ||
| 671 | catch (err) { | ||
| 670 | Ext.MessageBox.alert(_("Could not remove"), jsonData.message); | ||
| 671 | } | ||
| 672 | } | ||
| 673 | catch(err) { | ||
| 672 | 674 | this.el.unmask(); | |
| 673 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS") + ": " + err); | ||
| 674 | } | ||
| 675 | }, | ||
| 676 | failure: function(result, request) { | ||
| 675 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS") + ": " + err); | ||
| 676 | } | ||
| 677 | }, | ||
| 678 | failure: function(result, request) { | ||
| 677 | 679 | this.el.unmask(); | |
| 678 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS")); | ||
| 679 | } | ||
| 680 | }); | ||
| 681 | }, | ||
| 680 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS")); | ||
| 681 | } | ||
| 682 | }); | ||
| 683 | }, | ||
| 682 | 684 | ||
| 683 | 685 | sendBlinkRequest: function(record) { | |
| 684 | 686 | record.set('blink', true); | |
| 685 | 687 | var unblink = function(record) { | |
| 686 | record.set('blink', false); | ||
| 688 | record.set('blink', false); | ||
| 687 | 689 | } | |
| 688 | 690 | ||
| 689 | 691 | Ext.Ajax.request({ | |
| … | … | ||
| 693 | 693 | disableCaching: true, | |
| 694 | 694 | method: "GET", | |
| 695 | 695 | scope: this, | |
| 696 | params: { dsid : record.get('dsid') }, | ||
| 696 | params: { | ||
| 697 | dsid: record.get('dsid') | ||
| 698 | }, | ||
| 697 | 699 | success: function(result, request) { | |
| 698 | 700 | try { | |
| 699 | 701 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 700 | 702 | if (!jsonData.ok) { | |
| 701 | 703 | Ext.MessageBox.alert(_("Could not blink"), jsonData.message); | |
| 702 | 704 | } | |
| 703 | } catch (err) { | ||
| 704 | Ext.MessageBox.alert(_("Error"), | ||
| 705 | _("Could not send blink device command to dSS") + ": " + err); | ||
| 705 | } catch(err) { | ||
| 706 | Ext.MessageBox.alert(_("Error"), _("Could not send blink device command to dSS") + ": " + err); | ||
| 706 | 707 | } | |
| 707 | unblink.defer(2000, this, [ record ]); | ||
| 708 | unblink.defer(2000, this, [record]); | ||
| 708 | 709 | }, | |
| 709 | 710 | failure: function(result, request) { | |
| 710 | Ext.MessageBox.alert(_("Error"), | ||
| 711 | _("Could not send blink device command to dSS")); | ||
| 712 | unblink.defer(2000, this, [ record ]); | ||
| 711 | Ext.MessageBox.alert(_("Error"), _("Could not send blink device command to dSS")); | ||
| 712 | unblink.defer(2000, this, [record]); | ||
| 713 | 713 | } | |
| 714 | 714 | }); | |
| 715 | 715 | }, | |
| 716 | 716 | ||
| 717 | blinkDevice: function(item, event, rowIndex) { | ||
| 718 | var records; | ||
| 719 | var store = this.getStore(); | ||
| 717 | blinkDevice: function(item, event, rowIndex) { | ||
| 718 | var records; | ||
| 719 | var store = this.getStore(); | ||
| 720 | 720 | ||
| 721 | // we were called from the toolbar, so its possible that there is | ||
| 722 | // no device selection yet | ||
| 723 | var sel = this.getSelectionModel(); | ||
| 724 | if (!sel.hasSelection()) | ||
| 725 | { | ||
| 726 | Ext.MessageBox.alert(_("No device selected"), _("Please select a device from the list!")); | ||
| 727 | return; | ||
| 728 | } | ||
| 729 | records = sel.getSelections(); | ||
| 730 | for (var i = 0; i < records.length; i++) | ||
| 731 | { | ||
| 721 | // we were called from the toolbar, so its possible that there is | ||
| 722 | // no device selection yet | ||
| 723 | var sel = this.getSelectionModel(); | ||
| 724 | if (!sel.hasSelection()) { | ||
| 725 | Ext.MessageBox.alert(_("No device selected"), _("Please select a device from the list!")); | ||
| 726 | return; | ||
| 727 | } | ||
| 728 | records = sel.getSelections(); | ||
| 729 | for (var i = 0; i < records.length; i++) { | ||
| 732 | 730 | if (records[i].get('isPresent') === false) { | |
| 733 | 731 | continue; | |
| 734 | 732 | } | |
| 735 | 733 | ||
| 736 | 734 | this.sendBlinkRequest(records[i]); | |
| 737 | 735 | ||
| 738 | } | ||
| 739 | }, | ||
| 736 | } | ||
| 737 | }, | ||
| 740 | 738 | ||
| 741 | 739 | showCopyWindow: function() { | |
| 742 | var csvwindow = new dSS.util.GridToCSVWindow({ | ||
| 743 | gridPanel: this, | ||
| 740 | var csvwindow = new dSS.util.GridToCSVWindow({ | ||
| 741 | gridPanel: this, | ||
| 744 | 742 | windowWidth: 640, | |
| 745 | 743 | windowHeight: 480 | |
| 746 | 744 | }); | |
| … | … | ||
| 751 | 751 | disableCaching: true, | |
| 752 | 752 | method: 'GET', | |
| 753 | 753 | scope: this, | |
| 754 | params: { path: '/system/js/settings/' + property + '/session' }, | ||
| 754 | params: { | ||
| 755 | path: '/system/js/settings/' + property + '/session' | ||
| 756 | }, | ||
| 755 | 757 | success: function(result, request) { | |
| 756 | 758 | try { | |
| 757 | 759 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| … | … | ||
| 765 | 765 | disableCaching: true, | |
| 766 | 766 | method: 'GET', | |
| 767 | 767 | scope: this, | |
| 768 | params: { | ||
| 768 | params: { | ||
| 769 | 769 | path: '/system/js/settings/' + property + '/session', | |
| 770 | value: new_session | ||
| 770 | value: new_session | ||
| 771 | 771 | }, | |
| 772 | 772 | success: function(result, request) { | |
| 773 | 773 | try { | |
| … | … | ||
| 777 | 777 | } else { | |
| 778 | 778 | Ext.MessageBox.alert(_("Could not set session value"), jsonData.message); | |
| 779 | 779 | } | |
| 780 | } catch (err) { | ||
| 780 | } catch(err) { | ||
| 781 | 781 | Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err); | |
| 782 | 782 | } | |
| 783 | 783 | }, | |
| … | … | ||
| 788 | 788 | } else { | |
| 789 | 789 | Ext.MessageBox.alert(_("Could not get session value"), jsonData.message); | |
| 790 | 790 | } | |
| 791 | } catch (err) { | ||
| 791 | } catch(err) { | ||
| 792 | 792 | Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err); | |
| 793 | 793 | } | |
| 794 | 794 | }, | |
| … | … | ||
| 804 | 804 | disableCaching: true, | |
| 805 | 805 | method: "GET", | |
| 806 | 806 | scope: this, | |
| 807 | params: { subscriptionID : 333, name: "ping_result" }, | ||
| 807 | params: { | ||
| 808 | subscriptionID: 333, | ||
| 809 | name: "ping_result" | ||
| 810 | }, | ||
| 808 | 811 | success: function(result, request) { | |
| 809 | 812 | try { | |
| 810 | 813 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 811 | 814 | if (jsonData.ok) { | |
| 812 | var pingResult = new dSS.util.PingEventWindow({ windowWidth: 640, windowHeight: 480, maskElement: this.findParentByType(Ext.Viewport).el }); | ||
| 815 | var pingResult = new dSS.util.PingEventWindow({ | ||
| 816 | windowWidth: 640, | ||
| 817 | windowHeight: 480, | ||
| 818 | maskElement: this.findParentByType(Ext.Viewport).el | ||
| 819 | }); | ||
| 813 | 820 | pingResult.show(this); | |
| 814 | 821 | } else { | |
| 815 | 822 | Ext.MessageBox.alert(_("Ping subscription error"), jsonData.message); | |
| 816 | 823 | } | |
| 817 | } catch (err) { | ||
| 824 | } catch(err) { | ||
| 818 | 825 | Ext.MessageBox.alert(_("Error"), _("Could send subscribe command to dSS") + ": " + err); | |
| 819 | 826 | } | |
| 820 | 827 | }, | |
| … | … | ||
| 831 | 831 | }); | |
| 832 | 832 | }, | |
| 833 | 833 | ||
| 834 | deviceStatistics: function(item, event, rowIndex) { | ||
| 834 | deviceStatistics: function(item, event, rowIndex) { | ||
| 835 | 835 | var record; | |
| 836 | 836 | // we were called from the toolbar, so its possible that there is | |
| 837 | 837 | // no device selection yet | |
| 838 | 838 | var sel = this.getSelectionModel(); | |
| 839 | if (!sel.hasSelection()) | ||
| 840 | { | ||
| 839 | if (!sel.hasSelection()) { | ||
| 841 | 840 | Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!")); | |
| 842 | 841 | return; | |
| 843 | 842 | } | |
| … | … | ||
| 845 | 845 | ||
| 846 | 846 | var dsids = ""; | |
| 847 | 847 | var deviceArray = []; | |
| 848 | for (var i = 0; i < records.length; i++) | ||
| 849 | { | ||
| 848 | for (var i = 0; i < records.length; i++) { | ||
| 850 | 849 | if (records[i].get("isPresent") === false) { | |
| 851 | 850 | continue; | |
| 852 | 851 | } | |
| … | … | ||
| 854 | 854 | device.name = records[i].get("name"); | |
| 855 | 855 | deviceArray.push(device); | |
| 856 | 856 | dsids += device.dsid; | |
| 857 | if (i < records.length - 1) | ||
| 858 | dsids += ","; | ||
| 857 | if (i < records.length - 1) dsids += ","; | ||
| 859 | 858 | } | |
| 860 | |||
| 859 | |||
| 861 | 860 | if (deviceArray.length === 0) { | |
| 862 | 861 | Ext.Msg.alert(_("No devices present"), _("Your selection contained only non present devices!")); | |
| 863 | 862 | return; | |
| 864 | 863 | } | |
| 865 | 864 | ||
| 866 | 865 | var deviceRecord = Ext.data.Record.create([ | |
| 867 | { name: "dsid", mapping: "dsid"}, | ||
| 868 | { name: "name", mapping: "name"} | ||
| 869 | ]); | ||
| 866 | { | ||
| 867 | name: "dsid", | ||
| 868 | mapping: "dsid" | ||
| 869 | }, | ||
| 870 | { | ||
| 871 | name: "name", | ||
| 872 | mapping: "name" | ||
| 873 | }]); | ||
| 870 | 874 | ||
| 871 | 875 | var statsStore = new Ext.data.ArrayStore({ | |
| 872 | autoDestroy : true, | ||
| 873 | storeId : "statsStore", | ||
| 874 | idIndex : 0, | ||
| 875 | fields : deviceRecord, | ||
| 876 | autoDestroy: true, | ||
| 877 | storeId: "statsStore", | ||
| 878 | idIndex: 0, | ||
| 879 | fields: deviceRecord, | ||
| 876 | 880 | data: deviceArray | |
| 877 | 881 | }); | |
| 878 | 882 | ||
| … | … | ||
| 885 | 885 | var m_now = now.getMinutes(); | |
| 886 | 886 | ||
| 887 | 887 | m_now += 5; | |
| 888 | if (m_now >= 60) | ||
| 889 | { | ||
| 888 | if (m_now >= 60) { | ||
| 890 | 889 | h_now++; | |
| 891 | 890 | m_now = m_now - 60; | |
| 892 | 891 | } | |
| 893 | 892 | ||
| 894 | if (h_now >= 24) | ||
| 895 | h_now = 0; | ||
| 893 | if (h_now >= 24) h_now = 0; | ||
| 896 | 894 | ||
| 897 | 895 | var sep = ":"; | |
| 898 | 896 | ||
| 899 | if (m_now < 10) | ||
| 900 | sep = sep + "0"; | ||
| 897 | if (m_now < 10) sep = sep + "0"; | ||
| 901 | 898 | ||
| 902 | var statsForm = new dSS.util.DeviceStatisticsForm({ | ||
| 899 | var statsForm = new dSS.util.DeviceStatisticsForm({ | ||
| 903 | 900 | statisticsStore: statsStore, | |
| 904 | 901 | sep: sep, | |
| 905 | 902 | h_now: h_now, | |
| 906 | 903 | m_now: m_now | |
| 907 | 904 | }); | |
| 908 | 905 | ||
| 909 | var win = new dSS.util.DeviceStatisticsWindow({ | ||
| 910 | form : statsForm, | ||
| 911 | dsids : dsids, | ||
| 912 | maskElement : this.findParentByType(Ext.Viewport).el | ||
| 906 | var win = new dSS.util.DeviceStatisticsWindow({ | ||
| 907 | form: statsForm, | ||
| 908 | dsids: dsids, | ||
| 909 | maskElement: this.findParentByType(Ext.Viewport).el | ||
| 913 | 910 | }); | |
| 914 | 911 | ||
| 915 | 912 | win.show(this); | |
| 916 | } | ||
| 913 | } | ||
| 917 | 914 | }); | |
| 918 | 915 | ||
| 919 | 916 | Ext.reg('dssdevicepanel', dSS.grid.DevicePanel); |
webroot/js/dss/dss-setup-interface/dSS/grid/ModulatorPanel.js
(296 / 276)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/data/Loader> | |
| 3 | 3 | //= require <dSS/util/DSMStatisticsWindow> | |
| 4 | |||
| 5 | 4 | Ext.namespace('dSS', 'dSS.grid', 'dSS.data', 'dSS.config'); | |
| 6 | 5 | ||
| 7 | 6 | dSS.grid.ModulatorPanel = Ext.extend(Ext.grid.GridPanel, { | |
| 8 | 7 | initComponent: function() { | |
| 9 | 8 | ||
| 10 | 9 | var modulatorColumns = [ | |
| 11 | {id: 'dsid', header: _("dsid"), width: 190, sortable: true, dataIndex: "dsid" }, | ||
| 12 | {id: 'name', header: _("meter name"), width: 150, sortable: true, dataIndex: 'name'}, | ||
| 13 | {id: 'consumption', header: _("consumption (mW)"), width: 130, sortable: true, dataIndex: 'consumption'}, | ||
| 14 | {id: 'measureDate', header: _("measured"), width: 150, sortable: true, dataIndex: 'measureDate'} | ||
| 15 | ]; | ||
| 10 | { | ||
| 11 | id: 'dsid', | ||
| 12 | header: _("dsid"), | ||
| 13 | width: 190, | ||
| 14 | sortable: true, | ||
| 15 | dataIndex: "dsid" | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | id: 'name', | ||
| 19 | header: _("meter name"), | ||
| 20 | width: 150, | ||
| 21 | sortable: true, | ||
| 22 | dataIndex: 'name' | ||
| 23 | }, | ||
| 24 | { | ||
| 25 | id: 'consumption', | ||
| 26 | header: _("consumption (mW)"), | ||
| 27 | width: 130, | ||
| 28 | sortable: true, | ||
| 29 | dataIndex: 'consumption' | ||
| 30 | }, | ||
| 31 | { | ||
| 32 | id: 'measureDate', | ||
| 33 | header: _("measured"), | ||
| 34 | width: 150, | ||
| 35 | sortable: true, | ||
| 36 | dataIndex: 'measureDate' | ||
| 37 | }]; | ||
| 16 | 38 | ||
| 17 | var rowSelect = new Ext.grid.RowSelectionModel({singleSelect : true}); | ||
| 39 | var rowSelect = new Ext.grid.RowSelectionModel({ | ||
| 40 | singleSelect: true | ||
| 41 | }); | ||
| 18 | 42 | ||
| 19 | 43 | this.heightConfigured = false; | |
| 20 | 44 | ||
| 21 | 45 | Ext.apply(this, { | |
| 22 | store : dSS.data.Loader.getModulatorStore(), | ||
| 23 | columns : modulatorColumns, | ||
| 24 | enableDragDrop : false, | ||
| 25 | stripeRows : true, | ||
| 26 | forceFit : true, | ||
| 27 | title : _("Meters"), | ||
| 28 | selModel : rowSelect, | ||
| 46 | store: dSS.data.Loader.getModulatorStore(), | ||
| 47 | columns: modulatorColumns, | ||
| 48 | enableDragDrop: false, | ||
| 49 | stripeRows: true, | ||
| 50 | forceFit: true, | ||
| 51 | title: _("Meters"), | ||
| 52 | selModel: rowSelect, | ||
| 29 | 53 | viewConfig: { | |
| 30 | 54 | autoFill: true, | |
| 31 | 55 | getRowClass: function(record, index) { | |
| … | … | ||
| 66 | 66 | ||
| 67 | 67 | dSS.grid.ModulatorPanel.superclass.initComponent.apply(this, arguments); | |
| 68 | 68 | ||
| 69 | this.on( | ||
| 70 | 'afterrender', | ||
| 71 | function() { | ||
| 72 | this.setInitialSelection(); | ||
| 73 | if (this.heightConfigured === false) | ||
| 74 | { | ||
| 75 | this.heightConfigured = true; | ||
| 76 | this.setHeight(this.findParentByType('dsmoverviewpanel').getInnerHeight()/2); | ||
| 77 | } | ||
| 78 | |||
| 69 | this.on('afterrender', function() { | ||
| 70 | this.setInitialSelection(); | ||
| 71 | if (this.heightConfigured === false) { | ||
| 72 | this.heightConfigured = true; | ||
| 73 | this.setHeight(this.findParentByType('dsmoverviewpanel').getInnerHeight() / 2); | ||
| 79 | 74 | } | |
| 80 | ); | ||
| 81 | this.on( | ||
| 82 | 'rowcontextmenu', | ||
| 83 | function(grid, rowIndex, event) { | ||
| 84 | event.preventDefault(); | ||
| 85 | event.stopEvent(); | ||
| 86 | if(!this.contextMenu) { | ||
| 87 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 88 | } else { | ||
| 89 | this.contextMenu.removeAll(); | ||
| 90 | } | ||
| 91 | 75 | ||
| 92 | var sel = this.getSelectionModel(); | ||
| 76 | }); | ||
| 77 | this.on('rowcontextmenu', function(grid, rowIndex, event) { | ||
| 78 | event.preventDefault(); | ||
| 79 | event.stopEvent(); | ||
| 80 | if (!this.contextMenu) { | ||
| 81 | this.contextMenu = new Ext.menu.Menu({}); | ||
| 82 | } else { | ||
| 83 | this.contextMenu.removeAll(); | ||
| 84 | } | ||
| 93 | 85 | ||
| 94 | if (!sel.hasSelection()) { | ||
| 95 | sel.selectRow(rowIndex, false); | ||
| 96 | } | ||
| 86 | var sel = this.getSelectionModel(); | ||
| 97 | 87 | ||
| 98 | var showRemoveMenuItem = false; | ||
| 88 | if (!sel.hasSelection()) { | ||
| 89 | sel.selectRow(rowIndex, false); | ||
| 90 | } | ||
| 99 | 91 | ||
| 100 | var records = sel.getSelections(); | ||
| 92 | var showRemoveMenuItem = false; | ||
| 101 | 93 | ||
| 102 | for (var i = 0; i < records.length; i++) | ||
| 103 | { | ||
| 104 | var record = records[i]; | ||
| 94 | var records = sel.getSelections(); | ||
| 105 | 95 | ||
| 106 | // if at least one record can be removed - set the flag | ||
| 107 | if (record.get('isPresent') === false) { | ||
| 108 | showRemoveMenuItem = true; | ||
| 109 | break; | ||
| 110 | } | ||
| 96 | for (var i = 0; i < records.length; i++) { | ||
| 97 | var record = records[i]; | ||
| 98 | |||
| 99 | // if at least one record can be removed - set the flag | ||
| 100 | if (record.get('isPresent') === false) { | ||
| 101 | showRemoveMenuItem = true; | ||
| 102 | break; | ||
| 111 | 103 | } | |
| 112 | |||
| 113 | var menuItem = new Ext.menu.Item({ | ||
| 114 | text: _("Rename meter"), | ||
| 115 | icon: '/images/page_white_edit.png', | ||
| 116 | handler: this.editDevice.createDelegate(this, rowIndex, true) | ||
| 117 | }); | ||
| 104 | } | ||
| 118 | 105 | ||
| 119 | this.contextMenu.add(menuItem); | ||
| 106 | var menuItem = new Ext.menu.Item({ | ||
| 107 | text: _("Rename meter"), | ||
| 108 | icon: '/images/page_white_edit.png', | ||
| 109 | handler: this.editDevice.createDelegate(this, rowIndex, true) | ||
| 110 | }); | ||
| 120 | 111 | ||
| 112 | this.contextMenu.add(menuItem); | ||
| 113 | |||
| 114 | var menuItem = new Ext.menu.Item({ | ||
| 115 | text: _("Rescan circuit"), | ||
| 116 | icon: '/images/page_white_edit.png', | ||
| 117 | handler: this.rescanCircuit.createDelegate(this, rowIndex, true) | ||
| 118 | }); | ||
| 119 | this.contextMenu.add(menuItem); | ||
| 120 | |||
| 121 | if (showRemoveMenuItem === true) { | ||
| 121 | 122 | var menuItem = new Ext.menu.Item({ | |
| 122 | text: _("Rescan circuit"), | ||
| 123 | icon: '/images/page_white_edit.png', | ||
| 124 | handler: this.rescanCircuit.createDelegate(this, rowIndex, true) | ||
| 123 | text: _("Remove meter"), | ||
| 124 | icon: '/images/delete.png', | ||
| 125 | handler: this.removeMeter.createDelegate(this, rowIndex, true) | ||
| 125 | 126 | }); | |
| 126 | 127 | this.contextMenu.add(menuItem); | |
| 128 | } | ||
| 127 | 129 | ||
| 128 | if (showRemoveMenuItem === true) { | ||
| 129 | var menuItem = new Ext.menu.Item({ | ||
| 130 | text: _("Remove meter"), | ||
| 131 | icon: '/images/delete.png', | ||
| 132 | handler: this.removeMeter.createDelegate(this, rowIndex, true) | ||
| 133 | }); | ||
| 134 | this.contextMenu.add(menuItem); | ||
| 135 | } | ||
| 136 | |||
| 130 | var record = sel.getSelected(); | ||
| 137 | 131 | ||
| 138 | var record = sel.getSelected(); | ||
| 132 | if (dSS.config.features.dsmStatistics === true) { | ||
| 133 | var subMenu = new Ext.menu.Menu({}); | ||
| 139 | 134 | ||
| 140 | if (dSS.config.features.dsmStatistics === true) { | ||
| 141 | var subMenu = new Ext.menu.Menu({}); | ||
| 142 | |||
| 143 | if (record.get('isPresent') === true) { | ||
| 144 | var menuItem = new Ext.menu.Item({ | ||
| 145 | text: _("Meter statistics"), | ||
| 146 | icon: '/images/application_osx_terminal.png', | ||
| 147 | handler: this.dsmStatistics.createDelegate(this, rowIndex, true) | ||
| 148 | }); | ||
| 149 | subMenu.add(menuItem); | ||
| 150 | } | ||
| 151 | |||
| 135 | if (record.get('isPresent') === true) { | ||
| 152 | 136 | var menuItem = new Ext.menu.Item({ | |
| 153 | text: _("Abort meter statistics session"), | ||
| 137 | text: _("Meter statistics"), | ||
| 154 | 138 | icon: '/images/application_osx_terminal.png', | |
| 155 | handler: this.abortStatisticsRound.createDelegate(this, rowIndex, true) | ||
| 139 | handler: this.dsmStatistics.createDelegate(this, rowIndex, true) | ||
| 156 | 140 | }); | |
| 157 | 141 | subMenu.add(menuItem); | |
| 158 | |||
| 159 | var menuItem = new Ext.menu.Item({ | ||
| 160 | text: _("Statistics"), | ||
| 161 | icon: '/images/application_osx_terminal.png', | ||
| 162 | menu: subMenu | ||
| 163 | }); | ||
| 164 | this.contextMenu.add(menuItem); | ||
| 165 | 142 | } | |
| 166 | 143 | ||
| 167 | var xy = event.getXY(); | ||
| 168 | this.contextMenu.showAt(xy); | ||
| 169 | }, | ||
| 170 | this | ||
| 171 | ); | ||
| 144 | var menuItem = new Ext.menu.Item({ | ||
| 145 | text: _("Abort meter statistics session"), | ||
| 146 | icon: '/images/application_osx_terminal.png', | ||
| 147 | handler: this.abortStatisticsRound.createDelegate(this, rowIndex, true) | ||
| 148 | }); | ||
| 149 | subMenu.add(menuItem); | ||
| 172 | 150 | ||
| 173 | rowSelect.on( | ||
| 174 | 'rowselect', | ||
| 175 | function(selModel, rowIndex, dataRecord) { | ||
| 176 | var store = dSS.data.Loader.getDeviceStore(); | ||
| 177 | store.filterBy(function(record) { | ||
| 178 | if (record.get('modulatorDsid') === dataRecord.get('dsid')) { | ||
| 179 | return true; | ||
| 180 | } | ||
| 181 | return false; | ||
| 151 | var menuItem = new Ext.menu.Item({ | ||
| 152 | text: _("Statistics"), | ||
| 153 | icon: '/images/application_osx_terminal.png', | ||
| 154 | menu: subMenu | ||
| 182 | 155 | }); | |
| 183 | }, | ||
| 184 | this | ||
| 185 | ); | ||
| 156 | this.contextMenu.add(menuItem); | ||
| 157 | } | ||
| 158 | |||
| 159 | var xy = event.getXY(); | ||
| 160 | this.contextMenu.showAt(xy); | ||
| 161 | }, | ||
| 162 | this); | ||
| 163 | |||
| 164 | rowSelect.on('rowselect', function(selModel, rowIndex, dataRecord) { | ||
| 165 | var store = dSS.data.Loader.getDeviceStore(); | ||
| 166 | store.filterBy(function(record) { | ||
| 167 | if (record.get('modulatorDsid') === dataRecord.get('dsid')) { | ||
| 168 | return true; | ||
| 169 | } | ||
| 170 | return false; | ||
| 171 | }); | ||
| 172 | }, | ||
| 173 | this); | ||
| 186 | 174 | }, | |
| 187 | 175 | buildTopToolbar: function() { | |
| 188 | 176 | return [ | |
| 177 | { | ||
| 178 | cls: 'zonePanelMenu', | ||
| 179 | menu: [ | ||
| 189 | 180 | { | |
| 190 | cls: 'zonePanelMenu', | ||
| 191 | menu: [{ | ||
| 192 | text: _("Reload"), | ||
| 193 | handler: this.reload, | ||
| 194 | scope: this | ||
| 195 | }, | ||
| 196 | { | ||
| 197 | text: _("Rescan"), | ||
| 198 | handler: this.rescan, | ||
| 199 | scope: this | ||
| 200 | }] | ||
| 201 | }, | ||
| 202 | '->', | ||
| 203 | { | ||
| 204 | iconCls: 'copyToClipboardToolbarIcon', | ||
| 205 | handler: this.showCopyWindow, | ||
| 181 | text: _("Reload"), | ||
| 182 | handler: this.reload, | ||
| 206 | 183 | scope: this | |
| 207 | 184 | }, | |
| 208 | 185 | { | |
| 209 | iconCls: 'reloadAction', | ||
| 210 | handler: this.removeInactiveDevices, | ||
| 186 | text: _("Rescan"), | ||
| 187 | handler: this.rescan, | ||
| 211 | 188 | scope: this | |
| 212 | }, | ||
| 213 | { | ||
| 214 | iconCls: 'removeDeviceToolbarIcon', | ||
| 215 | handler: this.removeInactiveMeters, | ||
| 216 | scope: this | ||
| 217 | 189 | }] | |
| 190 | }, | ||
| 191 | '->', { | ||
| 192 | iconCls: 'copyToClipboardToolbarIcon', | ||
| 193 | handler: this.showCopyWindow, | ||
| 194 | scope: this | ||
| 195 | }, | ||
| 196 | { | ||
| 197 | iconCls: 'reloadAction', | ||
| 198 | handler: this.removeInactiveDevices, | ||
| 199 | scope: this | ||
| 200 | }, | ||
| 201 | { | ||
| 202 | iconCls: 'removeDeviceToolbarIcon', | ||
| 203 | handler: this.removeInactiveMeters, | ||
| 204 | scope: this | ||
| 205 | }] | ||
| 218 | 206 | }, | |
| 219 | 207 | ||
| 220 | 208 | editDevice: function(item, event, rowIndex) { | |
| 221 | 209 | var record = this.getStore().getAt(rowIndex); | |
| 222 | Ext.Msg.prompt(_("Rename meter"), _("Name") + ": ", function(btn, text){ | ||
| 223 | if(text !== record.get('name')) { | ||
| 210 | Ext.Msg.prompt(_("Rename meter"), _("Name") + ": ", function(btn, text) { | ||
| 211 | if (text !== record.get('name')) { | ||
| 224 | 212 | Ext.Ajax.request({ | |
| 225 | 213 | url: '/json/circuit/setName', | |
| 226 | 214 | disableCaching: true, | |
| 227 | 215 | method: "GET", | |
| 228 | params: { id: record.get('dsid'), | ||
| 229 | newName: text}, | ||
| 216 | params: { | ||
| 217 | id: record.get('dsid'), | ||
| 218 | newName: text | ||
| 219 | }, | ||
| 230 | 220 | success: function(result, request) { | |
| 231 | 221 | try { | |
| 232 | 222 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 233 | if(jsonData.ok) { | ||
| 223 | if (jsonData.ok) { | ||
| 234 | 224 | record.set('name', text); | |
| 235 | 225 | record.commit(); | |
| 236 | 226 | } else { | |
| 237 | 227 | Ext.MessageBox.alert(_("Error"), _("Could not rename meter")); | |
| 238 | 228 | } | |
| 239 | 229 | } | |
| 240 | catch (err) { | ||
| 230 | catch(err) { | ||
| 241 | 231 | Ext.MessageBox.alert(_("Error"), _("Could not rename meter")); | |
| 242 | 232 | } | |
| 243 | 233 | }, | |
| … | … | ||
| 236 | 236 | } | |
| 237 | 237 | }); | |
| 238 | 238 | } | |
| 239 | }, this, false, record.get('name')); | ||
| 239 | }, | ||
| 240 | this, false, record.get('name')); | ||
| 240 | 241 | }, | |
| 241 | 242 | setInitialSelection: function() { | |
| 242 | 243 | if (this.getStore().getCount() == 0) { | |
| … | … | ||
| 261 | 261 | this.getSelectionModel().fireEvent('rowselect', this.getSelectionModel(), index, record); | |
| 262 | 262 | }, | |
| 263 | 263 | rescanCircuit: function(item, event, rowIndex) { | |
| 264 | var record = this.getStore().getAt(rowIndex); | ||
| 265 | Ext.Ajax.request({ | ||
| 266 | url: '/json/circuit/rescan', | ||
| 267 | disableCaching: true, | ||
| 268 | method: "GET", | ||
| 269 | params: { id: record.get('dsid') }, | ||
| 270 | success: function(result, request) { | ||
| 271 | try { | ||
| 272 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 273 | if(jsonData.ok) { | ||
| 274 | // there is no point in reloading here, since the call to rescan is non blocking. | ||
| 275 | // when we get here, the apartment structure has not changed yet and there is | ||
| 276 | // no way to get a notification when the rescan process has finished. | ||
| 277 | // dSS.data.Loader.load(); | ||
| 278 | } else { | ||
| 279 | Ext.MessageBox.alert(_("Error"), _("Rescan failed")); | ||
| 264 | var record = this.getStore().getAt(rowIndex); | ||
| 265 | Ext.Ajax.request({ | ||
| 266 | url: '/json/circuit/rescan', | ||
| 267 | disableCaching: true, | ||
| 268 | method: "GET", | ||
| 269 | params: { | ||
| 270 | id: record.get('dsid') | ||
| 271 | }, | ||
| 272 | success: function(result, request) { | ||
| 273 | try { | ||
| 274 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 275 | if (jsonData.ok) { | ||
| 276 | // there is no point in reloading here, since the call to rescan is non blocking. | ||
| 277 | // when we get here, the apartment structure has not changed yet and there is | ||
| 278 | // no way to get a notification when the rescan process has finished. | ||
| 279 | // dSS.data.Loader.load(); | ||
| 280 | } else { | ||
| 281 | Ext.MessageBox.alert(_("Error"), _("Rescan failed")); | ||
| 282 | } | ||
| 283 | } | ||
| 284 | catch(err) { | ||
| 285 | Ext.MessageBox.alert(_("Error"), _("Rescan failed") + ": " + err); | ||
| 286 | } | ||
| 287 | }, | ||
| 288 | failure: function(result, request) { | ||
| 289 | Ext.MessageBox.alert(_("Error"), _("Rescan failed")); | ||
| 280 | 290 | } | |
| 281 | } | ||
| 282 | catch (err) { | ||
| 283 | Ext.MessageBox.alert(_("Error"), _("Rescan failed") + ": " + err); | ||
| 284 | } | ||
| 285 | }, | ||
| 286 | failure: function(result, request) { | ||
| 287 | Ext.MessageBox.alert(_("Error"), _("Rescan failed")); | ||
| 288 | } | ||
| 289 | }); | ||
| 291 | }); | ||
| 290 | 292 | }, | |
| 291 | 293 | removeInactiveDevices: function() { | |
| 292 | var sel = this.getSelectionModel(); | ||
| 293 | if (!sel.hasSelection()) { | ||
| 294 | Ext.Msg.alert(_("No meter selected"), _("Please select a meter from the list!")); | ||
| 295 | return; | ||
| 296 | } | ||
| 297 | |||
| 298 | record = sel.getSelected(); | ||
| 299 | var store = dSS.data.Loader.getDeviceStore(); | ||
| 300 | |||
| 301 | Ext.Ajax.request({ | ||
| 302 | url: '/json/structure/removeInactiveDevices', | ||
| 303 | disableCaching: true, | ||
| 304 | method: "GET", | ||
| 305 | scope: this, | ||
| 306 | params: { id : record.get('dsid') }, | ||
| 307 | success: function(result, request) { | ||
| 308 | try { | ||
| 309 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 310 | if(jsonData.ok) { | ||
| 311 | store.each( | ||
| 312 | function(rec) { | ||
| 294 | var sel = this.getSelectionModel(); | ||
| 295 | if (!sel.hasSelection()) { | ||
| 296 | Ext.Msg.alert(_("No meter selected"), _("Please select a meter from the list!")); | ||
| 297 | return; | ||
| 298 | } | ||
| 299 | |||
| 300 | record = sel.getSelected(); | ||
| 301 | var store = dSS.data.Loader.getDeviceStore(); | ||
| 302 | |||
| 303 | Ext.Ajax.request({ | ||
| 304 | url: '/json/structure/removeInactiveDevices', | ||
| 305 | disableCaching: true, | ||
| 306 | method: "GET", | ||
| 307 | scope: this, | ||
| 308 | params: { | ||
| 309 | id: record.get('dsid') | ||
| 310 | }, | ||
| 311 | success: function(result, request) { | ||
| 312 | try { | ||
| 313 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 314 | if (jsonData.ok) { | ||
| 315 | store.each( | ||
| 316 | function(rec) { | ||
| 313 | 317 | if (rec.get('modulatorDsid') == record.get('dsid')) { | |
| 314 | if (rec.get('isPresent') === false) { | ||
| 315 | store.remove(rec); | ||
| 316 | } | ||
| 318 | if (rec.get('isPresent') === false) { | ||
| 319 | store.remove(rec); | ||
| 320 | } | ||
| 317 | 321 | } | |
| 318 | }, | ||
| 319 | this | ||
| 320 | ); | ||
| 321 | } else { | ||
| 322 | Ext.MessageBox.alert(_("Could not remove"), jsonData.message); | ||
| 323 | } | ||
| 324 | } | ||
| 325 | catch (err) { | ||
| 326 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS") + ": " + err); | ||
| 327 | } | ||
| 328 | }, | ||
| 329 | failure: function(result, request) { | ||
| 330 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS")); | ||
| 331 | } | ||
| 332 | }); | ||
| 333 | |||
| 334 | |||
| 322 | }, | ||
| 323 | this); | ||
| 324 | } else { | ||
| 325 | Ext.MessageBox.alert(_("Could not remove"), jsonData.message); | ||
| 326 | } | ||
| 327 | } | ||
| 328 | catch(err) { | ||
| 329 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS") + ": " + err); | ||
| 330 | } | ||
| 331 | }, | ||
| 332 | failure: function(result, request) { | ||
| 333 | Ext.MessageBox.alert(_("Error"), _("Could send remove device command to dSS")); | ||
| 334 | } | ||
| 335 | }); | ||
| 336 | |||
| 335 | 337 | }, | |
| 336 | 338 | showCopyWindow: function() { | |
| 337 | var csvwindow = new dSS.util.GridToCSVWindow({ | ||
| 339 | var csvwindow = new dSS.util.GridToCSVWindow({ | ||
| 338 | 340 | gridPanel: this, | |
| 339 | 341 | windowWidth: 640, | |
| 340 | 342 | windowHeight: 120 | |
| 341 | 343 | }); | |
| 342 | 344 | csvwindow.show(this); | |
| 343 | 345 | }, | |
| 344 | |||
| 346 | |||
| 345 | 347 | dsmStatistics: function(item, event, rowIndex) { | |
| 346 | 348 | var record; | |
| 347 | 349 | // we were called from the toolbar, so its possible that there is | |
| 348 | 350 | // no device selection yet | |
| 349 | 351 | var sel = this.getSelectionModel(); | |
| 350 | if (!sel.hasSelection()) | ||
| 351 | { | ||
| 352 | if (!sel.hasSelection()) { | ||
| 352 | 353 | Ext.Msg.alert(_("No meter selected"), _("Please select a meter from the list!")); | |
| 353 | 354 | return; | |
| 354 | 355 | } | |
| 355 | |||
| 356 | |||
| 356 | 357 | records = sel.getSelections(); | |
| 357 | |||
| 358 | |||
| 358 | 359 | var dsms = ""; | |
| 359 | 360 | var dsmArray = []; | |
| 360 | for (var i = 0; i < records.length; i++) | ||
| 361 | { | ||
| 361 | for (var i = 0; i < records.length; i++) { | ||
| 362 | 362 | if (records[i].get("isPresent") === false) { | |
| 363 | 363 | continue; | |
| 364 | 364 | } | |
| … | … | ||
| 368 | 368 | dsm.busid = records[i].get("busId"); | |
| 369 | 369 | dsmArray.push(dsm); | |
| 370 | 370 | dsms += dsm.dsid; | |
| 371 | if (i < records.length - 1) | ||
| 372 | dsms += ","; | ||
| 371 | if (i < records.length - 1) dsms += ","; | ||
| 373 | 372 | } | |
| 374 | |||
| 373 | |||
| 375 | 374 | if (dsmArray.length === 0) { | |
| 376 | 375 | Ext.Msg.alert(_("No meters present"), _("Your selection contained only non present meters!")); | |
| 377 | 376 | return; | |
| 378 | 377 | } | |
| 379 | |||
| 378 | |||
| 380 | 379 | var dsmRecord = Ext.data.Record.create([ | |
| 381 | { name: "dsid", mapping: "dsid"}, | ||
| 382 | { name: "name", mapping: "name"}, | ||
| 383 | { name: "busid", mapping: "busid"} | ||
| 384 | ]); | ||
| 385 | |||
| 380 | { | ||
| 381 | name: "dsid", | ||
| 382 | mapping: "dsid" | ||
| 383 | }, | ||
| 384 | { | ||
| 385 | name: "name", | ||
| 386 | mapping: "name" | ||
| 387 | }, | ||
| 388 | { | ||
| 389 | name: "busid", | ||
| 390 | mapping: "busid" | ||
| 391 | }]); | ||
| 392 | |||
| 386 | 393 | var statsStore = new Ext.data.ArrayStore({ | |
| 387 | autoDestroy : true, | ||
| 388 | storeId : "statsStore", | ||
| 389 | idIndex : 0, | ||
| 390 | fields : dsmRecord, | ||
| 394 | autoDestroy: true, | ||
| 395 | storeId: "statsStore", | ||
| 396 | idIndex: 0, | ||
| 397 | fields: dsmRecord, | ||
| 391 | 398 | data: dsmArray | |
| 392 | 399 | }); | |
| 393 | 400 | var now = new Date(); | |
| 394 | 401 | var h_now = now.getHours(); | |
| 395 | 402 | var m_now = now.getMinutes(); | |
| 396 | |||
| 403 | |||
| 397 | 404 | m_now += 5; | |
| 398 | if (m_now >= 60) | ||
| 399 | { | ||
| 405 | if (m_now >= 60) { | ||
| 400 | 406 | h_now++; | |
| 401 | 407 | m_now = m_now - 60; | |
| 402 | 408 | } | |
| 403 | |||
| 404 | if (h_now >= 24) | ||
| 405 | h_now = 0; | ||
| 406 | |||
| 409 | |||
| 410 | if (h_now >= 24) h_now = 0; | ||
| 411 | |||
| 407 | 412 | var sep = ":"; | |
| 408 | |||
| 409 | if (m_now < 10) | ||
| 410 | sep = sep + "0"; | ||
| 411 | |||
| 413 | |||
| 414 | if (m_now < 10) sep = sep + "0"; | ||
| 415 | |||
| 412 | 416 | var statsForm = new dSS.util.DeviceStatisticsForm({ | |
| 413 | 417 | statisticsStore: statsStore, | |
| 414 | 418 | sep: sep, | |
| 415 | 419 | h_now: h_now, | |
| 416 | 420 | m_now: m_now | |
| 417 | 421 | }); | |
| 418 | |||
| 422 | |||
| 419 | 423 | var win = new dSS.util.DSMStatisticsWindow({ | |
| 420 | form : statsForm, | ||
| 421 | dsm : dsms, | ||
| 422 | maskElement : this.findParentByType(Ext.Viewport).el | ||
| 424 | form: statsForm, | ||
| 425 | dsm: dsms, | ||
| 426 | maskElement: this.findParentByType(Ext.Viewport).el | ||
| 423 | 427 | }); | |
| 424 | |||
| 428 | |||
| 425 | 429 | win.show(this); | |
| 426 | 430 | }, | |
| 427 | 431 | abortStatisticsRound: function() { | |
| … | … | ||
| 434 | 434 | disableCaching: true, | |
| 435 | 435 | method: 'GET', | |
| 436 | 436 | scope: this, | |
| 437 | params: { path: '/system/js/settings/dsmStatistics/session' }, | ||
| 437 | params: { | ||
| 438 | path: '/system/js/settings/dsmStatistics/session' | ||
| 439 | }, | ||
| 438 | 440 | success: function(result, request) { | |
| 439 | 441 | try { | |
| 440 | 442 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| … | … | ||
| 460 | 460 | } else { | |
| 461 | 461 | Ext.MessageBox.alert(_("Could not set statistics session value"), jsonData.message); | |
| 462 | 462 | } | |
| 463 | } catch (err) { | ||
| 463 | } catch(err) { | ||
| 464 | 464 | Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err); | |
| 465 | 465 | } | |
| 466 | 466 | }, | |
| … | … | ||
| 471 | 471 | } else { | |
| 472 | 472 | Ext.MessageBox.alert(_("Could not get dSM statistics session value"), jsonData.message); | |
| 473 | 473 | } | |
| 474 | } catch (err) { | ||
| 474 | } catch(err) { | ||
| 475 | 475 | Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err); | |
| 476 | 476 | } | |
| 477 | 477 | }, | |
| … | … | ||
| 487 | 487 | // we were called from the toolbar, so its possible that there is | |
| 488 | 488 | // no meter selection yet | |
| 489 | 489 | var sel = this.getSelectionModel(); | |
| 490 | if (!sel.hasSelection()) | ||
| 491 | { | ||
| 490 | if (!sel.hasSelection()) { | ||
| 492 | 491 | Ext.MessageBox.alert(_("No meter selected"), _("Please select a meter from the list!")); | |
| 493 | 492 | return; | |
| 494 | 493 | } | |
| … | … | ||
| 496 | 496 | var skippedPresent = false; | |
| 497 | 497 | var notPresent = new Array(); | |
| 498 | 498 | ||
| 499 | for (var i = 0; i < records.length; i++) | ||
| 500 | { | ||
| 499 | for (var i = 0; i < records.length; i++) { | ||
| 501 | 500 | var record = records[i]; | |
| 502 | 501 | ||
| 503 | 502 | // do not issue the ajax request if we know that it will fail | |
| … | … | ||
| 508 | 508 | notPresent.push(record); | |
| 509 | 509 | } | |
| 510 | 510 | ||
| 511 | if (notPresent.length > 0) | ||
| 512 | this.deleteMeter(notPresent); | ||
| 511 | if (notPresent.length > 0) this.deleteMeter(notPresent); | ||
| 513 | 512 | else { | |
| 514 | 513 | if (skippedPresent === true) { | |
| 515 | 514 | Ext.MessageBox.alert(_("Warning"), _("Present meters can not be removed!")); | |
| 516 | 515 | } | |
| 517 | 516 | } | |
| 518 | 517 | }, | |
| 519 | deleteMeter : function(records) { | ||
| 518 | deleteMeter: function(records) { | ||
| 520 | 519 | var store = this.getStore(); | |
| 521 | 520 | if (records.length < 1) { | |
| 522 | 521 | this.el.unmask(); | |
| … | … | ||
| 524 | 524 | ||
| 525 | 525 | var record = records.shift(); | |
| 526 | 526 | ||
| 527 | this.el.mask(_("Deleting meter") + ": " + record.get("dsid")); | ||
| 527 | this.el.mask(_("Deleting meter") + ": " + record.get("dsid")); | ||
| 528 | 528 | Ext.Ajax.request({ | |
| 529 | 529 | url: '/json/apartment/removeMeter', | |
| 530 | 530 | disableCaching: true, | |
| 531 | 531 | method: "GET", | |
| 532 | 532 | scope: this, | |
| 533 | params: { dsid : record.get('dsid') }, | ||
| 533 | params: { | ||
| 534 | dsid: record.get('dsid') | ||
| 535 | }, | ||
| 534 | 536 | success: function(result, request) { | |
| 535 | 537 | try { | |
| 536 | 538 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 537 | if(jsonData.ok) { | ||
| 539 | if (jsonData.ok) { | ||
| 538 | 540 | store.remove(record); | |
| 539 | 541 | this.deleteMeter(records); | |
| 540 | 542 | } else { | |
| … | … | ||
| 544 | 544 | Ext.MessageBox.alert(_("Could not remove"), jsonData.message); | |
| 545 | 545 | } | |
| 546 | 546 | } | |
| 547 | catch (err) { | ||
| 547 | catch(err) { | ||
| 548 | 548 | this.el.unmask(); | |
| 549 | 549 | Ext.MessageBox.alert(_("Error"), _("Could send remove meter command to dSS") + ": " + err); | |
| 550 | 550 | } | |
| … | … | ||
| 556 | 556 | }); | |
| 557 | 557 | }, | |
| 558 | 558 | removeInactiveMeters: function() { | |
| 559 | Ext.Ajax.request({ | ||
| 560 | url: '/json/apartment/removeInactiveMeters', | ||
| 561 | disableCaching: true, | ||
| 562 | method: "GET", | ||
| 563 | scope: this, | ||
| 564 | success: function(result, request) { | ||
| 565 | try { | ||
| 566 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 567 | if(jsonData.ok) { | ||
| 568 | dSS.data.Loader.load(); | ||
| 569 | } else { | ||
| 570 | Ext.MessageBox.alert(_("Could not remove inactive meters"), jsonData.message); | ||
| 571 | } | ||
| 572 | } | ||
| 573 | catch (err) { | ||
| 574 | Ext.MessageBox.alert(_("Error"), _("Could send remove inactive meters command to dSS") + ": " + err); | ||
| 575 | } | ||
| 576 | }, | ||
| 577 | failure: function(result, request) { | ||
| 578 | Ext.MessageBox.alert(_("Error"), _("Could send remove inactive meters command to dSS")); | ||
| 579 | } | ||
| 580 | }); | ||
| 559 | Ext.Ajax.request({ | ||
| 560 | url: '/json/apartment/removeInactiveMeters', | ||
| 561 | disableCaching: true, | ||
| 562 | method: "GET", | ||
| 563 | scope: this, | ||
| 564 | success: function(result, request) { | ||
| 565 | try { | ||
| 566 | var jsonData = Ext.util.JSON.decode(result.responseText); | ||
| 567 | if (jsonData.ok) { | ||
| 568 | dSS.data.Loader.load(); | ||
| 569 | } else { | ||
| 570 | Ext.MessageBox.alert(_("Could not remove inactive meters"), jsonData.message); | ||
| 571 | } | ||
| 572 | } | ||
| 573 | catch(err) { | ||
| 574 | Ext.MessageBox.alert(_("Error"), _("Could send remove inactive meters command to dSS") + ": " + err); | ||
| 575 | } | ||
| 576 | }, | ||
| 577 | failure: function(result, request) { | ||
| 578 | Ext.MessageBox.alert(_("Error"), _("Could send remove inactive meters command to dSS")); | ||
| 579 | } | ||
| 580 | }); | ||
| 581 | 581 | }, | |
| 582 | 582 | rescan: function() { | |
| 583 | 583 | this.ownerCt.ownerCt.zoneBrowser.rescan(); |
webroot/js/dss/dss-setup-interface/dSS/grid/jsLogFilesPanel.js
(51 / 53)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | |||
| 3 | 2 | Ext.namespace('dSS', 'dSS.system'); | |
| 4 | 3 | ||
| 5 | 4 | dSS.system.jsLogFilesPanel = Ext.extend(Ext.grid.GridPanel, { | |
| 6 | 5 | initComponent: function() { | |
| 7 | 6 | this.logFileRecord = Ext.data.Record.create([ | |
| 8 | { name: "logfile", mapping: "name" }, | ||
| 9 | { name: "download", mapping: "download" } | ||
| 10 | ]); | ||
| 7 | { | ||
| 8 | name: "logfile", | ||
| 9 | mapping: "name" | ||
| 10 | }, | ||
| 11 | { | ||
| 12 | name: "download", | ||
| 13 | mapping: "download" | ||
| 14 | }]); | ||
| 11 | 15 | ||
| 12 | 16 | this.logFileStore = new Ext.data.ArrayStore({ | |
| 13 | 17 | storeId: "logFileStore", | |
| … | … | ||
| 20 | 20 | ||
| 21 | 21 | Ext.apply(this, { | |
| 22 | 22 | columns: [ | |
| 23 | { | ||
| 24 | header: _("Log file"), sortable: true, | ||
| 25 | dataIndex: "name", id: "logfile" }, | ||
| 26 | { | ||
| 27 | header: _("Download"), sortable: true, | ||
| 28 | dataIndex: "download", width: 200 | ||
| 29 | } | ||
| 30 | ], | ||
| 23 | { | ||
| 24 | header: _("Log file"), | ||
| 25 | sortable: true, | ||
| 26 | dataIndex: "name", | ||
| 27 | id: "logfile" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | header: _("Download"), | ||
| 31 | sortable: true, | ||
| 32 | dataIndex: "download", | ||
| 33 | width: 200 | ||
| 34 | }], | ||
| 31 | 35 | store: this.logFileStore, | |
| 32 | 36 | stripeRows: true, | |
| 33 | 37 | autoScroll: true, | |
| 34 | 38 | autoExpandColumn: "logfile", | |
| 35 | 39 | layout: "fit", | |
| 36 | selModel: new Ext.grid.RowSelectionModel({ singleSelect: true }), | ||
| 37 | viewConfig: { autoFill: true } | ||
| 40 | selModel: new Ext.grid.RowSelectionModel({ | ||
| 41 | singleSelect: true | ||
| 42 | }), | ||
| 43 | viewConfig: { | ||
| 44 | autoFill: true | ||
| 45 | } | ||
| 38 | 46 | }); | |
| 39 | 47 | ||
| 40 | 48 | dSS.system.jsLogFilesPanel.superclass.initComponent.apply(this, arguments); | |
| 41 | 49 | ||
| 42 | this.on( | ||
| 43 | "afterrender", | ||
| 44 | function(component) { | ||
| 45 | this.fillStore(); | ||
| 46 | }, | ||
| 47 | this | ||
| 48 | ); | ||
| 50 | this.on("afterrender", function(component) { | ||
| 51 | this.fillStore(); | ||
| 52 | }, | ||
| 53 | this); | ||
| 49 | 54 | ||
| 50 | this.on( | ||
| 51 | "activate", | ||
| 52 | function(component) { | ||
| 53 | this.fillStore(); | ||
| 54 | var sel = this.getSelectionModel(); | ||
| 55 | if (sel.hasSelection()) { | ||
| 56 | var record = sel.getSelected(); | ||
| 57 | this.findParentByType("dsssystemjslogfiles").loadLog(record.get("name")); | ||
| 58 | } | ||
| 59 | }, | ||
| 60 | this | ||
| 61 | ); | ||
| 55 | this.on("activate", function(component) { | ||
| 56 | this.fillStore(); | ||
| 57 | var sel = this.getSelectionModel(); | ||
| 58 | if (sel.hasSelection()) { | ||
| 59 | var record = sel.getSelected(); | ||
| 60 | this.findParentByType("dsssystemjslogfiles").loadLog(record.get("name")); | ||
| 61 | } | ||
| 62 | }, | ||
| 63 | this); | ||
| 62 | 64 | ||
| 63 | |||
| 64 | this.on( | ||
| 65 | "cellclick", | ||
| 66 | function(grid, rowIndex, columnIndex, e) { | ||
| 67 | var record = grid.getStore().getAt(rowIndex); | ||
| 68 | this.findParentByType("dsssystemjslogfiles").loadLog(record.get("name")); | ||
| 69 | }, | ||
| 70 | this | ||
| 71 | ); | ||
| 65 | this.on("cellclick", function(grid, rowIndex, columnIndex, e) { | ||
| 66 | var record = grid.getStore().getAt(rowIndex); | ||
| 67 | this.findParentByType("dsssystemjslogfiles").loadLog(record.get("name")); | ||
| 68 | }, | ||
| 69 | this); | ||
| 72 | 70 | }, | |
| 73 | 71 | ||
| 74 | 72 | fillStore: function() { | |
| … | … | ||
| 74 | 74 | url: "/json/property/getChildren", | |
| 75 | 75 | method: "GET", | |
| 76 | 76 | scope: this, | |
| 77 | params: { path: "/system/js/logsfiles" }, | ||
| 77 | params: { | ||
| 78 | path: "/system/js/logsfiles" | ||
| 79 | }, | ||
| 78 | 80 | success: function(result, request) { | |
| 79 | 81 | try { | |
| 80 | 82 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 81 | 83 | if (jsonData.ok) { | |
| 82 | 84 | for (i = 0; i < jsonData.result.length; i++) { | |
| 83 | var link = "<span class=\"x-green-button-link\">" + | ||
| 84 | "<a target=\"_blank\" title=\"" + | ||
| 85 | _("Right click and select Save Link As to " + | ||
| 86 | "download the log file.") + | ||
| 87 | "\" href=\"/download/" + jsonData.result[i].name + "\">" + jsonData.result[i].name + "</a></span>"; | ||
| 85 | var link = "<span class=\"x-green-button-link\">" + "<a target=\"_blank\" title=\"" + _("Right click and select Save Link As to " + "download the log file.") + "\" href=\"/download/" + jsonData.result[i].name + "\">" + jsonData.result[i].name + "</a></span>"; | ||
| 88 | 86 | jsonData.result[i].download = link; | |
| 89 | 87 | var r = new this.logFileRecord( | |
| 90 | jsonData.result[i] | ||
| 91 | ); | ||
| 88 | jsonData.result[i]); | ||
| 92 | 89 | ||
| 93 | if (this.logFileStore.findExact("name", | ||
| 94 | r.get("name")) == -1) { | ||
| 90 | if (this.logFileStore.findExact("name", r.get("name")) == - 1) { | ||
| 95 | 91 | this.logFileStore.add([r]); | |
| 96 | 92 | } | |
| 97 | 93 | } | |
| 98 | 94 | } else { | |
| 99 | 95 | Ext.MessageBox.alert(_("Error"), _("Could not get properties from dSS")); | |
| 100 | 96 | } | |
| 101 | } catch (err) { | ||
| 97 | } catch(err) { | ||
| 102 | 98 | Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS") + ": " + err); | |
| 103 | 99 | } | |
| 104 | 100 | }, |
webroot/js/dss/dss-setup-interface/dSS/scene/SceneWindowLight.js
(195 / 199)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/config/Config> | |
| 3 | 3 | //= require <dSS/util/Util> | |
| 4 | |||
| 5 | 4 | Ext.namespace("dSS", "dSS.scene", "dSS.config", "dSS.util"); | |
| 6 | 5 | ||
| 7 | 6 | // parameters: | |
| … | … | ||
| 8 | 8 | // dsid | |
| 9 | 9 | dSS.scene.SceneWindowLight = Ext.extend(Ext.Window, { | |
| 10 | 10 | constructor: function(config) { | |
| 11 | this.messagePanel = new Ext.Panel( | ||
| 12 | { | ||
| 13 | xtype: 'panel', | ||
| 14 | ref: 'message', | ||
| 15 | id: 'message', | ||
| 16 | height: 20, | ||
| 17 | columnWidth: 1, | ||
| 18 | bodyCfg: { cls: 'x-text-align-center x-window-body' }, | ||
| 19 | autoEl: 'span', | ||
| 20 | html: _("Move slider to change brightness."), | ||
| 21 | bodyBorder: false | ||
| 22 | } | ||
| 23 | ); | ||
| 11 | this.messagePanel = new Ext.Panel({ | ||
| 12 | xtype: 'panel', | ||
| 13 | ref: 'message', | ||
| 14 | id: 'message', | ||
| 15 | height: 20, | ||
| 16 | columnWidth: 1, | ||
| 17 | bodyCfg: { | ||
| 18 | cls: 'x-text-align-center x-window-body' | ||
| 19 | }, | ||
| 20 | autoEl: 'span', | ||
| 21 | html: _("Move slider to change brightness."), | ||
| 22 | bodyBorder: false | ||
| 23 | }); | ||
| 24 | 24 | ||
| 25 | 25 | this.dsid = config.dsid; | |
| 26 | 26 | ||
| 27 | 27 | Ext.apply(this, { | |
| 28 | 28 | layout: 'fit', | |
| 29 | width: 370, | ||
| 29 | width: 370, | ||
| 30 | 30 | height: 220, | |
| 31 | resizable : false, | ||
| 31 | resizable: false, | ||
| 32 | 32 | iconCls: 'functionLightIcon', | |
| 33 | title: _("Control light"), | ||
| 34 | items: | ||
| 35 | [ | ||
| 33 | title: _("Control light"), | ||
| 34 | items: [ | ||
| 35 | { | ||
| 36 | xtype: 'panel', | ||
| 37 | bodyCfg: { | ||
| 38 | cls: 'x-window-body' | ||
| 39 | }, | ||
| 40 | bodyBorder: false, | ||
| 41 | border: false, | ||
| 42 | frame: false, | ||
| 43 | hideBorders: true, | ||
| 44 | layout: 'table', | ||
| 45 | layoutConfig: { | ||
| 46 | columns: 6, | ||
| 47 | tableAttrs: { | ||
| 48 | width: '100%' | ||
| 49 | } | ||
| 50 | }, | ||
| 51 | items: [ | ||
| 36 | 52 | { | |
| 37 | 53 | xtype: 'panel', | |
| 38 | bodyCfg: { cls: 'x-window-body' }, | ||
| 54 | bodyCfg: { | ||
| 55 | cls: 'x-window-body' | ||
| 56 | }, | ||
| 57 | colspan: 6, | ||
| 58 | html: '', | ||
| 59 | height: 30, | ||
| 39 | 60 | bodyBorder: false, | |
| 40 | 61 | border: false, | |
| 41 | 62 | frame: false, | |
| 42 | hideBorders: true, | ||
| 63 | items: [ | ||
| 64 | { | ||
| 65 | xtype: 'label', | ||
| 66 | ctCls: 'x-text-align-center x-text-top-margin', | ||
| 67 | text: _("dsid") + ": " + config.dsid | ||
| 68 | }] | ||
| 69 | }, | ||
| 70 | { | ||
| 71 | xtype: 'panel', | ||
| 72 | html: '', | ||
| 73 | width: 25, | ||
| 74 | rowspan: 5, | ||
| 75 | bodyBorder: false, | ||
| 76 | border: false, | ||
| 77 | frame: false | ||
| 78 | }, | ||
| 79 | { | ||
| 80 | xtype: 'panel', | ||
| 81 | bodyCfg: { | ||
| 82 | cls: 'x-window-body' | ||
| 83 | }, | ||
| 84 | colspan: 4, | ||
| 43 | 85 | layout: 'table', | |
| 44 | layoutConfig: | ||
| 45 | { | ||
| 46 | columns : 6, | ||
| 47 | tableAttrs: { width: '100%' } | ||
| 86 | layoutConfig: { | ||
| 87 | columns: 3, | ||
| 88 | tableAttrs: { | ||
| 89 | width: '100%' | ||
| 90 | } | ||
| 48 | 91 | }, | |
| 49 | 92 | items: [ | |
| 50 | { | ||
| 51 | xtype: 'panel', | ||
| 52 | bodyCfg: { cls: 'x-window-body' }, | ||
| 53 | colspan: 6, | ||
| 54 | html: '', | ||
| 55 | height: 30, | ||
| 56 | bodyBorder: false, | ||
| 57 | border: false, | ||
| 58 | frame: false, | ||
| 59 | items: | ||
| 60 | [ | ||
| 61 | { | ||
| 62 | xtype: 'label', | ||
| 63 | ctCls: 'x-text-align-center x-text-top-margin', | ||
| 64 | text: _("dsid") + ": " + config.dsid | ||
| 65 | } | ||
| 66 | ] | ||
| 93 | { | ||
| 94 | xtype: 'panel', | ||
| 95 | bodyCfg: { | ||
| 96 | cls: 'x-window-body' | ||
| 67 | 97 | }, | |
| 68 | { | ||
| 69 | xtype: 'panel', | ||
| 70 | html: '', | ||
| 71 | width: 25, | ||
| 72 | rowspan: 5, | ||
| 73 | bodyBorder: false, | ||
| 74 | border: false, | ||
| 75 | frame: false | ||
| 98 | autoEl: { | ||
| 99 | tag: 'img', | ||
| 100 | align: 'left', | ||
| 101 | src: '/images/lightbulb_off.png' | ||
| 102 | } | ||
| 103 | }, | ||
| 104 | this.messagePanel, { | ||
| 105 | xtype: 'panel', | ||
| 106 | bodyCfg: { | ||
| 107 | cls: 'x-window-body' | ||
| 76 | 108 | }, | |
| 77 | { | ||
| 78 | xtype: 'panel', | ||
| 79 | bodyCfg: { cls: 'x-window-body' }, | ||
| 80 | colspan: 4, | ||
| 81 | layout: 'table', | ||
| 82 | layoutConfig: | ||
| 83 | { | ||
| 84 | columns : 3, | ||
| 85 | tableAttrs: { width: '100%' } | ||
| 86 | }, | ||
| 87 | items: [ | ||
| 88 | { | ||
| 89 | xtype: 'panel', | ||
| 90 | bodyCfg: { cls: 'x-window-body' }, | ||
| 91 | autoEl: { | ||
| 92 | tag: 'img', | ||
| 93 | align: 'left', | ||
| 94 | src: '/images/lightbulb_off.png' | ||
| 95 | } | ||
| 96 | }, | ||
| 97 | this.messagePanel, | ||
| 98 | { | ||
| 99 | xtype: 'panel', | ||
| 100 | bodyCfg: { cls: 'x-window-body' }, | ||
| 101 | autoEl: { | ||
| 102 | tag: 'img', | ||
| 103 | align: 'right', | ||
| 104 | src: '/images/lightbulb.png' | ||
| 105 | } | ||
| 106 | }, | ||
| 107 | |||
| 108 | ] | ||
| 109 | }, | ||
| 110 | { | ||
| 111 | xtype: 'panel', | ||
| 112 | html: '', | ||
| 113 | width: 25, | ||
| 114 | rowspan: 5, | ||
| 115 | bodyBorder: false, | ||
| 116 | border: false, | ||
| 117 | frame:false | ||
| 118 | }, | ||
| 119 | { | ||
| 120 | xtype: 'slider', | ||
| 121 | minValue: 0, | ||
| 122 | increment: 1, | ||
| 123 | maxValue: 100, | ||
| 124 | plugins: new Ext.slider.Tip({ | ||
| 125 | getText: function(thumb){ | ||
| 126 | return String.format('{0}%', | ||
| 127 | thumb.value); | ||
| 128 | } | ||
| 129 | }), | ||
| 130 | colspan: 4, | ||
| 131 | listeners: { | ||
| 132 | changeComplete: | ||
| 133 | this.handleSliderChanged.createDelegate(this) | ||
| 134 | } | ||
| 135 | }, | ||
| 136 | { | ||
| 137 | xtype: 'button', | ||
| 138 | layout: 'fit', | ||
| 139 | width: 70, | ||
| 140 | text: _("Scene") + " 1", | ||
| 141 | handler: function() { | ||
| 142 | dSS.util.callScene(config.dsid, | ||
| 143 | dSS.config.scenes.T0_S1); | ||
| 144 | } | ||
| 145 | }, | ||
| 146 | { | ||
| 147 | xtype: 'button', | ||
| 148 | layout: 'fit', | ||
| 149 | width: 70, | ||
| 150 | text: _("Scene") + " 2", | ||
| 151 | handler: function() { | ||
| 152 | dSS.util.callScene(config.dsid, | ||
| 153 | dSS.config.scenes.T0_S2); | ||
| 154 | } | ||
| 155 | }, | ||
| 156 | { | ||
| 157 | xtype: 'button', | ||
| 158 | layout: 'fit', | ||
| 159 | width: 70, | ||
| 160 | text: _("Scene") + " 3", | ||
| 161 | handler: function() { | ||
| 162 | dSS.util.callScene(config.dsid, | ||
| 163 | dSS.config.scenes.T0_S3); | ||
| 164 | } | ||
| 165 | }, | ||
| 166 | { | ||
| 167 | xtype: 'button', | ||
| 168 | layout: 'fit', | ||
| 169 | width: 70, | ||
| 170 | text: _("Scene") + " 4", | ||
| 171 | handler: function() { | ||
| 172 | dSS.util.callScene(config.dsid, | ||
| 173 | dSS.config.scenes.T0_S4); | ||
| 174 | } | ||
| 175 | }, | ||
| 176 | { | ||
| 177 | xtype: 'panel', | ||
| 178 | bodyCfg: { cls: 'x-window-body' }, | ||
| 179 | html: '', | ||
| 180 | height: 15, | ||
| 181 | colspan: 6, | ||
| 182 | bodyBorder: false, | ||
| 183 | border: false, | ||
| 184 | frame: false | ||
| 185 | }, | ||
| 186 | { | ||
| 187 | xtype: 'panel', | ||
| 188 | html: '', | ||
| 189 | bodyBorder: false, | ||
| 190 | border: false, | ||
| 191 | frame: false | ||
| 192 | }, | ||
| 193 | { | ||
| 194 | xtype: 'button', | ||
| 195 | layout: 'fit', | ||
| 196 | width: 70, | ||
| 197 | text: _("On"), | ||
| 198 | handler: function() { | ||
| 199 | dSS.util.callScene(config.dsid, | ||
| 200 | dSS.config.scenes.MAX); | ||
| 201 | } | ||
| 202 | }, | ||
| 203 | { | ||
| 204 | xtype: 'button', | ||
| 205 | width: 70, | ||
| 206 | text: _("Off"), | ||
| 207 | handler: function() { | ||
| 208 | dSS.util.callScene(config.dsid, | ||
| 209 | dSS.config.scenes.MIN); | ||
| 210 | } | ||
| 109 | autoEl: { | ||
| 110 | tag: 'img', | ||
| 111 | align: 'right', | ||
| 112 | src: '/images/lightbulb.png' | ||
| 211 | 113 | } | |
| 114 | }, | ||
| 115 | |||
| 212 | 116 | ] | |
| 213 | } | ||
| 214 | ], | ||
| 215 | buttons:[{ | ||
| 117 | }, | ||
| 118 | { | ||
| 119 | xtype: 'panel', | ||
| 120 | html: '', | ||
| 121 | width: 25, | ||
| 122 | rowspan: 5, | ||
| 123 | bodyBorder: false, | ||
| 124 | border: false, | ||
| 125 | frame: false | ||
| 126 | }, | ||
| 127 | { | ||
| 128 | xtype: 'slider', | ||
| 129 | minValue: 0, | ||
| 130 | increment: 1, | ||
| 131 | maxValue: 100, | ||
| 132 | plugins: new Ext.slider.Tip({ | ||
| 133 | getText: function(thumb) { | ||
| 134 | return String.format('{0}%', thumb.value); | ||
| 135 | } | ||
| 136 | }), | ||
| 137 | colspan: 4, | ||
| 138 | listeners: { | ||
| 139 | changeComplete: this.handleSliderChanged.createDelegate(this) | ||
| 140 | } | ||
| 141 | }, | ||
| 142 | { | ||
| 143 | xtype: 'button', | ||
| 144 | layout: 'fit', | ||
| 145 | width: 70, | ||
| 146 | text: _("Scene") + " 1", | ||
| 147 | handler: function() { | ||
| 148 | dSS.util.callScene(config.dsid, dSS.config.scenes.T0_S1); | ||
| 149 | } | ||
| 150 | }, | ||
| 151 | { | ||
| 152 | xtype: 'button', | ||
| 153 | layout: 'fit', | ||
| 154 | width: 70, | ||
| 155 | text: _("Scene") + " 2", | ||
| 156 | handler: function() { | ||
| 157 | dSS.util.callScene(config.dsid, dSS.config.scenes.T0_S2); | ||
| 158 | } | ||
| 159 | }, | ||
| 160 | { | ||
| 161 | xtype: 'button', | ||
| 162 | layout: 'fit', | ||
| 163 | width: 70, | ||
| 164 | text: _("Scene") + " 3", | ||
| 165 | handler: function() { | ||
| 166 | dSS.util.callScene(config.dsid, dSS.config.scenes.T0_S3); | ||
| 167 | } | ||
| 168 | }, | ||
| 169 | { | ||
| 170 | xtype: 'button', | ||
| 171 | layout: 'fit', | ||
| 172 | width: 70, | ||
| 173 | text: _("Scene") + " 4", | ||
| 174 | handler: function() { | ||
| 175 | dSS.util.callScene(config.dsid, dSS.config.scenes.T0_S4); | ||
| 176 | } | ||
| 177 | }, | ||
| 178 | { | ||
| 179 | xtype: 'panel', | ||
| 180 | bodyCfg: { | ||
| 181 | cls: 'x-window-body' | ||
| 182 | }, | ||
| 183 | html: '', | ||
| 184 | height: 15, | ||
| 185 | colspan: 6, | ||
| 186 | bodyBorder: false, | ||
| 187 | border: false, | ||
| 188 | frame: false | ||
| 189 | }, | ||
| 190 | { | ||
| 191 | xtype: 'panel', | ||
| 192 | html: '', | ||
| 193 | bodyBorder: false, | ||
| 194 | border: false, | ||
| 195 | frame: false | ||
| 196 | }, | ||
| 197 | { | ||
| 198 | xtype: 'button', | ||
| 199 | layout: 'fit', | ||
| 200 | width: 70, | ||
| 201 | text: _("On"), | ||
| 202 | handler: function() { | ||
| 203 | dSS.util.callScene(config.dsid, dSS.config.scenes.MAX); | ||
| 204 | } | ||
| 205 | }, | ||
| 206 | { | ||
| 207 | xtype: 'button', | ||
| 208 | width: 70, | ||
| 209 | text: _("Off"), | ||
| 210 | handler: function() { | ||
| 211 | dSS.util.callScene(config.dsid, dSS.config.scenes.MIN); | ||
| 212 | } | ||
| 213 | }] | ||
| 214 | }], | ||
| 215 | buttons: [ | ||
| 216 | { | ||
| 216 | 217 | text: _("Close"), | |
| 217 | 218 | scope: this, | |
| 218 | handler: function() | ||
| 219 | { | ||
| 219 | handler: function() { | ||
| 220 | 220 | // close ping form dialog | |
| 221 | 221 | this.maskElement.unmask(); | |
| 222 | 222 | this.close(); | |
| … | … | ||
| 225 | 225 | }); | |
| 226 | 226 | ||
| 227 | 227 | dSS.scene.SceneWindowLight.superclass.constructor.apply(this, arguments); | |
| 228 | |||
| 228 | |||
| 229 | 229 | this.maskElement.mask(); | |
| 230 | 230 | ||
| 231 | this.on( | ||
| 232 | "beforedestroy", | ||
| 233 | function(component) { | ||
| 234 | this.maskElement.unmask(); | ||
| 235 | }, | ||
| 236 | this | ||
| 237 | ); | ||
| 238 | |||
| 231 | this.on("beforedestroy", function(component) { | ||
| 232 | this.maskElement.unmask(); | ||
| 233 | }, | ||
| 234 | this); | ||
| 235 | |||
| 239 | 236 | }, | |
| 240 | 237 | handleSliderChanged: function(slider, newVal, thumb) { | |
| 241 | 238 | this.messagePanel.update(_("Brightness set to") + ": " + newVal + "%"); | |
| … | … | ||
| 243 | 243 | } else if (value > 255) { | |
| 244 | 244 | value = 255; | |
| 245 | 245 | } | |
| 246 | |||
| 246 | |||
| 247 | 247 | dSS.util.setValueOnDevice(this.dsid, Math.round(value)); | |
| 248 | 248 | } | |
| 249 | 249 | }); |
webroot/js/dss/dss-setup-interface/dSS/scene/SceneWindowShadow.js
(84 / 91)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/config/Config> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.scene", "dSS.config"); | |
| 5 | 4 | ||
| 6 | 5 | // parameters: | |
| … | … | ||
| 10 | 10 | ||
| 11 | 11 | Ext.apply(this, { | |
| 12 | 12 | layout: 'fit', | |
| 13 | width: 300, | ||
| 13 | width: 300, | ||
| 14 | 14 | height: 145, | |
| 15 | resizable : false, | ||
| 15 | resizable: false, | ||
| 16 | 16 | iconCls: 'functionShadowIcon', | |
| 17 | title: _("Control blinds"), | ||
| 18 | items: | ||
| 19 | [ | ||
| 17 | title: _("Control blinds"), | ||
| 18 | items: [ | ||
| 19 | { | ||
| 20 | xtype: 'panel', | ||
| 21 | bodyCfg: { | ||
| 22 | cls: 'x-window-body' | ||
| 23 | }, | ||
| 24 | bodyBorder: false, | ||
| 25 | border: false, | ||
| 26 | frame: false, | ||
| 27 | hideBorders: true, | ||
| 28 | layout: 'table', | ||
| 29 | layoutConfig: { | ||
| 30 | columns: 5, | ||
| 31 | tableAttrs: { | ||
| 32 | width: '100%' | ||
| 33 | } | ||
| 34 | }, | ||
| 35 | items: [ | ||
| 20 | 36 | { | |
| 21 | 37 | xtype: 'panel', | |
| 22 | bodyCfg: { cls: 'x-window-body' }, | ||
| 38 | bodyCfg: { | ||
| 39 | cls: 'x-window-body' | ||
| 40 | }, | ||
| 41 | colspan: 5, | ||
| 42 | html: '', | ||
| 43 | height: 30, | ||
| 23 | 44 | bodyBorder: false, | |
| 24 | 45 | border: false, | |
| 25 | 46 | frame: false, | |
| 26 | hideBorders: true, | ||
| 27 | layout: 'table', | ||
| 28 | layoutConfig: | ||
| 29 | { | ||
| 30 | columns : 5, | ||
| 31 | tableAttrs: { width: '100%' } | ||
| 32 | }, | ||
| 33 | 47 | items: [ | |
| 34 | { | ||
| 35 | xtype: 'panel', | ||
| 36 | bodyCfg: { cls: 'x-window-body' }, | ||
| 37 | colspan: 5, | ||
| 38 | html: '', | ||
| 39 | height: 30, | ||
| 40 | bodyBorder: false, | ||
| 41 | border: false, | ||
| 42 | frame: false, | ||
| 43 | items: | ||
| 44 | [ | ||
| 45 | { | ||
| 46 | xtype: 'label', | ||
| 47 | ctCls: 'x-text-align-center x-text-top-margin', | ||
| 48 | text: _("dsid") + ": " + config.dsid | ||
| 49 | } | ||
| 50 | ] | ||
| 51 | }, | ||
| 52 | { | ||
| 53 | xtype: 'panel', | ||
| 54 | html: '', | ||
| 55 | width: 25, | ||
| 56 | bodyBorder: false, | ||
| 57 | border: false, | ||
| 58 | frame: false | ||
| 59 | }, | ||
| 48 | { | ||
| 49 | xtype: 'label', | ||
| 50 | ctCls: 'x-text-align-center x-text-top-margin', | ||
| 51 | text: _("dsid") + ": " + config.dsid | ||
| 52 | }] | ||
| 53 | }, | ||
| 54 | { | ||
| 55 | xtype: 'panel', | ||
| 56 | html: '', | ||
| 57 | width: 25, | ||
| 58 | bodyBorder: false, | ||
| 59 | border: false, | ||
| 60 | frame: false | ||
| 61 | }, | ||
| 60 | 62 | ||
| 61 | { | ||
| 62 | xtype: 'button', | ||
| 63 | layout: 'fit', | ||
| 64 | width: 70, | ||
| 65 | text: _("Up"), | ||
| 66 | handler: function() { | ||
| 67 | dSS.util.callScene(config.dsid, | ||
| 68 | dSS.config.scenes.MAX); | ||
| 69 | } | ||
| 70 | }, | ||
| 71 | { | ||
| 72 | xtype: 'button', | ||
| 73 | width: 70, | ||
| 74 | text: _("Stop"), | ||
| 75 | handler: function() { | ||
| 76 | dSS.util.callScene(config.dsid, | ||
| 77 | dSS.config.scenes.STOP); | ||
| 78 | } | ||
| 79 | }, | ||
| 80 | { | ||
| 81 | xtype: 'button', | ||
| 82 | width: 70, | ||
| 83 | text: _("Down"), | ||
| 84 | handler: function() { | ||
| 85 | dSS.util.callScene(config.dsid, | ||
| 86 | dSS.config.scenes.MIN); | ||
| 87 | } | ||
| 88 | }, | ||
| 89 | { | ||
| 90 | xtype: 'panel', | ||
| 91 | html: '', | ||
| 92 | width: 25, | ||
| 93 | bodyBorder: false, | ||
| 94 | border: false, | ||
| 95 | frame: false | ||
| 96 | } | ||
| 97 | ] | ||
| 98 | } | ||
| 99 | ], | ||
| 100 | buttons:[{ | ||
| 63 | { | ||
| 64 | xtype: 'button', | ||
| 65 | layout: 'fit', | ||
| 66 | width: 70, | ||
| 67 | text: _("Up"), | ||
| 68 | handler: function() { | ||
| 69 | dSS.util.callScene(config.dsid, dSS.config.scenes.MAX); | ||
| 70 | } | ||
| 71 | }, | ||
| 72 | { | ||
| 73 | xtype: 'button', | ||
| 74 | width: 70, | ||
| 75 | text: _("Stop"), | ||
| 76 | handler: function() { | ||
| 77 | dSS.util.callScene(config.dsid, dSS.config.scenes.STOP); | ||
| 78 | } | ||
| 79 | }, | ||
| 80 | { | ||
| 81 | xtype: 'button', | ||
| 82 | width: 70, | ||
| 83 | text: _("Down"), | ||
| 84 | handler: function() { | ||
| 85 | dSS.util.callScene(config.dsid, dSS.config.scenes.MIN); | ||
| 86 | } | ||
| 87 | }, | ||
| 88 | { | ||
| 89 | xtype: 'panel', | ||
| 90 | html: '', | ||
| 91 | width: 25, | ||
| 92 | bodyBorder: false, | ||
| 93 | border: false, | ||
| 94 | frame: false | ||
| 95 | }] | ||
| 96 | }], | ||
| 97 | buttons: [ | ||
| 98 | { | ||
| 101 | 99 | text: _("Close"), | |
| 102 | 100 | scope: this, | |
| 103 | handler: function() | ||
| 104 | { | ||
| 101 | handler: function() { | ||
| 105 | 102 | // close ping form dialog | |
| 106 | 103 | this.maskElement.unmask(); | |
| 107 | 104 | this.close(); | |
| … | … | ||
| 107 | 107 | }); | |
| 108 | 108 | ||
| 109 | 109 | dSS.scene.SceneWindowShadow.superclass.constructor.apply(this, arguments); | |
| 110 | |||
| 110 | |||
| 111 | 111 | this.maskElement.mask(); | |
| 112 | 112 | ||
| 113 | this.on( | ||
| 114 | "beforedestroy", | ||
| 115 | function(component) { | ||
| 116 | this.maskElement.unmask(); | ||
| 117 | }, | ||
| 118 | this | ||
| 119 | ); | ||
| 120 | |||
| 113 | this.on("beforedestroy", function(component) { | ||
| 114 | this.maskElement.unmask(); | ||
| 115 | }, | ||
| 116 | this); | ||
| 117 | |||
| 121 | 118 | } | |
| 122 | 119 | }); |
webroot/js/dss/dss-setup-interface/dSS/system/PropertyTree.js
(67 / 62)
|   | |||
| 1 | 1 | //= require <dSS/tree/PropertyTreeLoader> | |
| 2 | |||
| 3 | 2 | Ext.namespace('dSS', 'dSS.system'); | |
| 4 | 3 | ||
| 5 | 4 | dSS.system.PropertyTree = Ext.extend(Ext.Panel, { | |
| 6 | initComponent: function() { | ||
| 5 | initComponent: function() { | ||
| 7 | 6 | ||
| 8 | Ext.apply(this, { | ||
| 9 | layout: 'border', | ||
| 10 | items: [{ | ||
| 11 | xtype: 'treepanel', | ||
| 12 | ref: 'propertytree', | ||
| 13 | region: 'center', | ||
| 14 | width: 225, // give east and west regions a width | ||
| 15 | minSize: 175, | ||
| 16 | maxSize: 400, | ||
| 17 | autoScroll: true, | ||
| 18 | animate: true, | ||
| 19 | enableDD: false, | ||
| 20 | containerScroll: true, | ||
| 21 | border: false, | ||
| 22 | loader: new dSS.tree.PropertyTreeLoader(), | ||
| 23 | root: new Ext.tree.AsyncTreeNode({ | ||
| 24 | expanded: false, | ||
| 25 | path: '/', | ||
| 26 | type: 'none', | ||
| 27 | text: 'dSS', | ||
| 28 | leaf: false | ||
| 29 | }), | ||
| 30 | rootVisible: true, | ||
| 31 | listeners: { append: this.handleAppend } | ||
| 32 | } | ||
| 33 | ] | ||
| 34 | }); | ||
| 7 | Ext.apply(this, { | ||
| 8 | layout: 'border', | ||
| 9 | items: [ | ||
| 10 | { | ||
| 11 | xtype: 'treepanel', | ||
| 12 | ref: 'propertytree', | ||
| 13 | region: 'center', | ||
| 14 | width: 225, | ||
| 15 | // give east and west regions a width | ||
| 16 | minSize: 175, | ||
| 17 | maxSize: 400, | ||
| 18 | autoScroll: true, | ||
| 19 | animate: true, | ||
| 20 | enableDD: false, | ||
| 21 | containerScroll: true, | ||
| 22 | border: false, | ||
| 23 | loader: new dSS.tree.PropertyTreeLoader(), | ||
| 24 | root: new Ext.tree.AsyncTreeNode({ | ||
| 25 | expanded: false, | ||
| 26 | path: '/', | ||
| 27 | type: 'none', | ||
| 28 | text: 'dSS', | ||
| 29 | leaf: false | ||
| 30 | }), | ||
| 31 | rootVisible: true, | ||
| 32 | listeners: { | ||
| 33 | append: this.handleAppend | ||
| 34 | } | ||
| 35 | }] | ||
| 36 | }); | ||
| 35 | 37 | ||
| 36 | dSS.system.PropertyTree.superclass.initComponent.apply(this, arguments); | ||
| 37 | }, | ||
| 38 | handleAppend: function(tree, parent, node, index) { | ||
| 39 | if (node.attributes.type === 'none') return; | ||
| 40 | var url = "/json/property/"; | ||
| 41 | switch(node.attributes.type) { | ||
| 42 | case 'string': | ||
| 43 | url += 'getString'; | ||
| 44 | break; | ||
| 45 | case 'integer': | ||
| 46 | url += 'getInteger'; | ||
| 47 | break; | ||
| 48 | case 'boolean': | ||
| 49 | url += 'getBoolean'; | ||
| 50 | break; | ||
| 51 | default: | ||
| 52 | return; | ||
| 53 | } | ||
| 54 | Ext.Ajax.request({ | ||
| 55 | url: url, | ||
| 56 | params: { path: node.attributes.path }, | ||
| 57 | method: 'GET', | ||
| 58 | success: function(response, opts) { | ||
| 59 | var obj = Ext.decode(response.responseText); | ||
| 60 | if(obj.ok === true) { | ||
| 61 | node.setText(node.text + " : " + obj.result.value); | ||
| 62 | } | ||
| 63 | }, | ||
| 64 | failure: function(response, opts) { | ||
| 65 | Ext.MessageBox.alert(_("Error"), _("Server side failure with status code") + ": " + response.status); | ||
| 66 | } | ||
| 67 | }); | ||
| 68 | } | ||
| 38 | dSS.system.PropertyTree.superclass.initComponent.apply(this, arguments); | ||
| 39 | }, | ||
| 40 | handleAppend: function(tree, parent, node, index) { | ||
| 41 | if (node.attributes.type === 'none') return; | ||
| 42 | var url = "/json/property/"; | ||
| 43 | switch (node.attributes.type) { | ||
| 44 | case 'string': | ||
| 45 | url += 'getString'; | ||
| 46 | break; | ||
| 47 | case 'integer': | ||
| 48 | url += 'getInteger'; | ||
| 49 | break; | ||
| 50 | case 'boolean': | ||
| 51 | url += 'getBoolean'; | ||
| 52 | break; | ||
| 53 | default: | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | Ext.Ajax.request({ | ||
| 57 | url: | ||
| 58 | url, | ||
| 59 | params: { | ||
| 60 | path: node.attributes.path | ||
| 61 | }, | ||
| 62 | method: 'GET', | ||
| 63 | success: function(response, opts) { | ||
| 64 | var obj = Ext.decode(response.responseText); | ||
| 65 | if (obj.ok === true) { | ||
| 66 | node.setText(node.text + " : " + obj.result.value); | ||
| 67 | } | ||
| 68 | }, | ||
| 69 | failure: function(response, opts) { | ||
| 70 | Ext.MessageBox.alert(_("Error"), _("Server side failure with status code") + ": " + response.status); | ||
| 71 | } | ||
| 72 | }); | ||
| 73 | } | ||
| 69 | 74 | }); | |
| 70 | 75 | ||
| 71 | 76 | Ext.reg('dsssystempropertytree', dSS.system.PropertyTree); |
webroot/js/dss/dss-setup-interface/dSS/system/jsLogFiles.js
(24 / 27)
|   | |||
| 1 | 1 | //= require <dSS/grid/jsLogFilesPanel> | |
| 2 | |||
| 3 | 2 | Ext.namespace('dSS', 'dSS.system', 'dSS.grid'); | |
| 4 | 3 | ||
| 5 | 4 | dSS.system.jsLogFiles = Ext.extend(Ext.Panel, { | |
| 6 | 5 | initComponent: function() { | |
| 7 | this.textPanel = new Ext.Panel({ | ||
| 8 | region: "center", | ||
| 9 | autoScroll: true, | ||
| 10 | bodyCfg: { tag: "pre" } | ||
| 11 | }); | ||
| 6 | this.textPanel = new Ext.Panel({ | ||
| 7 | region: "center", | ||
| 8 | autoScroll: true, | ||
| 9 | bodyCfg: { | ||
| 10 | tag: "pre" | ||
| 11 | } | ||
| 12 | }); | ||
| 12 | 13 | ||
| 13 | 14 | this.heightConfigured = false; | |
| 14 | |||
| 15 | |||
| 15 | 16 | Ext.apply(this, { | |
| 16 | 17 | layout: 'border', | |
| 17 | items: [{ | ||
| 18 | xtype: 'dssjslogfilespanel', | ||
| 19 | ref: 'jsLogFilesPanel', | ||
| 20 | region: 'north', | ||
| 21 | split : true | ||
| 18 | items: [ | ||
| 19 | { | ||
| 20 | xtype: 'dssjslogfilespanel', | ||
| 21 | ref: 'jsLogFilesPanel', | ||
| 22 | region: 'north', | ||
| 23 | split: true | ||
| 22 | 24 | }, | |
| 23 | this.textPanel | ||
| 24 | ] | ||
| 25 | this.textPanel] | ||
| 25 | 26 | }); | |
| 26 | |||
| 27 | |||
| 27 | 28 | dSS.system.jsLogFiles.superclass.initComponent.apply(this, arguments); | |
| 28 | 29 | ||
| 29 | this.on( | ||
| 30 | "activate", | ||
| 31 | function(component) { | ||
| 32 | this.jsLogFilesPanel.fireEvent("activate"); | ||
| 30 | this.on("activate", function(component) { | ||
| 31 | this.jsLogFilesPanel.fireEvent("activate"); | ||
| 33 | 32 | ||
| 34 | if (this.heightConfigured === false) | ||
| 35 | { | ||
| 36 | this.heightConfigured = true; | ||
| 37 | this.jsLogFilesPanel.setHeight(this.getInnerHeight()/3); | ||
| 38 | } | ||
| 39 | }, | ||
| 40 | this | ||
| 41 | ); | ||
| 33 | if (this.heightConfigured === false) { | ||
| 34 | this.heightConfigured = true; | ||
| 35 | this.jsLogFilesPanel.setHeight(this.getInnerHeight() / 3); | ||
| 36 | } | ||
| 37 | }, | ||
| 38 | this); | ||
| 42 | 39 | }, | |
| 43 | 40 | ||
| 44 | 41 | loadLog: function(logname) { |
webroot/js/dss/dss-setup-interface/dSS/system/logfiles.js
(16 / 9)
|   | |||
| 1 | |||
| 2 | 1 | Ext.namespace('dSS', 'dSS.system'); | |
| 3 | 2 | ||
| 4 | 3 | dSS.system.logfiles = Ext.extend(Ext.Panel, { | |
| … | … | ||
| 5 | 5 | Ext.apply(this, { | |
| 6 | 6 | layout: 'table', | |
| 7 | 7 | title: _("Logfiles"), | |
| 8 | defaults: { border: false }, | ||
| 9 | layoutConfig: { | ||
| 8 | defaults: { | ||
| 9 | border: false | ||
| 10 | }, | ||
| 11 | layoutConfig: { | ||
| 10 | 12 | columns: 2, | |
| 11 | 13 | tableAttrs: { | |
| 12 | 14 | width: '100%' | |
| 13 | 15 | } | |
| 14 | 16 | }, | |
| 15 | items: [{ | ||
| 17 | items: [ | ||
| 18 | { | ||
| 16 | 19 | colspan: 2, | |
| 17 | 20 | html: '<h2>LOGFILES</h2>' | |
| 18 | },{ | ||
| 21 | }, | ||
| 22 | { | ||
| 19 | 23 | width: '70%', | |
| 20 | 24 | html: '<h2>This is a placeholder</h2><p>Sample text.<br/><br/><br/></p>' | |
| 21 | },{ | ||
| 25 | }, | ||
| 26 | { | ||
| 22 | 27 | html: '<p class="x-green-button-link"><a href="/images/ds_logo.gif">sample link</a></p>' | |
| 23 | },{ | ||
| 28 | }, | ||
| 29 | { | ||
| 24 | 30 | colspan: 2, | |
| 25 | 31 | html: '<h2>CONFIGURATION FILES</h2>' | |
| 26 | },{ | ||
| 32 | }, | ||
| 33 | { | ||
| 27 | 34 | html: '<h2>Current system configuration</h2><p>Download current system configuration file.<br/> Use: "Right Click > Save Target As..." to download the file. </p>' | |
| 28 | },{ | ||
| 35 | }, | ||
| 36 | { | ||
| 29 | 37 | html: '<p class="x-green-button-link"><a href="/download/apartment.xml" target=":_blank">apartment.xml</a></p>' | |
| 30 | 38 | }] | |
| 31 | 39 | }); |
webroot/js/dss/dss-setup-interface/dSS/tree/PropertyTreeLoader.js
(56 / 50)
|   | |||
| 1 | 1 | Ext.namespace('dSS', 'dSS.tree'); | |
| 2 | 2 | ||
| 3 | 3 | dSS.tree.PropertyTreeLoader = Ext.extend(Ext.tree.TreeLoader, { | |
| 4 | constructor: function(config) { | ||
| 5 | |||
| 6 | Ext.apply(this, { dataUrl: '/json/property/getChildren', requestMethod: 'GET' }); | ||
| 7 | dSS.data.DeviceStore.superclass.constructor.call(this, arguments); | ||
| 8 | }, | ||
| 9 | requestData: function(node, callback, scope){ | ||
| 10 | if(this.fireEvent("beforeload", this, node, callback) !== false){ | ||
| 11 | this.transId = Ext.Ajax.request({ | ||
| 12 | method:this.requestMethod, | ||
| 13 | url: this.dataUrl||this.url, | ||
| 14 | success: this.handleResponse, | ||
| 15 | failure: this.handleFailure, | ||
| 16 | scope: this, | ||
| 17 | argument: {callback: callback, node: node, scope: scope}, | ||
| 18 | params: this.getParams(node) | ||
| 19 | }); | ||
| 20 | }else{ | ||
| 21 | // if the load is cancelled, make sure we notify | ||
| 22 | // the node that we are done | ||
| 23 | this.runCallback(callback, scope || node, []); | ||
| 24 | } | ||
| 25 | }, | ||
| 26 | processResponse : function(response, node, callback, scope){ | ||
| 27 | var json = response.responseText; | ||
| 28 | try { | ||
| 29 | var o = response.responseData || Ext.decode(json); | ||
| 30 | o = o.result; | ||
| 31 | node.beginUpdate(); | ||
| 32 | for(var i = 0, len = o.length; i < len; i++){ | ||
| 33 | var rawNode = o[i]; | ||
| 34 | rawNode.text = rawNode.name; | ||
| 35 | rawNode.leaf = rawNode.type === 'none' ? false : true; | ||
| 36 | rawNode.path = node.attributes.path === '/' ? | ||
| 37 | node.attributes.path + rawNode.name : node.attributes.path + '/' + rawNode.name; | ||
| 38 | var n = this.createNode(rawNode); | ||
| 39 | if(n){ | ||
| 40 | node.appendChild(n); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | node.endUpdate(); | ||
| 44 | this.runCallback(callback, scope || node, [node]); | ||
| 45 | }catch(e){ | ||
| 46 | this.handleFailure(response); | ||
| 47 | } | ||
| 48 | }, | ||
| 49 | getParams: function(node) { | ||
| 50 | var buf = []; | ||
| 51 | buf.push('path', '=', encodeURIComponent(node.attributes.path)); | ||
| 52 | return buf.join(''); | ||
| 53 | } | ||
| 4 | constructor: function(config) { | ||
| 5 | |||
| 6 | Ext.apply(this, { | ||
| 7 | dataUrl: '/json/property/getChildren', | ||
| 8 | requestMethod: 'GET' | ||
| 9 | }); | ||
| 10 | dSS.data.DeviceStore.superclass.constructor.call(this, arguments); | ||
| 11 | }, | ||
| 12 | requestData: function(node, callback, scope) { | ||
| 13 | if (this.fireEvent("beforeload", this, node, callback) !== false) { | ||
| 14 | this.transId = Ext.Ajax.request({ | ||
| 15 | method: this.requestMethod, | ||
| 16 | url: this.dataUrl || this.url, | ||
| 17 | success: this.handleResponse, | ||
| 18 | failure: this.handleFailure, | ||
| 19 | scope: this, | ||
| 20 | argument: { | ||
| 21 | callback: callback, | ||
| 22 | node: node, | ||
| 23 | scope: scope | ||
| 24 | }, | ||
| 25 | params: this.getParams(node) | ||
| 26 | }); | ||
| 27 | } else { | ||
| 28 | // if the load is cancelled, make sure we notify | ||
| 29 | // the node that we are done | ||
| 30 | this.runCallback(callback, scope || node, []); | ||
| 31 | } | ||
| 32 | }, | ||
| 33 | processResponse: function(response, node, callback, scope) { | ||
| 34 | var json = response.responseText; | ||
| 35 | try { | ||
| 36 | var o = response.responseData || Ext.decode(json); | ||
| 37 | o = o.result; | ||
| 38 | node.beginUpdate(); | ||
| 39 | for (var i = 0, len = o.length; i < len; i++) { | ||
| 40 | var rawNode = o[i]; | ||
| 41 | rawNode.text = rawNode.name; | ||
| 42 | rawNode.leaf = rawNode.type === 'none' ? false: true; | ||
| 43 | rawNode.path = node.attributes.path === '/' ? node.attributes.path + rawNode.name: node.attributes.path + '/' + rawNode.name; | ||
| 44 | var n = this.createNode(rawNode); | ||
| 45 | if (n) { | ||
| 46 | node.appendChild(n); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | node.endUpdate(); | ||
| 50 | this.runCallback(callback, scope || node, [node]); | ||
| 51 | } catch(e) { | ||
| 52 | this.handleFailure(response); | ||
| 53 | } | ||
| 54 | }, | ||
| 55 | getParams: function(node) { | ||
| 56 | var buf = []; | ||
| 57 | buf.push('path', '=', encodeURIComponent(node.attributes.path)); | ||
| 58 | return buf.join(''); | ||
| 59 | } | ||
| 54 | 60 | }); |
webroot/js/dss/dss-setup-interface/dSS/util/DSMStatisticsWindow.js
(25 / 36)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/PingEventWindow> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.util"); | |
| 5 | 4 | ||
| 6 | 5 | dSS.util.DSMStatisticsWindow = Ext.extend(Ext.Window, { | |
| 7 | 6 | initComponent: function() { | |
| 8 | 7 | Ext.apply(this, { | |
| 9 | 8 | layout: "fit", | |
| 10 | width: 380, | ||
| 9 | width: 380, | ||
| 11 | 10 | height: 475, | |
| 12 | items: [ this.form ], | ||
| 13 | buttons:[{ | ||
| 11 | items: [this.form], | ||
| 12 | buttons: [ | ||
| 13 | { | ||
| 14 | 14 | text: _("OK"), | |
| 15 | 15 | formBind: true, | |
| 16 | 16 | scope: this, | |
| 17 | handler: function() | ||
| 18 | { | ||
| 19 | if (!this.form.getForm().isValid()) | ||
| 20 | { | ||
| 17 | handler: function() { | ||
| 18 | if (!this.form.getForm().isValid()) { | ||
| 21 | 19 | return; | |
| 22 | 20 | } | |
| 23 | 21 | ||
| … | … | ||
| 30 | 30 | d.setHours(hours); | |
| 31 | 31 | d.setMinutes(minutes); | |
| 32 | 32 | ||
| 33 | if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) | ||
| 34 | { | ||
| 33 | if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) { | ||
| 35 | 34 | Ext.MessageBox.alert(_("Error"), _("Event time must be in the future!")); | |
| 36 | 35 | return; | |
| 37 | 36 | } | |
| 38 | 37 | ||
| 39 | function pad(n){ return n < 10 ? '0' + n : n } | ||
| 38 | function pad(n) { | ||
| 39 | return n < 10 ? '0' + n: n | ||
| 40 | } | ||
| 40 | 41 | ||
| 41 | param_time = "time=" + d.getUTCFullYear() + | ||
| 42 | pad(d.getUTCMonth() + 1) + | ||
| 43 | pad(d.getUTCDate()) + 'T' + | ||
| 44 | pad(d.getUTCHours()) + | ||
| 45 | pad(d.getUTCMinutes()) + | ||
| 46 | pad(d.getUTCSeconds()) + 'Z' + ";"; | ||
| 42 | param_time = "time=" + d.getUTCFullYear() + pad(d.getUTCMonth() + 1) + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + pad(d.getUTCMinutes()) + pad(d.getUTCSeconds()) + 'Z' + ";"; | ||
| 47 | 43 | } | |
| 48 | 44 | ||
| 49 | var param = param_time + | ||
| 50 | "delay=" + this.form.getForm().getValues().delay + | ||
| 51 | ";repeat=" + this.form.getForm().getValues().repeat + | ||
| 52 | ";dsm=" + this.dsm; | ||
| 45 | var param = param_time + "delay=" + this.form.getForm().getValues().delay + ";repeat=" + this.form.getForm().getValues().repeat + ";dsm=" + this.dsm; | ||
| 53 | 46 | ||
| 54 | 47 | // close statistics form dialog | |
| 55 | 48 | this.maskElement.unmask(); | |
| … | … | ||
| 50 | 50 | ||
| 51 | 51 | this.raiseStatisticsEvent(param, param_time.length); | |
| 52 | 52 | } | |
| 53 | },{ | ||
| 53 | }, | ||
| 54 | { | ||
| 54 | 55 | text: _("Cancel"), | |
| 55 | scope : this, | ||
| 56 | handler: function() | ||
| 57 | { | ||
| 56 | scope: this, | ||
| 57 | handler: function() { | ||
| 58 | 58 | this.close(); | |
| 59 | 59 | this.maskElement.unmask(); | |
| 60 | 60 | } | |
| … | … | ||
| 62 | 62 | }); | |
| 63 | 63 | ||
| 64 | 64 | dSS.util.DSMStatisticsWindow.superclass.initComponent.apply(this, arguments); | |
| 65 | |||
| 65 | |||
| 66 | 66 | this.maskElement.mask(); | |
| 67 | 67 | }, | |
| 68 | 68 | raiseStatisticsEvent: function(param, later) { | |
| … | … | ||
| 71 | 71 | disableCaching: true, | |
| 72 | 72 | method: "GET", | |
| 73 | 73 | scope: this, | |
| 74 | params: { name: "dsm_statistics", parameter: param }, | ||
| 74 | params: { | ||
| 75 | name: "dsm_statistics", | ||
| 76 | parameter: param | ||
| 77 | }, | ||
| 75 | 78 | success: function(result, request) { | |
| 76 | 79 | try { | |
| 77 | 80 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 78 | if(jsonData.ok) { | ||
| 81 | if (jsonData.ok) { | ||
| 79 | 82 | var title = _("Statistics result information"); | |
| 80 | 83 | var message = _("The statistics results can be viewed in the js plugin log files section"); | |
| 81 | 84 | var file = dSS.config.settings["dsmStatistics"].logfile; | |
| 82 | 85 | ||
| 83 | 86 | if (file != undefined) { | |
| 84 | message = message + _(" or downloaded here: ") + | ||
| 85 | "<span class=\"x-green-button-link\">" + | ||
| 86 | "<a target=\"_blank\" title=\"" + | ||
| 87 | _("Right click and select Save Link As to download" + | ||
| 88 | " the log file.") + "\" href=\"/download/" + | ||
| 89 | file + "\">" + file + "</a></span>"; | ||
| 87 | message = message + _(" or downloaded here: ") + "<span class=\"x-green-button-link\">" + "<a target=\"_blank\" title=\"" + _("Right click and select Save Link As to download" + " the log file.") + "\" href=\"/download/" + file + "\">" + file + "</a></span>"; | ||
| 90 | 88 | } else { | |
| 91 | 89 | message = message + "."; | |
| 92 | 90 | } | |
| … | … | ||
| 99 | 99 | Ext.MessageBox.alert(_("Statistics error"), jsonData.message); | |
| 100 | 100 | } | |
| 101 | 101 | } | |
| 102 | catch (err) { | ||
| 102 | catch(err) { | ||
| 103 | 103 | Ext.MessageBox.alert(_("Error"), _("Could send statistics command to dSS") + ": " + err); | |
| 104 | 104 | } | |
| 105 | 105 | }, | |
| … | … | ||
| 107 | 107 | Ext.MessageBox.alert(_("Error"), _("Could send stat command to dSS")); | |
| 108 | 108 | } | |
| 109 | 109 | }); | |
| 110 | |||
| 110 | |||
| 111 | 111 | } | |
| 112 | 112 | }); | |
| 113 | 113 |
webroot/js/dss/dss-setup-interface/dSS/util/DeviceStatisticsForm.js
(56 / 56)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/RadioTextField> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.util"); | |
| 5 | 4 | ||
| 6 | 5 | dSS.util.DeviceStatisticsForm = Ext.extend(Ext.FormPanel, { | |
| … | … | ||
| 10 | 10 | title: _("Device Statistics Settings"), | |
| 11 | 11 | labelWidth: 135, | |
| 12 | 12 | items: [ | |
| 13 | new Ext.grid.GridPanel({ | ||
| 14 | title: _("Statistics for following devices will be requested") + ":", | ||
| 15 | columns: [ | ||
| 16 | { header: _("dsid"), id: "dsid" }, | ||
| 17 | { header: _("name"), id: "name" } | ||
| 18 | ], | ||
| 19 | autoExpandColumn: "dsid", | ||
| 20 | store: this.statisticsStore, | ||
| 21 | disableSelection: true, | ||
| 22 | frame: false, | ||
| 23 | forceFit: true, | ||
| 24 | stripeRows: true, | ||
| 25 | height: 180, | ||
| 26 | autoScroll: true, | ||
| 27 | viewConfig: { autoFill: true } | ||
| 28 | }), | ||
| 29 | new Ext.Panel({ | ||
| 30 | height: 10 | ||
| 31 | }), | ||
| 32 | new Ext.form.Radio({ | ||
| 33 | name: "timefield_rb", | ||
| 34 | fieldLabel: _("Request start time"), | ||
| 35 | boxLabel: _("Now"), | ||
| 36 | checked: true | ||
| 37 | }), | ||
| 38 | new dSS.util.RadioTimeField({ | ||
| 39 | rbname : "timefield_rb", | ||
| 40 | name: "time", | ||
| 41 | fieldWidth : 140, | ||
| 42 | timeFieldWidth: 182, | ||
| 43 | format : "H:i", | ||
| 44 | allowBlank: false, | ||
| 45 | value: this.h_now + this.sep + this.m_now, | ||
| 46 | timeFieldEnabled: false | ||
| 47 | }), | ||
| 48 | new Ext.form.NumberField({ | ||
| 49 | width: 200, | ||
| 50 | id: "delay", | ||
| 51 | allowBlank: false, | ||
| 52 | allowNegative: false, | ||
| 53 | allowDecimals: false, | ||
| 54 | value: "300", | ||
| 55 | minValue: "1", | ||
| 56 | fieldLabel: _("Delay between repetitions (seconds)") | ||
| 57 | }), | ||
| 58 | new Ext.form.NumberField({ | ||
| 59 | width: 200, | ||
| 60 | id: "repeat", | ||
| 61 | allowBlank: false, | ||
| 62 | allowNegative: false, | ||
| 63 | allowDecimals: false, | ||
| 64 | value: "0", | ||
| 65 | fieldLabel: _("Repeat times") | ||
| 66 | }) | ||
| 67 | ] | ||
| 13 | new Ext.grid.GridPanel({ | ||
| 14 | title: _("Statistics for following devices will be requested") + ":", | ||
| 15 | columns: [ | ||
| 16 | { | ||
| 17 | header: _("dsid"), | ||
| 18 | id: "dsid" | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | header: _("name"), | ||
| 22 | id: "name" | ||
| 23 | }], | ||
| 24 | autoExpandColumn: "dsid", | ||
| 25 | store: this.statisticsStore, | ||
| 26 | disableSelection: true, | ||
| 27 | frame: false, | ||
| 28 | forceFit: true, | ||
| 29 | stripeRows: true, | ||
| 30 | height: 180, | ||
| 31 | autoScroll: true, | ||
| 32 | viewConfig: { | ||
| 33 | autoFill: true | ||
| 34 | } | ||
| 35 | }), new Ext.Panel({ | ||
| 36 | height: 10 | ||
| 37 | }), new Ext.form.Radio({ | ||
| 38 | name: "timefield_rb", | ||
| 39 | fieldLabel: _("Request start time"), | ||
| 40 | boxLabel: _("Now"), | ||
| 41 | checked: true | ||
| 42 | }), new dSS.util.RadioTimeField({ | ||
| 43 | rbname: "timefield_rb", | ||
| 44 | name: "time", | ||
| 45 | fieldWidth: 140, | ||
| 46 | timeFieldWidth: 182, | ||
| 47 | format: "H:i", | ||
| 48 | allowBlank: false, | ||
| 49 | value: this.h_now + this.sep + this.m_now, | ||
| 50 | timeFieldEnabled: false | ||
| 51 | }), new Ext.form.NumberField({ | ||
| 52 | width: 200, | ||
| 53 | id: "delay", | ||
| 54 | allowBlank: false, | ||
| 55 | allowNegative: false, | ||
| 56 | allowDecimals: false, | ||
| 57 | value: "300", | ||
| 58 | minValue: "1", | ||
| 59 | fieldLabel: _("Delay between repetitions (seconds)") | ||
| 60 | }), new Ext.form.NumberField({ | ||
| 61 | width: 200, | ||
| 62 | id: "repeat", | ||
| 63 | allowBlank: false, | ||
| 64 | allowNegative: false, | ||
| 65 | allowDecimals: false, | ||
| 66 | value: "0", | ||
| 67 | fieldLabel: _("Repeat times") | ||
| 68 | })] | ||
| 68 | 69 | ||
| 69 | 70 | }); | |
| 70 | 71 |
webroot/js/dss/dss-setup-interface/dSS/util/DeviceStatisticsWindow.js
(27 / 38)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/PingEventWindow> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.util"); | |
| 5 | 4 | ||
| 6 | 5 | dSS.util.DeviceStatisticsWindow = Ext.extend(Ext.Window, { | |
| 7 | 6 | initComponent: function() { | |
| 8 | 7 | Ext.apply(this, { | |
| 9 | 8 | layout: "fit", | |
| 10 | width: 380, | ||
| 9 | width: 380, | ||
| 11 | 10 | height: 475, | |
| 12 | items: [ this.form ], | ||
| 13 | buttons:[{ | ||
| 11 | items: [this.form], | ||
| 12 | buttons: [ | ||
| 13 | { | ||
| 14 | 14 | text: _("OK"), | |
| 15 | 15 | formBind: true, | |
| 16 | 16 | scope: this, | |
| 17 | handler: function() | ||
| 18 | { | ||
| 19 | if (!this.form.getForm().isValid()) | ||
| 20 | { | ||
| 17 | handler: function() { | ||
| 18 | if (!this.form.getForm().isValid()) { | ||
| 21 | 19 | return; | |
| 22 | 20 | } | |
| 23 | 21 | ||
| … | … | ||
| 30 | 30 | d.setHours(hours); | |
| 31 | 31 | d.setMinutes(minutes); | |
| 32 | 32 | ||
| 33 | if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) | ||
| 34 | { | ||
| 33 | if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) { | ||
| 35 | 34 | Ext.MessageBox.alert(_("Error"), _("Event time must be in the future!")); | |
| 36 | 35 | return; | |
| 37 | 36 | } | |
| 38 | 37 | ||
| 39 | function pad(n){ return n < 10 ? '0' + n : n } | ||
| 38 | function pad(n) { | ||
| 39 | return n < 10 ? '0' + n: n | ||
| 40 | } | ||
| 40 | 41 | ||
| 41 | param_time = "time=" + d.getUTCFullYear() + | ||
| 42 | pad(d.getUTCMonth() + 1) + | ||
| 43 | pad(d.getUTCDate()) + 'T' + | ||
| 44 | pad(d.getUTCHours()) + | ||
| 45 | pad(d.getUTCMinutes()) + | ||
| 46 | pad(d.getUTCSeconds()) + 'Z' + ";"; | ||
| 42 | param_time = "time=" + d.getUTCFullYear() + pad(d.getUTCMonth() + 1) + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + pad(d.getUTCMinutes()) + pad(d.getUTCSeconds()) + 'Z' + ";"; | ||
| 47 | 43 | } | |
| 48 | 44 | ||
| 49 | var param = param_time + | ||
| 50 | "delay=" + this.form.getForm().getValues().delay + | ||
| 51 | ";repeat=" + this.form.getForm().getValues().repeat + | ||
| 52 | ";dsid=" + this.dsids; | ||
| 45 | var param = param_time + "delay=" + this.form.getForm().getValues().delay + ";repeat=" + this.form.getForm().getValues().repeat + ";dsid=" + this.dsids; | ||
| 53 | 46 | ||
| 54 | 47 | // close statistics form dialog | |
| 55 | 48 | this.maskElement.unmask(); | |
| … | … | ||
| 50 | 50 | ||
| 51 | 51 | this.raiseStatisticsEvent(param, param_time.length); | |
| 52 | 52 | } | |
| 53 | },{ | ||
| 53 | }, | ||
| 54 | { | ||
| 54 | 55 | text: _("Cancel"), | |
| 55 | scope : this, | ||
| 56 | handler: function() | ||
| 57 | { | ||
| 56 | scope: this, | ||
| 57 | handler: function() { | ||
| 58 | 58 | this.close(); | |
| 59 | 59 | this.maskElement.unmask(); | |
| 60 | 60 | } | |
| … | … | ||
| 62 | 62 | }); | |
| 63 | 63 | ||
| 64 | 64 | dSS.util.DeviceStatisticsWindow.superclass.initComponent.apply(this, arguments); | |
| 65 | |||
| 65 | |||
| 66 | 66 | this.maskElement.mask(); | |
| 67 | 67 | }, | |
| 68 | 68 | raiseStatisticsEvent: function(param, later) { | |
| … | … | ||
| 71 | 71 | disableCaching: true, | |
| 72 | 72 | method: "GET", | |
| 73 | 73 | scope: this, | |
| 74 | params: { name: "device_statistics", parameter: param }, | ||
| 74 | params: { | ||
| 75 | name: "device_statistics", | ||
| 76 | parameter: param | ||
| 77 | }, | ||
| 75 | 78 | success: function(result, request) { | |
| 76 | 79 | try { | |
| 77 | 80 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 78 | if(jsonData.ok) { | ||
| 81 | if (jsonData.ok) { | ||
| 79 | 82 | var title = _("Statistics result information"); | |
| 80 | 83 | var message = _("The statistics results can be viewed in the js plugin log files section"); | |
| 81 | 84 | var file = dSS.config.settings["deviceStatistics"].logfile; | |
| 82 | 85 | ||
| 83 | 86 | if (file != undefined) { | |
| 84 | message = message + _(" or downloaded here: ") + | ||
| 85 | "<span class=\"x-green-button-link\">" + | ||
| 86 | "<a target=\"_blank\" title=\"" + | ||
| 87 | _("Right click and select Save Link As to download" + | ||
| 88 | " the log file.") + "\" href=\"/download/" + | ||
| 89 | file + "\">" + file + "</a></span>"; | ||
| 90 | } else { | ||
| 87 | message = message + _(" or downloaded here: ") + "<span class=\"x-green-button-link\">" + "<a target=\"_blank\" title=\"" + _("Right click and select Save Link As to download" + " the log file.") + "\" href=\"/download/" + file + "\">" + file + "</a></span>"; | ||
| 88 | } else { | ||
| 91 | 89 | message = message + "."; | |
| 92 | } | ||
| 90 | } | ||
| 93 | 91 | ||
| 94 | 92 | Ext.MessageBox.show({ | |
| 95 | 93 | title: title, | |
| … | … | ||
| 99 | 99 | Ext.MessageBox.alert(_("Statistics error"), jsonData.message); | |
| 100 | 100 | } | |
| 101 | 101 | } | |
| 102 | catch (err) { | ||
| 102 | catch(err) { | ||
| 103 | 103 | Ext.MessageBox.alert(_("Error"), _("Could send statistics command to dSS") + ": " + err); | |
| 104 | 104 | } | |
| 105 | 105 | }, | |
| … | … | ||
| 107 | 107 | Ext.MessageBox.alert(_("Error"), _("Could send stat command to dSS")); | |
| 108 | 108 | } | |
| 109 | 109 | }); | |
| 110 | |||
| 110 | |||
| 111 | 111 | } | |
| 112 | 112 | }); | |
| 113 | 113 |
webroot/js/dss/dss-setup-interface/dSS/util/ExtendedPingForm.js
(57 / 57)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/RadioTextField> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.util"); | |
| 5 | 4 | ||
| 6 | 5 | dSS.util.ExtendedPingForm = Ext.extend(Ext.FormPanel, { | |
| … | … | ||
| 10 | 10 | title: _("Extended Ping Settings"), | |
| 11 | 11 | labelWidth: 135, | |
| 12 | 12 | items: [ | |
| 13 | new Ext.grid.GridPanel({ | ||
| 14 | title: _("Following devices will be pinged") + ":", | ||
| 15 | columns: [ | ||
| 16 | { header: _("dsid"), id: "dsid" }, | ||
| 17 | { header: _("name"), id: "name" } | ||
| 18 | ], | ||
| 19 | autoExpandColumn: "dsid", | ||
| 20 | store: this.pingStore, | ||
| 21 | disableSelection: true, | ||
| 22 | frame: false, | ||
| 23 | forceFit: true, | ||
| 24 | stripeRows: true, | ||
| 25 | height: 180, | ||
| 26 | autoScroll: true, | ||
| 27 | viewConfig: { autoFill: true } | ||
| 28 | }), | ||
| 29 | new Ext.Panel({ | ||
| 30 | height: 10 | ||
| 31 | }), | ||
| 32 | new Ext.form.Radio({ | ||
| 33 | name: "timefield_rb", | ||
| 34 | fieldLabel: _("Ping start time"), | ||
| 35 | boxLabel: _("Now"), | ||
| 36 | checked: true | ||
| 37 | }), | ||
| 38 | new dSS.util.RadioTimeField({ | ||
| 39 | rbname : "timefield_rb", | ||
| 40 | name: "time", | ||
| 41 | fieldWidth : 140, | ||
| 42 | timeFieldWidth: 182, | ||
| 43 | format : "H:i", | ||
| 44 | allowBlank: false, | ||
| 45 | value: this.h_now + this.sep + this.m_now, | ||
| 46 | timeFieldEnabled: false | ||
| 47 | }), | ||
| 48 | new Ext.form.NumberField({ | ||
| 49 | width: 200, | ||
| 50 | id: "delay", | ||
| 51 | allowBlank: false, | ||
| 52 | allowNegative: false, | ||
| 53 | allowDecimals: false, | ||
| 54 | value: "300", | ||
| 55 | minValue: "1", | ||
| 56 | fieldLabel: _("Delay between repetitions (seconds)") | ||
| 57 | }), | ||
| 58 | new Ext.form.NumberField({ | ||
| 59 | width: 200, | ||
| 60 | id: "repeat", | ||
| 61 | allowBlank: false, | ||
| 62 | allowNegative: false, | ||
| 63 | allowDecimals: false, | ||
| 64 | value: "1", | ||
| 65 | minValue: "1", | ||
| 66 | fieldLabel: _("Number of pings per device") | ||
| 67 | }) | ||
| 68 | ] | ||
| 13 | new Ext.grid.GridPanel({ | ||
| 14 | title: _("Following devices will be pinged") + ":", | ||
| 15 | columns: [ | ||
| 16 | { | ||
| 17 | header: _("dsid"), | ||
| 18 | id: "dsid" | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | header: _("name"), | ||
| 22 | id: "name" | ||
| 23 | }], | ||
| 24 | autoExpandColumn: "dsid", | ||
| 25 | store: this.pingStore, | ||
| 26 | disableSelection: true, | ||
| 27 | frame: false, | ||
| 28 | forceFit: true, | ||
| 29 | stripeRows: true, | ||
| 30 | height: 180, | ||
| 31 | autoScroll: true, | ||
| 32 | viewConfig: { | ||
| 33 | autoFill: true | ||
| 34 | } | ||
| 35 | }), new Ext.Panel({ | ||
| 36 | height: 10 | ||
| 37 | }), new Ext.form.Radio({ | ||
| 38 | name: "timefield_rb", | ||
| 39 | fieldLabel: _("Ping start time"), | ||
| 40 | boxLabel: _("Now"), | ||
| 41 | checked: true | ||
| 42 | }), new dSS.util.RadioTimeField({ | ||
| 43 | rbname: "timefield_rb", | ||
| 44 | name: "time", | ||
| 45 | fieldWidth: 140, | ||
| 46 | timeFieldWidth: 182, | ||
| 47 | format: "H:i", | ||
| 48 | allowBlank: false, | ||
| 49 | value: this.h_now + this.sep + this.m_now, | ||
| 50 | timeFieldEnabled: false | ||
| 51 | }), new Ext.form.NumberField({ | ||
| 52 | width: 200, | ||
| 53 | id: "delay", | ||
| 54 | allowBlank: false, | ||
| 55 | allowNegative: false, | ||
| 56 | allowDecimals: false, | ||
| 57 | value: "300", | ||
| 58 | minValue: "1", | ||
| 59 | fieldLabel: _("Delay between repetitions (seconds)") | ||
| 60 | }), new Ext.form.NumberField({ | ||
| 61 | width: 200, | ||
| 62 | id: "repeat", | ||
| 63 | allowBlank: false, | ||
| 64 | allowNegative: false, | ||
| 65 | allowDecimals: false, | ||
| 66 | value: "1", | ||
| 67 | minValue: "1", | ||
| 68 | fieldLabel: _("Number of pings per device") | ||
| 69 | })] | ||
| 69 | 70 | ||
| 70 | 71 | }); | |
| 71 | 72 |
webroot/js/dss/dss-setup-interface/dSS/util/ExtendedPingWindow.js
(34 / 33)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/PingEventWindow> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.util"); | |
| 5 | 4 | ||
| 6 | 5 | dSS.util.ExtendedPingWindow = Ext.extend(Ext.Window, { | |
| 7 | 6 | initComponent: function() { | |
| 8 | 7 | Ext.apply(this, { | |
| 9 | 8 | layout: "fit", | |
| 10 | width: 380, | ||
| 9 | width: 380, | ||
| 11 | 10 | height: 465, | |
| 12 | items: [ this.form ], | ||
| 13 | buttons:[{ | ||
| 11 | items: [this.form], | ||
| 12 | buttons: [ | ||
| 13 | { | ||
| 14 | 14 | text: _("OK"), | |
| 15 | 15 | formBind: true, | |
| 16 | 16 | scope: this, | |
| 17 | handler: function() | ||
| 18 | { | ||
| 19 | if (!this.form.getForm().isValid()) | ||
| 20 | { | ||
| 17 | handler: function() { | ||
| 18 | if (!this.form.getForm().isValid()) { | ||
| 21 | 19 | return; | |
| 22 | 20 | } | |
| 23 | 21 | ||
| … | … | ||
| 30 | 30 | d.setHours(hours); | |
| 31 | 31 | d.setMinutes(minutes); | |
| 32 | 32 | ||
| 33 | if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) | ||
| 34 | { | ||
| 33 | if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) { | ||
| 35 | 34 | Ext.MessageBox.alert(_("Error"), _("Event time must be in the future!")); | |
| 36 | 35 | return; | |
| 37 | 36 | } | |
| 38 | 37 | ||
| 39 | function pad(n){ return n < 10 ? '0' + n : n } | ||
| 38 | function pad(n) { | ||
| 39 | return n < 10 ? '0' + n: n | ||
| 40 | } | ||
| 40 | 41 | ||
| 41 | param_time = "time=" + d.getUTCFullYear() + | ||
| 42 | pad(d.getUTCMonth() + 1) + | ||
| 43 | pad(d.getUTCDate()) + 'T' + | ||
| 44 | pad(d.getUTCHours()) + | ||
| 45 | pad(d.getUTCMinutes()) + | ||
| 46 | pad(d.getUTCSeconds()) + 'Z' + ";"; | ||
| 42 | param_time = "time=" + d.getUTCFullYear() + pad(d.getUTCMonth() + 1) + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + pad(d.getUTCMinutes()) + pad(d.getUTCSeconds()) + 'Z' + ";"; | ||
| 47 | 43 | } | |
| 48 | 44 | ||
| 49 | var param = param_time + | ||
| 50 | "delay=" + this.form.getForm().getValues().delay + | ||
| 51 | ";repeat=" + this.form.getForm().getValues().repeat + | ||
| 52 | ";dsid=" + this.dsids; | ||
| 45 | var param = param_time + "delay=" + this.form.getForm().getValues().delay + ";repeat=" + this.form.getForm().getValues().repeat + ";dsid=" + this.dsids; | ||
| 53 | 46 | ||
| 54 | 47 | // close ping form dialog | |
| 55 | 48 | this.maskElement.unmask(); | |
| … | … | ||
| 62 | 62 | disableCaching: true, | |
| 63 | 63 | method: "GET", | |
| 64 | 64 | scope: this, | |
| 65 | params: { subscriptionID : 333, name: "ping_result" }, | ||
| 65 | params: { | ||
| 66 | subscriptionID: 333, | ||
| 67 | name: "ping_result" | ||
| 68 | }, | ||
| 66 | 69 | success: function(result, request) { | |
| 67 | 70 | try { | |
| 68 | 71 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| … | … | ||
| 74 | 74 | } else { | |
| 75 | 75 | Ext.MessageBox.alert(_("Ping subscription error"), jsonData.message); | |
| 76 | 76 | } | |
| 77 | } catch (err) { | ||
| 77 | } catch(err) { | ||
| 78 | 78 | Ext.MessageBox.alert(_("Error"), _("Could send subscribe command to dSS") + ": " + err); | |
| 79 | 79 | } | |
| 80 | 80 | }, | |
| … | … | ||
| 84 | 84 | }); | |
| 85 | 85 | } | |
| 86 | 86 | } | |
| 87 | },{ | ||
| 87 | }, | ||
| 88 | { | ||
| 88 | 89 | text: _("Cancel"), | |
| 89 | scope : this, | ||
| 90 | handler: function() | ||
| 91 | { | ||
| 90 | scope: this, | ||
| 91 | handler: function() { | ||
| 92 | 92 | this.close(); | |
| 93 | 93 | this.maskElement.unmask(); | |
| 94 | 94 | } | |
| … | … | ||
| 96 | 96 | }); | |
| 97 | 97 | ||
| 98 | 98 | dSS.util.ExtendedPingWindow.superclass.initComponent.apply(this, arguments); | |
| 99 | |||
| 99 | |||
| 100 | 100 | this.maskElement.mask(); | |
| 101 | 101 | }, | |
| 102 | 102 | raisePingEvent: function(param, later) { | |
| … | … | ||
| 105 | 105 | disableCaching: true, | |
| 106 | 106 | method: "GET", | |
| 107 | 107 | scope: this, | |
| 108 | params: { name: "ping", parameter: param }, | ||
| 108 | params: { | ||
| 109 | name: "ping", | ||
| 110 | parameter: param | ||
| 111 | }, | ||
| 109 | 112 | success: function(result, request) { | |
| 110 | 113 | try { | |
| 111 | 114 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 112 | if(jsonData.ok) { | ||
| 115 | if (jsonData.ok) { | ||
| 113 | 116 | if (later > 0) { | |
| 114 | 117 | var title = _("Ping result information"); | |
| 115 | 118 | var message = _("You specified a ping event in the future, the results will be available in the log files section as soon as the ping starts."); | |
| … | … | ||
| 123 | 123 | minWidth: 300 | |
| 124 | 124 | }); | |
| 125 | 125 | } else { | |
| 126 | var pingResult = new dSS.util.PingEventWindow({ windowWidth: 640, windowHeight: 480, maskElement: this.maskElement }); | ||
| 126 | var pingResult = new dSS.util.PingEventWindow({ | ||
| 127 | windowWidth: 640, | ||
| 128 | windowHeight: 480, | ||
| 129 | maskElement: this.maskElement | ||
| 130 | }); | ||
| 127 | 131 | pingResult.show(this); | |
| 128 | 132 | } | |
| 129 | 133 | } else { | |
| 130 | 134 | Ext.MessageBox.alert(_("Ping error"), jsonData.message); | |
| 131 | 135 | } | |
| 132 | 136 | } | |
| 133 | catch (err) { | ||
| 137 | catch(err) { | ||
| 134 | 138 | Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS") + ": " + err); | |
| 135 | 139 | } | |
| 136 | 140 | }, | |
| … | … | ||
| 142 | 142 | Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS")); | |
| 143 | 143 | } | |
| 144 | 144 | }); | |
| 145 | |||
| 145 | |||
| 146 | 146 | } | |
| 147 | 147 | }); | |
| 148 | 148 |
webroot/js/dss/dss-setup-interface/dSS/util/GridToCSVWindow.js
(24 / 37)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | |||
| 3 | 2 | Ext.namespace("dSS", "dSS.util"); | |
| 4 | 3 | ||
| 5 | 4 | dSS.util.GridToCSVWindow = Ext.extend(Ext.Window, { | |
| 6 | constructor: function(config) | ||
| 7 | { | ||
| 5 | constructor: function(config) { | ||
| 8 | 6 | var records; | |
| 9 | 7 | ||
| 10 | 8 | // we were called from the toolbar, so its possible that there is | |
| 11 | 9 | // no device selection yet | |
| 12 | 10 | var sel = config.gridPanel.getSelectionModel(); | |
| 13 | 11 | var all = false; | |
| 14 | if (!sel.hasSelection()) | ||
| 15 | { | ||
| 12 | if (!sel.hasSelection()) { | ||
| 16 | 13 | sel.selectAll(); | |
| 17 | 14 | all = true; | |
| 18 | 15 | } | |
| … | … | ||
| 20 | 20 | ||
| 21 | 21 | var csvData = ""; | |
| 22 | 22 | var csvHeader = ""; | |
| 23 | for (i = 0; i < records.length; i++) | ||
| 24 | { | ||
| 23 | for (i = 0; i < records.length; i++) { | ||
| 25 | 24 | var line = ""; | |
| 26 | for (j = 0; j < cCount; j++) | ||
| 27 | { | ||
| 28 | if (!col.isHidden(j)) | ||
| 29 | { | ||
| 25 | for (j = 0; j < cCount; j++) { | ||
| 26 | if (!col.isHidden(j)) { | ||
| 30 | 27 | var colId = col.getColumnId(j); | |
| 31 | if (colId === "on") | ||
| 32 | continue; | ||
| 28 | if (colId === "on") continue; | ||
| 33 | 29 | ||
| 34 | 30 | // render csv header | |
| 35 | if (i === 0) | ||
| 36 | { | ||
| 31 | if (i === 0) { | ||
| 37 | 32 | var sep = ""; | |
| 38 | if ((j > 0) && (csvHeader != "")) | ||
| 39 | sep = ","; | ||
| 33 | if ((j > 0) && (csvHeader != "")) sep = ","; | ||
| 40 | 34 | ||
| 41 | csvHeader = csvHeader + sep + col.getColumnHeader(j); | ||
| 35 | csvHeader = csvHeader + sep + col.getColumnHeader(j); | ||
| 42 | 36 | } | |
| 43 | 37 | ||
| 44 | 38 | var val = records[i].get(colId); | |
| 45 | if (val === undefined) | ||
| 46 | val = ""; | ||
| 39 | if (val === undefined) val = ""; | ||
| 47 | 40 | ||
| 48 | 41 | var sep = ""; | |
| 49 | if ((j > 0) && (line != "")) | ||
| 50 | sep = ","; | ||
| 42 | if ((j > 0) && (line != "")) sep = ","; | ||
| 51 | 43 | ||
| 52 | |||
| 53 | 44 | line = line + sep + val; | |
| 54 | 45 | } | |
| 55 | 46 | } | |
| … | … | ||
| 49 | 49 | ||
| 50 | 50 | csvData = csvHeader + "<br/>" + csvData; | |
| 51 | 51 | ||
| 52 | if (all === true) | ||
| 53 | sel.clearSelections(); | ||
| 52 | if (all === true) sel.clearSelections(); | ||
| 54 | 53 | ||
| 55 | Ext.apply(this, { | ||
| 56 | layout: "border", | ||
| 57 | title: _("Select text, right click, copy"), | ||
| 58 | width: config.windowWidth, | ||
| 59 | height: config.windowHeight, | ||
| 60 | items: [ | ||
| 54 | Ext.apply(this, { | ||
| 55 | layout: "border", | ||
| 56 | title: _("Select text, right click, copy"), | ||
| 57 | width: config.windowWidth, | ||
| 58 | height: config.windowHeight, | ||
| 59 | items: [ | ||
| 61 | 60 | new Ext.Panel({ | |
| 62 | 61 | region: "center", | |
| 63 | 62 | autoScroll: true, | |
| 64 | 63 | layout: "fit", | |
| 65 | 64 | html: csvData | |
| 66 | }) | ||
| 67 | ], | ||
| 68 | buttons:[{ | ||
| 69 | text: _("Close"), | ||
| 70 | handler: this.close.createDelegate(this) | ||
| 71 | }] | ||
| 65 | })], | ||
| 66 | buttons: [ | ||
| 67 | { | ||
| 68 | text: _("Close"), | ||
| 69 | handler: this.close.createDelegate(this) | ||
| 70 | }] | ||
| 72 | 71 | }); | |
| 73 | 72 | ||
| 74 | 73 | dSS.util.GridToCSVWindow.superclass.constructor.apply(this, arguments); |
webroot/js/dss/dss-setup-interface/dSS/util/PingEventWindow.js
(131 / 99)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | |||
| 3 | 2 | Ext.namespace("dSS", "dSS.util"); | |
| 4 | 3 | ||
| 5 | 4 | dSS.util.PingEventWindow = Ext.extend(Ext.Window, { | |
| 6 | constructor: function(config) | ||
| 7 | { | ||
| 5 | constructor: function(config) { | ||
| 8 | 6 | // special session id used throughout the code | |
| 9 | 7 | this.sid = 333; | |
| 10 | 8 | ||
| … | … | ||
| 13 | 13 | this.maskElement = config.maskElement; | |
| 14 | 14 | ||
| 15 | 15 | this.eventRecord = Ext.data.Record.create([ | |
| 16 | { name: "logged to", mapping: "logfile" }, | ||
| 17 | { name: "dsid", mapping: "dsid" }, | ||
| 18 | { name: "timestamp", mapping: "timestamp" }, | ||
| 19 | { name: "receive", mapping: "receive" }, | ||
| 20 | { name: "send", mapping: "send" }, | ||
| 21 | { name: "name", mapping: "name" }, | ||
| 22 | { name: "reqindex", mapping: "reqindex" } | ||
| 23 | ]); | ||
| 16 | { | ||
| 17 | name: "logged to", | ||
| 18 | mapping: "logfile" | ||
| 19 | }, | ||
| 20 | { | ||
| 21 | name: "dsid", | ||
| 22 | mapping: "dsid" | ||
| 23 | }, | ||
| 24 | { | ||
| 25 | name: "timestamp", | ||
| 26 | mapping: "timestamp" | ||
| 27 | }, | ||
| 28 | { | ||
| 29 | name: "receive", | ||
| 30 | mapping: "receive" | ||
| 31 | }, | ||
| 32 | { | ||
| 33 | name: "send", | ||
| 34 | mapping: "send" | ||
| 35 | }, | ||
| 36 | { | ||
| 37 | name: "name", | ||
| 38 | mapping: "name" | ||
| 39 | }, | ||
| 40 | { | ||
| 41 | name: "reqindex", | ||
| 42 | mapping: "reqindex" | ||
| 43 | }]); | ||
| 24 | 44 | ||
| 25 | 45 | this.pingEventStore = new Ext.data.ArrayStore({ | |
| 26 | autoDestroy : true, | ||
| 27 | storeId : "pingEventStore", | ||
| 28 | idIndex : 0, | ||
| 29 | fields : this.eventRecord | ||
| 46 | autoDestroy: true, | ||
| 47 | storeId: "pingEventStore", | ||
| 48 | idIndex: 0, | ||
| 49 | fields: this.eventRecord | ||
| 30 | 50 | }); | |
| 31 | 51 | ||
| 32 | this.resultPanel = new Ext.grid.GridPanel({ /* | ||
| 52 | this.resultPanel = new Ext.grid.GridPanel({ | ||
| 53 | /* | ||
| 33 | 54 | colModel: new Ext.grid.ColumnModel({ | |
| 34 | 55 | defaults: { sortable : false } | |
| 35 | 56 | }),*/ | |
| 36 | columns: [ | ||
| 37 | { | ||
| 38 | header: _("timestamp"), dataIndex: "timestamp", | ||
| 39 | xtype: "datecolumn", id: "timestamp", | ||
| 40 | format: "Y-m-d\\&\\n\\b\\s\\p\\;H:i:s", | ||
| 41 | sortable: true, | ||
| 42 | id: "timestamp" | ||
| 43 | }, | ||
| 44 | { | ||
| 45 | header: "#", dataIndex: "reqindex", id: "dsid", | ||
| 46 | sortable: false, width: 35 | ||
| 47 | }, | ||
| 48 | { | ||
| 49 | header: _("dsid"), dataIndex: "dsid", id: "dsid", | ||
| 50 | sortable: false | ||
| 51 | }, | ||
| 52 | { | ||
| 53 | header: _("send"), dataIndex: "send", sortable: false, | ||
| 54 | width: 50 | ||
| 55 | }, | ||
| 56 | { | ||
| 57 | header: _("receive"), dataIndex: "receive", | ||
| 58 | sortable: false, width: 50 | ||
| 59 | }, | ||
| 60 | { | ||
| 61 | header: _("name"), dataIndex: "name", sortable: false | ||
| 62 | }, | ||
| 63 | { | ||
| 64 | header: _("logged to"), dataIndex: "logfile", | ||
| 65 | sortable: false, | ||
| 66 | renderer: function(val) { | ||
| 67 | if (val != null) { | ||
| 68 | return "<span class=\"x-green-button-link\"><a target=\"_blank\" title=\"" + | ||
| 69 | _("Right click and select Save Link As to download the log file.") | ||
| 70 | + "\" href=\"/download/" + val + "\">" + val + "</a></span>"; | ||
| 71 | } | ||
| 72 | return val; | ||
| 73 | } | ||
| 57 | columns: [ | ||
| 58 | { | ||
| 59 | header: _("timestamp"), | ||
| 60 | dataIndex: "timestamp", | ||
| 61 | xtype: "datecolumn", | ||
| 62 | id: "timestamp", | ||
| 63 | format: "Y-m-d\\&\\n\\b\\s\\p\\;H:i:s", | ||
| 64 | sortable: true, | ||
| 65 | id: "timestamp" | ||
| 66 | }, | ||
| 67 | { | ||
| 68 | header: "#", | ||
| 69 | dataIndex: "reqindex", | ||
| 70 | id: "dsid", | ||
| 71 | sortable: false, | ||
| 72 | width: 35 | ||
| 73 | }, | ||
| 74 | { | ||
| 75 | header: _("dsid"), | ||
| 76 | dataIndex: "dsid", | ||
| 77 | id: "dsid", | ||
| 78 | sortable: false | ||
| 79 | }, | ||
| 80 | { | ||
| 81 | header: _("send"), | ||
| 82 | dataIndex: "send", | ||
| 83 | sortable: false, | ||
| 84 | width: 50 | ||
| 85 | }, | ||
| 86 | { | ||
| 87 | header: _("receive"), | ||
| 88 | dataIndex: "receive", | ||
| 89 | sortable: false, | ||
| 90 | width: 50 | ||
| 91 | }, | ||
| 92 | { | ||
| 93 | header: _("name"), | ||
| 94 | dataIndex: "name", | ||
| 95 | sortable: false | ||
| 96 | }, | ||
| 97 | { | ||
| 98 | header: _("logged to"), | ||
| 99 | dataIndex: "logfile", | ||
| 100 | sortable: false, | ||
| 101 | renderer: function(val) { | ||
| 102 | if (val != null) { | ||
| 103 | return "<span class=\"x-green-button-link\"><a target=\"_blank\" title=\"" + _("Right click and select Save Link As to download the log file.") + "\" href=\"/download/" + val + "\">" + val + "</a></span>"; | ||
| 74 | 104 | } | |
| 75 | ], | ||
| 76 | autoExpandColumn: "timestamp", | ||
| 77 | store: this.pingEventStore, | ||
| 78 | disableSelection: true, | ||
| 79 | frame: false, | ||
| 80 | forceFit: true, | ||
| 81 | stripeRows: true, | ||
| 82 | region: "center", | ||
| 83 | autoScroll: true, | ||
| 84 | layout: "fit", | ||
| 85 | viewConfig: { autoFill: true } | ||
| 86 | }); | ||
| 105 | return val; | ||
| 106 | } | ||
| 107 | }], | ||
| 108 | autoExpandColumn: "timestamp", | ||
| 109 | store: this.pingEventStore, | ||
| 110 | disableSelection: true, | ||
| 111 | frame: false, | ||
| 112 | forceFit: true, | ||
| 113 | stripeRows: true, | ||
| 114 | region: "center", | ||
| 115 | autoScroll: true, | ||
| 116 | layout: "fit", | ||
| 117 | viewConfig: { | ||
| 118 | autoFill: true | ||
| 119 | } | ||
| 120 | }); | ||
| 87 | 121 | ||
| 88 | Ext.apply(this, { | ||
| 89 | layout: "border", | ||
| 90 | title: _("Ping results"), | ||
| 91 | width: config.windowWidth, | ||
| 92 | height: config.windowHeight, | ||
| 93 | items: [ this.resultPanel ], | ||
| 94 | buttons:[{ | ||
| 95 | text: _("Close"), | ||
| 96 | handler: this.close.createDelegate(this) | ||
| 97 | }] | ||
| 122 | Ext.apply(this, { | ||
| 123 | layout: "border", | ||
| 124 | title: _("Ping results"), | ||
| 125 | width: config.windowWidth, | ||
| 126 | height: config.windowHeight, | ||
| 127 | items: [this.resultPanel], | ||
| 128 | buttons: [ | ||
| 129 | { | ||
| 130 | text: _("Close"), | ||
| 131 | handler: this.close.createDelegate(this) | ||
| 132 | }] | ||
| 98 | 133 | }); | |
| 99 | 134 | ||
| 100 | 135 | dSS.util.PingEventWindow.superclass.constructor.apply(this, arguments); | |
| 101 | 136 | this.maskElement.mask(); | |
| 102 | 137 | ||
| 103 | this.on( | ||
| 104 | "afterrender", | ||
| 105 | function(component) { | ||
| 106 | this.getNextEvent(); | ||
| 107 | }, | ||
| 108 | this | ||
| 109 | ); | ||
| 138 | this.on("afterrender", function(component) { | ||
| 139 | this.getNextEvent(); | ||
| 140 | }, | ||
| 141 | this); | ||
| 110 | 142 | ||
| 111 | this.on( | ||
| 112 | "beforedestroy", | ||
| 113 | function(component) { | ||
| 114 | this.stopRequests = true; | ||
| 115 | this.maskElement.unmask(); | ||
| 116 | }, | ||
| 117 | this | ||
| 118 | ); | ||
| 143 | this.on("beforedestroy", function(component) { | ||
| 144 | this.stopRequests = true; | ||
| 145 | this.maskElement.unmask(); | ||
| 146 | }, | ||
| 147 | this); | ||
| 119 | 148 | }, | |
| 120 | 149 | ||
| 121 | 150 | getNextEvent: function() { | |
| … | … | ||
| 155 | 155 | disableCaching: true, | |
| 156 | 156 | method: "GET", | |
| 157 | 157 | scope: this, | |
| 158 | params: { subscriptionID : 333, name: "ping_result" }, | ||
| 158 | params: { | ||
| 159 | subscriptionID: 333, | ||
| 160 | name: "ping_result" | ||
| 161 | }, | ||
| 159 | 162 | success: function(result, request) { | |
| 160 | 163 | try { | |
| 161 | 164 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 162 | 165 | if (!jsonData.ok) { | |
| 163 | 166 | Ext.MessageBox.alert(_("Ping event unsubscribe error"), jsonData.message); | |
| 164 | 167 | } | |
| 165 | } catch (err) { | ||
| 168 | } catch(err) { | ||
| 166 | 169 | Ext.MessageBox.alert(_("Error"), _("Could not send unsubscribe command to dSS") + ": " + err); | |
| 167 | 170 | } | |
| 168 | 171 | }, | |
| … | … | ||
| 181 | 181 | url: "/json/event/get", | |
| 182 | 182 | method: "GET", | |
| 183 | 183 | scope: this, | |
| 184 | params: { subscriptionID : this.sid, timeout : "2000" }, | ||
| 184 | params: { | ||
| 185 | subscriptionID: this.sid, | ||
| 186 | timeout: "2000" | ||
| 187 | }, | ||
| 185 | 188 | success: function(result, request) { | |
| 186 | 189 | try { | |
| 187 | 190 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 188 | 191 | if (jsonData.ok) { | |
| 189 | 192 | for (i = 0; i < jsonData.result.events.length; i++) { | |
| 190 | 193 | var r = new this.eventRecord( | |
| 191 | jsonData.result.events[i].properties | ||
| 192 | ); | ||
| 194 | jsonData.result.events[i].properties); | ||
| 193 | 195 | this.pingEventStore.add([r]); | |
| 194 | 196 | } | |
| 195 | |||
| 197 | |||
| 196 | 198 | this.getNextEvent(); | |
| 197 | 199 | ||
| 198 | 200 | } else { | |
| 199 | 201 | Ext.MessageBox.alert(_("Error"), _("Could not get ping event from dSS")); | |
| 200 | 202 | } | |
| 201 | } catch (err) { | ||
| 203 | } catch(err) { | ||
| 202 | 204 | if (this.data != null) // window was closed | |
| 203 | Ext.MessageBox.alert(_("Error"), _("Could send get command to dSS") + ": " + err); | ||
| 205 | Ext.MessageBox.alert(_("Error"), _("Could send get command to dSS") + ": " + err); | ||
| 204 | 206 | } | |
| 205 | 207 | }, | |
| 206 | 208 | failure: function(result, request) { |
webroot/js/dss/dss-setup-interface/dSS/util/RadioTextField.js
(23 / 22)
|   | |||
| 3 | 3 | dSS.util.RadioTimeField = Ext.extend(Ext.Panel, { | |
| 4 | 4 | constructor: function(config) { | |
| 5 | 5 | ||
| 6 | var rb = new Ext.form.Radio({ name: config.rbname, boxLabel: " " }); | ||
| 6 | var rb = new Ext.form.Radio({ | ||
| 7 | name: config.rbname, | ||
| 8 | boxLabel: " " | ||
| 9 | }); | ||
| 7 | 10 | ||
| 8 | 11 | var tfield = new Ext.form.TimeField({ | |
| 9 | name: config.name, | ||
| 10 | width: config.timeFieldWidth, | ||
| 11 | format: config.format, | ||
| 12 | allowBlank: config.allowBlank, | ||
| 13 | value: config.value | ||
| 12 | name: config.name, | ||
| 13 | width: config.timeFieldWidth, | ||
| 14 | format: config.format, | ||
| 15 | allowBlank: config.allowBlank, | ||
| 16 | value: config.value | ||
| 14 | 17 | }); | |
| 15 | 18 | ||
| 16 | 19 | if (config.timeFieldEnabled === false) { | |
| … | … | ||
| 24 | 24 | layout: "column", | |
| 25 | 25 | height: 40, | |
| 26 | 26 | items: [ | |
| 27 | new Ext.Panel({ height : 26, width : config.fieldWidth }), | ||
| 28 | rb, | ||
| 29 | tfield | ||
| 30 | ] | ||
| 27 | new Ext.Panel({ | ||
| 28 | height: 26, | ||
| 29 | width: config.fieldWidth | ||
| 30 | }), rb, tfield] | ||
| 31 | 31 | }); | |
| 32 | 32 | ||
| 33 | 33 | dSS.util.RadioTimeField.superclass.constructor.apply(this, arguments); | |
| 34 | |||
| 35 | rb.on('check', | ||
| 36 | function(e,checked) { | ||
| 37 | if (checked) { | ||
| 38 | tfield.enable(); | ||
| 39 | tfield.focus(); | ||
| 40 | } else { | ||
| 41 | tfield.disable(); | ||
| 42 | } | ||
| 43 | 34 | ||
| 44 | }, | ||
| 45 | this | ||
| 46 | ); | ||
| 35 | rb.on('check', function(e, checked) { | ||
| 36 | if (checked) { | ||
| 37 | tfield.enable(); | ||
| 38 | tfield.focus(); | ||
| 39 | } else { | ||
| 40 | tfield.disable(); | ||
| 41 | } | ||
| 42 | |||
| 43 | }, | ||
| 44 | this); | ||
| 47 | 45 | } | |
| 48 | 46 | }); | |
| 49 | 47 |
webroot/js/dss/dss-setup-interface/dSS/util/TimeInfo.js
(53 / 28)
|   | |||
| 1 | function dateprint(date, month, year, hour, minute /*, second */) | ||
| 2 | { | ||
| 3 | switch (month) | ||
| 4 | { | ||
| 5 | case 0 : month = "Jan"; break; | ||
| 6 | case 1 : month = "Feb"; break; | ||
| 7 | case 2 : month = "Mar"; break; | ||
| 8 | case 3 : month = "Apr"; break; | ||
| 9 | case 4 : month = "May"; break; | ||
| 10 | case 5 : month = "Jun"; break; | ||
| 11 | case 6 : month = "Jul"; break; | ||
| 12 | case 7 : month = "Aug"; break; | ||
| 13 | case 8 : month = "Sep"; break; | ||
| 14 | case 9 : month = "Oct"; break; | ||
| 15 | case 10 : month = "Nov"; break; | ||
| 16 | case 11 : month = "Dec"; break; | ||
| 17 | default : month = ""; break; | ||
| 18 | } | ||
| 1 | function dateprint(date, month, year, hour, minute | ||
| 2 | /*, second */ | ||
| 3 | ) { | ||
| 4 | switch (month) { | ||
| 5 | case 0: | ||
| 6 | month = "Jan"; | ||
| 7 | break; | ||
| 8 | case 1: | ||
| 9 | month = "Feb"; | ||
| 10 | break; | ||
| 11 | case 2: | ||
| 12 | month = "Mar"; | ||
| 13 | break; | ||
| 14 | case 3: | ||
| 15 | month = "Apr"; | ||
| 16 | break; | ||
| 17 | case 4: | ||
| 18 | month = "May"; | ||
| 19 | break; | ||
| 20 | case 5: | ||
| 21 | month = "Jun"; | ||
| 22 | break; | ||
| 23 | case 6: | ||
| 24 | month = "Jul"; | ||
| 25 | break; | ||
| 26 | case 7: | ||
| 27 | month = "Aug"; | ||
| 28 | break; | ||
| 29 | case 8: | ||
| 30 | month = "Sep"; | ||
| 31 | break; | ||
| 32 | case 9: | ||
| 33 | month = "Oct"; | ||
| 34 | break; | ||
| 35 | case 10: | ||
| 36 | month = "Nov"; | ||
| 37 | break; | ||
| 38 | case 11: | ||
| 39 | month = "Dec"; | ||
| 40 | break; | ||
| 41 | default: | ||
| 42 | month = ""; | ||
| 43 | break; | ||
| 44 | } | ||
| 19 | 45 | ||
| 20 | if (hour < 10) | ||
| 21 | hour = ('0' + hour); | ||
| 46 | if (hour < 10) hour = ('0' + hour); | ||
| 22 | 47 | ||
| 23 | if (minute < 10) | ||
| 24 | minute = ('0' + minute); | ||
| 48 | if (minute < 10) minute = ('0' + minute); | ||
| 25 | 49 | /* | |
| 26 | 50 | if (second < 10) | |
| 27 | 51 | second = ('0' + second); | |
| 28 | 52 | */ | |
| 29 | return month + ' ' + date + ' ' + hour + ':' + minute + ', ' + year; // + '.' + second; | ||
| 53 | return month + ' ' + date + ' ' + hour + ':' + minute + ', ' + year; // + '.' + second; | ||
| 30 | 54 | } | |
| 31 | 55 | ||
| 32 | function updateDSSTime() | ||
| 33 | { | ||
| 34 | var t = new Date(new Date().getTime()-dSS.config.dSSTimeDiff); | ||
| 35 | Ext.get('dssTime').update(dateprint(t.getUTCDate(), t.getUTCMonth(), t.getUTCFullYear(), t.getUTCHours(), t.getUTCMinutes() /*, t.getUTCSeconds() */ )); | ||
| 36 | setTimeout('updateDSSTime()', 1000); | ||
| 56 | function updateDSSTime() { | ||
| 57 | var t = new Date(new Date().getTime() - dSS.config.dSSTimeDiff); | ||
| 58 | Ext.get('dssTime').update(dateprint(t.getUTCDate(), t.getUTCMonth(), t.getUTCFullYear(), t.getUTCHours(), t.getUTCMinutes() | ||
| 59 | /*, t.getUTCSeconds() */ | ||
| 60 | )); | ||
| 61 | setTimeout('updateDSSTime()', 1000); | ||
| 37 | 62 | } |
webroot/js/dss/dss-setup-interface/dSS/util/Util.js
(35 / 39)
|   | |||
| 5 | 5 | var dSsubclass = (functionID & 0xfc0) >> 6; | |
| 6 | 6 | var dSfuncModule = (functionID & 0x3f); | |
| 7 | 7 | ||
| 8 | return [ dSclass, dSsubclass, dSfuncModule ]; | ||
| 8 | return [dSclass, dSsubclass, dSfuncModule]; | ||
| 9 | 9 | } | |
| 10 | 10 | ||
| 11 | 11 | dSS.util.callScene = function(dsid, sceneNumber) { | |
| … | … | ||
| 13 | 13 | url: '/json/device/callScene', | |
| 14 | 14 | disableCaching: true, | |
| 15 | 15 | method: "GET", | |
| 16 | params: { dsid : dsid, | ||
| 17 | sceneNumber : sceneNumber }, | ||
| 16 | params: { | ||
| 17 | dsid: dsid, | ||
| 18 | sceneNumber: sceneNumber | ||
| 19 | }, | ||
| 18 | 20 | success: function(result, request) { | |
| 19 | 21 | try { | |
| 20 | 22 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 21 | 23 | if (!jsonData.ok) { | |
| 22 | Ext.MessageBox.alert(_("Could not call scene") + " " + | ||
| 23 | sceneNumber, jsonData.message); | ||
| 24 | Ext.MessageBox.alert(_("Could not call scene") + " " + sceneNumber, jsonData.message); | ||
| 24 | 25 | } | |
| 25 | } catch (err) { | ||
| 26 | Ext.MessageBox.alert(_("Error"), | ||
| 27 | _("Could not send callScene command to dSS") + ": " + err); | ||
| 26 | } catch(err) { | ||
| 27 | Ext.MessageBox.alert(_("Error"), _("Could not send callScene command to dSS") + ": " + err); | ||
| 28 | 28 | } | |
| 29 | 29 | }, | |
| 30 | 30 | failure: function(result, request) { | |
| 31 | Ext.MessageBox.alert(_("Error"), | ||
| 32 | _("Could not send callScene command to dSS")); | ||
| 31 | Ext.MessageBox.alert(_("Error"), _("Could not send callScene command to dSS")); | ||
| 33 | 32 | } | |
| 34 | 33 | }); | |
| 35 | 34 | } | |
| … | … | ||
| 38 | 38 | url: '/json/zone/callScene', | |
| 39 | 39 | disableCaching: true, | |
| 40 | 40 | method: "GET", | |
| 41 | params: { id : zoneId, | ||
| 42 | sceneNumber : sceneNumber, | ||
| 43 | groupID : groupId}, | ||
| 41 | params: { | ||
| 42 | id: zoneId, | ||
| 43 | sceneNumber: sceneNumber, | ||
| 44 | groupID: groupId | ||
| 45 | }, | ||
| 44 | 46 | success: function(result, request) { | |
| 45 | 47 | try { | |
| 46 | 48 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 47 | 49 | if (!jsonData.ok) { | |
| 48 | Ext.MessageBox.alert(_("Could not call scene") + " " + | ||
| 49 | sceneNumber, jsonData.message); | ||
| 50 | Ext.MessageBox.alert(_("Could not call scene") + " " + sceneNumber, jsonData.message); | ||
| 50 | 51 | } | |
| 51 | } catch (err) { | ||
| 52 | Ext.MessageBox.alert(_("Error"), | ||
| 53 | _("Could not send callScene command to dSS") + ": " + err); | ||
| 52 | } catch(err) { | ||
| 53 | Ext.MessageBox.alert(_("Error"), _("Could not send callScene command to dSS") + ": " + err); | ||
| 54 | 54 | } | |
| 55 | 55 | }, | |
| 56 | 56 | failure: function(result, request) { | |
| 57 | Ext.MessageBox.alert(_("Error"), | ||
| 58 | _("Could not send callScene command to dSS")); | ||
| 57 | Ext.MessageBox.alert(_("Error"), _("Could not send callScene command to dSS")); | ||
| 59 | 58 | } | |
| 60 | 59 | }); | |
| 61 | 60 | } | |
| … | … | ||
| 64 | 64 | url: '/json/zone/saveScene', | |
| 65 | 65 | disableCaching: true, | |
| 66 | 66 | method: "GET", | |
| 67 | params: { id : zoneId, | ||
| 68 | sceneNumber : sceneNumber, | ||
| 69 | groupID : groupId}, | ||
| 67 | params: { | ||
| 68 | id: zoneId, | ||
| 69 | sceneNumber: sceneNumber, | ||
| 70 | groupID: groupId | ||
| 71 | }, | ||
| 70 | 72 | success: function(result, request) { | |
| 71 | 73 | try { | |
| 72 | 74 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 73 | 75 | if (!jsonData.ok) { | |
| 74 | Ext.MessageBox.alert(_("Could not save scene") + " " + | ||
| 75 | sceneNumber, jsonData.message); | ||
| 76 | Ext.MessageBox.alert(_("Could not save scene") + " " + sceneNumber, jsonData.message); | ||
| 76 | 77 | } | |
| 77 | } catch (err) { | ||
| 78 | Ext.MessageBox.alert(_("Error"), | ||
| 79 | _("Could not send saveScene command to dSS") + ": " + err); | ||
| 78 | } catch(err) { | ||
| 79 | Ext.MessageBox.alert(_("Error"), _("Could not send saveScene command to dSS") + ": " + err); | ||
| 80 | 80 | } | |
| 81 | 81 | }, | |
| 82 | 82 | failure: function(result, request) { | |
| 83 | Ext.MessageBox.alert(_("Error"), | ||
| 84 | _("Could not send saveScene command to dSS")); | ||
| 83 | Ext.MessageBox.alert(_("Error"), _("Could not send saveScene command to dSS")); | ||
| 85 | 84 | } | |
| 86 | 85 | }); | |
| 87 | 86 | } | |
| … | … | ||
| 90 | 90 | url: '/json/device/setValue', | |
| 91 | 91 | disableCaching: true, | |
| 92 | 92 | method: "GET", | |
| 93 | params: { dsid : dsid, | ||
| 94 | value : value }, | ||
| 93 | params: { | ||
| 94 | dsid: dsid, | ||
| 95 | value: value | ||
| 96 | }, | ||
| 95 | 97 | success: function(result, request) { | |
| 96 | 98 | try { | |
| 97 | 99 | var jsonData = Ext.util.JSON.decode(result.responseText); | |
| 98 | 100 | if (!jsonData.ok) { | |
| 99 | Ext.MessageBox.alert(_("Could not set value") + ": " + | ||
| 100 | jsonData.message); | ||
| 101 | Ext.MessageBox.alert(_("Could not set value") + ": " + jsonData.message); | ||
| 101 | 102 | } | |
| 102 | } catch (err) { | ||
| 103 | Ext.MessageBox.alert(_("Error"), | ||
| 104 | _("Could not send setValue command to dSS") + ": " + err); | ||
| 103 | } catch(err) { | ||
| 104 | Ext.MessageBox.alert(_("Error"), _("Could not send setValue command to dSS") + ": " + err); | ||
| 105 | 105 | } | |
| 106 | 106 | }, | |
| 107 | 107 | failure: function(result, request) { | |
| 108 | Ext.MessageBox.alert(_("Error"), | ||
| 109 | _("Could not send setValue command to dSS")); | ||
| 108 | Ext.MessageBox.alert(_("Error"), _("Could not send setValue command to dSS")); | ||
| 110 | 109 | } | |
| 111 | 110 | }); | |
| 112 | 111 |
webroot/js/dss/dss-setup-interface/dss-overview-page.js
(51 / 54)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | 2 | //= require <dSS/util/TimeInfo> | |
| 3 | |||
| 4 | 3 | Ext.namespace("dSS", "dSS.config"); | |
| 5 | 4 | ||
| 6 | Ext.onReady(function(){ | ||
| 7 | Ext.get('start').remove(); | ||
| 5 | Ext.onReady(function() { | ||
| 6 | Ext.get('start').remove(); | ||
| 8 | 7 | dSS.config.dSSTimeDiff = 0; | |
| 9 | 8 | ||
| 10 | var viewport = new Ext.Viewport({ | ||
| 11 | layout: 'border', | ||
| 12 | items: [ | ||
| 13 | { | ||
| 14 | xtype: 'box', | ||
| 15 | region: 'north', | ||
| 16 | height: 80, // give north and south regions a height | ||
| 17 | autoEl: { | ||
| 18 | tag: 'div', | ||
| 19 | html:'<a href="http://digitalstrom.org/" alt="' + _("visit digitalSTROM.org") + '"><img id="logo" src="/images/ds_logo.gif" alt="dS-Logo"></a>' + | ||
| 20 | '<h1><a href="http://digitalstrom.org/" alt="visit digitalSTROM.org">' + _("digitalSTROM Server Overview") + '</a></h1>' + | ||
| 21 | '<p><span id= \'dssVersion\'>-</span>, <span id=\'dssTime\'>-</span></p>' | ||
| 22 | } | ||
| 23 | }, { | ||
| 24 | region: 'center', | ||
| 25 | xtype: 'panel', | ||
| 26 | hideBorders: true, | ||
| 27 | // TODO: fixme | ||
| 28 | autoLoad: '/locale/de_DE/overview-links.html' | ||
| 29 | }] | ||
| 30 | }); | ||
| 9 | var viewport = new Ext.Viewport({ | ||
| 10 | layout: 'border', | ||
| 11 | items: [ | ||
| 12 | { | ||
| 13 | xtype: 'box', | ||
| 14 | region: 'north', | ||
| 15 | height: 80, | ||
| 16 | // give north and south regions a height | ||
| 17 | autoEl: { | ||
| 18 | tag: 'div', | ||
| 19 | html: '<a href="http://digitalstrom.org/" alt="' + _("visit digitalSTROM.org") + '"><img id="logo" src="/images/ds_logo.gif" alt="dS-Logo"></a>' + '<h1><a href="http://digitalstrom.org/" alt="visit digitalSTROM.org">' + _("digitalSTROM Server Overview") + '</a></h1>' + '<p><span id= \'dssVersion\'>-</span>, <span id=\'dssTime\'>-</span></p>' | ||
| 20 | } | ||
| 21 | }, | ||
| 22 | { | ||
| 23 | region: 'center', | ||
| 24 | xtype: 'panel', | ||
| 25 | hideBorders: true, | ||
| 26 | // TODO: fixme | ||
| 27 | autoLoad: '/locale/de_DE/overview-links.html' | ||
| 28 | }] | ||
| 29 | }); | ||
| 31 | 30 | ||
| 32 | Ext.Ajax.request({ | ||
| 33 | url : "/json/system/version", | ||
| 34 | disableCaching : true, | ||
| 35 | success : function(response, options) { | ||
| 36 | try{ | ||
| 37 | var data = Ext.decode(response.responseText); | ||
| 38 | if(data.ok === false) { | ||
| 39 | throw new Ext.Error(_("Could not get dSS version!"), data.error); | ||
| 40 | } | ||
| 41 | Ext.get("dssVersion").update(data.message); | ||
| 31 | Ext.Ajax.request({ | ||
| 32 | url: "/json/system/version", | ||
| 33 | disableCaching: true, | ||
| 34 | success: function(response, options) { | ||
| 35 | try { | ||
| 36 | var data = Ext.decode(response.responseText); | ||
| 37 | if (data.ok === false) { | ||
| 38 | throw new Ext.Error(_("Could not get dSS version!"), data.error); | ||
| 39 | } | ||
| 40 | Ext.get("dssVersion").update(data.message); | ||
| 42 | 41 | ||
| 43 | } catch(error) { | ||
| 44 | } | ||
| 45 | }, | ||
| 46 | failure : function(response, options) {} | ||
| 47 | }); | ||
| 42 | } catch(error) {} | ||
| 43 | }, | ||
| 44 | failure: function(response, options) {} | ||
| 45 | }); | ||
| 48 | 46 | ||
| 49 | Ext.Ajax.request({ | ||
| 50 | url : "/json/system/time", | ||
| 51 | disableCaching : true, | ||
| 52 | scope : this, | ||
| 53 | success : function(response, options) { | ||
| 54 | try{ | ||
| 55 | var data = Ext.decode(response.responseText); | ||
| 56 | if(data.ok === false) { | ||
| 57 | throw new Ext.Error(_("Could not get dSS time!"), data.error); | ||
| 58 | } | ||
| 47 | Ext.Ajax.request({ | ||
| 48 | url: "/json/system/time", | ||
| 49 | disableCaching: true, | ||
| 50 | scope: this, | ||
| 51 | success: function(response, options) { | ||
| 52 | try { | ||
| 53 | var data = Ext.decode(response.responseText); | ||
| 54 | if (data.ok === false) { | ||
| 55 | throw new Ext.Error(_("Could not get dSS time!"), data.error); | ||
| 56 | } | ||
| 59 | 57 | dSS.config.dSSTimeDiff = (new Date().getTime() - (parseInt(data.message, 10) * 1000)); | |
| 60 | 58 | updateDSSTime(); | |
| 61 | 59 | ||
| 62 | } catch(error) { | ||
| 63 | } | ||
| 64 | }, | ||
| 65 | failure : function(response, options) {} | ||
| 66 | }); | ||
| 60 | } catch(error) {} | ||
| 61 | }, | ||
| 62 | failure: function(response, options) {} | ||
| 63 | }); | ||
| 67 | 64 | ||
| 68 | 65 | }); |
webroot/js/dss/dss-setup-interface/dss-setup-interface.js
(114 / 111)
|   | |||
| 8 | 8 | //= require <dSS/GlossaryPanel> | |
| 9 | 9 | //= require <dSS/util/TimeInfo> | |
| 10 | 10 | //= require <dSS/config/Config> | |
| 11 | |||
| 12 | 11 | Ext.namespace("dSS", "dSS.config"); | |
| 13 | 12 | ||
| 14 | Ext.onReady(function(){ | ||
| 15 | Ext.get('start').remove(); | ||
| 16 | |||
| 17 | var viewport = new Ext.Viewport({ | ||
| 18 | layout: 'border', | ||
| 19 | items: [ | ||
| 20 | { | ||
| 21 | xtype: 'box', | ||
| 22 | region: 'north', | ||
| 23 | height: 80, // give north and south regions a height | ||
| 24 | autoEl: { | ||
| 25 | tag: 'div', | ||
| 26 | html:'<a href="http://digitalstrom.org/" alt="' + _("visit digitalSTROM.org") + '"><img id="logo" src="/images/ds_logo.gif" alt="dS-Logo"></a>' + | ||
| 27 | '<h1><a href="http://digitalstrom.org/" alt="visit digitalSTROM.org">' + _("digitalSTROM Setup") + '</a></h1>' + | ||
| 28 | '<p><span id= \'dssVersion\'>-</span>, <span id=\'dssTime\'>-</span></p>' | ||
| 29 | } | ||
| 30 | }, { | ||
| 31 | region: 'center', | ||
| 32 | xtype: 'tabpanel', | ||
| 33 | activeItem: 0, | ||
| 34 | items: [ | ||
| 35 | { | ||
| 36 | title: gt.ngettext("Zone", "n% Zones", 2), | ||
| 37 | xtype: 'dsszonebrowser', | ||
| 38 | ref: 'zoneBrowser' | ||
| 39 | }, { | ||
| 40 | title: gt.ngettext("Scene", 2), | ||
| 41 | xtype: 'dssscenespanel', | ||
| 42 | ref: 'scenesPanel' | ||
| 43 | }, { | ||
| 44 | title: gt.ngettext("Circuit", "n% Circuits", 2), | ||
| 45 | xtype: 'dsmoverviewpanel', | ||
| 46 | ref: 'dSMOverviewPanel' | ||
| 47 | }, { | ||
| 48 | title: _("System Properties"), | ||
| 49 | xtype: 'dsssystempanel', | ||
| 50 | ref: 'systemPanel' | ||
| 51 | },{ | ||
| 52 | title: _("Glossary"), | ||
| 53 | xtype: 'dssglossarypanel', | ||
| 54 | ref: 'glossaryPanel' | ||
| 55 | } | ||
| 56 | ] | ||
| 57 | }] | ||
| 58 | }); | ||
| 13 | Ext.onReady(function() { | ||
| 14 | Ext.get('start').remove(); | ||
| 59 | 15 | ||
| 60 | Ext.Ajax.request({ | ||
| 61 | url : "/json/system/version", | ||
| 62 | disableCaching : true, | ||
| 63 | success : function(response, options) { | ||
| 64 | try{ | ||
| 65 | var data = Ext.decode(response.responseText); | ||
| 66 | if(data.ok === false) { | ||
| 67 | throw new Ext.Error(_("Could not get dSS version!"), data.error); | ||
| 68 | } | ||
| 69 | Ext.get("dssVersion").update(data.message); | ||
| 16 | var viewport = new Ext.Viewport({ | ||
| 17 | layout: 'border', | ||
| 18 | items: [ | ||
| 19 | { | ||
| 20 | xtype: 'box', | ||
| 21 | region: 'north', | ||
| 22 | height: 80, | ||
| 23 | // give north and south regions a height | ||
| 24 | autoEl: { | ||
| 25 | tag: 'div', | ||
| 26 | html: '<a href="http://digitalstrom.org/" alt="' + _("visit digitalSTROM.org") + '"><img id="logo" src="/images/ds_logo.gif" alt="dS-Logo"></a>' + '<h1><a href="http://digitalstrom.org/" alt="visit digitalSTROM.org">' + _("digitalSTROM Setup") + '</a></h1>' + '<p><span id= \'dssVersion\'>-</span>, <span id=\'dssTime\'>-</span></p>' | ||
| 27 | } | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | region: 'center', | ||
| 31 | xtype: 'tabpanel', | ||
| 32 | activeItem: 0, | ||
| 33 | items: [ | ||
| 34 | { | ||
| 35 | title: gt.ngettext("Zone", "n% Zones", 2), | ||
| 36 | xtype: 'dsszonebrowser', | ||
| 37 | ref: 'zoneBrowser' | ||
| 38 | }, | ||
| 39 | { | ||
| 40 | title: gt.ngettext("Scene", 2), | ||
| 41 | xtype: 'dssscenespanel', | ||
| 42 | ref: 'scenesPanel' | ||
| 43 | }, | ||
| 44 | { | ||
| 45 | title: gt.ngettext("Circuit", "n% Circuits", 2), | ||
| 46 | xtype: 'dsmoverviewpanel', | ||
| 47 | ref: 'dSMOverviewPanel' | ||
| 48 | }, | ||
| 49 | { | ||
| 50 | title: _("System Properties"), | ||
| 51 | xtype: 'dsssystempanel', | ||
| 52 | ref: 'systemPanel' | ||
| 53 | }, | ||
| 54 | { | ||
| 55 | title: _("Glossary"), | ||
| 56 | xtype: 'dssglossarypanel', | ||
| 57 | ref: 'glossaryPanel' | ||
| 58 | }] | ||
| 59 | }] | ||
| 60 | }); | ||
| 70 | 61 | ||
| 71 | } catch(error) { | ||
| 72 | } | ||
| 73 | }, | ||
| 74 | failure : function(response, options) {} | ||
| 75 | }); | ||
| 62 | Ext.Ajax.request({ | ||
| 63 | url: "/json/system/version", | ||
| 64 | disableCaching: true, | ||
| 65 | success: function(response, options) { | ||
| 66 | try { | ||
| 67 | var data = Ext.decode(response.responseText); | ||
| 68 | if (data.ok === false) { | ||
| 69 | throw new Ext.Error(_("Could not get dSS version!"), data.error); | ||
| 70 | } | ||
| 71 | Ext.get("dssVersion").update(data.message); | ||
| 76 | 72 | ||
| 77 | Ext.Ajax.request({ | ||
| 78 | url : "/json/system/time", | ||
| 79 | disableCaching : true, | ||
| 80 | scope : this, | ||
| 81 | success : function(response, options) { | ||
| 82 | try{ | ||
| 83 | var data = Ext.decode(response.responseText); | ||
| 84 | if(data.ok === false) { | ||
| 85 | throw new Ext.Error(_("Could not get dSS time!"), data.error); | ||
| 86 | } | ||
| 73 | } catch(error) {} | ||
| 74 | }, | ||
| 75 | failure: function(response, options) {} | ||
| 76 | }); | ||
| 77 | |||
| 78 | Ext.Ajax.request({ | ||
| 79 | url: "/json/system/time", | ||
| 80 | disableCaching: true, | ||
| 81 | scope: this, | ||
| 82 | success: function(response, options) { | ||
| 83 | try { | ||
| 84 | var data = Ext.decode(response.responseText); | ||
| 85 | if (data.ok === false) { | ||
| 86 | throw new Ext.Error(_("Could not get dSS time!"), data.error); | ||
| 87 | } | ||
| 87 | 88 | dSS.config.dSSTimeDiff = (new Date().getTime() - (parseInt(data.message, 10) * 1000)); | |
| 88 | 89 | updateDSSTime(); | |
| 89 | 90 | ||
| 90 | } catch(error) { | ||
| 91 | } | ||
| 92 | }, | ||
| 93 | failure : function(response, options) {} | ||
| 94 | }); | ||
| 91 | } catch(error) {} | ||
| 92 | }, | ||
| 93 | failure: function(response, options) {} | ||
| 94 | }); | ||
| 95 | 95 | ||
| 96 | 96 | Ext.Ajax.request({ | |
| 97 | url : "/json/property/getChildren", | ||
| 98 | params : { path : "/system/js/features" }, | ||
| 99 | scope : this, | ||
| 100 | method : "GET", | ||
| 101 | disableCaching : true, | ||
| 102 | success : function(response, options) { | ||
| 97 | url: "/json/property/getChildren", | ||
| 98 | params: { | ||
| 99 | path: "/system/js/features" | ||
| 100 | }, | ||
| 101 | scope: this, | ||
| 102 | method: "GET", | ||
| 103 | disableCaching: true, | ||
| 104 | success: function(response, options) { | ||
| 103 | 105 | try { | |
| 104 | 106 | var jsonData = Ext.util.JSON.decode(response.responseText); | |
| 105 | 107 | if (jsonData.ok) { | |
| 106 | 108 | for (i = 0; i < jsonData.result.length; i++) { | |
| 107 | dSS.config.features[jsonData.result[i].name] = true; | ||
| 109 | dSS.config.features[jsonData.result[i].name] = true; | ||
| 108 | 110 | } | |
| 109 | 111 | } else { | |
| 110 | 112 | Ext.MessageBox.alert(_("Error"), _("Could not get properties from dSS")); | |
| 111 | 113 | } | |
| 112 | } catch (err) { | ||
| 114 | } catch(err) { | ||
| 113 | 115 | Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS") + ": " + err); | |
| 114 | 116 | } | |
| 115 | |||
| 117 | |||
| 116 | 118 | }, | |
| 117 | failure : function(response, options) { | ||
| 119 | failure: function(response, options) { | ||
| 118 | 120 | Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS")); | |
| 119 | 121 | } | |
| 120 | }); | ||
| 122 | }); | ||
| 121 | 123 | ||
| 122 | 124 | Ext.Ajax.request({ | |
| 123 | url : "/json/property/getChildren", | ||
| 124 | params : { path : "/system/js/settings" }, | ||
| 125 | scope : this, | ||
| 126 | method : "GET", | ||
| 127 | disableCaching : true, | ||
| 128 | success : function(response, options) { | ||
| 125 | url: "/json/property/getChildren", | ||
| 126 | params: { | ||
| 127 | path: "/system/js/settings" | ||
| 128 | }, | ||
| 129 | scope: this, | ||
| 130 | method: "GET", | ||
| 131 | disableCaching: true, | ||
| 132 | success: function(response, options) { | ||
| 129 | 133 | try { | |
| 130 | 134 | var jsonData = Ext.util.JSON.decode(response.responseText); | |
| 131 | 135 | if (jsonData.ok) { | |
| 132 | for (i = 0; i < jsonData.result.length; i++) { | ||
| 133 | /* | ||
| 136 | for (i = 0; i < jsonData.result.length; i++) { | ||
| 137 | /* | ||
| 134 | 138 | dSS.config.settings[jsonData.result[i].name] = jsonData.result[i]; | |
| 135 | 139 | */ | |
| 136 | 140 | getLogFileProperties(jsonData.result[i]); | |
| … | … | ||
| 142 | 142 | } else { | |
| 143 | 143 | Ext.MessageBox.alert(_("Error"), _("Could not get properties from dSS")); | |
| 144 | 144 | } | |
| 145 | } catch (err) { | ||
| 145 | } catch(err) { | ||
| 146 | 146 | Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS") + ": " + err); | |
| 147 | 147 | } | |
| 148 | |||
| 148 | |||
| 149 | 149 | }, | |
| 150 | failure : function(response, options) { | ||
| 150 | failure: function(response, options) { | ||
| 151 | 151 | Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS")); | |
| 152 | 152 | } | |
| 153 | }); | ||
| 153 | }); | ||
| 154 | 154 | ||
| 155 | 155 | function getLogFileProperties(res) { | |
| 156 | 156 | Ext.Ajax.request({ | |
| 157 | url : "/json/property/getString", | ||
| 158 | params : { | ||
| 159 | path : "/system/js/settings/" + res.name + "/logfile" | ||
| 160 | }, | ||
| 161 | scope : this, | ||
| 162 | method : "GET", | ||
| 163 | disableCaching : true, | ||
| 164 | success : function(response, options) { | ||
| 157 | url: "/json/property/getString", | ||
| 158 | params: { | ||
| 159 | path: "/system/js/settings/" + res.name + "/logfile" | ||
| 160 | }, | ||
| 161 | scope: this, | ||
| 162 | method: "GET", | ||
| 163 | disableCaching: true, | ||
| 164 | success: function(response, options) { | ||
| 165 | 165 | try { | |
| 166 | 166 | var jsonData = Ext.util.JSON.decode(response.responseText); | |
| 167 | 167 | if (jsonData.ok) { | |
| 168 | 168 | dSS.config.settings[res.name] = {}; | |
| 169 | 169 | dSS.config.settings[res.name].logfile = jsonData.result.value; | |
| 170 | 170 | } | |
| 171 | } catch (err) { | ||
| 172 | } | ||
| 171 | } catch(err) {} | ||
| 173 | 172 | }, | |
| 174 | failure : function(response, options) { | ||
| 173 | failure: function(response, options) { | ||
| 175 | 174 | Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS")); | |
| 176 | 175 | } | |
| 177 | }); | ||
| 176 | }); | ||
| 178 | 177 | } | |
| 179 | 178 | }); |

