diff --git a/pyweb/mumble/templates/mumble/mumble.html b/pyweb/mumble/templates/mumble/mumble.html index f72ac87..c42fb9f 100644 --- a/pyweb/mumble/templates/mumble/mumble.html +++ b/pyweb/mumble/templates/mumble/mumble.html @@ -224,7 +224,39 @@ }, {% if IsAdmin %} { 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 %} ], }], }); diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 090ba2b..97ff32e 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -205,6 +205,19 @@ def get_admin( request, server ): data[fld] = getattr( srv, fld ) 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 @EXT_DIRECT_PROVIDER.register_method( "Mumble" ) def users( request, server ):