Browse Source

add a ban viewer panel

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
770eceef83
  1. 52
      pyweb/mumble/media/js/banviewer.js
  2. 3
      pyweb/mumble/models.py
  3. 4
      pyweb/mumble/templates/mumble/mumble.html
  4. 12
      pyweb/mumble/views.py

52
pyweb/mumble/media/js/banviewer.js

@ -0,0 +1,52 @@
// kate: space-indent on; indent-width 4; replace-tabs on;
Ext.namespace('Ext.ux');
Ext.ux.BanViewerPanel = function( config ){
Ext.apply( this, config );
Ext.applyIf( this, {
xtype: 'grid',
title: gettext('Bans'),
colModel: new Ext.grid.ColumnModel([{
header: gettext('Timestamp'),
dataIndex: 'start',
width: 100,
renderer: function( value ){
return new Date(value*1000).format( "Y-m-d H:i:s" );
}
}, {
header: gettext('Duration'),
width: 100,
dataIndex: 'duration'
}, {
header: gettext('Reason'),
width: 500,
dataIndex: 'reason'
}]),
bbar: [{
iconCls: 'x-tbar-loading',
tooltip: gettext('Refresh'),
handler: function(){
this.ownerCt.ownerCt.store.reload();
}
}],
store: new Ext.data.DirectStore({
baseParams: {'server': this.server},
directFn: Mumble.bans,
paramOrder: ['server'],
root: 'data',
fields: ['start', 'address', 'bits', 'duration', 'reason'],
autoLoad: true,
remoteSort: false
}),
viewConfig: { forceFit: true }
});
Ext.ux.LogViewerPanel.superclass.constructor.call( this );
}
Ext.extend( Ext.ux.BanViewerPanel, Ext.grid.EditorGridPanel, {
} );
Ext.reg( 'banViewerPanel', Ext.ux.BanViewerPanel );

3
pyweb/mumble/models.py

@ -307,6 +307,9 @@ class Mumble( models.Model ):
ctl = property( lambda self: self.server.ctl )
def getBans( self ):
return self.ctl.getBans( self.srvid )
def getConf( self, field ):
return self.ctl.getConf( self.srvid, field )

4
pyweb/mumble/templates/mumble/mumble.html

@ -17,6 +17,7 @@
<script type="text/javascript" src="{{ MUMBLE_MEDIA_PREFIX }}js/rendermumbleserver.js"></script>
<script type="text/javascript" src="{{ MUMBLE_MEDIA_PREFIX }}js/usereditor.js"></script>
<script type="text/javascript" src="{{ MUMBLE_MEDIA_PREFIX }}js/logviewer.js"></script>
<script type="text/javascript" src="{{ MUMBLE_MEDIA_PREFIX }}js/banviewer.js"></script>
<script type="text/javascript" src="{{ MUMBLE_MEDIA_PREFIX }}js/buttoniframewindow.js"></script>
<script type="text/javascript" src="{{ MUMBLE_MEDIA_PREFIX }}js/loginout_buttons.js"></script>
<script type="text/javascript">
@ -147,6 +148,9 @@
}, {
xtype: 'logViewerPanel',
server: {{ MumbleServer.id }}
}, {
xtype: 'banViewerPanel',
server: {{ MumbleServer.id }}
}
{% endif %}
{% endif %}

12
pyweb/mumble/views.py

@ -244,6 +244,18 @@ def log( request, server, start, limit, filter ):
for ent in srv.getLog( start, (start + limit), filter )
], 'success': True }
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def bans( request, server ):
""" Retrieve log messages. """
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( "Access denied" )
return { 'data': [
{ 'start': ent.start, 'address': ent.address, 'bits': ent.bits,
'duration': ent.duration, 'reason': ent.reason }
for ent in srv.getBans()
], 'success': True }
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def moveUser( request, server, sessionid, channelid ):
srv = get_object_or_404( Mumble, id=int(server) )

Loading…
Cancel
Save