[dss-commits] r8869 - in dss/trunk: data/webroot data/webroot/images data/webroot/js websrc/dss-setup-interface/dSS
dss-commits at forum.digitalstrom.org
dss-commits at forum.digitalstrom.org
Thu Oct 29 10:06:28 CET 2009
Author: mfernandez
Date: 2009-10-29 10:06:28 +0100 (Thu, 29 Oct 2009)
New Revision: 8869
Added:
dss/trunk/data/webroot/images/edit.gif
Modified:
dss/trunk/data/webroot/js/dss-setup-interface.js
dss/trunk/data/webroot/setup.html
dss/trunk/websrc/dss-setup-interface/dSS/ZoneBrowser.js
dss/trunk/websrc/dss-setup-interface/dSS/ZonePanel.js
Log:
Added form to rename a zone.
Added: dss/trunk/data/webroot/images/edit.gif
===================================================================
--- dss/trunk/data/webroot/images/edit.gif (rev 0)
+++ dss/trunk/data/webroot/images/edit.gif 2009-10-29 09:06:28 UTC (rev 8869)
@@ -0,0 +1,7 @@
+GIF89a ÷ 1ÿÿÿ S V j d Z mÂÜÂðöðou
+s
+ïöï·@@¿×¿@@77¹ïõï00¿Ø¿==CC00j©jc¥c``ñ÷ñ@@j11o«op¥pð÷ðlªl00@@ßíßÀÛÀ55::44 ` q @}@ g wy} O ] { , DP àÀ
+*Dx C x°E
+.8 `Á A>` qÉ&@òb&C4ÈÀR#r.hð DK
+äóÂÅD°Ñ(Æ r.Uú xxq`j¯J=(ý
+¶ìhAý:£
Û·o×A·®]²3 ;
\ No newline at end of file
Property changes on: dss/trunk/data/webroot/images/edit.gif
___________________________________________________________________
Added: svn:executable
+ *
Modified: dss/trunk/data/webroot/js/dss-setup-interface.js
===================================================================
--- dss/trunk/data/webroot/js/dss-setup-interface.js 2009-10-27 14:26:50 UTC (rev 8868)
+++ dss/trunk/data/webroot/js/dss-setup-interface.js 2009-10-29 09:06:28 UTC (rev 8869)
@@ -125,7 +125,7 @@
dSS.ZonePanel = Ext.extend(Ext.Panel, {
initComponent: function() {
Ext.apply(this, {
- title:'Zones',
+ title:'Rooms',
layout: 'border',
items: [{ xtype: 'dsszoneview', ref: 'zoneView', region: 'center'}]
});
@@ -136,15 +136,18 @@
},
buildTopToolbar: function() {
- return ['->',
- {
- text: 'New Zone',
+ return [{
iconCls: 'newZoneAction',
handler: this.createNewZone,
scope: this
},
{
- text: 'Reload',
+ iconCls: 'editZoneAction',
+ handler: this.editZone,
+ scope: this
+ },
+ '->',
+ {
iconCls: 'reloadAction',
handler: this.reload,
scope: this
@@ -152,9 +155,46 @@
];
},
+ editZone: function() {
+ var zoneStore = this.zoneView.getStore();
+ if(this.zoneView.getSelectionCount() !== 1) {
+ return;
+ } else {
+ var record = this.zoneView.getSelectedRecords()[0];
+ Ext.Msg.prompt('Rename room', 'New name for room:', function(btn, text){
+ if(text !== record.get('name')) {
+ Ext.Ajax.request({
+ url: '/json/zone/setName',
+ disableCaching: true,
+ method: "GET",
+ params: { id: record.get('id'),
+ newName: text},
+ success: function(result, request) {
+ try {
+ var jsonData = Ext.util.JSON.decode(result.responseText);
+ if(jsonData.ok) {
+ record.set('name', text);
+ record.commit();
+ } else {
+ Ext.MessageBox.alert('Error', 'Could not rename room');
+ }
+ }
+ catch (err) {
+ Ext.MessageBox.alert('Error', 'Could not rename room');
+ }
+ },
+ failure: function(result, request) {
+ Ext.MessageBox.alert('Error', 'Could not rename room');
+ },
+ });
+ }
+ }, this, false, record.get('name'));
+ }
+ },
+
createNewZone: function() {
var zoneStore = this.zoneView.getStore();
- Ext.Msg.prompt('Create new zone', 'Name for new Zone:', function(btn, text){
+ Ext.Msg.prompt('Create new room', 'Name for new room:', function(btn, text){
if (btn == 'ok'){
for(var i = 0; i <= zoneStore.data.length; i++) {
if(zoneStore.findExact('id', i) === -1) {
@@ -354,7 +394,7 @@
}
zones.push({
id: zone.id,
- name: zone.id === 0 ? 'Uncategorized' : zone.name
+ name: zone.name ? zone.name : 'No name'
});
Ext.each(zone.devices, function(device) {
for(var i = 0; i < devices.length; i++) {
Modified: dss/trunk/data/webroot/setup.html
===================================================================
--- dss/trunk/data/webroot/setup.html 2009-10-27 14:26:50 UTC (rev 8868)
+++ dss/trunk/data/webroot/setup.html 2009-10-29 09:06:28 UTC (rev 8869)
@@ -44,6 +44,10 @@
.newZoneAction {
background-image: url(images/add_zone.gif) !important;
}
+
+ .editZoneAction {
+ background-image: url(images/edit.gif) !important;
+ }
</style>
</head>
<body>
Modified: dss/trunk/websrc/dss-setup-interface/dSS/ZoneBrowser.js
===================================================================
--- dss/trunk/websrc/dss-setup-interface/dSS/ZoneBrowser.js 2009-10-27 14:26:50 UTC (rev 8868)
+++ dss/trunk/websrc/dss-setup-interface/dSS/ZoneBrowser.js 2009-10-29 09:06:28 UTC (rev 8869)
@@ -59,7 +59,7 @@
}
zones.push({
id: zone.id,
- name: zone.id === 0 ? 'Uncategorized' : zone.name
+ name: zone.name ? zone.name : 'No name'
});
Ext.each(zone.devices, function(device) {
for(var i = 0; i < devices.length; i++) {
Modified: dss/trunk/websrc/dss-setup-interface/dSS/ZonePanel.js
===================================================================
--- dss/trunk/websrc/dss-setup-interface/dSS/ZonePanel.js 2009-10-27 14:26:50 UTC (rev 8868)
+++ dss/trunk/websrc/dss-setup-interface/dSS/ZonePanel.js 2009-10-29 09:06:28 UTC (rev 8869)
@@ -5,7 +5,7 @@
dSS.ZonePanel = Ext.extend(Ext.Panel, {
initComponent: function() {
Ext.apply(this, {
- title:'Zones',
+ title:'Rooms',
layout: 'border',
items: [{ xtype: 'dsszoneview', ref: 'zoneView', region: 'center'}]
//tbar: ['->', createZoneAction, reloadAction]
@@ -17,15 +17,21 @@
},
buildTopToolbar: function() {
- return ['->',
- {
- text: 'New Zone',
+ return [{
+ //text: 'New Zone',
iconCls: 'newZoneAction',
handler: this.createNewZone,
scope: this
},
{
- text: 'Reload',
+ //text: 'Edit Room
+ iconCls: 'editZoneAction',
+ handler: this.editZone,
+ scope: this
+ },
+ '->',
+ {
+ //text: 'Reload',
iconCls: 'reloadAction',
handler: this.reload,
scope: this
@@ -33,9 +39,46 @@
];
},
+ editZone: function() {
+ var zoneStore = this.zoneView.getStore();
+ if(this.zoneView.getSelectionCount() !== 1) {
+ return;
+ } else {
+ var record = this.zoneView.getSelectedRecords()[0];
+ Ext.Msg.prompt('Rename room', 'New name for room:', function(btn, text){
+ if(text !== record.get('name')) {
+ Ext.Ajax.request({
+ url: '/json/zone/setName',
+ disableCaching: true,
+ method: "GET",
+ params: { id: record.get('id'),
+ newName: text},
+ success: function(result, request) {
+ try {
+ var jsonData = Ext.util.JSON.decode(result.responseText);
+ if(jsonData.ok) {
+ record.set('name', text);
+ record.commit();
+ } else {
+ Ext.MessageBox.alert('Error', 'Could not rename room');
+ }
+ }
+ catch (err) {
+ Ext.MessageBox.alert('Error', 'Could not rename room');
+ }
+ },
+ failure: function(result, request) {
+ Ext.MessageBox.alert('Error', 'Could not rename room');
+ },
+ });
+ }
+ }, this, false, record.get('name'));
+ }
+ },
+
createNewZone: function() {
var zoneStore = this.zoneView.getStore();
- Ext.Msg.prompt('Create new zone', 'Name for new Zone:', function(btn, text){
+ Ext.Msg.prompt('Create new room', 'Name for new room:', function(btn, text){
if (btn == 'ok'){
for(var i = 0; i <= zoneStore.data.length; i++) {
if(zoneStore.findExact('id', i) === -1) {
More information about the dss-commits
mailing list