Commit 7b2ae65f178833194b623eb83ed9defaf1c38ad9

  • avatar
  • Sergey 'Jin' Bostandzhyan <jin @deve…per.digitalstrom.org>
  • Fri Aug 06 00:45:46 CEST 2010
Processed all UI sources using a js beautifier
webroot/js/dss/dss-setup-interface/dSS/GetTextHelper.js
(6 / 4)
  
11var params = {
2 "domain" : "dss-installer",
3 "locale_data" : json_locale_data
4 };
2 "domain": "dss-installer",
3 "locale_data": json_locale_data
4};
55
66var gt = new Gettext(params);
77
8function _(msgid) { return gt.gettext(msgid); }
8function _(msgid) {
9 return gt.gettext(msgid);
10}
webroot/js/dss/dss-setup-interface/dSS/GlossaryPanel.js
(15 / 16)
  
11//= require <dSS/GetTextHelper>
2
32Ext.namespace('dSS');
43
54dSS.GlossaryPanel = Ext.extend(Ext.Panel, {
6 initComponent: function() {
5 initComponent: function() {
76
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 });
2019
21 dSS.GlossaryPanel.superclass.initComponent.apply(this, arguments);
22 }
20 dSS.GlossaryPanel.superclass.initComponent.apply(this, arguments);
21 }
2322});
2423
2524Ext.reg('dssglossarypanel', dSS.GlossaryPanel);
webroot/js/dss/dss-setup-interface/dSS/MessageBus.js
(0 / 1)
  
11//= require <dSS/MessageBusImpl>
2
32Ext.namespace('dSS');
43
54dSS.MessageBus = (function() {
webroot/js/dss/dss-setup-interface/dSS/MessageBusImpl.js
(6 / 6)
  
11Ext.namespace('dSS');
22
33dSS.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 }
1010});
webroot/js/dss/dss-setup-interface/dSS/ScenesPanel.js
(165 / 193)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/Util>
3
43Ext.namespace('dSS');
54
65dSS.ScenesPanel = Ext.extend(Ext.Panel, {
7 initComponent: function() {
6 initComponent: function() {
87
9 var contentPanel = {
10 ref: 'contentPanel',
11 region: 'center',
12 layout: 'card',
8 var contentPanel = {
9 ref: 'contentPanel',
10 region: 'center',
11 layout: 'card',
1312 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 };
2220
23 this.treePanel = new Ext.tree.TreePanel(
24 {
21 this.treePanel = new Ext.tree.TreePanel({
2522 useArrows: true,
2623 autoScroll: true,
2724 animate: true,
3434
3535 this.treePanel.getRootNode().expand();
3636
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 });
5948
49 Ext.apply(this, {
50 layout: 'border',
51 border: false,
52 bodyBorder: false,
53 items: [treeHolder, contentPanel]
54 });
55
6056 this.updateTree();
6157
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 });
6661
67 dSS.ScenesPanel.superclass.initComponent.apply(this, arguments);
62 dSS.ScenesPanel.superclass.initComponent.apply(this, arguments);
6863
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);
8476
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();
9080
91 if (!node.isSelected()) {
92 node.select();
93 this.handleNodeClick(node);
94 }
81 if (!node.isSelected()) {
82 node.select();
83 this.handleNodeClick(node);
84 }
9585
96 if (!node.isLeaf()) {
97 return;
98 }
86 if (!node.isLeaf()) {
87 return;
88 }
9989
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 }
10595
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)
112102
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);
119109
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 },
126115 updateTree: function() {
127116 // for leafs the id is encoded as: zone id - group - scene number
128117 // when no group is desired, 0 is used
129118 function generateSubNodes(zoneId) {
130119 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 }];
177156 }
178157
179158 var selModel = this.treePanel.getSelectionModel();
161161 if (selectedNode != null) {
162162 selectedPath = selectedNode.getPath();
163163 }
164
164
165165 var zStore = dSS.data.Loader.getZoneStore();
166166 var devStore = dSS.data.Loader.getDeviceStore();
167167 var nodes = [];
168168 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);
187187
188188 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();
195193 }
194 }
196195 });
197196 } else {
198197 if (root.firstChild != null) {
199198 root.firstChild.select();
200199 }
201200 }
202
201
203202 if (selModel.getSelectedNode() != null) {
204203 this.handleNodeClick(selModel.getSelectedNode());
205204 }
206
205
207206 },
208207 handleNodeClick: function(node) {
209208 if (!this.isVisible()) {
231231
232232 var nodeType = path[2].split('-');
233233 // all leaf node ids will have 3 components: zone-group-scene
234 if (nodeType.length < 3) {
234 if (nodeType.length < 3) {
235235 return false;
236236 }
237237
254254 }
255255
256256 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;
262262 }
263263 }
264264 return false;
265265 });
266266 },
267267 buildTopToolbar: function() {
268 return [
269 '->',
268 return ['->', {
269 cls: 'zonePanelMenu',
270 menu: [
270271 {
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 }];
284282 },
285283 rescan: function() {
286284 this.ownerCt.zoneBrowser.rescan();
288288 },
289289
290290 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 };
297296
298297 var ids = id.split('-');
299298 if (ids.length < 3) {
webroot/js/dss/dss-setup-interface/dSS/SystemPanel.js
(86 / 90)
  
22//= require <dSS/system/PropertyTree>
33//= require <dSS/system/logfiles>
44//= require <dSS/system/jsLogFiles>
5
65Ext.namespace('dSS');
76
87dSS.SystemPanel = Ext.extend(Ext.Panel, {
9 initComponent: function() {
8 initComponent: function() {
109
11 var tabRecord = Ext.data.Record.create([ { name:"title" } ]);
10 var tabRecord = Ext.data.Record.create([
11 {
12 name: "title"
13 }]);
1214
13 var tabStore = new Ext.data.Store({}, tabRecord);
15 var tabStore = new Ext.data.Store({},
16 tabRecord);
1417
15 var contentPanel = {
16 ref: 'contentPanel',
17 region: 'center',
18 layout: 'card',
18 var contentPanel = {
19 ref: 'contentPanel',
20 region: 'center',
21 layout: 'card',
1922 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: [
4026 {
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 },
5131 {
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 },
6436 {
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 };
7142
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 });
7355
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 },
107103 rescan: function() {
108104 this.ownerCt.zoneBrowser.rescan();
109105 },
webroot/js/dss/dss-setup-interface/dSS/ZoneBrowser.js
(51 / 57)
  
22//= require <dSS/ZonePanel>
33//= require <dSS/grid/DevicePanel>
44//= require <dSS/MessageBus>
5
65Ext.namespace('dSS');
76
87dSS.ZoneBrowser = Ext.extend(Ext.Panel, {
9 initComponent: function() {
8 initComponent: function() {
109
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 });
2930
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);
3633
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();
4353 },
44 this
45 );
54 failure: function(result, request) {
55 this.el.unmask();
56 Ext.MessageBox.alert(_("Error"), _("Rescan failed"));
57 }
58 });
59 },
4660
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 }
7064
7165});
7266
webroot/js/dss/dss-setup-interface/dSS/ZonePanel.js
(180 / 166)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/ZoneView>
3
43Ext.namespace('dSS');
54
65dSS.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 });
1418
15 this.tbar = this.buildTopToolbar();
19 this.tbar = this.buildTopToolbar();
1620
17 this.zoneSortMode = 0;
21 this.zoneSortMode = 0;
1822
19 dSS.ZonePanel.superclass.initComponent.apply(this, arguments);
20 },
23 dSS.ZonePanel.superclass.initComponent.apply(this, arguments);
24 },
2125
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 },
3540
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 },
4246
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 },
97104
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) {
104111
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) {
114123
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 });
115156
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 },
161176 sortZonesCycle: function() {
162177 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;
184198 }
185199 }
186200});
webroot/js/dss/dss-setup-interface/dSS/ZoneView.js
(184 / 194)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/data/ZoneStore>
33//= require <dSS/data/Loader>
4
54Ext.namespace('dSS');
65
76dSS.ZoneView = Ext.extend(Ext.DataView, {
8 initComponent: function() {
7 initComponent: function() {
98
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>');
2321
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 });
3533
36 dSS.ZoneView.superclass.initComponent.apply(this, arguments);
34 dSS.ZoneView.superclass.initComponent.apply(this, arguments);
3735
38 dSS.data.Loader.getDeviceStore().on(
39 'load',
40 this.updateNumDevicesHeader,
41 this
42 );
36 dSS.data.Loader.getDeviceStore().on('load', this.updateNumDevicesHeader, this);
4337
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) {
4941 /*
5042 var l = nodes.length;
5143 var s = l != 1 ? 's' : '';
5244 this.findParentByType('dsszonepanel').setTitle(gt.ngettext("Zone", "n% Zones", l));
5345 */
54 this.filterDevices();
55 this.updateNumDevicesHeader();
56 },
57 this
58 );
46 this.filterDevices();
47 this.updateNumDevicesHeader();
48 },
49 this);
5950
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);
116105
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 }
127114
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)
134121
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)
141128
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)
148135
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 },
155141
156142 filterDevices: function() {
157143 var selectedZones = this.getSelectedRecords();
158144 var store = dSS.data.Loader.getDeviceStore();
159145
160 if(selectedZones.length === 0) {
146 if (selectedZones.length === 0) {
161147 store.clearFilter();
162148 return;
163149 }
164150 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')) {
167153 return true;
168154 }
169155 }
161161 var count = dSS.data.Loader.getDeviceStore().getRange().length;
162162 var selectedZones = this.getSelectedRecords();
163163 var title = '';
164 if(selectedZones.length === 0) {
164 if (selectedZones.length === 0) {
165165 title = _("Devices in all rooms");
166166 } else {
167167 title = _("Devices in room") + " \"" + selectedZones[0].get('name') + " - " + selectedZones[0].get('id') + "\"";
169169 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>");
170170 },
171171
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 }
183183
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 },
207209
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 }
232236});
233237
234238Ext.reg('dsszoneview', dSS.ZoneView);
webroot/js/dss/dss-setup-interface/dSS/dSMOverviewPanel.js
(10 / 10)
  
