Browse Source

implement moving channels via drag&drop, don't set leaf:true on channels so they can be drop targets

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
13c86e9cae
  1. 5
      pyweb/mumble/MumbleCtlDbus.py
  2. 7
      pyweb/mumble/MumbleCtlIce.py
  3. 6
      pyweb/mumble/media/js/channelviewer.js
  4. 3
      pyweb/mumble/models.py
  5. 5
      pyweb/mumble/templates/mumble/mumble.html
  6. 21
      pyweb/mumble/views.py

5
pyweb/mumble/MumbleCtlDbus.py

@ -306,6 +306,11 @@ class MumbleCtlDbus_118(MumbleCtlBase):
(session, ismute, isdeaf, suppressed, selfMute, selfDeaf, channel) = srv.getPlayerState(dbus.UInt32(sessionid))
srv.setPlayerState((session, ismute, deaf, suppressed, selfMute, selfDeaf, channel))
def moveChannel(self, srvid, channelid, parentid):
srv = self._getDbusServerObject(srvid)
(chanid, name, parent, links) = srv.getChannelState(dbus.UInt32(channelid))
srv.setChannelState((chanid, name, parentid, links))
@staticmethod
def convertDbusTypeToNative(data):
#i know dbus.* type is extends python native type.

7
pyweb/mumble/MumbleCtlIce.py

@ -434,6 +434,13 @@ class MumbleCtlIce_118(MumbleCtlBase):
def getLog( self, srvid, first=0, last=100 ):
return self._getIceServerObject(srvid).getLog( first, last )
@protectDjangoErrPage
def moveChannel(self, srvid, channelid, parentid):
srv = self._getIceServerObject(srvid)
state = srv.getChannelState(channelid)
state.parent = parentid
srv.setChannelState(state)
@protectDjangoErrPage
def moveUser(self, srvid, sessionid, channelid):
srv = self._getIceServerObject(srvid)

6
pyweb/mumble/media/js/channelviewer.js

@ -77,6 +77,8 @@ Ext.ux.MumbleChannelViewer = function( config ){
dragdrop: function( tree, node, targetdd, ev ){
if( typeof node.attributes.userdata != "undefined" )
tree.fireEvent("moveUser", tree, node.attributes.userdata, targetdd.dragOverData.target.attributes.chandata);
else if( typeof node.attributes.chandata != "undefined" )
tree.fireEvent("moveChannel", tree, node.attributes.chandata, targetdd.dragOverData.target.attributes.chandata);
}
});
@ -121,7 +123,7 @@ Ext.ux.MumbleChannelViewer = function( config ){
this.addEvents({
'moveUser': true,
'moveChannel': true //TODO
'moveChannel': true
});
this.autoRefreshId = 0;
@ -174,7 +176,6 @@ Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, {
text: json.channels[i].name,
id: ("channel_" + json.channels[i].id),
nodeType: 'async',
leaf: true,
allowDrag: true,
allowDrop: true,
draggable: true,
@ -184,7 +185,6 @@ Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, {
chandata: json.channels[i],
imageurl: tree.imageurl
};
node.leaf = false;
node.children.push( child );
subchan_users += populateNode( child, json.channels[i] );
}

3
pyweb/mumble/models.py

@ -566,6 +566,9 @@ class Mumble( models.Model ):
def deafenUser( self, sessionid, deafen=True ):
return self.ctl.moveUser( self.srvid, sessionid, deafen )
def moveChannel( self, channelid, parentid ):
return self.ctl.moveChannel( self.srvid, channelid, parentid )
def getLog( self, first=0, last=100, filter="" ):
""" Return log entries from ``first`` to ``last`` that contain ``filter`` (if any). """
logentries = self.ctl.getLog( self.srvid, first, last )

5
pyweb/mumble/templates/mumble/mumble.html

@ -63,7 +63,10 @@
imageurl: '{{MUMBLE_MEDIA_PREFIX}}/img',
listeners: {
moveUser: function( tree, userdata, chandata ){
User.move( {{MumbleServer.id}}, userdata.session, chandata.id )
Mumble.moveUser( {{MumbleServer.id}}, userdata.session, chandata.id );
},
moveChannel: function( tree, chandata, targetdata ){
Mumble.moveChannel( {{MumbleServer.id}}, chandata.id, targetdata.id );
}
}
}, {

21
pyweb/mumble/views.py

@ -244,6 +244,20 @@ 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 moveUser( request, server, sessionid, channelid ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.moveUser( sessionid, channelid )
@EXT_DIRECT_PROVIDER.register_method( "Mumble" )
def moveChannel( request, server, channelid, parentid ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.moveChannel( channelid, parentid )
@EXT_DIRECT_PROVIDER.register_method( "MumbleUserAdmin" )
def users( request, server ):
@ -329,13 +343,6 @@ def update_avatar( request, userid ):
return HttpResponse( "false", mimetype="text/html" )
@EXT_DIRECT_PROVIDER.register_method( "User" )
def move( request, server, sessionid, channelid ):
srv = get_object_or_404( Mumble, id=int(server) )
if not srv.isUserAdmin( request.user ):
raise Exception( 'Access denied' )
srv.moveUser( sessionid, channelid )
def mmng_tree( request, server ):
""" Return a JSON representation of the channel tree suitable for
Murmur Manager:

Loading…
Cancel
Save