Browse Source

hide admin stuff for normal users in the UI

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
549ce65632
  1. 468
      pyweb/mumble/media/js/channelviewerplugins.js
  2. 6
      pyweb/mumble/templates/mumble/mumble.html

468
pyweb/mumble/media/js/channelviewerplugins.js

@ -17,163 +17,177 @@ Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, {
activate: function( userdata ){
if( !this.wnd ){
this.userdata = userdata;
this.wnd = new Ext.Window({
title: this.windowTitle || gettext("User details"),
layout: 'fit',
items: [{
xtype: "tabpanel",
activeTab: 0,
tabitems = [{
xtype: "form",
border: false,
title: gettext("User comment"),
items: [{
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "comment",
value: userdata.comment,
}],
}, {
title: gettext("Avatar"),
scope: this,
listeners: {
afterrender: function( panel ){
Mumble.hasTexture( this.scope.serverid, this.scope.userdata.userid, function(provider, response){
if( response.result.has ){
panel.el.dom.children[0].children[0].innerHTML = String.format(
'<img src="{0}" alt="avatar" />', response.result.url
);
}
else{
panel.el.dom.children[0].children[0].innerHTML =
gettext("This user does not have an Avatar.");
}
} );
}
},
html: gettext("Loading..."),
}, {
title: gettext("Infos"),
xtype: "form",
border: false,
items: [{
xtype: "form",
border: false,
title: gettext("User comment"),
items: [{
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "comment",
value: userdata.comment,
}],
xtype: "checkbox",
fieldLabel: gettext("Authenticated"),
disabled: true,
name: "a",
checked: (this.userdata.userid != -1)
}, {
title: gettext("Avatar"),
scope: this,
listeners: {
afterrender: function( panel ){
Mumble.hasTexture( this.scope.serverid, this.scope.userdata.userid, function(provider, response){
if( response.result.has ){
panel.el.dom.children[0].children[0].innerHTML = String.format(
'<img src="{0}" alt="avatar" />', response.result.url
);
}
else{
panel.el.dom.children[0].children[0].innerHTML =
gettext("This user does not have an Avatar.");
}
} );
}
},
html: gettext("Loading..."),
xtype: "checkbox",
fieldLabel: gettext("Self-Deafened"),
disabled: true,
name: "sd",
checked: this.userdata.selfDeaf
}, {
xtype: "checkbox",
fieldLabel: gettext("Deafened"),
disabled: true,
name: "d",
checked: this.userdata.deaf
}, {
xtype: "checkbox",
fieldLabel: gettext("Self-Muted"),
disabled: true,
name: "sm",
checked: this.userdata.selfMute
}, {
xtype: "checkbox",
fieldLabel: gettext("Muted"),
disabled: true,
name: "m",
checked: this.userdata.mute
}, {
title: gettext("Infos"),
xtype: "form",
border: false,
items: [{
xtype: "checkbox",
fieldLabel: gettext("Authenticated"),
name: "a",
checked: (this.userdata.userid != -1)
}, {
xtype: "checkbox",
fieldLabel: gettext("Self-Deafened"),
name: "sd",
checked: this.userdata.selfDeaf
}, {
xtype: "checkbox",
fieldLabel: gettext("Deafened"),
name: "d",
checked: this.userdata.deaf
}, {
xtype: "checkbox",
fieldLabel: gettext("Self-Muted"),
name: "sm",
checked: this.userdata.selfMute
}, {
xtype: "checkbox",
fieldLabel: gettext("Muted"),
name: "m",
checked: this.userdata.mute
}, {
xtype: "checkbox",
fieldLabel: gettext("Suppressed"),
name: "s",
checked: this.userdata.suppress
}, {
xtype: "checkbox",
fieldLabel: gettext("Priority Speaker"),
name: "p",
checked: this.userdata.prioritySpeaker
}, {
xtype: "checkbox",
fieldLabel: gettext("Recording"),
name: "r",
checked: this.userdata.recording
}]
xtype: "checkbox",
fieldLabel: gettext("Suppressed"),
disabled: true,
name: "s",
checked: this.userdata.suppress
}, {
xtype: "form",
border: false,
title: gettext("Administration"),
items: [{
xtype: "checkbox",
fieldLabel: gettext("Ban"),
name: "ban"
}, {
xtype: "numberfield",
fieldLabel: gettext("Ban duration"),
value: 3600,
name: "duration"
}, {
xtype: "label",
text: gettext("Only if banning. Set to 0 for permanent ban, any other value for the ban duration in seconds."),
cls: "form_hint_label",
}, {
xtype: "textfield",
fieldLabel: gettext("Reason"),
name: "reason"
}],
fbar: [{
scope: this,
text: gettext("Kick"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.kickUser(
this.serverid, this.userdata.session, f.reason, (f.ban || false), parseInt(f.duration)
);
}
}, {
text: gettext("Mute"),
enableToggle: true,
scope: this,
ref: '../mutebutton',
pressed: this.userdata.mute,
disabled: this.userdata.deaf,
toggleHandler: function(btn, state){
Mumble.muteUser(this.serverid, this.userdata.session, state);
}
}, {
text: gettext("Deafen"),
enableToggle: true,
scope: this,
ref: '../deafenbutton',
pressed: this.userdata.deaf,
toggleHandler: function(btn, state){
Mumble.deafenUser(this.serverid, this.userdata.session, state);
if( state )
btn.refOwner.mutebutton.toggle(true, true);
btn.refOwner.mutebutton.setDisabled(state);
}
}],
xtype: "checkbox",
fieldLabel: gettext("Priority Speaker"),
disabled: true,
name: "p",
checked: this.userdata.prioritySpeaker
}, {
xtype: "form",
border: false,
title: gettext("Send message"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "message"
}],
fbar: [{
scope: this,
text: gettext("Send message"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.sendMessage(this.serverid, this.userdata.session, f.message);
}
}]
xtype: "checkbox",
fieldLabel: gettext("Recording"),
disabled: true,
name: "r",
checked: this.userdata.recording
}]
}];
if( this.is_admin ){
tabitems.push({
xtype: "form",
border: false,
title: gettext("Administration"),
items: [{
xtype: "checkbox",
fieldLabel: gettext("Ban"),
name: "ban"
}, {
xtype: "numberfield",
fieldLabel: gettext("Ban duration"),
value: 3600,
name: "duration"
}, {
xtype: "label",
text: gettext("Only if banning. Set to 0 for permanent ban, any other value for the ban duration in seconds."),
cls: "form_hint_label",
}, {
xtype: "textfield",
fieldLabel: gettext("Reason"),
name: "reason"
}],
}],
fbar: [{
scope: this,
text: gettext("Kick"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.kickUser(
this.serverid, this.userdata.session, f.reason, (f.ban || false), parseInt(f.duration)
);
}
}, {
text: gettext("Mute"),
enableToggle: true,
scope: this,
ref: '../mutebutton',
pressed: this.userdata.mute,
disabled: this.userdata.deaf,
toggleHandler: function(btn, state){
Mumble.muteUser(this.serverid, this.userdata.session, state);
}
}, {
text: gettext("Deafen"),
enableToggle: true,
scope: this,
ref: '../deafenbutton',
pressed: this.userdata.deaf,
toggleHandler: function(btn, state){
Mumble.deafenUser(this.serverid, this.userdata.session, state);
if( state )
btn.refOwner.mutebutton.toggle(true, true);
btn.refOwner.mutebutton.setDisabled(state);
}
}],
}, {
xtype: "form",
border: false,
title: gettext("Send message"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "message"
}],
fbar: [{
scope: this,
text: gettext("Send message"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.sendMessage(this.serverid, this.userdata.session, f.message);
}
}]
});
}
this.wnd = new Ext.Window({
title: this.windowTitle || gettext("User details"),
layout: 'fit',
items: {
xtype: "tabpanel",
activeTab: 0,
border: false,
items: tabitems,
},
width: 500,
height: 300,
scope: this,
@ -212,85 +226,93 @@ Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
activate: function( chandata ){
if( !this.wnd ){
this.chandata = chandata;
tabitems = [{
xtype: "form",
border: false,
title: gettext("Channel description"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "textfield",
fieldLabel: "x",
hideLabel: true,
name: "name",
value: chandata.name
}, {
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "description",
value: chandata.description
}],
}];
if( this.is_admin ){
Ext.apply( tabitems[0], {
fbar: [{
text: gettext('Add subchannel...'),
scope: this,
handler: function(btn){
Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
if (btn == 'ok'){
Mumble.addChannel( this.serverid, text, this.chandata.id );
}
}, this);
}
}, {
scope: this,
text: gettext("Submit name/description"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description);
}
}, {
text: gettext('Delete channel'),
scope: this,
handler: function(btn){
Ext.Msg.confirm(
gettext('Confirm channel deletion'),
interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
function(btn){
if( btn == 'yes' ){
Mumble.removeChannel( this.serverid, this.chandata.id );
}
}, this);
}
}]
});
tabitems.push({
xtype: "form",
border: false,
title: gettext("Send message"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "checkbox",
fieldLabel: gettext('Cascade to subchannels'),
name: 'tree'
}, {
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "message"
}],
fbar: [{
scope: this,
text: gettext("Send message"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.sendMessageChannel(this.serverid, this.chandata.id, (f.tree || false), f.message);
}
}]
});
}
this.wnd = new Ext.Window({
title: this.windowTitle || gettext("Channel details"),
layout: 'fit',
items: [{
xtype: "tabpanel",
activeTab: 0,
items: [{
xtype: "form",
border: false,
title: gettext("Channel description"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "textfield",
fieldLabel: "x",
hideLabel: true,
name: "name",
value: chandata.name
}, {
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "description",
value: chandata.description
}],
fbar: [{
text: gettext('Add subchannel...'),
scope: this,
handler: function(btn){
Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
if (btn == 'ok'){
Mumble.addChannel( this.serverid, text, this.chandata.id );
}
}, this);
}
}, {
scope: this,
text: gettext("Submit name/description"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description);
}
}, {
text: gettext('Delete channel'),
scope: this,
handler: function(btn){
Ext.Msg.confirm(
gettext('Confirm channel deletion'),
interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
function(btn){
if( btn == 'yes' ){
Mumble.removeChannel( this.serverid, this.chandata.id );
}
}, this);
}
}]
}, {
xtype: "form",
border: false,
title: gettext("Send message"),
defaults: { "anchor": "-20px" },
items: [{
xtype: "checkbox",
fieldLabel: gettext('Cascade to subchannels'),
name: 'tree'
}, {
xtype: "htmleditor",
fieldLabel: 'x',
hideLabel: true,
name: "message"
}],
fbar: [{
scope: this,
text: gettext("Send message"),
handler: function(btn){
f = btn.ownerCt.ownerCt.getForm().getValues();
Mumble.sendMessageChannel(this.serverid, this.chandata.id, (f.tree || false), f.message);
}
}]
}],
items: tabitems
}],
width: 500,
height: 300,

6
pyweb/mumble/templates/mumble/mumble.html

@ -79,10 +79,12 @@
enableDD: true,
plugins: [
new Ext.ux.MumbleUserEditor({
serverid: {{MumbleServer.id}}
serverid: {{MumbleServer.id}},
is_admin: {{ IsAdmin|lower }}
}),
new Ext.ux.MumbleChannelEditor({
serverid: {{MumbleServer.id}}
serverid: {{MumbleServer.id}},
is_admin: {{ IsAdmin|lower }}
})
],
source_url: "{% url mumble.views.cvp_json MumbleServer.id %}",

Loading…
Cancel
Save