[dss-commits] digitalSTROM web-sources branch, master, updated. fa31ec75f6a3df65902637e37949f64e4039f6ec

git version control dss-commits at forum.digitalstrom.org
Wed Dec 16 16:08:31 CET 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM web-sources".

The branch, master has been updated
       via  fa31ec75f6a3df65902637e37949f64e4039f6ec (commit)
      from  0de2f6e09d4f9fc182f9bc3e1f02255f92c1a883 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fa31ec75f6a3df65902637e37949f64e4039f6ec
Author: Matias E. Fernandez <“mfernandez at futurelab.ch”>
Date:   Wed Dec 16 16:05:37 2009 +0100

    Added dSM Overview in System Panel

-----------------------------------------------------------------------

Changes:
diff --git a/dss-setup-interface/dSS/SystemPanel.js b/dss-setup-interface/dSS/SystemPanel.js
index 7060a5b..ff2f55a 100644
--- a/dss-setup-interface/dSS/SystemPanel.js
+++ b/dss-setup-interface/dSS/SystemPanel.js
@@ -1,4 +1,5 @@
 //= require <dSS/system/PropertyTree.js>
+//= require <dSS/system/dSMOverview.js>
 
 Ext.namespace('dSS');
 
@@ -23,6 +24,15 @@ dSS.SystemPanel = Ext.extend(Ext.Panel, {
 					title: 'Property Tree',
 					xtype: 'dsssystempropertytree',
 					ref: 'systemPropertyTree'
+				}, {
+					title: 'DSM Overview',
+					xtype: 'panel',
+					layout: 'border',
+					items: [{
+						xtype: 'dsmoverview',
+						ref: 'systemdSMOverview',
+						region: 'center'
+					}]
 				}
 			]
 		};
diff --git a/dss-setup-interface/dSS/system/dSMOverview.js b/dss-setup-interface/dSS/system/dSMOverview.js
new file mode 100644
index 0000000..cf31b48
--- /dev/null
+++ b/dss-setup-interface/dSS/system/dSMOverview.js
@@ -0,0 +1,164 @@
+Ext.namespace('dSS', 'dSS.system');
+
+dSS.system.dSMOverview = Ext.extend(Ext.grid.GridPanel, {
+
+	initComponent: function() {
+
+		var deviceRecord = Ext.data.Record.create([
+			{name:"name"},
+			{name:"id"},
+			{name:"on"},
+			{name:"circuit"},
+			{name:"modulator"},
+			{name:"zone"},
+			{name:"isPresent"},
+			{name:"firstSeen"},
+			{name:"lastDiscovered"}
+		]);
+
+		// a json reader to read the device data
+		var deviceReader = new Ext.data.JsonReader(
+			{
+				root:"devices"
+			},
+			deviceRecord
+		);
+		
+
+		this.groupingStore = new Ext.data.GroupingStore({
+					autoDestroy: true,
+					reader: deviceReader,
+					sortInfo: {field: 'modulator', direction: 'ASC'},
+					groupOnSort: false,
+					remoteGroup: true,
+					groupField: 'modulator'
+		});
+
+		this.colModel = new Ext.grid.ColumnModel({
+					columns:[
+							{header: 'Modulator', dataIndex: 'modulator'},
+							{header: 'dSID', width: 150, dataIndex: 'id', groupable: false},
+							{header: 'Zone', dataIndex: 'zone', groupable: false}
+					],
+					defaults: {
+							sortable: false,
+							menuDisabled: true,
+							width: 20
+					}
+		});
+
+		var groupingView = new Ext.grid.GroupingView({
+					forceFit: true,
+					showGroupName: true,
+					hideGroupedColumn: true,
+					enableNoGroups: false,
+					enableGroupingMenu: false,
+					groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
+		});
+
+		Ext.apply(this, {
+			layout: 'border',
+			store: this.groupingStore,
+			colModel: this.colModel,
+			view: groupingView
+		});
+
+		dSS.system.dSMOverview.superclass.initComponent.apply(this, arguments);
+		
+		this.on({
+			scope: this,
+			afterrender: this.loadData
+		});
+	},
+
+	allDevices: [],
+
+	processStructure: function(structure) {
+		var devices = [], zones = [];
+		Ext.each(structure.apartment.zones, function(zone) {
+			if(zone.id === 0) { // Skip zone 0
+				Ext.each(zone.devices, function(device) {
+					device.firstSeen = Date.parseDate(device.firstSeen, "U");
+					device.lastDiscovered =  Date.parseDate(device.lastDiscovered, "U");
+					devices.push(device);
+				});
+			}
+			zones.push({
+				id: zone.id,
+				name: zone.name ? zone.name : 'No name',
+				primary: zone['firstZoneOnModulator'] !== undefined ? true : false
+			});
+			Ext.each(zone.devices, function(device) {
+				for(var i = 0; i < devices.length; i++) {
+					if(devices[i].id == device.id) {
+						devices[i].zone = zone.id;
+					}
+				}
+			});
+		});
+		this.allDevices = devices;
+	},
+
+	processCircuits: function(circuits) {
+		Ext.each(this.allDevices, function(device) {
+			var circuitID = device.circuitID;
+			for( var i = 0; i < circuits.length; i++) {
+				if(circuits[i].busid == circuitID) {
+					device.circuit = circuits[i].name;
+					device.modulator = circuits[i].dsid;
+				}
+			}
+		});
+		this.groupingStore.loadData({devices: this.allDevices});
+	},
+
+	loadStructure: function() {
+		Ext.Ajax.request({
+			url: '/json/apartment/getStructure',
+			disableCaching: true,
+			method: "GET",
+			scope: this,
+			success: function(result, request) {
+				try {
+					var jsonData = Ext.util.JSON.decode(result.responseText);
+					this.processStructure(jsonData);
+				}
+				catch (err) {
+					Ext.MessageBox.alert('AJAX Error', 'Error loading apartment structure: "' + err + '"');
+				}
+				this.loadCircuits();
+			},
+			failure: function(result, request) {
+				Ext.MessageBox.alert('AJAX Error', 'Could not load "' + request.url + '"');
+			}
+		});
+	},
+
+	loadCircuits: function() {
+		Ext.Ajax.request({
+			url: '/json/apartment/getCircuits',
+			disableCaching: true,
+			method: "GET",
+			scope: this,
+			success: function(result, request) {
+				try {
+					var jsonData = Ext.util.JSON.decode(result.responseText);
+					this.processCircuits(jsonData.result.circuits);
+				}
+				catch (err) {
+					Ext.MessageBox.alert('AJAX Error', 'Could not load circuits: "' + err + '"');
+				}
+			},
+			failure: function(result, request) {
+				Ext.MessageBox.alert('AJAX Error', 'Could not load "' + request.url + '"');
+			}
+		});
+	},
+
+	loadData: function() {
+		this.loadStructure();
+	}
+
+});
+
+Ext.reg('dsmoverview', dSS.system.dSMOverview);


hooks/post-receive
-- 
digitalSTROM web-sources


More information about the dss-commits mailing list