add default channel in connection dialog/connect

This commit is contained in:
encrypt 2020-03-15 20:50:54 +01:00
parent 3dda3d27fe
commit ac6e230c26
3 changed files with 16 additions and 3 deletions

View file

@ -9,7 +9,8 @@ window.mumbleWebConfig = {
'port': true, 'port': true,
'token': true, 'token': true,
'username': true, 'username': true,
'password': true 'password': true,
'channelName': false
}, },
// Default values for user settings // Default values for user settings
// You can see your current value by typing `localStorage.getItem('mumble.$setting')` in the web console. // You can see your current value by typing `localStorage.getItem('mumble.$setting')` in the web console.

View file

@ -52,6 +52,10 @@
<td>Password</td> <td>Password</td>
<td><input id="password" type="password" data-bind="value: password"></td> <td><input id="password" type="password" data-bind="value: password"></td>
</tr> </tr>
<tr data-bind="if: $root.config.connectDialog.channelName">
<td>Channel</td>
<td><input id="channelName" type="text" data-bind="value: channelName"></td>
</tr>
</table> </table>
<div class="dialog-footer"> <div class="dialog-footer">
<input class="dialog-close" type="button" data-bind="click: hide" value="Cancel"> <input class="dialog-close" type="button" data-bind="click: hide" value="Cancel">

View file

@ -55,13 +55,14 @@ function ConnectDialog () {
self.token = ko.observable('') self.token = ko.observable('')
self.username = ko.observable('') self.username = ko.observable('')
self.password = ko.observable('') self.password = ko.observable('')
self.channelName = ko.observable('')
self.joinOnly = ko.observable(false) self.joinOnly = ko.observable(false)
self.visible = ko.observable(true) self.visible = ko.observable(true)
self.show = self.visible.bind(self.visible, true) self.show = self.visible.bind(self.visible, true)
self.hide = self.visible.bind(self.visible, false) self.hide = self.visible.bind(self.visible, false)
self.connect = function () { self.connect = function () {
self.hide() self.hide()
ui.connect(self.username(), self.address(), self.port(), self.token(), self.password()) ui.connect(self.username(), self.address(), self.port(), self.token(), self.password(), self.channelName())
} }
} }
@ -331,7 +332,7 @@ class GlobalBindings {
return '[' + new Date().toLocaleTimeString('en-US') + ']' return '[' + new Date().toLocaleTimeString('en-US') + ']'
} }
this.connect = (username, host, port, token, password) => { this.connect = (username, host, port, token, password, channelName = "") => {
this.resetClient() this.resetClient()
this.remoteHost(host) this.remoteHost(host)
@ -363,6 +364,10 @@ class GlobalBindings {
// Register all channels, recursively // Register all channels, recursively
const registerChannel = channel => { const registerChannel = channel => {
this._newChannel(channel) this._newChannel(channel)
// join channel
if (channel.name === channelName) {
client.self.setChannel(channel)
}
channel.children.forEach(registerChannel) channel.children.forEach(registerChannel)
} }
registerChannel(client.root) registerChannel(client.root)
@ -901,6 +906,9 @@ window.onload = function () {
if (queryParams.password) { if (queryParams.password) {
ui.connectDialog.password(queryParams.password) ui.connectDialog.password(queryParams.password)
} }
if (queryParams.channelName) {
ui.connectDialog.channelName(queryParams.channelName)
}
if (queryParams.avatarurl) { if (queryParams.avatarurl) {
// Download the avatar and upload it to the mumble server when connected // Download the avatar and upload it to the mumble server when connected
let url = queryParams.avatarurl let url = queryParams.avatarurl