[dss-commits] r8892 - in dss/trunk: data/webroot data/webroot/images data/webroot/js websrc/dss-setup-interface/dSS/grid

dss-commits at forum.digitalstrom.org dss-commits at forum.digitalstrom.org
Fri Nov 6 17:10:41 CET 2009


Author: mfernandez
Date: 2009-11-06 17:10:41 +0100 (Fri, 06 Nov 2009)
New Revision: 8892

Added:
   dss/trunk/data/webroot/images/off.png
   dss/trunk/data/webroot/images/on.png
Modified:
   dss/trunk/data/webroot/js/dss-setup-interface.js
   dss/trunk/data/webroot/setup.html
   dss/trunk/websrc/dss-setup-interface/dSS/grid/DevicePanel.js
Log:
Added on/off button to device grid

Added: dss/trunk/data/webroot/images/off.png
===================================================================
--- dss/trunk/data/webroot/images/off.png	                        (rev 0)
+++ dss/trunk/data/webroot/images/off.png	2009-11-06 16:10:41 UTC (rev 8892)
@@ -0,0 +1,8 @@
+‰PNG
+
+   
+IHDR         Vu\ç   	pHYs     šœ  ™IDAT(5‘ßNaÅ«_ÒP
+6ѺD.¸0
+ÜÀUïðÁwð©L|>€‰	šra("Rhq]þ).Åõ̶d²ß~sΙ3óyËå‹(ŠâÙlÆt:MrµZáœ#›Í’ÏçI§Óžá<#,‹x2™ð±ÝæÓã#éÑô?©'Òï£#*•
+¾ï{^q¿ßg¿Ùd÷á"ÁÎÃ!¨v¥.Í“n<óáâ‚Ý^6ÔÔÅ:$$ÕKíÓS~Èš©ý×››¿ESz’.÷÷DšëYÞ¿ÜÞry}ªí·V^^àY%S¶œÏ‰ÖkÔ[KF"Ýng[‰uH¬¼¾‚ßD\dÊF°œÇ±op©TŠ_²R¼»CðGiàHiÊóßþÎN²Þ­B¡ÀÕÁS´¥FF¦’¯Ý›ÈÀ÷)—Ël•J%‚ãcÎÒ¢FGS%ñ³Xd[˜jµŠËd2^­V‹¿kÀÎÙ{ƒŸm­Š±l˜²ëõ:¹\ÎK^ÚŠaÆM=^K³‡´0»fÔ
+lwï3ÝÞMv™¯     IEND®B`‚
\ No newline at end of file

Added: dss/trunk/data/webroot/images/on.png
===================================================================
--- dss/trunk/data/webroot/images/on.png	                        (rev 0)
+++ dss/trunk/data/webroot/images/on.png	2009-11-06 16:10:41 UTC (rev 8892)
@@ -0,0 +1,9 @@
+‰PNG
+
+   
+IHDR         Vu\ç   	pHYs     šœ  ²IDAT(M‘ÍnÚ@…?GŽ*BÄŸÒª•E]€*ÁM%Xôò}ªJ}…,û•X”Š
+´¤(®ÁÆ€±=vï8›^éhF÷žsæh®q8Е$I¾ï—ˆãÓ4i4t:ªÕª¡y†DQTìv;ŒGœJ„u¹g—yÄû#æFq{úÀ`0 Ýn†ëºÅz½fZ]°­‡Äy‚—‡l³=›ÔfX4—|Þ~b2™`Ú¶Í÷lίk¥r¢üˆ“ùì”WŠlåòóMÄ—Ç{:?:˜–e±¸y’¡¸gö*ÄÎ\<9ÿfA!ϲªÙÌçs‰¸Ù0{½â”$ó¸tÖùÃü@š¤HN
+û…Ïr¹ÄÔ¿²<oˆŠgÉñ˜Å¥3G%‚œBN¥f¥R!~
+ùýÊ™¡„¨É©@ˆž-ûºüÞ‹n·ËÛU
+Bhøxÿ!’ž˜´Ý:ý~Ÿ‹^¯Çñ‘÷7 ‡‘¸ja 8Ë]êõ’»Ö„ápˆY«ÕŒÑhT¤ßR¾NïùSwq®ž·ß
+®JgMÇ4›M£Ü´vñ<¯˜N§Ìf3ô"ué¸:†vÖdÝûVùmJ.¨R    IEND®B`‚
\ No newline at end of file

Modified: dss/trunk/data/webroot/js/dss-setup-interface.js
===================================================================
--- dss/trunk/data/webroot/js/dss-setup-interface.js	2009-11-06 16:10:39 UTC (rev 8891)
+++ dss/trunk/data/webroot/js/dss-setup-interface.js	2009-11-06 16:10:41 UTC (rev 8892)
@@ -366,10 +366,19 @@
 dSS.grid.DevicePanel = Ext.extend(Ext.grid.GridPanel, {
 	initComponent: function() {
 
+		var stateRenderer = function(value, metaData, record, rowIndex, colIndex, store) {
+			if(record.get('on')) {
+				metaData.css = 'isOn';
+			} else {
+				metaData.css = 'isOff';
+			}
+			return String.format('<img class="padding-img" src="{0}"/>',Ext.BLANK_IMAGE_URL);
+		};
+
 		var deviceCols = [
+			{header: "on", width: 14, resizable: false, sortable: true, dataIndex: 'on', renderer: stateRenderer},
 			{id: 'id', header: "id",  width: 150, sortable: true, dataIndex: 'id'},
 			{id: 'name', header: "name", width: 150, sortable: true, dataIndex: 'name', editable: true, editor: new Ext.form.TextField()},
-			{header: "on", width: 50, sortable: true, dataIndex: 'on'},
 			{header: "circuit", width: 100, sortable: true, dataIndex: 'circuit'},
 			{header: "modulator", width: 150, sortable: true, dataIndex: 'modulator'},
 			{header: "zone", width: 50, sortable: true, dataIndex: 'zone'},
@@ -423,10 +432,36 @@
 			},
 			this
 		);
+
+		this.on(
+			'cellclick',
+			function (grid, rowIndex, columnIndex, event) {
+				if(columnIndex === 0) {
+					var record = this.getStore().getAt(rowIndex);
+					Ext.Ajax.request({
+						url: record.get('on') ? '/json/device/turnOff' : '/json/device/turnOn',
+						disableCaching: true,
+						method: "GET",
+						params: { dsid: record.get('id') },
+						success: function(result, request) {
+							try {
+								var jsonData = Ext.util.JSON.decode(result.responseText);
+								if(jsonData.ok) {
+									record.set('on', record.get('on') ? false : true );
+									record.commit();
+								}
+							} catch(err) {
+								Ext.MessageBox.alert('Error', err);
+							}
+						}
+					});
+				}
+			},
+			this
+		);
 	},
 	editDevice: function(item, event, rowIndex) {
 		var record = this.getStore().getAt(rowIndex);
-		debugger;
 		Ext.Msg.prompt('Edit device', 'Name:', function(btn, text){
 			if(text !== record.get('name')) {
 				Ext.Ajax.request({

Modified: dss/trunk/data/webroot/setup.html
===================================================================
--- dss/trunk/data/webroot/setup.html	2009-11-06 16:10:39 UTC (rev 8891)
+++ dss/trunk/data/webroot/setup.html	2009-11-06 16:10:41 UTC (rev 8892)
@@ -52,6 +52,18 @@
 			.nonPresentDevice table {
 				color: #505050;
 			}
+			
+			.isOn
+			{
+				background:url(/images/on.png) center no-repeat !important;
+				cursor: pointer;
+			}
+			
+			.isOff
+			{
+				background:url(/images/off.png) center no-repeat !important;
+				cursor: pointer;
+			}
 		</style>
 	</head>
 	<body>

Modified: dss/trunk/websrc/dss-setup-interface/dSS/grid/DevicePanel.js
===================================================================
--- dss/trunk/websrc/dss-setup-interface/dSS/grid/DevicePanel.js	2009-11-06 16:10:39 UTC (rev 8891)
+++ dss/trunk/websrc/dss-setup-interface/dSS/grid/DevicePanel.js	2009-11-06 16:10:41 UTC (rev 8892)
@@ -5,10 +5,19 @@
 dSS.grid.DevicePanel = Ext.extend(Ext.grid.GridPanel, {
 	initComponent: function() {
 		
+		var stateRenderer = function(value, metaData, record, rowIndex, colIndex, store) {
+			if(record.get('on')) {
+				metaData.css = 'isOn';
+			} else {
+				metaData.css = 'isOff';
+			}
+			return String.format('<img class="padding-img" src="{0}"/>',Ext.BLANK_IMAGE_URL);
+		};
+		
 		var deviceCols = [
+			{header: "on", width: 14, resizable: false, sortable: true, dataIndex: 'on', renderer: stateRenderer},
 			{id: 'id', header: "id",  width: 150, sortable: true, dataIndex: 'id'},
 			{id: 'name', header: "name", width: 150, sortable: true, dataIndex: 'name', editable: true, editor: new Ext.form.TextField()},
-			{header: "on", width: 50, sortable: true, dataIndex: 'on'},
 			{header: "circuit", width: 100, sortable: true, dataIndex: 'circuit'},
 			{header: "modulator", width: 150, sortable: true, dataIndex: 'modulator'},
 			{header: "zone", width: 50, sortable: true, dataIndex: 'zone'},
@@ -64,6 +73,33 @@
 			},
 			this
 		);
+		
+		this.on(
+			'cellclick',
+			function (grid, rowIndex, columnIndex, event) {
+				if(columnIndex === 0) {
+					var record = this.getStore().getAt(rowIndex);
+					Ext.Ajax.request({
+						url: record.get('on') ? '/json/device/turnOff' : '/json/device/turnOn',
+						disableCaching: true,
+						method: "GET",
+						params: { dsid: record.get('id') },
+						success: function(result, request) {
+							try {
+								var jsonData = Ext.util.JSON.decode(result.responseText);
+								if(jsonData.ok) {
+									record.set('on', record.get('on') ? false : true );
+									record.commit();
+								}
+							} catch(err) {
+								Ext.MessageBox.alert('Error', err);
+							}
+						}
+					});
+				}
+			},
+			this
+		);
 	},
 	editDevice: function(item, event, rowIndex) {
 		var record = this.getStore().getAt(rowIndex);



More information about the dss-commits mailing list