Browse Source

properly handle servers being offline in the server list

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
121607468f
  1. 17
      pyweb/mumble/templates/mumble/list.html
  2. 20
      pyweb/mumble/views.py

17
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;
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;
});
}

20
pyweb/mumble/views.py

@ -92,17 +92,17 @@ 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
if srv.booted:
return {
'id': srv.id,
'name': srv.name,
'booted': True,
'motd': srv.motd,
'connecturl': srv.connecturl,
'prettyversion': srv.prettyversion,
@ -115,10 +115,14 @@ def serverinfo( request, server ):
'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),) );
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.

Loading…
Cancel
Save