Browse Source

add a log viewer

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
a6dfc29f2e
  1. 34
      pyweb/mumble/templates/mumble/mumble.html
  2. 13
      pyweb/mumble/views.py

34
pyweb/mumble/templates/mumble/mumble.html

@ -224,7 +224,39 @@
}, },
{% if IsAdmin %} { {% if IsAdmin %} {
xtype: "userEditorPanel", xtype: "userEditorPanel",
} {% endif %}
}, {% endif %}
{
xtype: 'grid',
title: gettext('Log messages'),
colModel: new Ext.grid.ColumnModel([{
header: gettext('Timestamp'),
dataIndex: 'timestamp',
width: 100,
renderer: function( value ){
return new Date(value*1000).format( "Y-m-d H:i:s" );
}
}, {
header: gettext('Log entry'),
width: 500,
dataIndex: 'txt'
}]),
store: new Ext.data.DirectStore({
baseParams: {'server': 1, 'start': 0, 'limit': 100},
directFn: Mumble.log,
paramOrder: ['server', 'start', 'limit'],
paramsNames: {
start: 'start',
limit: 'limit',
sort: 'sort',
dir: 'dir'
},
root: 'data',
fields: ['timestamp', 'txt'],
autoLoad: true,
remoteSort: false
}),
viewConfig: { forceFit: true }
}
{% endif %} ], {% endif %} ],
}], }],
}); });

13
pyweb/mumble/views.py

@ -205,6 +205,19 @@ def get_admin( request, server ):
data[fld] = getattr( srv, fld ) data[fld] = getattr( srv, fld )
return { 'data': data, 'success': True } return { 'data': data, 'success': True }
@login_required
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def log( request, server, start, limit ):
""" Retrieve log messages. """
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( "Access denied" )
return { 'data': [
{ 'timestamp': ent.timestamp, 'txt': ent.txt }
for ent in srv.ctl.getLog( srv.srvid, start, (start + limit) )
], 'success': True }
@login_required @login_required
@EXT_DIRECT_PROVIDER.register_method( "Mumble" ) @EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def users( request, server ): def users( request, server ):

Loading…
Cancel
Save