11//= require <dSS/grid/ModulatorPanel>
22//= require <dSS/ZonePanel>
3
43Ext.namespace('dSS', 'dSS.system', 'dSS.grid');
54
65dSS.system.dSMOverview = Ext.extend(Ext.Panel, {
99 layout: 'border',
1010 items: [
1111 {
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'
1920 }]
2021 });
21
22
2223 dSS.system.dSMOverview.superclass.initComponent.apply(this, arguments);
23 }
24 }
2425});
2526
2627Ext.reg('dsmoverviewpanel', dSS.system.dSMOverview);
webroot/js/dss/dss-setup-interface/dSS/data/CircuitStore.js
(38 / 22)
  
11Ext.namespace('dSS', 'dSS.data');
22
33dSS.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 }]);
1631
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);
2437
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 }
2844});
webroot/js/dss/dss-setup-interface/dSS/data/DeviceStore.js
(55 / 36)
  
11Ext.namespace('dSS', 'dSS.data');
22
33dSS.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 }
4059});
webroot/js/dss/dss-setup-interface/dSS/data/Loader.js
(0 / 1)
  
11//= require <dSS/data/LoaderImpl>
2
32Ext.namespace('dSS', 'dSS.data');
43
54dSS.data.Loader = (function() {
webroot/js/dss/dss-setup-interface/dSS/data/LoaderImpl.js
(82 / 77)
  
11//= require <dSS/data/ModulatorStore>
22//= require <dSS/data/DeviceStore>
33//= require <dSS/data/ZoneStore>
4
54Ext.namespace('dSS', 'dSS.data');
65
76dSS.data.LoaderImpl = Ext.extend(Ext.util.Observable, {
87
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 },
1415
15 load: function() {
16 this.modulatorStore.load();
17 this.loadStructure();
18 },
16 load: function() {
17 this.modulatorStore.load();
18 this.loadStructure();
19 },
1920
20 getModulatorStore: function() {
21 return this.modulatorStore;
22 },
21 getModulatorStore: function() {
22 return this.modulatorStore;
23 },
2324
24 getDeviceStore: function() {
25 return this.deviceStore;
26 },
25 getDeviceStore: function() {
26 return this.deviceStore;
27 },
2728
28 getZoneStore: function() {
29 return this.zoneStore;
30 },
29 getZoneStore: function() {
30 return this.zoneStore;
31 },
3132
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 },
3254
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 });
6684 });
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 }
9297
9398});
webroot/js/dss/dss-setup-interface/dSS/data/ModulatorStore.js
(81 / 63)
  
11Ext.namespace('dSS', 'dSS.data');
22
33dSS.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 }]);
1838
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);
2644
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);
2950
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;
4667
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;
6075 }
61
62 } else {
63 Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server"));
76 });
77 if (modified === true) {
78 store.commitChanges();
6479 }
65 }
66 catch (err) {
80
81 } else {
6782 Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server"));
6883 }
69 },
70 failure: function(result, request) {
84 }
85 catch(err) {
7186 Ext.MessageBox.alert(_("Error"), _("Could not get metering data from server"));
7287 }
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);
7795 }
7896});
webroot/js/dss/dss-setup-interface/dSS/data/ZoneStore.js
(25 / 19)
  
11Ext.namespace('dSS', 'dSS.data');
22
33dSS.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 }
2329});
webroot/js/dss/dss-setup-interface/dSS/grid/DevicePanel.js
(548 / 480)
  
