From 73b67fd879adaf58eb2ba4de9022027cc72709f3 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 2 Jul 2010 18:41:32 +0200 Subject: [PATCH] outsource the channel viewer class into its own file --- htdocs/js/channelviewer.js | 76 +++++++++++++++++++++ htdocs/js/mumble.js | 83 ++--------------------- htdocs/js/usereditor.js | 19 ++---- pyweb/mumble/templates/mumble/mumble.html | 6 +- 4 files changed, 93 insertions(+), 91 deletions(-) create mode 100644 htdocs/js/channelviewer.js diff --git a/htdocs/js/channelviewer.js b/htdocs/js/channelviewer.js new file mode 100644 index 0000000..d3e3f2e --- /dev/null +++ b/htdocs/js/channelviewer.js @@ -0,0 +1,76 @@ +// kate: space-indent on; indent-width 4; replace-tabs on; + +Ext.namespace('Ext.ux'); + +Ext.ux.MumbleChannelViewer = function( config ){ + Ext.apply( this, config ); + + Ext.applyIf( this, { + title: gettext("Channel Viewer"), + root: { + text: gettext("Loading..."), + leaf: true + }, + buttons: [{ + text: gettext("Refresh"), + handler: this.refresh, + scope: this + }], + } ); + + Ext.ux.MumbleChannelViewer.superclass.constructor.call( this ); + this.refresh(); +} + +Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, { + refresh: function(){ + var conn = new Ext.data.Connection(); + conn.request({ + url: this.source_url, + scope: this, + success: function( resp, opt ){ + respdata = Ext.decode( resp.responseText ); + root = { + text: respdata.name, + id: "mumbroot", + leaf: false, + icon: '/static/mumble/mumble.16x16.png', + children: [], + }; + function populateNode( node, json ){ + subchan_users = 0; + for( var i = 0; i < json.channels.length; i++ ){ + child = { + text: json.channels[i].name, + id: ("channel_" + json.channels[i].id), + leaf: false, + icon: '/static/mumble/channel.png', + children: [], + }; + node.children.push( child ); + subchan_users += populateNode( child, json.channels[i] ); + } + for( var i = 0; i < json.users.length; i++ ){ + child = { + text: json.users[i].name, + id: ("user_" + json.users[i].id), + leaf: true, + icon: '/static/mumble/talking_off.png', + }; + node.children.push( child ); + } + if( json.id == 0 || json.users.length > 0 || subchan_users ) + node.expanded = true; + return subchan_users + json.users.length; + } + populateNode( root, respdata.root ); + this.setRootNode( root ); + }, + failure: function( resp, opt ){ + alert("fail"); + }, + }); + }, +} ); + +Ext.reg( 'mumblechannelviewer', Ext.ux.MumbleChannelViewer ); diff --git a/htdocs/js/mumble.js b/htdocs/js/mumble.js index 25dd67b..ab4cf82 100644 --- a/htdocs/js/mumble.js +++ b/htdocs/js/mumble.js @@ -1,80 +1,5 @@ // kate: space-indent on; indent-width 4; replace-tabs on; -Ext.namespace('Ext.ux'); - -Ext.ux.MumbleChannelViewer = function( config ){ - Ext.apply( this, config ); - - Ext.applyIf( this, { - title: gettext("Channel Viewer"), - root: { - text: gettext("Loading..."), - leaf: true - }, - buttons: [{ - text: gettext("Refresh"), - handler: this.refresh, - scope: this - }], - } ); - - Ext.ux.MumbleChannelViewer.superclass.constructor.call( this ); - this.refresh(); -} - -Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, { - refresh: function(){ - var conn = new Ext.data.Connection(); - conn.request({ - url: this.source_url, - scope: this, - success: function( resp, opt ){ - respdata = Ext.decode( resp.responseText ); - root = { - text: respdata.name, - id: "mumbroot", - leaf: false, - icon: '/static/mumble/mumble.16x16.png', - children: [], - }; - function populateNode( node, json ){ - subchan_users = 0; - for( var i = 0; i < json.channels.length; i++ ){ - child = { - text: json.channels[i].name, - id: ("channel_" + json.channels[i].id), - leaf: false, - icon: '/static/mumble/channel.png', - children: [], - }; - node.children.push( child ); - subchan_users += populateNode( child, json.channels[i] ); - } - for( var i = 0; i < json.users.length; i++ ){ - child = { - text: json.users[i].name, - id: ("user_" + json.users[i].id), - leaf: true, - icon: '/static/mumble/talking_off.png', - }; - node.children.push( child ); - } - if( json.id == 0 || json.users.length > 0 || subchan_users ) - node.expanded = true; - return subchan_users + json.users.length; - } - populateNode( root, respdata.root ); - this.setRootNode( root ); - }, - failure: function( resp, opt ){ - alert("fail"); - }, - }); - }, -} ); - -Ext.reg( 'mumblechannelviewer', Ext.ux.MumbleChannelViewer ); - function render_mumble( divname, urls ){ var mainpanel = new Ext.Panel({ renderTo: divname, @@ -117,15 +42,17 @@ function render_mumble( divname, urls ){ items: [{ region: "north", layout: "hbox", - height: 200, + height: 220, items: [{ flex: 1, + height: 200, title: gettext("Texture"), - html: "texture!" + html: String.format('Avatar', urls.myavatar), }, { flex: 1, + height: 200, title: gettext("Gravatar"), - html: "gravatar!", + html: String.format('grAvatar', urls.gravatar), }], }, { region: "center", diff --git a/htdocs/js/usereditor.js b/htdocs/js/usereditor.js index d393f84..e25de86 100644 --- a/htdocs/js/usereditor.js +++ b/htdocs/js/usereditor.js @@ -18,12 +18,10 @@ Ext.ux.UserEditorPanel = function( config ){ { name: 'delete', type: 'bool' } ]); - userAdminStore = new Ext.data.Store({ - url: config.mumble_users_url, - reader: new Ext.data.JsonReader({ - root: 'objects', - fields: userRecord - }), + userAdminStore = new Ext.data.DirectStore({ + baseParams: { server: 1 }, + directFn: Mumble.users, + fields: userRecord, autoLoad: true, remoteSort: false }); @@ -47,12 +45,9 @@ Ext.ux.UserEditorPanel = function( config ){ triggerAction: 'all', valueField: 'uid', displayField: 'uname', - store: new Ext.data.Store({ - url: config.django_users_url, - reader: new Ext.data.JsonReader({ - fields: [ 'uid', 'uname' ], - root: 'objects' - }), + store: new Ext.data.DirectStore({ + directFn: Mumble.djangousers, + fields: [ 'uid', 'uname' ], autoLoad: true }) }); diff --git a/pyweb/mumble/templates/mumble/mumble.html b/pyweb/mumble/templates/mumble/mumble.html index f83cb3a..b509f40 100644 --- a/pyweb/mumble/templates/mumble/mumble.html +++ b/pyweb/mumble/templates/mumble/mumble.html @@ -12,6 +12,8 @@ {% endblock %} {% block HeadTag %} + +