[dss-commits] r8868 - in dss/trunk: data/webroot data/webroot/js websrc/dss-setup-interface websrc/dss-setup-interface/dSS websrc/dss-setup-interface/dSS/tree
dss-commits at forum.digitalstrom.org
dss-commits at forum.digitalstrom.org
Tue Oct 27 15:26:50 CET 2009
Author: mfernandez
Date: 2009-10-27 15:26:50 +0100 (Tue, 27 Oct 2009)
New Revision: 8868
Added:
dss/trunk/websrc/dss-setup-interface/dSS/SystemPropertyTree.js
dss/trunk/websrc/dss-setup-interface/dSS/tree/
dss/trunk/websrc/dss-setup-interface/dSS/tree/PropertyTreeLoader.js
Modified:
dss/trunk/data/webroot/js/dss-setup-interface.js
dss/trunk/data/webroot/setup.html
dss/trunk/websrc/dss-setup-interface/dss-setup-interface.js
Log:
Added first version of property tree browser
Modified: dss/trunk/data/webroot/js/dss-setup-interface.js
===================================================================
--- dss/trunk/data/webroot/js/dss-setup-interface.js 2009-10-27 14:11:08 UTC (rev 8867)
+++ dss/trunk/data/webroot/js/dss-setup-interface.js 2009-10-27 14:26:50 UTC (rev 8868)
@@ -433,7 +433,131 @@
});
Ext.reg('dsszonebrowser', dSS.ZoneBrowser);
+Ext.namespace('dSS', 'dSS.tree');
+dSS.tree.PropertyTreeLoader = Ext.extend(Ext.tree.TreeLoader, {
+ constructor: function(config) {
+
+ Ext.apply(this, { dataUrl: '/json/property/getChildren', requestMethod: 'GET' });
+ dSS.data.DeviceStore.superclass.constructor.call(this, arguments);
+ },
+ requestData: function(node, callback, scope){
+ if(this.fireEvent("beforeload", this, node, callback) !== false){
+ this.transId = Ext.Ajax.request({
+ method:this.requestMethod,
+ url: this.dataUrl||this.url,
+ success: this.handleResponse,
+ failure: this.handleFailure,
+ scope: this,
+ argument: {callback: callback, node: node, scope: scope},
+ params: this.getParams(node)
+ });
+ }else{
+ this.runCallback(callback, scope || node, []);
+ }
+ },
+ processResponse : function(response, node, callback, scope){
+ var json = response.responseText;
+ try {
+ var o = response.responseData || Ext.decode(json);
+ o = o.result;
+ node.beginUpdate();
+ for(var i = 0, len = o.length; i < len; i++){
+ var rawNode = o[i];
+ rawNode.text = rawNode.name;
+ rawNode.leaf = rawNode.type === 'none' ? false : true;
+ rawNode.path = node.attributes.path === '/' ?
+ node.attributes.path + rawNode.name : node.attributes.path + '/' + rawNode.name;
+ var n = this.createNode(rawNode);
+ if(n){
+ node.appendChild(n);
+ }
+ }
+ node.endUpdate();
+ this.runCallback(callback, scope || node, [node]);
+ }catch(e){
+ this.handleFailure(response);
+ }
+ },
+ getParams: function(node) {
+ var buf = [];
+ buf.push('path', '=', encodeURIComponent(node.attributes.path));
+ return buf.join('');
+ }
+});
+
+Ext.namespace('dSS');
+
+dSS.SystemPropertyTree = Ext.extend(Ext.Panel, {
+ initComponent: function() {
+
+ Ext.apply(this, {
+ layout: 'border',
+ items: [{
+ xtype: 'treepanel',
+ ref: 'propertytree',
+ region: 'center',
+ width: 225, // give east and west regions a width
+ minSize: 175,
+ maxSize: 400,
+ autoScroll: true,
+ animate: true,
+ enableDD: false,
+ containerScroll: true,
+ border: false,
+ loader: new dSS.tree.PropertyTreeLoader(),
+ root: new Ext.tree.AsyncTreeNode({
+ expanded: false,
+ path: '/',
+ type: 'none',
+ text: 'dSS',
+ leaf: false,
+ }),
+ rootVisible: true,
+ listeners: {
+ append: this.handleAppend
+ }
+ }
+ ]
+ });
+
+ dSS.ZoneBrowser.superclass.initComponent.apply(this, arguments);
+ },
+ handleAppend: function(tree, parent, node, index) {
+ if (node.attributes.type === 'none') return;
+ var url = "/json/property/";
+ switch(node.attributes.type) {
+ case 'string':
+ url += 'getString';
+ break;
+ case 'integer':
+ url += 'getInteger';
+ break;
+ case 'boolean':
+ url += 'getBoolean';
+ break;
+ default:
+ return;
+ }
+ Ext.Ajax.request({
+ url: url,
+ params: { path: node.attributes.path },
+ method: 'GET',
+ success: function(response, opts) {
+ var obj = Ext.decode(response.responseText);
+ if(obj.ok === true) {
+ node.setText(node.text + " : " + obj.result.value);
+ }
+ },
+ failure: function(response, opts) {
+ console.log('server-side failure with status code ' + response.status);
+ }
+ });
+ }
+});
+
+Ext.reg('dsssystempropertytree', dSS.SystemPropertyTree);
+
Ext.onReady(function(){
Ext.get('start').remove();
var viewport = new Ext.Viewport({
@@ -456,6 +580,10 @@
title: 'Zones',
xtype: 'dsszonebrowser',
ref: 'zonebrowser'
+ },{
+ title: 'System Properties',
+ xtype: 'dsssystempropertytree',
+ ref: 'systempropertytree'
}
]
}]
Modified: dss/trunk/data/webroot/setup.html
===================================================================
--- dss/trunk/data/webroot/setup.html 2009-10-27 14:11:08 UTC (rev 8867)
+++ dss/trunk/data/webroot/setup.html 2009-10-27 14:26:50 UTC (rev 8868)
@@ -6,8 +6,8 @@
<link rel="stylesheet" type="text/css" href="js/lib/extjs/resources/css/ext-all.css" />
<!-- ExtJS libraries -->
- <script type="text/javascript" src="js/lib/extjs/adapter/ext/ext-base.js"></script>
- <script type="text/javascript" src="js/lib/extjs/ext-all.js"></script>
+ <script type="text/javascript" src="js/lib/extjs/adapter/ext/ext-base-debug.js"></script>
+ <script type="text/javascript" src="js/lib/extjs/ext-all-debug.js"></script>
<!-- ExtJS extensions -->
<script type="text/javascript" src="js/DataView-more.js"></script>
Added: dss/trunk/websrc/dss-setup-interface/dSS/SystemPropertyTree.js
===================================================================
--- dss/trunk/websrc/dss-setup-interface/dSS/SystemPropertyTree.js (rev 0)
+++ dss/trunk/websrc/dss-setup-interface/dSS/SystemPropertyTree.js 2009-10-27 14:26:50 UTC (rev 8868)
@@ -0,0 +1,73 @@
+//= require <dSS/tree/PropertyTreeLoader>
+
+Ext.namespace('dSS');
+
+dSS.SystemPropertyTree = Ext.extend(Ext.Panel, {
+ initComponent: function() {
+
+ Ext.apply(this, {
+ layout: 'border',
+ items: [{
+ xtype: 'treepanel',
+ ref: 'propertytree',
+ region: 'center',
+ width: 225, // give east and west regions a width
+ minSize: 175,
+ maxSize: 400,
+ autoScroll: true,
+ animate: true,
+ enableDD: false,
+ containerScroll: true,
+ border: false,
+ loader: new dSS.tree.PropertyTreeLoader(),
+ root: new Ext.tree.AsyncTreeNode({
+ expanded: false,
+ path: '/',
+ type: 'none',
+ text: 'dSS',
+ leaf: false,
+ }),
+ rootVisible: true,
+ listeners: {
+ append: this.handleAppend
+ }
+ }
+ ]
+ });
+
+ dSS.ZoneBrowser.superclass.initComponent.apply(this, arguments);
+ },
+ handleAppend: function(tree, parent, node, index) {
+ if (node.attributes.type === 'none') return;
+ var url = "/json/property/";
+ switch(node.attributes.type) {
+ case 'string':
+ url += 'getString';
+ break;
+ case 'integer':
+ url += 'getInteger';
+ break;
+ case 'boolean':
+ url += 'getBoolean';
+ break;
+ default:
+ return;
+ }
+ Ext.Ajax.request({
+ url: url,
+ params: { path: node.attributes.path },
+ method: 'GET',
+ success: function(response, opts) {
+ var obj = Ext.decode(response.responseText);
+ if(obj.ok === true) {
+ node.setText(node.text + " : " + obj.result.value);
+ }
+ },
+ failure: function(response, opts) {
+ console.log('server-side failure with status code ' + response.status);
+ }
+ });
+ }
+});
+
+Ext.reg('dsssystempropertytree', dSS.SystemPropertyTree);
\ No newline at end of file
Added: dss/trunk/websrc/dss-setup-interface/dSS/tree/PropertyTreeLoader.js
===================================================================
--- dss/trunk/websrc/dss-setup-interface/dSS/tree/PropertyTreeLoader.js (rev 0)
+++ dss/trunk/websrc/dss-setup-interface/dSS/tree/PropertyTreeLoader.js 2009-10-27 14:26:50 UTC (rev 8868)
@@ -0,0 +1,54 @@
+Ext.namespace('dSS', 'dSS.tree');
+
+dSS.tree.PropertyTreeLoader = Ext.extend(Ext.tree.TreeLoader, {
+ constructor: function(config) {
+
+ Ext.apply(this, { dataUrl: '/json/property/getChildren', requestMethod: 'GET' });
+ dSS.data.DeviceStore.superclass.constructor.call(this, arguments);
+ },
+ requestData: function(node, callback, scope){
+ if(this.fireEvent("beforeload", this, node, callback) !== false){
+ this.transId = Ext.Ajax.request({
+ method:this.requestMethod,
+ url: this.dataUrl||this.url,
+ success: this.handleResponse,
+ failure: this.handleFailure,
+ scope: this,
+ argument: {callback: callback, node: node, scope: scope},
+ params: this.getParams(node)
+ });
+ }else{
+ // if the load is cancelled, make sure we notify
+ // the node that we are done
+ this.runCallback(callback, scope || node, []);
+ }
+ },
+ processResponse : function(response, node, callback, scope){
+ var json = response.responseText;
+ try {
+ var o = response.responseData || Ext.decode(json);
+ o = o.result;
+ node.beginUpdate();
+ for(var i = 0, len = o.length; i < len; i++){
+ var rawNode = o[i];
+ rawNode.text = rawNode.name;
+ rawNode.leaf = rawNode.type === 'none' ? false : true;
+ rawNode.path = node.attributes.path === '/' ?
+ node.attributes.path + rawNode.name : node.attributes.path + '/' + rawNode.name;
+ var n = this.createNode(rawNode);
+ if(n){
+ node.appendChild(n);
+ }
+ }
+ node.endUpdate();
+ this.runCallback(callback, scope || node, [node]);
+ }catch(e){
+ this.handleFailure(response);
+ }
+ },
+ getParams: function(node) {
+ var buf = [];
+ buf.push('path', '=', encodeURIComponent(node.attributes.path));
+ return buf.join('');
+ }
+});
\ No newline at end of file
Modified: dss/trunk/websrc/dss-setup-interface/dss-setup-interface.js
===================================================================
--- dss/trunk/websrc/dss-setup-interface/dss-setup-interface.js 2009-10-27 14:11:08 UTC (rev 8867)
+++ dss/trunk/websrc/dss-setup-interface/dss-setup-interface.js 2009-10-27 14:26:50 UTC (rev 8868)
@@ -1,4 +1,5 @@
//= require <dSS/ZoneBrowser>
+//= require <dSS/SystemPropertyTree>
Ext.onReady(function(){
Ext.get('start').remove();
@@ -22,6 +23,10 @@
title: 'Zones',
xtype: 'dsszonebrowser',
ref: 'zonebrowser'
+ },{
+ title: 'System Properties',
+ xtype: 'dsssystempropertytree',
+ ref: 'systempropertytree'
}
]
}]
More information about the dss-commits
mailing list