1010//= requie <dSS/config/Config>
1111//= require <dSS/scene/SceneWindowShadow>
1212//= require <dSS/scene/SceneWindowLight>
13
1413Ext.namespace('dSS', 'dSS.grid');
1514
1615dSS.grid.DevicePanel = Ext.extend(Ext.grid.GridPanel, {
17 initComponent: function() {
16 initComponent: function() {
1817
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) {
2120 metaData.css = 'isDisabled';
2221 }
2322 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 }
2928 }
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 };
3231
3332 var lockRenderer = function(value, metaData, record, rowIndex, colIndex, store) {
34 if(record.get('isPresent') === false) {
33 if (record.get('isPresent') === false) {
3534 metaData.css = 'lockDisabled';
3635 }
3736 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 }
4342 }
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 };
4645
4746 var devTypeRenderer = function(value, metaData, record, rowIndex, colIndex, store) {
4847
49 var present = record.get('isPresent');
48 var present = record.get('isPresent');
5049
51 var fid = dSS.util.parseFunctionID(record.get('functionID'));
50 var fid = dSS.util.parseFunctionID(record.get('functionID'));
5251
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);
5453
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';
9160 }
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 }
9591
92 return retval;
93 };
9694
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 }];
109177
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 });
129197
130198 this.tbar = this.buildTopToolbar();
131199
132 dSS.grid.DevicePanel.superclass.initComponent.apply(this, arguments);
200 dSS.grid.DevicePanel.superclass.initComponent.apply(this, arguments);
133201
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 }
146212
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 }
151217
152 var showRemoveMenuItem = false;
153 var presentInSelection = false;
218 var showRemoveMenuItem = false;
219 var presentInSelection = false;
154220
155 if (sel.getSelected().get("isPresent") === true) {
156 showPingMenuItem = true;
157 }
221 if (sel.getSelected().get("isPresent") === true) {
222 showPingMenuItem = true;
223 }
158224
159 var records = sel.getSelections();
225 var records = sel.getSelections();
160226
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];
164229
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;
177236 }
178237
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;
193240 }
241 }
194242
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)
197249
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 }
206258
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({});
213261
262 if (presentInSelection === true) {
214263 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)
225267 });
226 this.contextMenu.add(menuItem);
268 subMenu.add(menuItem);
227269 }
228270
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);
240277
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);
249284
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 }
256292
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) {
257306 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)
261310 });
262 this.contextMenu.add(menuItem);
311 subMenu.add(menuItem);
263312 }
264313
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);
273320
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 }
279328
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 }
283337
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);
290342
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;
333393 }
334 },
335 this
336 );
337 },
394 }
395 },
396 this);
397 },
338398
339399 buildTopToolbar: function() {
340400 return ['->', {
341401 iconCls: 'copyToClipboardToolbarIcon',
342402 handler: this.showCopyWindow,
343403 scope: this
344 },{
404 },
405 {
345406 iconCls: 'editDeviceToolbarIcon',
346407 handler: this.editDevice,
347408 scope: this
348 },{
409 },
410 {
349411 iconCls: 'pingDeviceToolbarIcon',
350412 handler: this.pingDevice,
351413 scope: this
352 },{
414 },
415 {
353416 iconCls: 'removeDeviceToolbarIcon',
354417 handler: this.removeDevice,
355418 scope: this
356419 }];
357420 },
358421
359 editDevice: function(item, event, rowIndex) {
422 editDevice: function(item, event, rowIndex) {
360423 var record;
361424 // we were called from the toolbar, so its possible that there is
362425 // no device selection yet
363426 var sel = this.getSelectionModel();
364 if (!sel.hasSelection())
365 {
427 if (!sel.hasSelection()) {
366428 Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!"));
367429 return;
368430 }
369431
370 if (sel.getSelections().length > 1)
371 {
432 if (sel.getSelections().length > 1) {
372433 Ext.Msg.alert(_("Multiple devices selected"), _("It is not possible to edit multiple devices simultaneously, please select only one device!"));
373434 return;
374435 }
375436
376437 record = sel.getSelected();
377438
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 },
407471
408 pingDevice: function(item, event, rowIndex) {
472 pingDevice: function(item, event, rowIndex) {
409473 var record;
410474 // we were called from the toolbar, so its possible that there is
411475 // no device selection yet
412476 var sel = this.getSelectionModel();
413 if (!sel.hasSelection())
414 {
477 if (!sel.hasSelection()) {
415478 Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!"));
416479 return;
417480 }
418481
419 if (sel.getSelections().length > 1)
420 {
482 if (sel.getSelections().length > 1) {
421483 Ext.Msg.alert(_("Multiple devices selected"), _("It is not possible to ping multiple devices simultaneously, please select only one device or use extended ping!"));
422484 return;
423485 }
491491 return;
492492 }
493493
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 },
524526
525 extendedPing: function(item, event, rowIndex) {
527 extendedPing: function(item, event, rowIndex) {
526528 var record;
527529 // we were called from the toolbar, so its possible that there is
528530 // no device selection yet
529531 var sel = this.getSelectionModel();
530 if (!sel.hasSelection())
531 {
532 if (!sel.hasSelection()) {
532533 Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!"));
533534 return;
534535 }
538538
539539 var dsids = "";
540540 var deviceArray = [];
541 for (var i = 0; i < records.length; i++)
542 {
541 for (var i = 0; i < records.length; i++) {
543542 if (records[i].get("isPresent") === false) {
544543 continue;
545544 }
547547 device.name = records[i].get("name");
548548 deviceArray.push(device);
549549 dsids += device.dsid;
550 if (i < records.length - 1)
551 dsids += ",";
550 if (i < records.length - 1) dsids += ",";
552551 }
553
552
554553 if (deviceArray.length === 0) {
555554 Ext.Msg.alert(_("No devices present"), _("Your selection contained only non present devices which can not be pinged!"));
556555 return;
557556 }
558557
559558 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 }]);
563567
564568 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,
569573 data: deviceArray
570574 });
571575
578578 var m_now = now.getMinutes();
579579
580580 m_now += 5;
581 if (m_now >= 60)
582 {
581 if (m_now >= 60) {
583582 h_now++;
584583 m_now = m_now - 60;
585584 }
586585
587 if (h_now >= 24)
588 h_now = 0;
586 if (h_now >= 24) h_now = 0;
589587
590588 var sep = ":";
591589
592 if (m_now < 10)
593 sep = sep + "0";
590 if (m_now < 10) sep = sep + "0";
594591
595 var pingForm = new dSS.util.ExtendedPingForm({
592 var pingForm = new dSS.util.ExtendedPingForm({
596593 pingStore: pingStore,
597594 sep: sep,
598595 h_now: h_now,
599596 m_now: m_now
600597 });
601598
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
606603 });
607604
608605 win.show(this);
609 },
606 },
610607
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();
614611
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();
624620
625 var skippedPresent = false;
621 var skippedPresent = false;
626622 var notPresent = new Array();
627623
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];
631626
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) {
634629 skippedPresent = true;
635 continue;
636 }
630 continue;
631 }
637632
638633 notPresent.push(record);
639 }
634 }
640635
641 if (notPresent.length > 0)
642 this.deleteDevice(notPresent);
636 if (notPresent.length > 0) this.deleteDevice(notPresent);
643637 else {
644638 if (skippedPresent === true) {
645639 Ext.MessageBox.alert(_("Warning"), _("Present devices can not be removed!"));
646640 }
647641 }
648 },
642 },
649643
650 deleteDevice : function(records) {
651 var store = this.getStore();
644 deleteDevice: function(records) {
645 var store = this.getStore();
652646 if (records.length < 1) {
653647 this.el.unmask();
654648 return;
650650
651651 var record = records.shift();
652652
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);
665667 this.deleteDevice(records);
666 } else {
668 } else {
667669 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) {
672674 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) {
677679 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 },
682684
683685 sendBlinkRequest: function(record) {
684686 record.set('blink', true);
685687 var unblink = function(record) {
686 record.set('blink', false);
688 record.set('blink', false);
687689 }
688690
689691 Ext.Ajax.request({
693693 disableCaching: true,
694694 method: "GET",
695695 scope: this,
696 params: { dsid : record.get('dsid') },
696 params: {
697 dsid: record.get('dsid')
698 },
697699 success: function(result, request) {
698700 try {
699701 var jsonData = Ext.util.JSON.decode(result.responseText);
700702 if (!jsonData.ok) {
701703 Ext.MessageBox.alert(_("Could not blink"), jsonData.message);
702704 }
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);
706707 }
707 unblink.defer(2000, this, [ record ]);
708 unblink.defer(2000, this, [record]);
708709 },
709710 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]);
713713 }
714714 });
715715 },
716716
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();
720720
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++) {
732730 if (records[i].get('isPresent') === false) {
733731 continue;
734732 }
735733
736734 this.sendBlinkRequest(records[i]);
737735
738 }
739 },
736 }
737 },
740738
741739 showCopyWindow: function() {
742 var csvwindow = new dSS.util.GridToCSVWindow({
743 gridPanel: this,
740 var csvwindow = new dSS.util.GridToCSVWindow({
741 gridPanel: this,
744742 windowWidth: 640,
745743 windowHeight: 480
746744 });
751751 disableCaching: true,
752752 method: 'GET',
753753 scope: this,
754 params: { path: '/system/js/settings/' + property + '/session' },
754 params: {
755 path: '/system/js/settings/' + property + '/session'
756 },
755757 success: function(result, request) {
756758 try {
757759 var jsonData = Ext.util.JSON.decode(result.responseText);
765765 disableCaching: true,
766766 method: 'GET',
767767 scope: this,
768 params: {
768 params: {
769769 path: '/system/js/settings/' + property + '/session',
770 value: new_session
770 value: new_session
771771 },
772772 success: function(result, request) {
773773 try {
777777 } else {
778778 Ext.MessageBox.alert(_("Could not set session value"), jsonData.message);
779779 }
780 } catch (err) {
780 } catch(err) {
781781 Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err);
782782 }
783783 },
788788 } else {
789789 Ext.MessageBox.alert(_("Could not get session value"), jsonData.message);
790790 }
791 } catch (err) {
791 } catch(err) {
792792 Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err);
793793 }
794794 },
804804 disableCaching: true,
805805 method: "GET",
806806 scope: this,
807 params: { subscriptionID : 333, name: "ping_result" },
807 params: {
808 subscriptionID: 333,
809 name: "ping_result"
810 },
808811 success: function(result, request) {
809812 try {
810813 var jsonData = Ext.util.JSON.decode(result.responseText);
811814 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 });
813820 pingResult.show(this);
814821 } else {
815822 Ext.MessageBox.alert(_("Ping subscription error"), jsonData.message);
816823 }
817 } catch (err) {
824 } catch(err) {
818825 Ext.MessageBox.alert(_("Error"), _("Could send subscribe command to dSS") + ": " + err);
819826 }
820827 },
831831 });
832832 },
833833
834 deviceStatistics: function(item, event, rowIndex) {
834 deviceStatistics: function(item, event, rowIndex) {
835835 var record;
836836 // we were called from the toolbar, so its possible that there is
837837 // no device selection yet
838838 var sel = this.getSelectionModel();
839 if (!sel.hasSelection())
840 {
839 if (!sel.hasSelection()) {
841840 Ext.Msg.alert(_("No device selected"), _("Please select a device from the list!"));
842841 return;
843842 }
845845
846846 var dsids = "";
847847 var deviceArray = [];
848 for (var i = 0; i < records.length; i++)
849 {
848 for (var i = 0; i < records.length; i++) {
850849 if (records[i].get("isPresent") === false) {
851850 continue;
852851 }
854854 device.name = records[i].get("name");
855855 deviceArray.push(device);
856856 dsids += device.dsid;
857 if (i < records.length - 1)
858 dsids += ",";
857 if (i < records.length - 1) dsids += ",";
859858 }
860
859
861860 if (deviceArray.length === 0) {
862861 Ext.Msg.alert(_("No devices present"), _("Your selection contained only non present devices!"));
863862 return;
864863 }
865864
866865 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 }]);
870874
871875 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,
876880 data: deviceArray
877881 });
878882
885885 var m_now = now.getMinutes();
886886
887887 m_now += 5;
888 if (m_now >= 60)
889 {
888 if (m_now >= 60) {
890889 h_now++;
891890 m_now = m_now - 60;
892891 }
893892
894 if (h_now >= 24)
895 h_now = 0;
893 if (h_now >= 24) h_now = 0;
896894
897895 var sep = ":";
898896
899 if (m_now < 10)
900 sep = sep + "0";
897 if (m_now < 10) sep = sep + "0";
901898
902 var statsForm = new dSS.util.DeviceStatisticsForm({
899 var statsForm = new dSS.util.DeviceStatisticsForm({
903900 statisticsStore: statsStore,
904901 sep: sep,
905902 h_now: h_now,
906903 m_now: m_now
907904 });
908905
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
913910 });
914911
915912 win.show(this);
916 }
913 }
917914});
918915
919916Ext.reg('dssdevicepanel', dSS.grid.DevicePanel);
webroot/js/dss/dss-setup-interface/dSS/grid/ModulatorPanel.js
(296 / 276)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/data/Loader>
33//= require <dSS/util/DSMStatisticsWindow>
4
54Ext.namespace('dSS', 'dSS.grid', 'dSS.data', 'dSS.config');
65
76dSS.grid.ModulatorPanel = Ext.extend(Ext.grid.GridPanel, {
87 initComponent: function() {
98
109 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 }];
1638
17 var rowSelect = new Ext.grid.RowSelectionModel({singleSelect : true});
39 var rowSelect = new Ext.grid.RowSelectionModel({
40 singleSelect: true
41 });
1842
1943 this.heightConfigured = false;
2044
2145 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,
2953 viewConfig: {
3054 autoFill: true,
3155 getRowClass: function(record, index) {
6666
6767 dSS.grid.ModulatorPanel.superclass.initComponent.apply(this, arguments);
6868
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);
7974 }
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 }
9175
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 }
9385
94 if (!sel.hasSelection()) {
95 sel.selectRow(rowIndex, false);
96 }
86 var sel = this.getSelectionModel();
9787
98 var showRemoveMenuItem = false;
88 if (!sel.hasSelection()) {
89 sel.selectRow(rowIndex, false);
90 }
9991
100 var records = sel.getSelections();
92 var showRemoveMenuItem = false;
10193
102 for (var i = 0; i < records.length; i++)
103 {
104 var record = records[i];
94 var records = sel.getSelections();
10595
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;
111103 }
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 }
118105
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 });
120111
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) {
121122 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)
125126 });
126127 this.contextMenu.add(menuItem);
128 }
127129
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();
137131
138 var record = sel.getSelected();
132 if (dSS.config.features.dsmStatistics === true) {
133 var subMenu = new Ext.menu.Menu({});
139134
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) {
152136 var menuItem = new Ext.menu.Item({
153 text: _("Abort meter statistics session"),
137 text: _("Meter statistics"),
154138 icon: '/images/application_osx_terminal.png',
155 handler: this.abortStatisticsRound.createDelegate(this, rowIndex, true)
139 handler: this.dsmStatistics.createDelegate(this, rowIndex, true)
156140 });
157141 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);
165142 }
166143
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);
172150
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
182155 });
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);
186174 },
187175 buildTopToolbar: function() {
188176 return [
177 {
178 cls: 'zonePanelMenu',
179 menu: [
189180 {
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,
206183 scope: this
207184 },
208185 {
209 iconCls: 'reloadAction',
210 handler: this.removeInactiveDevices,
186 text: _("Rescan"),
187 handler: this.rescan,
211188 scope: this
212 },
213 {
214 iconCls: 'removeDeviceToolbarIcon',
215 handler: this.removeInactiveMeters,
216 scope: this
217189 }]
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 }]
218206 },
219207
220208 editDevice: function(item, event, rowIndex) {
221209 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')) {
224212 Ext.Ajax.request({
225213 url: '/json/circuit/setName',
226214 disableCaching: true,
227215 method: "GET",
228 params: { id: record.get('dsid'),
229 newName: text},
216 params: {
217 id: record.get('dsid'),
218 newName: text
219 },
230220 success: function(result, request) {
231221 try {
232222 var jsonData = Ext.util.JSON.decode(result.responseText);
233 if(jsonData.ok) {
223 if (jsonData.ok) {
234224 record.set('name', text);
235225 record.commit();
236226 } else {
237227 Ext.MessageBox.alert(_("Error"), _("Could not rename meter"));
238228 }
239229 }
240 catch (err) {
230 catch(err) {
241231 Ext.MessageBox.alert(_("Error"), _("Could not rename meter"));
242232 }
243233 },
236236 }
237237 });
238238 }
239 }, this, false, record.get('name'));
239 },
240 this, false, record.get('name'));
240241 },
241242 setInitialSelection: function() {
242243 if (this.getStore().getCount() == 0) {
261261 this.getSelectionModel().fireEvent('rowselect', this.getSelectionModel(), index, record);
262262 },
263263 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"));
280290 }
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 });
290292 },
291293 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) {
313317 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 }
317321 }
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
335337 },
336338 showCopyWindow: function() {
337 var csvwindow = new dSS.util.GridToCSVWindow({
339 var csvwindow = new dSS.util.GridToCSVWindow({
338340 gridPanel: this,
339341 windowWidth: 640,
340342 windowHeight: 120
341343 });
342344 csvwindow.show(this);
343345 },
344
346
345347 dsmStatistics: function(item, event, rowIndex) {
346348 var record;
347349 // we were called from the toolbar, so its possible that there is
348350 // no device selection yet
349351 var sel = this.getSelectionModel();
350 if (!sel.hasSelection())
351 {
352 if (!sel.hasSelection()) {
352353 Ext.Msg.alert(_("No meter selected"), _("Please select a meter from the list!"));
353354 return;
354355 }
355
356
356357 records = sel.getSelections();
357
358
358359 var dsms = "";
359360 var dsmArray = [];
360 for (var i = 0; i < records.length; i++)
361 {
361 for (var i = 0; i < records.length; i++) {
362362 if (records[i].get("isPresent") === false) {
363363 continue;
364364 }
368368 dsm.busid = records[i].get("busId");
369369 dsmArray.push(dsm);
370370 dsms += dsm.dsid;
371 if (i < records.length - 1)
372 dsms += ",";
371 if (i < records.length - 1) dsms += ",";
373372 }
374
373
375374 if (dsmArray.length === 0) {
376375 Ext.Msg.alert(_("No meters present"), _("Your selection contained only non present meters!"));
377376 return;
378377 }
379
378
380379 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
386393 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,
391398 data: dsmArray
392399 });
393400 var now = new Date();
394401 var h_now = now.getHours();
395402 var m_now = now.getMinutes();
396
403
397404 m_now += 5;
398 if (m_now >= 60)
399 {
405 if (m_now >= 60) {
400406 h_now++;
401407 m_now = m_now - 60;
402408 }
403
404 if (h_now >= 24)
405 h_now = 0;
406
409
410 if (h_now >= 24) h_now = 0;
411
407412 var sep = ":";
408
409 if (m_now < 10)
410 sep = sep + "0";
411
413
414 if (m_now < 10) sep = sep + "0";
415
412416 var statsForm = new dSS.util.DeviceStatisticsForm({
413417 statisticsStore: statsStore,
414418 sep: sep,
415419 h_now: h_now,
416420 m_now: m_now
417421 });
418
422
419423 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
423427 });
424
428
425429 win.show(this);
426430 },
427431 abortStatisticsRound: function() {
434434 disableCaching: true,
435435 method: 'GET',
436436 scope: this,
437 params: { path: '/system/js/settings/dsmStatistics/session' },
437 params: {
438 path: '/system/js/settings/dsmStatistics/session'
439 },
438440 success: function(result, request) {
439441 try {
440442 var jsonData = Ext.util.JSON.decode(result.responseText);
460460 } else {
461461 Ext.MessageBox.alert(_("Could not set statistics session value"), jsonData.message);
462462 }
463 } catch (err) {
463 } catch(err) {
464464 Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err);
465465 }
466466 },
471471 } else {
472472 Ext.MessageBox.alert(_("Could not get dSM statistics session value"), jsonData.message);
473473 }
474 } catch (err) {
474 } catch(err) {
475475 Ext.MessageBox.alert(_("Error"), _("Could send command to dSS") + ": " + err);
476476 }
477477 },
487487 // we were called from the toolbar, so its possible that there is
488488 // no meter selection yet
489489 var sel = this.getSelectionModel();
490 if (!sel.hasSelection())
491 {
490 if (!sel.hasSelection()) {
492491 Ext.MessageBox.alert(_("No meter selected"), _("Please select a meter from the list!"));
493492 return;
494493 }
496496 var skippedPresent = false;
497497 var notPresent = new Array();
498498
499 for (var i = 0; i < records.length; i++)
500 {
499 for (var i = 0; i < records.length; i++) {
501500 var record = records[i];
502501
503502 // do not issue the ajax request if we know that it will fail
508508 notPresent.push(record);
509509 }
510510
511 if (notPresent.length > 0)
512 this.deleteMeter(notPresent);
511 if (notPresent.length > 0) this.deleteMeter(notPresent);
513512 else {
514513 if (skippedPresent === true) {
515514 Ext.MessageBox.alert(_("Warning"), _("Present meters can not be removed!"));
516515 }
517516 }
518517 },
519 deleteMeter : function(records) {
518 deleteMeter: function(records) {
520519 var store = this.getStore();
521520 if (records.length < 1) {
522521 this.el.unmask();
524524
525525 var record = records.shift();
526526
527 this.el.mask(_("Deleting meter") + ": " + record.get("dsid"));
527 this.el.mask(_("Deleting meter") + ": " + record.get("dsid"));
528528 Ext.Ajax.request({
529529 url: '/json/apartment/removeMeter',
530530 disableCaching: true,
531531 method: "GET",
532532 scope: this,
533 params: { dsid : record.get('dsid') },
533 params: {
534 dsid: record.get('dsid')
535 },
534536 success: function(result, request) {
535537 try {
536538 var jsonData = Ext.util.JSON.decode(result.responseText);
537 if(jsonData.ok) {
539 if (jsonData.ok) {
538540 store.remove(record);
539541 this.deleteMeter(records);
540542 } else {
544544 Ext.MessageBox.alert(_("Could not remove"), jsonData.message);
545545 }
546546 }
547 catch (err) {
547 catch(err) {
548548 this.el.unmask();
549549 Ext.MessageBox.alert(_("Error"), _("Could send remove meter command to dSS") + ": " + err);
550550 }
556556 });
557557 },
558558 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 });
581581 },
582582 rescan: function() {
583583 this.ownerCt.ownerCt.zoneBrowser.rescan();
webroot/js/dss/dss-setup-interface/dSS/grid/jsLogFilesPanel.js
(51 / 53)
  
11//= require <dSS/GetTextHelper>
2
32Ext.namespace('dSS', 'dSS.system');
43
54dSS.system.jsLogFilesPanel = Ext.extend(Ext.grid.GridPanel, {
65 initComponent: function() {
76 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 }]);
1115
1216 this.logFileStore = new Ext.data.ArrayStore({
1317 storeId: "logFileStore",
2020
2121 Ext.apply(this, {
2222 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 }],
3135 store: this.logFileStore,
3236 stripeRows: true,
3337 autoScroll: true,
3438 autoExpandColumn: "logfile",
3539 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 }
3846 });
3947
4048 dSS.system.jsLogFilesPanel.superclass.initComponent.apply(this, arguments);
4149
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);
4954
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);
6264
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);
7270 },
7371
7472 fillStore: function() {
7474 url: "/json/property/getChildren",
7575 method: "GET",
7676 scope: this,
77 params: { path: "/system/js/logsfiles" },
77 params: {
78 path: "/system/js/logsfiles"
79 },
7880 success: function(result, request) {
7981 try {
8082 var jsonData = Ext.util.JSON.decode(result.responseText);
8183 if (jsonData.ok) {
8284 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>";
8886 jsonData.result[i].download = link;
8987 var r = new this.logFileRecord(
90 jsonData.result[i]
91 );
88 jsonData.result[i]);
9289
93 if (this.logFileStore.findExact("name",
94 r.get("name")) == -1) {
90 if (this.logFileStore.findExact("name", r.get("name")) == - 1) {
9591 this.logFileStore.add([r]);
9692 }
9793 }
9894 } else {
9995 Ext.MessageBox.alert(_("Error"), _("Could not get properties from dSS"));
10096 }
101 } catch (err) {
97 } catch(err) {
10298 Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS") + ": " + err);
10399 }
104100 },
webroot/js/dss/dss-setup-interface/dSS/scene/SceneWindowLight.js
(195 / 199)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/config/Config>
33//= require <dSS/util/Util>
4
54Ext.namespace("dSS", "dSS.scene", "dSS.config", "dSS.util");
65
76// parameters:
88// dsid
99dSS.scene.SceneWindowLight = Ext.extend(Ext.Window, {
1010 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 });
2424
2525 this.dsid = config.dsid;
2626
2727 Ext.apply(this, {
2828 layout: 'fit',
29 width: 370,
29 width: 370,
3030 height: 220,
31 resizable : false,
31 resizable: false,
3232 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: [
3652 {
3753 xtype: 'panel',
38 bodyCfg: { cls: 'x-window-body' },
54 bodyCfg: {
55 cls: 'x-window-body'
56 },
57 colspan: 6,
58 html: '',
59 height: 30,
3960 bodyBorder: false,
4061 border: false,
4162 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,
4385 layout: 'table',
44 layoutConfig:
45 {
46 columns : 6,
47 tableAttrs: { width: '100%' }
86 layoutConfig: {
87 columns: 3,
88 tableAttrs: {
89 width: '100%'
90 }
4891 },
4992 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'
6797 },
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'
76108 },
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'
211113 }
114 },
115
212116 ]
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 {
216217 text: _("Close"),
217218 scope: this,
218 handler: function()
219 {
219 handler: function() {
220220 // close ping form dialog
221221 this.maskElement.unmask();
222222 this.close();
225225 });
226226
227227 dSS.scene.SceneWindowLight.superclass.constructor.apply(this, arguments);
228
228
229229 this.maskElement.mask();
230230
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
239236 },
240237 handleSliderChanged: function(slider, newVal, thumb) {
241238 this.messagePanel.update(_("Brightness set to") + ": " + newVal + "%");
243243 } else if (value > 255) {
244244 value = 255;
245245 }
246
246
247247 dSS.util.setValueOnDevice(this.dsid, Math.round(value));
248248 }
249249});
webroot/js/dss/dss-setup-interface/dSS/scene/SceneWindowShadow.js
(84 / 91)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/config/Config>
3
43Ext.namespace("dSS", "dSS.scene", "dSS.config");
54
65// parameters:
1010
1111 Ext.apply(this, {
1212 layout: 'fit',
13 width: 300,
13 width: 300,
1414 height: 145,
15 resizable : false,
15 resizable: false,
1616 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: [
2036 {
2137 xtype: 'panel',
22 bodyCfg: { cls: 'x-window-body' },
38 bodyCfg: {
39 cls: 'x-window-body'
40 },
41 colspan: 5,
42 html: '',
43 height: 30,
2344 bodyBorder: false,
2445 border: false,
2546 frame: false,
26 hideBorders: true,
27 layout: 'table',
28 layoutConfig:
29 {
30 columns : 5,
31 tableAttrs: { width: '100%' }
32 },
3347 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 },
6062
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 {
10199 text: _("Close"),
102100 scope: this,
103 handler: function()
104 {
101 handler: function() {
105102 // close ping form dialog
106103 this.maskElement.unmask();
107104 this.close();
107107 });
108108
109109 dSS.scene.SceneWindowShadow.superclass.constructor.apply(this, arguments);
110
110
111111 this.maskElement.mask();
112112
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
121118 }
122119});
webroot/js/dss/dss-setup-interface/dSS/system/PropertyTree.js
(67 / 62)
  
11//= require <dSS/tree/PropertyTreeLoader>
2
32Ext.namespace('dSS', 'dSS.system');
43
54dSS.system.PropertyTree = Ext.extend(Ext.Panel, {
6 initComponent: function() {
5 initComponent: function() {
76
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 });
3537
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 }
6974});
7075
7176Ext.reg('dsssystempropertytree', dSS.system.PropertyTree);
webroot/js/dss/dss-setup-interface/dSS/system/jsLogFiles.js
(24 / 27)
  
