Commit 3fe1397f02b313bbcd2f15bda4dc670a2b5f05ce
- Diff rendering mode:
- inline
- side by side
dss-setup-interface/dSS/ScenesPanel.js
(72 / 22)
|   | |||
| 1 | 1 | //= require <dSS/GetTextHelper> | |
| 2 | //= require <dSS/util/Util> | ||
| 2 | 3 | ||
| 3 | 4 | Ext.namespace('dSS'); | |
| 4 | 5 | ||
| … | … | ||
| 133 | 133 | ); | |
| 134 | 134 | }, | |
| 135 | 135 | updateTree: function() { | |
| 136 | // for leafs the id is encoded as: zone id - group - scene number | ||
| 137 | // when no group is desired, 0 is used | ||
| 136 | 138 | function generateSubNodes(zoneId) { | |
| 137 | 139 | return [ | |
| 138 | 140 | { | |
| 139 | 141 | text: _("Light"), | |
| 140 | id: 'light-' + zoneId, | ||
| 142 | id: zoneId + '-' + dSS.config.groups.LIGHT + '-all', | ||
| 141 | 143 | leaf: false, | |
| 142 | 144 | children: [ | |
| 143 | 145 | { | |
| 144 | text: _("Light scene") + " 0", | ||
| 145 | id: 'ls-0-' + zoneId, | ||
| 146 | leaf: true | ||
| 147 | }, | ||
| 148 | { | ||
| 149 | 146 | text: _("Light scene") + " 1", | |
| 150 | id: 'ls-1-' + zoneId, | ||
| 147 | id: zoneId + '-' + | ||
| 148 | dSS.config.groups.LIGHT + '-' + | ||
| 149 | dSS.config.scenes.T0_S1, | ||
| 151 | 150 | leaf: true | |
| 152 | 151 | }, | |
| 153 | 152 | { | |
| 154 | 153 | text: _("Light scene") + " 2", | |
| 155 | id: 'ls-2-' + zoneId, | ||
| 154 | id: zoneId + '-' + | ||
| 155 | dSS.config.groups.LIGHT + '-' + | ||
| 156 | dSS.config.scenes.T0_S2, | ||
| 156 | 157 | leaf: true | |
| 157 | 158 | }, | |
| 158 | 159 | { | |
| 159 | 160 | text: _("Light scene") + " 3", | |
| 160 | id: 'ls-3-' + zoneId, | ||
| 161 | id: zoneId + '-' + | ||
| 162 | dSS.config.groups.LIGHT + '-' + | ||
| 163 | dSS.config.scenes.T0_S3, | ||
| 161 | 164 | leaf: true | |
| 162 | 165 | }, | |
| 163 | 166 | { | |
| 164 | 167 | text: _("Light scene") + " 4", | |
| 165 | id: 'ls-4-' + zoneId, | ||
| 168 | id: zoneId + '-' + | ||
| 169 | dSS.config.groups.LIGHT + '-' + | ||
| 170 | dSS.config.scenes.T0_S4, | ||
| 166 | 171 | leaf: true | |
| 167 | 172 | } | |
| 168 | 173 | ] | |
| 169 | 174 | }, | |
| 170 | 175 | { | |
| 171 | 176 | text: _("Leave home"), | |
| 172 | id: 'leave-' + zoneId, | ||
| 177 | id: zoneId + '-all-' + dSS.config.scenes.ABSENT, | ||
| 173 | 178 | leaf: true | |
| 174 | 179 | }, | |
| 175 | 180 | { | |
| 176 | 181 | text: _("Door bell"), | |
| 177 | id: 'bell-' + zoneId, | ||
| 182 | id: zoneId + '-all-' + dSS.config.scenes.SIG_BELL, | ||
| 178 | 183 | leaf: true | |
| 179 | 184 | } | |
| 180 | 185 | ]; | |
| … | … | ||
| 211 | 211 | handleNodeClick: function(node) { | |
| 212 | 212 | var store = dSS.data.Loader.getDeviceStore(); | |
| 213 | 213 | store.clearFilter(); | |
| 214 | |||
| 215 | if (node === null) { | ||
| 216 | return; | ||
| 217 | } | ||
| 218 | |||
| 214 | 219 | // we are on the zone node | |
| 215 | 220 | var path = node.getPath().split('/').slice(1); | |
| 216 | 221 | if (path.length < 2) { | |
| … | … | ||
| 231 | 231 | var fid = dSS.util.parseFunctionID(record.get('functionID')); | |
| 232 | 232 | ||
| 233 | 233 | var nodeType = path[2].split('-'); | |
| 234 | if (nodeType.length != 2) { | ||
| 234 | // all leaf node ids will have 3 components: zone-group-scene | ||
| 235 | if (nodeType.length < 3) { | ||
| 235 | 236 | return false; | |
| 236 | 237 | } | |
| 237 | 238 | ||
| 238 | switch (nodeType[0]) { | ||
| 239 | case "leave": | ||
| 240 | return true; | ||
| 241 | case "light": | ||
| 242 | if (fid[0] === 1) { | ||
| 239 | // if the group is set, we sort only by group | ||
| 240 | if (nodeType[1] != 'all') { | ||
| 241 | var group = parseInt(nodeType[1]); | ||
| 242 | if (!isNaN(group)) { | ||
| 243 | if (fid[0] === group) { | ||
| 243 | 244 | return true; | |
| 244 | 245 | } | |
| 245 | break; | ||
| 246 | case "bell": | ||
| 247 | if ((fid[0] === 1) || (fid[0] === 7)) { | ||
| 246 | |||
| 247 | return false; | ||
| 248 | } | ||
| 249 | } | ||
| 250 | |||
| 251 | // at this stage groups do not matter, scene filtering applies | ||
| 252 | var scene = parseInt(nodeType[2]); | ||
| 253 | if (isNaN(scene)) { | ||
| 254 | return false; | ||
| 255 | } | ||
| 256 | |||
| 257 | switch (scene) { | ||
| 258 | case dSS.config.scenes.ABSENT: | ||
| 259 | return true; | ||
| 260 | case dSS.config.scenes.SIG_BELL: | ||
| 261 | if ((fid[0] === dSS.config.groups.LIGHT) || | ||
| 262 | (fid[0] === dSS.config.groups.ACCESS)) { | ||
| 248 | 263 | return true; | |
| 249 | 264 | } | |
| 250 | 265 | break; | |
| … | … | ||
| 295 | 295 | this.ownerCt.zoneBrowser.loadData(); | |
| 296 | 296 | }, | |
| 297 | 297 | callScene: function(node) { | |
| 298 | console.log(node); | ||
| 298 | if ((node === null) || (!node.isLeaf())) { | ||
| 299 | return; | ||
| 300 | } | ||
| 301 | |||
| 302 | var ids = node.id.split('-'); | ||
| 303 | if (ids.length < 3) { | ||
| 304 | return; | ||
| 305 | } | ||
| 306 | |||
| 307 | var zoneId = parseInt(ids[0]); | ||
| 308 | if (isNaN(zoneId)) { | ||
| 309 | return; | ||
| 310 | } | ||
| 311 | |||
| 312 | var groupId = parseInt(ids[1]); | ||
| 313 | if (isNaN(groupId)) { | ||
| 314 | groupId = null; | ||
| 315 | } | ||
| 316 | |||
| 317 | var sceneNumber = parseInt(ids[2]); | ||
| 318 | if (isNaN(sceneNumber)) { | ||
| 319 | return; | ||
| 320 | } | ||
| 321 | |||
| 322 | dSS.util.callSceneOnZone(zoneId, sceneNumber, groupId); | ||
| 299 | 323 | }, | |
| 300 | 324 | saveScene: function(node) { | |
| 301 | 325 | console.log(node); |

