diff --git a/pyweb/mumble/templates/mumble/list.html b/pyweb/mumble/templates/mumble/list.html index 3a6b2e9..918eabc 100644 --- a/pyweb/mumble/templates/mumble/list.html +++ b/pyweb/mumble/templates/mumble/list.html @@ -51,11 +51,16 @@ singleSelect: true, store: new Ext.data.DirectStore({ directFn: MumbleList.servers, - fields: [ 'id', 'name' ], + fields: [ 'id', 'name', 'booted' ], autoLoad: true, listeners: { load: function( store, records, objects ){ - mainpanel.serverlist.select(0); + for( var i = 0; i < records.length; i++ ){ + if( records[i].data.booted ){ + mainpanel.serverlist.select(records[i]); + return; + } + } } } }), @@ -66,16 +71,16 @@ }], listeners: { dblclick: function(listview){ - selectedstuff = listview.getSelectedRecords(); - MumbleList.serverurl( selectedstuff[0].data.id, function(provider, response){ - window.location.href = response.result; - }); + location.href = mainpanel.selectedServer.detailsurl; }, selectionchange: function(listview, nodes){ selectedstuff = listview.getSelectedRecords(); MumbleList.serverinfo( selectedstuff[0].data.id, function(provider, response){ mainpanel.selectedServer = response.result; - var info = renderserverinfos(response.result); + if( response.result.booted ) + var info = renderserverinfos(response.result); + else + var info = gettext("This server is currently offline."); mainpanel.descrippanel.el.dom.children[1].children[0].innerHTML = info; }); } diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 1af6edd..184b348 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -92,33 +92,37 @@ def mumbles( request, mobile=False ): @EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) def servers( request ): - mms = Mumble.objects.all().order_by( "name" ).values( "id", "name" ) - - return [{ 'id': mm['id'], 'name': mm['name'] } for mm in mms] + mms = Mumble.objects.all().order_by( "name" ) + return [{ 'id': mm.id, 'name': mm.name, 'booted': mm.booted } for mm in mms] @EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) def serverinfo( request, server ): srv = Mumble.objects.get( id=int(server) ) - # users_regged users_online channel_cnt uptime upsince minurl - return { - 'id': srv.id, - 'name': srv.name, - 'motd': srv.motd, - 'connecturl': srv.connecturl, - 'prettyversion': srv.prettyversion, - 'url': srv.url, - 'users_regged': srv.users_regged, - 'users_online': srv.users_online, - 'channel_cnt': srv.channel_cnt, - 'uptime': srv.uptime, - 'upsince': unicode(srv.upsince), - 'minurl': reverse( mobile_show, args=(server,) ), - 'detailsurl': reverse( show, args=(server,) ), - } - -@EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) -def serverurl( request, server ): - return reverse( show, args=(int(server),) ); + if srv.booted: + return { + 'id': srv.id, + 'name': srv.name, + 'booted': True, + 'motd': srv.motd, + 'connecturl': srv.connecturl, + 'prettyversion': srv.prettyversion, + 'url': srv.url, + 'users_regged': srv.users_regged, + 'users_online': srv.users_online, + 'channel_cnt': srv.channel_cnt, + 'uptime': srv.uptime, + 'upsince': unicode(srv.upsince), + 'minurl': reverse( mobile_show, args=(server,) ), + 'detailsurl': reverse( show, args=(server,) ), + } + else: + return{ + 'id': srv.id, + 'name': srv.name, + 'booted': False, + 'minurl': reverse( mobile_show, args=(server,) ), + 'detailsurl': reverse( show, args=(server,) ), + } def show( request, server ): """ Display the channel list for the given Server ID.