11//= require <dSS/grid/jsLogFilesPanel>
2
32Ext.namespace('dSS', 'dSS.system', 'dSS.grid');
43
54dSS.system.jsLogFiles = Ext.extend(Ext.Panel, {
65 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 });
1213
1314 this.heightConfigured = false;
14
15
1516 Ext.apply(this, {
1617 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
2224 },
23 this.textPanel
24 ]
25 this.textPanel]
2526 });
26
27
2728 dSS.system.jsLogFiles.superclass.initComponent.apply(this, arguments);
2829
29 this.on(
30 "activate",
31 function(component) {
32 this.jsLogFilesPanel.fireEvent("activate");
30 this.on("activate", function(component) {
31 this.jsLogFilesPanel.fireEvent("activate");
3332
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);
4239 },
4340
4441 loadLog: function(logname) {
webroot/js/dss/dss-setup-interface/dSS/system/logfiles.js
(16 / 9)
  
1
21Ext.namespace('dSS', 'dSS.system');
32
43dSS.system.logfiles = Ext.extend(Ext.Panel, {
55 Ext.apply(this, {
66 layout: 'table',
77 title: _("Logfiles"),
8 defaults: { border: false },
9 layoutConfig: {
8 defaults: {
9 border: false
10 },
11 layoutConfig: {
1012 columns: 2,
1113 tableAttrs: {
1214 width: '100%'
1315 }
1416 },
15 items: [{
17 items: [
18 {
1619 colspan: 2,
1720 html: '<h2>LOGFILES</h2>'
18 },{
21 },
22 {
1923 width: '70%',
2024 html: '<h2>This is a placeholder</h2><p>Sample text.<br/><br/><br/></p>'
21 },{
25 },
26 {
2227 html: '<p class="x-green-button-link"><a href="/images/ds_logo.gif">sample link</a></p>'
23 },{
28 },
29 {
2430 colspan: 2,
2531 html: '<h2>CONFIGURATION FILES</h2>'
26 },{
32 },
33 {
2734 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 {
2937 html: '<p class="x-green-button-link"><a href="/download/apartment.xml" target=":_blank">apartment.xml</a></p>'
3038 }]
3139 });
webroot/js/dss/dss-setup-interface/dSS/tree/PropertyTreeLoader.js
(56 / 50)
  
11Ext.namespace('dSS', 'dSS.tree');
22
33dSS.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 }
5460});
webroot/js/dss/dss-setup-interface/dSS/util/DSMStatisticsWindow.js
(25 / 36)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/PingEventWindow>
3
43Ext.namespace("dSS", "dSS.util");
54
65dSS.util.DSMStatisticsWindow = Ext.extend(Ext.Window, {
76 initComponent: function() {
87 Ext.apply(this, {
98 layout: "fit",
10 width: 380,
9 width: 380,
1110 height: 475,
12 items: [ this.form ],
13 buttons:[{
11 items: [this.form],
12 buttons: [
13 {
1414 text: _("OK"),
1515 formBind: true,
1616 scope: this,
17 handler: function()
18 {
19 if (!this.form.getForm().isValid())
20 {
17 handler: function() {
18 if (!this.form.getForm().isValid()) {
2119 return;
2220 }
2321
3030 d.setHours(hours);
3131 d.setMinutes(minutes);
3232
33 if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes()))
34 {
33 if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) {
3534 Ext.MessageBox.alert(_("Error"), _("Event time must be in the future!"));
3635 return;
3736 }
3837
39 function pad(n){ return n < 10 ? '0' + n : n }
38 function pad(n) {
39 return n < 10 ? '0' + n: n
40 }
4041
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' + ";";
4743 }
4844
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;
5346
5447 // close statistics form dialog
5548 this.maskElement.unmask();
5050
5151 this.raiseStatisticsEvent(param, param_time.length);
5252 }
53 },{
53 },
54 {
5455 text: _("Cancel"),
55 scope : this,
56 handler: function()
57 {
56 scope: this,
57 handler: function() {
5858 this.close();
5959 this.maskElement.unmask();
6060 }
6262 });
6363
6464 dSS.util.DSMStatisticsWindow.superclass.initComponent.apply(this, arguments);
65
65
6666 this.maskElement.mask();
6767 },
6868 raiseStatisticsEvent: function(param, later) {
7171 disableCaching: true,
7272 method: "GET",
7373 scope: this,
74 params: { name: "dsm_statistics", parameter: param },
74 params: {
75 name: "dsm_statistics",
76 parameter: param
77 },
7578 success: function(result, request) {
7679 try {
7780 var jsonData = Ext.util.JSON.decode(result.responseText);
78 if(jsonData.ok) {
81 if (jsonData.ok) {
7982 var title = _("Statistics result information");
8083 var message = _("The statistics results can be viewed in the js plugin log files section");
8184 var file = dSS.config.settings["dsmStatistics"].logfile;
8285
8386 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>";
9088 } else {
9189 message = message + ".";
9290 }
9999 Ext.MessageBox.alert(_("Statistics error"), jsonData.message);
100100 }
101101 }
102 catch (err) {
102 catch(err) {
103103 Ext.MessageBox.alert(_("Error"), _("Could send statistics command to dSS") + ": " + err);
104104 }
105105 },
107107 Ext.MessageBox.alert(_("Error"), _("Could send stat command to dSS"));
108108 }
109109 });
110
110
111111 }
112112});
113113
webroot/js/dss/dss-setup-interface/dSS/util/DeviceStatisticsForm.js
(56 / 56)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/RadioTextField>
3
43Ext.namespace("dSS", "dSS.util");
54
65dSS.util.DeviceStatisticsForm = Ext.extend(Ext.FormPanel, {
1010 title: _("Device Statistics Settings"),
1111 labelWidth: 135,
1212 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 })]
6869
6970 });
7071
webroot/js/dss/dss-setup-interface/dSS/util/DeviceStatisticsWindow.js
(27 / 38)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/PingEventWindow>
3
43Ext.namespace("dSS", "dSS.util");
54
65dSS.util.DeviceStatisticsWindow = Ext.extend(Ext.Window, {
76 initComponent: function() {
87 Ext.apply(this, {
98 layout: "fit",
10 width: 380,
9 width: 380,
1110 height: 475,
12 items: [ this.form ],
13 buttons:[{
11 items: [this.form],
12 buttons: [
13 {
1414 text: _("OK"),
1515 formBind: true,
1616 scope: this,
17 handler: function()
18 {
19 if (!this.form.getForm().isValid())
20 {
17 handler: function() {
18 if (!this.form.getForm().isValid()) {
2119 return;
2220 }
2321
3030 d.setHours(hours);
3131 d.setMinutes(minutes);
3232
33 if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes()))
34 {
33 if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) {
3534 Ext.MessageBox.alert(_("Error"), _("Event time must be in the future!"));
3635 return;
3736 }
3837
39 function pad(n){ return n < 10 ? '0' + n : n }
38 function pad(n) {
39 return n < 10 ? '0' + n: n
40 }
4041
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' + ";";
4743 }
4844
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;
5346
5447 // close statistics form dialog
5548 this.maskElement.unmask();
5050
5151 this.raiseStatisticsEvent(param, param_time.length);
5252 }
53 },{
53 },
54 {
5455 text: _("Cancel"),
55 scope : this,
56 handler: function()
57 {
56 scope: this,
57 handler: function() {
5858 this.close();
5959 this.maskElement.unmask();
6060 }
6262 });
6363
6464 dSS.util.DeviceStatisticsWindow.superclass.initComponent.apply(this, arguments);
65
65
6666 this.maskElement.mask();
6767 },
6868 raiseStatisticsEvent: function(param, later) {
7171 disableCaching: true,
7272 method: "GET",
7373 scope: this,
74 params: { name: "device_statistics", parameter: param },
74 params: {
75 name: "device_statistics",
76 parameter: param
77 },
7578 success: function(result, request) {
7679 try {
7780 var jsonData = Ext.util.JSON.decode(result.responseText);
78 if(jsonData.ok) {
81 if (jsonData.ok) {
7982 var title = _("Statistics result information");
8083 var message = _("The statistics results can be viewed in the js plugin log files section");
8184 var file = dSS.config.settings["deviceStatistics"].logfile;
8285
8386 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 {
9189 message = message + ".";
92 }
90 }
9391
9492 Ext.MessageBox.show({
9593 title: title,
9999 Ext.MessageBox.alert(_("Statistics error"), jsonData.message);
100100 }
101101 }
102 catch (err) {
102 catch(err) {
103103 Ext.MessageBox.alert(_("Error"), _("Could send statistics command to dSS") + ": " + err);
104104 }
105105 },
107107 Ext.MessageBox.alert(_("Error"), _("Could send stat command to dSS"));
108108 }
109109 });
110
110
111111 }
112112});
113113
webroot/js/dss/dss-setup-interface/dSS/util/ExtendedPingForm.js
(57 / 57)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/RadioTextField>
3
43Ext.namespace("dSS", "dSS.util");
54
65dSS.util.ExtendedPingForm = Ext.extend(Ext.FormPanel, {
1010 title: _("Extended Ping Settings"),
1111 labelWidth: 135,
1212 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 })]
6970
7071 });
7172
webroot/js/dss/dss-setup-interface/dSS/util/ExtendedPingWindow.js
(34 / 33)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/PingEventWindow>
3
43Ext.namespace("dSS", "dSS.util");
54
65dSS.util.ExtendedPingWindow = Ext.extend(Ext.Window, {
76 initComponent: function() {
87 Ext.apply(this, {
98 layout: "fit",
10 width: 380,
9 width: 380,
1110 height: 465,
12 items: [ this.form ],
13 buttons:[{
11 items: [this.form],
12 buttons: [
13 {
1414 text: _("OK"),
1515 formBind: true,
1616 scope: this,
17 handler: function()
18 {
19 if (!this.form.getForm().isValid())
20 {
17 handler: function() {
18 if (!this.form.getForm().isValid()) {
2119 return;
2220 }
2321
3030 d.setHours(hours);
3131 d.setMinutes(minutes);
3232
33 if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes()))
34 {
33 if ((hours * 60 + minutes) <= (current.getHours() * 60 + current.getMinutes())) {
3534 Ext.MessageBox.alert(_("Error"), _("Event time must be in the future!"));
3635 return;
3736 }
3837
39 function pad(n){ return n < 10 ? '0' + n : n }
38 function pad(n) {
39 return n < 10 ? '0' + n: n
40 }
4041
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' + ";";
4743 }
4844
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;
5346
5447 // close ping form dialog
5548 this.maskElement.unmask();
6262 disableCaching: true,
6363 method: "GET",
6464 scope: this,
65 params: { subscriptionID : 333, name: "ping_result" },
65 params: {
66 subscriptionID: 333,
67 name: "ping_result"
68 },
6669 success: function(result, request) {
6770 try {
6871 var jsonData = Ext.util.JSON.decode(result.responseText);
7474 } else {
7575 Ext.MessageBox.alert(_("Ping subscription error"), jsonData.message);
7676 }
77 } catch (err) {
77 } catch(err) {
7878 Ext.MessageBox.alert(_("Error"), _("Could send subscribe command to dSS") + ": " + err);
7979 }
8080 },
8484 });
8585 }
8686 }
87 },{
87 },
88 {
8889 text: _("Cancel"),
89 scope : this,
90 handler: function()
91 {
90 scope: this,
91 handler: function() {
9292 this.close();
9393 this.maskElement.unmask();
9494 }
9696 });
9797
9898 dSS.util.ExtendedPingWindow.superclass.initComponent.apply(this, arguments);
99
99
100100 this.maskElement.mask();
101101 },
102102 raisePingEvent: function(param, later) {
105105 disableCaching: true,
106106 method: "GET",
107107 scope: this,
108 params: { name: "ping", parameter: param },
108 params: {
109 name: "ping",
110 parameter: param
111 },
109112 success: function(result, request) {
110113 try {
111114 var jsonData = Ext.util.JSON.decode(result.responseText);
112 if(jsonData.ok) {
115 if (jsonData.ok) {
113116 if (later > 0) {
114117 var title = _("Ping result information");
115118 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.");
123123 minWidth: 300
124124 });
125125 } 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 });
127131 pingResult.show(this);
128132 }
129133 } else {
130134 Ext.MessageBox.alert(_("Ping error"), jsonData.message);
131135 }
132136 }
133 catch (err) {
137 catch(err) {
134138 Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS") + ": " + err);
135139 }
136140 },
142142 Ext.MessageBox.alert(_("Error"), _("Could send ping command to dSS"));
143143 }
144144 });
145
145
146146 }
147147});
148148
webroot/js/dss/dss-setup-interface/dSS/util/GridToCSVWindow.js
(24 / 37)
  
11//= require <dSS/GetTextHelper>
2
32Ext.namespace("dSS", "dSS.util");
43
54dSS.util.GridToCSVWindow = Ext.extend(Ext.Window, {
6 constructor: function(config)
7 {
5 constructor: function(config) {
86 var records;
97
108 // we were called from the toolbar, so its possible that there is
119 // no device selection yet
1210 var sel = config.gridPanel.getSelectionModel();
1311 var all = false;
14 if (!sel.hasSelection())
15 {
12 if (!sel.hasSelection()) {
1613 sel.selectAll();
1714 all = true;
1815 }
2020
2121 var csvData = "";
2222 var csvHeader = "";
23 for (i = 0; i < records.length; i++)
24 {
23 for (i = 0; i < records.length; i++) {
2524 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)) {
3027 var colId = col.getColumnId(j);
31 if (colId === "on")
32 continue;
28 if (colId === "on") continue;
3329
3430 // render csv header
35 if (i === 0)
36 {
31 if (i === 0) {
3732 var sep = "";
38 if ((j > 0) && (csvHeader != ""))
39 sep = ",";
33 if ((j > 0) && (csvHeader != "")) sep = ",";
4034
41 csvHeader = csvHeader + sep + col.getColumnHeader(j);
35 csvHeader = csvHeader + sep + col.getColumnHeader(j);
4236 }
4337
4438 var val = records[i].get(colId);
45 if (val === undefined)
46 val = "";
39 if (val === undefined) val = "";
4740
4841 var sep = "";
49 if ((j > 0) && (line != ""))
50 sep = ",";
42 if ((j > 0) && (line != "")) sep = ",";
5143
52
5344 line = line + sep + val;
5445 }
5546 }
4949
5050 csvData = csvHeader + "<br/>" + csvData;
5151
52 if (all === true)
53 sel.clearSelections();
52 if (all === true) sel.clearSelections();
5453
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: [
6160 new Ext.Panel({
6261 region: "center",
6362 autoScroll: true,
6463 layout: "fit",
6564 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 }]
7271 });
7372
7473 dSS.util.GridToCSVWindow.superclass.constructor.apply(this, arguments);
webroot/js/dss/dss-setup-interface/dSS/util/PingEventWindow.js
(131 / 99)
  
11//= require <dSS/GetTextHelper>
2
32Ext.namespace("dSS", "dSS.util");
43
54dSS.util.PingEventWindow = Ext.extend(Ext.Window, {
6 constructor: function(config)
7 {
5 constructor: function(config) {
86 // special session id used throughout the code
97 this.sid = 333;
108
1313 this.maskElement = config.maskElement;
1414
1515 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 }]);
2444
2545 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
3050 });
3151
32 this.resultPanel = new Ext.grid.GridPanel({ /*
52 this.resultPanel = new Ext.grid.GridPanel({
53 /*
3354 colModel: new Ext.grid.ColumnModel({
3455 defaults: { sortable : false }
3556 }),*/
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>";
74104 }
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 });
87121
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 }]
98133 });
99134
100135 dSS.util.PingEventWindow.superclass.constructor.apply(this, arguments);
101136 this.maskElement.mask();
102137
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);
110142
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);
119148 },
120149
121150 getNextEvent: function() {
155155 disableCaching: true,
156156 method: "GET",
157157 scope: this,
158 params: { subscriptionID : 333, name: "ping_result" },
158 params: {
159 subscriptionID: 333,
160 name: "ping_result"
161 },
159162 success: function(result, request) {
160163 try {
161164 var jsonData = Ext.util.JSON.decode(result.responseText);
162165 if (!jsonData.ok) {
163166 Ext.MessageBox.alert(_("Ping event unsubscribe error"), jsonData.message);
164167 }
165 } catch (err) {
168 } catch(err) {
166169 Ext.MessageBox.alert(_("Error"), _("Could not send unsubscribe command to dSS") + ": " + err);
167170 }
168171 },
181181 url: "/json/event/get",
182182 method: "GET",
183183 scope: this,
184 params: { subscriptionID : this.sid, timeout : "2000" },
184 params: {
185 subscriptionID: this.sid,
186 timeout: "2000"
187 },
185188 success: function(result, request) {
186189 try {
187190 var jsonData = Ext.util.JSON.decode(result.responseText);
188191 if (jsonData.ok) {
189192 for (i = 0; i < jsonData.result.events.length; i++) {
190193 var r = new this.eventRecord(
191 jsonData.result.events[i].properties
192 );
194 jsonData.result.events[i].properties);
193195 this.pingEventStore.add([r]);
194196 }
195
197
196198 this.getNextEvent();
197199
198200 } else {
199201 Ext.MessageBox.alert(_("Error"), _("Could not get ping event from dSS"));
200202 }
201 } catch (err) {
203 } catch(err) {
202204 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);
204206 }
205207 },
206208 failure: function(result, request) {
webroot/js/dss/dss-setup-interface/dSS/util/RadioTextField.js
(23 / 22)
  
33dSS.util.RadioTimeField = Ext.extend(Ext.Panel, {
44 constructor: function(config) {
55
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 });
710
811 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
1417 });
1518
1619 if (config.timeFieldEnabled === false) {
2424 layout: "column",
2525 height: 40,
2626 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]
3131 });
3232
3333 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 }
4334
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);
4745 }
4846});
4947
webroot/js/dss/dss-setup-interface/dSS/util/TimeInfo.js
(53 / 28)
  
