[dss-commits] r8891 - in dss/trunk: 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:39 CET 2009


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

Added:
   dss/trunk/data/webroot/images/page_white_edit.png
Modified:
   dss/trunk/data/webroot/js/dss-setup-interface.js
   dss/trunk/websrc/dss-setup-interface/dSS/grid/DevicePanel.js
Log:
Device editing added to device grid

Added a context menu with option to edit device.

Added: dss/trunk/data/webroot/images/page_white_edit.png
===================================================================
--- dss/trunk/data/webroot/images/page_white_edit.png	                        (rev 0)
+++ dss/trunk/data/webroot/images/page_white_edit.png	2009-11-06 16:10:39 UTC (rev 8891)
@@ -0,0 +1,6 @@
+‰PNG
+
+   
+IHDR         óÿa   gAMA  ¯È7Šé   tEXtSoftware Adobe ImageReadyqÉe<  üIDAT8ˍ“ßKSaÇWEDBԅЍá}a? „‚P3B¨‹î²]t±+$aA	‚„I¨ÅX^¤ns‹\[sK·p;;gçœýìÓû¶±É¦øp¼Ï÷sÞç¼ç±6qt	ºwá°`¿ÌÔ°U]ù|^)•J•r¹L+Ä:N§sb»¤&è–á\.‡®ëu²Ù,™L†d2iIâYBÓ—øùÖÁÒÔ)–ŸvÉð>)¦iR(¬»DÓ4E!•J¡Åß°áEYyZ‚ÌÊ,žÇ½›M®!†a ª*›?fH¯> °>ÏƧG¾9ÊQ7¾×Ì&h£Þ³|–}+ë¤ý÷©nŒð
+¶¾Ý$øj˜ïÏ÷øùcM‚í¨‰¤}w©˜ôµ+˜±ÔU;±—}Œœ92XͶ$ü¢çÅÑjxów?Yÿ=“gÑ~ªÇÚZÌ\¸-¶ý32L>vEìdíÙiÔä/«¦­ øešÀ{;Ëž÷^D°µt‡ðTú߈õ]v¼ë5Jhò.ûA¾Š·zÆ{Ñþ„¬ð®Çõã<N
+Þ	¼Ž“̍%óS,ëì(èï9ÀØÕN\ϱ8s‹l2ji#íÿÚÍA*2Ó8'Äߧ˅½„E­&°QÐ!%{çrô;dö?!n,üÈp    IEND®B`‚
\ No newline at end of file


Property changes on: dss/trunk/data/webroot/images/page_white_edit.png
___________________________________________________________________
Added: svn:executable
   + *

Modified: dss/trunk/data/webroot/js/dss-setup-interface.js
===================================================================
--- dss/trunk/data/webroot/js/dss-setup-interface.js	2009-11-06 16:10:36 UTC (rev 8890)
+++ dss/trunk/data/webroot/js/dss-setup-interface.js	2009-11-06 16:10:39 UTC (rev 8891)
@@ -403,10 +403,58 @@
 
 		this.on(
 			'rowcontextmenu',
-			function() {
+			function(grid, rowIndex, event) {
+				event.preventDefault();
+				event.stopEvent();
+				if(!this.contextMenu) {
+					this.contextMenu = new Ext.menu.Menu({});
+				} else {
+					this.contextMenu.removeAll();
+				}
+
+				var menuItem = new Ext.menu.Item({
+					text: 'Edit Device',
+					icon: '/images/page_white_edit.png',
+					handler: this.editDevice.createDelegate(this, rowIndex, true)
+				});
+				this.contextMenu.add(menuItem)
+				var xy = event.getXY();
+				this.contextMenu.showAt(xy);
 			},
 			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({
+					url: '/json/device/setName',
+					disableCaching: true,
+					method: "GET",
+					params: { dsid: 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 device');
+							}
+						}
+						catch (err) {
+							Ext.MessageBox.alert('Error', 'Could not rename device');
+						}
+					},
+					failure: function(result, request) {
+						Ext.MessageBox.alert('Error', 'Could not rename device');
+					},
+				});
+			}
+		}, this, false, record.get('name'));
 	}
 });
 

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:36 UTC (rev 8890)
+++ dss/trunk/websrc/dss-setup-interface/dSS/grid/DevicePanel.js	2009-11-06 16:10:39 UTC (rev 8891)
@@ -44,11 +44,57 @@
 		// exist, like event handling.
 		this.on(
 			'rowcontextmenu',
-			function() {
-				//console.log('rowcontextmenu');
+			function(grid, rowIndex, event) {
+				event.preventDefault();
+				event.stopEvent();
+				if(!this.contextMenu) {
+					this.contextMenu = new Ext.menu.Menu({});
+				} else {
+					this.contextMenu.removeAll();
+				}
+				
+				var menuItem = new Ext.menu.Item({
+					text: 'Edit Device',
+					icon: '/images/page_white_edit.png',
+					handler: this.editDevice.createDelegate(this, rowIndex, true)
+				});
+				this.contextMenu.add(menuItem)
+				var xy = event.getXY();
+				this.contextMenu.showAt(xy);
 			},
 			this
 		);
+	},
+	editDevice: function(item, event, rowIndex) {
+		var record = this.getStore().getAt(rowIndex);
+		Ext.Msg.prompt('Edit device', 'Name:', function(btn, text){
+			if(text !== record.get('name')) {
+				Ext.Ajax.request({
+					url: '/json/device/setName',
+					disableCaching: true,
+					method: "GET",
+					params: { dsid: 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 device');
+							}
+						}
+						catch (err) {
+							Ext.MessageBox.alert('Error', 'Could not rename device');
+						}
+					},
+					failure: function(result, request) {
+						Ext.MessageBox.alert('Error', 'Could not rename device');
+					},
+				});
+			}
+		}, this, false, record.get('name'));
 	}
 });
 



More information about the dss-commits mailing list