Added AddChanelDialog and fixed add channel menu options

Must be registered user to be able to add, use mumble-django or something to add a user with password login.
This commit is contained in:
raddinox 2020-08-13 23:21:54 +02:00 committed by Jonas Herzig
parent cad3a3e07b
commit 9f36bc7c3b
3 changed files with 62 additions and 4 deletions

View file

@ -78,6 +78,22 @@
</form>
</div>
<!-- /ko -->
<!-- ko with: addChannelDialog -->
<div class="add-channel-dialog dialog" data-bind="visible: visible()">
<div class="dialog-header">
Add channel
</div>
<form data-bind="submit: addchannel">
<table>
<tr>
<td>Channel</td>
<td><input id="channelName" type="text" data-bind="value: channelName" required></td>
</tr>
</table>
<input class="dialog-submit" type="submit" value="Add channel">
</form>
</div>
<!-- /ko -->
<!-- ko with: connectDialog -->
<div class="join-dialog dialog" data-bind="visible: visible() && joinOnly()">
<div class="dialog-header">
@ -413,7 +429,7 @@
class="join">
Join Channel
</li>
<li data-bind="css: { disabled: !canAdd() }"
<li data-bind="css: { disabled: !canAdd() }, click: $root.openAddChannel.bind($root, $root.thisUser())"
class="add">
Add
</li>
@ -421,7 +437,7 @@
class="edit">
Edit
</li>
<li data-bind="css: { disabled: !canRemove() }"
<li data-bind="css: { disabled: !canRemove() }, click: $root.ChannelRemove.bind($root, $root.thisUser())"
class="remove">
Remove
</li>

View file

@ -88,6 +88,20 @@ function ContextMenu () {
self.target = ko.observable()
}
function AddChannelDialog () {
var self = this;
self.channelName = ko.observable('')
self.parentID = 0;
self.visible = ko.observable(false);
self.show = self.visible.bind(self.visible, true)
self.hide = self.visible.bind(self.visible, false)
self.addchannel = function() {
self.hide();
ui.addchannel(self.channelName());
}
}
function ConnectDialog () {
var self = this
self.address = ko.observable('')
@ -327,6 +341,7 @@ class GlobalBindings {
this.userContextMenu = new ContextMenu()
this.channelContextMenu = new ContextMenu()
this.connectDialog = new ConnectDialog()
this.addChannelDialog = new AddChannelDialog()
this.connectErrorDialog = new ConnectErrorDialog(this.connectDialog)
this.connectionInfo = new ConnectionInfo(this)
this.commentDialog = new CommentDialog()
@ -372,6 +387,32 @@ class GlobalBindings {
this.settingsDialog(new SettingsDialog(this.settings))
}
this.openAddChannel = (user, channel) => {
this.addChannelDialog.parentID = channel.model._id;
this.addChannelDialog.show()
}
this.addchannel = (channelName) => {
var msg = {
name: 'ChannelState',
payload: {
parent: this.addChannelDialog.parentID || 0,
name: channelName
}
}
this.client._send(msg);
}
this.ChannelRemove = (user, channel) => {
var msg = {
name: 'ChannelRemove',
payload: {
channel_id: channel.model._id
}
}
this.client._send(msg);
}
this.applySettings = () => {
const settingsDialog = this.settingsDialog()
@ -689,13 +730,13 @@ class GlobalBindings {
return true // TODO check for perms
}
ui.canAdd = () => {
return false // TODO check for perms and implement
return true // TODO check for perms
}
ui.canEdit = () => {
return false // TODO check for perms and implement
}
ui.canRemove = () => {
return false // TODO check for perms and implement
return true // TODO check for perms
}
ui.canLink = () => {
return false // TODO check for perms and implement

View file

@ -138,6 +138,7 @@ class WorkerBasedMumbleClient extends EventEmitter {
connector._addCall(this, 'setSelfMute', id)
connector._addCall(this, 'setSelfTexture', id)
connector._addCall(this, 'setAudioQuality', id)
connector._addCall(this, '_send', id)
connector._addCall(this, 'disconnect', id)
let _disconnect = this.disconnect