1function 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 }
1function 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 }
1945
20 if (hour < 10)
21 hour = ('0' + hour);
46 if (hour < 10) hour = ('0' + hour);
2247
23 if (minute < 10)
24 minute = ('0' + minute);
48 if (minute < 10) minute = ('0' + minute);
2549 /*
2650 if (second < 10)
2751 second = ('0' + second);
2852 */
29 return month + ' ' + date + ' ' + hour + ':' + minute + ', ' + year; // + '.' + second;
53 return month + ' ' + date + ' ' + hour + ':' + minute + ', ' + year; // + '.' + second;
3054}
3155
32function 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);
56function 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);
3762}
webroot/js/dss/dss-setup-interface/dSS/util/Util.js
(35 / 39)
  
55 var dSsubclass = (functionID & 0xfc0) >> 6;
66 var dSfuncModule = (functionID & 0x3f);
77
8 return [ dSclass, dSsubclass, dSfuncModule ];
8 return [dSclass, dSsubclass, dSfuncModule];
99}
1010
1111dSS.util.callScene = function(dsid, sceneNumber) {
1313 url: '/json/device/callScene',
1414 disableCaching: true,
1515 method: "GET",
16 params: { dsid : dsid,
17 sceneNumber : sceneNumber },
16 params: {
17 dsid: dsid,
18 sceneNumber: sceneNumber
19 },
1820 success: function(result, request) {
1921 try {
2022 var jsonData = Ext.util.JSON.decode(result.responseText);
2123 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);
2425 }
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);
2828 }
2929 },
3030 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"));
3332 }
3433 });
3534}
3838 url: '/json/zone/callScene',
3939 disableCaching: true,
4040 method: "GET",
41 params: { id : zoneId,
42 sceneNumber : sceneNumber,
43 groupID : groupId},
41 params: {
42 id: zoneId,
43 sceneNumber: sceneNumber,
44 groupID: groupId
45 },
4446 success: function(result, request) {
4547 try {
4648 var jsonData = Ext.util.JSON.decode(result.responseText);
4749 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);
5051 }
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);
5454 }
5555 },
5656 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"));
5958 }
6059 });
6160}
6464 url: '/json/zone/saveScene',
6565 disableCaching: true,
6666 method: "GET",
67 params: { id : zoneId,
68 sceneNumber : sceneNumber,
69 groupID : groupId},
67 params: {
68 id: zoneId,
69 sceneNumber: sceneNumber,
70 groupID: groupId
71 },
7072 success: function(result, request) {
7173 try {
7274 var jsonData = Ext.util.JSON.decode(result.responseText);
7375 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);
7677 }
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);
8080 }
8181 },
8282 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"));
8584 }
8685 });
8786}
9090 url: '/json/device/setValue',
9191 disableCaching: true,
9292 method: "GET",
93 params: { dsid : dsid,
94 value : value },
93 params: {
94 dsid: dsid,
95 value: value
96 },
9597 success: function(result, request) {
9698 try {
9799 var jsonData = Ext.util.JSON.decode(result.responseText);
98100 if (!jsonData.ok) {
99 Ext.MessageBox.alert(_("Could not set value") + ": " +
100 jsonData.message);
101 Ext.MessageBox.alert(_("Could not set value") + ": " + jsonData.message);
101102 }
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);
105105 }
106106 },
107107 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"));
110109 }
111110 });
112111
webroot/js/dss/dss-setup-interface/dss-overview-page.js
(51 / 54)
  
