[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¦¯ÝÈÀ÷)ËlJ%ã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:ªÕª¡yDQTìv;GJu¹gyÄû#æFq{úÀ`0 ÝnëºÅz½fZ]°Äyl³=ÔfX4|Þ~b2`Ú¶Í÷lίk¥r¢üùìWlåòóMÄÇ{:?:e±¸y¡¸gö*ÄÎ\<9ÿfA!ϲªÙÌçs¸Ù0{½â$ó¸tÖùÃü@¤HN
+û
Ïr¹ÄÔ¿²<ogÉñÅ¥3G%BN¥f¥R!~
+ùýÊ¡¨É©@-ûºüÞn·ËÛU
+Bhøxÿ!´Ý:ý~^¯Çñ÷7 ¸ja 8Ë]êõ»ÖápY«ÕÑhT¤ßR¾NïùSwq®·ß
+®JgMÇ4M£Ü´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