Commit 3fe1397f02b313bbcd2f15bda4dc670a2b5f05ce

  • avatar
  • Sergey 'Jin' Bostandzhyan <jin @deve…per.digitalstrom.org>
  • Wed Jul 28 13:30:31 CEST 2010
Changed node id scheme and parsing,added callScene

It is now possible to call the appropriate scenes from the menu.
dss-setup-interface/dSS/ScenesPanel.js
(72 / 22)
  
11//= require <dSS/GetTextHelper>
2//= require <dSS/util/Util>
23
34Ext.namespace('dSS');
45
133133 );
134134 },
135135 updateTree: function() {
136 // for leafs the id is encoded as: zone id - group - scene number
137 // when no group is desired, 0 is used
136138 function generateSubNodes(zoneId) {
137139 return [
138140 {
139141 text: _("Light"),
140 id: 'light-' + zoneId,
142 id: zoneId + '-' + dSS.config.groups.LIGHT + '-all',
141143 leaf: false,
142144 children: [
143145 {
144 text: _("Light scene") + " 0",
145 id: 'ls-0-' + zoneId,
146 leaf: true
147 },
148 {
149146 text: _("Light scene") + " 1",
150 id: 'ls-1-' + zoneId,
147 id: zoneId + '-' +
148 dSS.config.groups.LIGHT + '-' +
149 dSS.config.scenes.T0_S1,
151150 leaf: true
152151 },
153152 {
154153 text: _("Light scene") + " 2",
155 id: 'ls-2-' + zoneId,
154 id: zoneId + '-' +
155 dSS.config.groups.LIGHT + '-' +
156 dSS.config.scenes.T0_S2,
156157 leaf: true
157158 },
158159 {
159160 text: _("Light scene") + " 3",
160 id: 'ls-3-' + zoneId,
161 id: zoneId + '-' +
162 dSS.config.groups.LIGHT + '-' +
163 dSS.config.scenes.T0_S3,
161164 leaf: true
162165 },
163166 {
164167 text: _("Light scene") + " 4",
165 id: 'ls-4-' + zoneId,
168 id: zoneId + '-' +
169 dSS.config.groups.LIGHT + '-' +
170 dSS.config.scenes.T0_S4,
166171 leaf: true
167172 }
168173 ]
169174 },
170175 {
171176 text: _("Leave home"),
172 id: 'leave-' + zoneId,
177 id: zoneId + '-all-' + dSS.config.scenes.ABSENT,
173178 leaf: true
174179 },
175180 {
176181 text: _("Door bell"),
177 id: 'bell-' + zoneId,
182 id: zoneId + '-all-' + dSS.config.scenes.SIG_BELL,
178183 leaf: true
179184 }
180185 ];
211211 handleNodeClick: function(node) {
212212 var store = dSS.data.Loader.getDeviceStore();
213213 store.clearFilter();
214
215 if (node === null) {
216 return;
217 }
218
214219 // we are on the zone node
215220 var path = node.getPath().split('/').slice(1);
216221 if (path.length < 2) {
231231 var fid = dSS.util.parseFunctionID(record.get('functionID'));
232232
233233 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) {
235236 return false;
236237 }
237238
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) {
243244 return true;
244245 }
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)) {
248263 return true;
249264 }
250265 break;
295295 this.ownerCt.zoneBrowser.loadData();
296296 },
297297 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);
299323 },
300324 saveScene: function(node) {
301325 console.log(node);