11//= require <dSS/GetTextHelper>
22//= require <dSS/util/TimeInfo>
3
43Ext.namespace("dSS", "dSS.config");
54
6Ext.onReady(function(){
7 Ext.get('start').remove();
5Ext.onReady(function() {
6 Ext.get('start').remove();
87 dSS.config.dSSTimeDiff = 0;
98
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 });
3130
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);
4241
43 } catch(error) {
44 }
45 },
46 failure : function(response, options) {}
47 });
42 } catch(error) {}
43 },
44 failure: function(response, options) {}
45 });
4846
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 }
5957 dSS.config.dSSTimeDiff = (new Date().getTime() - (parseInt(data.message, 10) * 1000));
6058 updateDSSTime();
6159
62 } catch(error) {
63 }
64 },
65 failure : function(response, options) {}
66 });
60 } catch(error) {}
61 },
62 failure: function(response, options) {}
63 });
6764
6865});
webroot/js/dss/dss-setup-interface/dss-setup-interface.js
(114 / 111)
  
88//= require <dSS/GlossaryPanel>
99//= require <dSS/util/TimeInfo>
1010//= require <dSS/config/Config>
11
1211Ext.namespace("dSS", "dSS.config");
1312
14Ext.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 });
13Ext.onReady(function() {
14 Ext.get('start').remove();
5915
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 });
7061
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);
7672
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 }
8788 dSS.config.dSSTimeDiff = (new Date().getTime() - (parseInt(data.message, 10) * 1000));
8889 updateDSSTime();
8990
90 } catch(error) {
91 }
92 },
93 failure : function(response, options) {}
94 });
91 } catch(error) {}
92 },
93 failure: function(response, options) {}
94 });
9595
9696 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) {
103105 try {
104106 var jsonData = Ext.util.JSON.decode(response.responseText);
105107 if (jsonData.ok) {
106108 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;
108110 }
109111 } else {
110112 Ext.MessageBox.alert(_("Error"), _("Could not get properties from dSS"));
111113 }
112 } catch (err) {
114 } catch(err) {
113115 Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS") + ": " + err);
114116 }
115
117
116118 },
117 failure : function(response, options) {
119 failure: function(response, options) {
118120 Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS"));
119121 }
120 });
122 });
121123
122124 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) {
129133 try {
130134 var jsonData = Ext.util.JSON.decode(response.responseText);
131135 if (jsonData.ok) {
132 for (i = 0; i < jsonData.result.length; i++) {
133 /*
136 for (i = 0; i < jsonData.result.length; i++) {
137 /*
134138 dSS.config.settings[jsonData.result[i].name] = jsonData.result[i];
135139 */
136140 getLogFileProperties(jsonData.result[i]);
142142 } else {
143143 Ext.MessageBox.alert(_("Error"), _("Could not get properties from dSS"));
144144 }
145 } catch (err) {
145 } catch(err) {
146146 Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS") + ": " + err);
147147 }
148
148
149149 },
150 failure : function(response, options) {
150 failure: function(response, options) {
151151 Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS"));
152152 }
153 });
153 });
154154
155155 function getLogFileProperties(res) {
156156 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) {
165165 try {
166166 var jsonData = Ext.util.JSON.decode(response.responseText);
167167 if (jsonData.ok) {
168168 dSS.config.settings[res.name] = {};
169169 dSS.config.settings[res.name].logfile = jsonData.result.value;
170170 }
171 } catch (err) {
172 }
171 } catch(err) {}
173172 },
174 failure : function(response, options) {
173 failure: function(response, options) {
175174 Ext.MessageBox.alert(_("Error"), _("Could send getChildren command to dSS"));
176175 }
177 });
176 });
178177 }
179178});