mumble tokens basic implementation, connection dialog token is replaced with tokens
This commit is contained in:
parent
973a7245d0
commit
003dc96ce1
|
@ -41,9 +41,22 @@
|
||||||
<td><input id="port" type="text" data-bind="value: port" required></td>
|
<td><input id="port" type="text" data-bind="value: port" required></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr data-bind="if: $root.config.connectDialog.token">
|
<tr data-bind="if: $root.config.connectDialog.token">
|
||||||
<td>Token</td>
|
<td>Tokens</td>
|
||||||
<td><input id="token" type="text" data-bind="value: token"></td>
|
<td>
|
||||||
|
<input type="text" data-bind='value: tokenToAdd, valueUpdate: "afterkeydown"'>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr data-bind="if: $root.config.connectDialog.token">
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<button class="dialog-submit" type="button" data-bind="enable: selectedTokens().length > 0, click: removeSelectedTokens()">Remove</button>
|
||||||
|
<button class="dialog-submit" type="button" data-bind="enable: tokenToAdd().length > 0, click: addToken()">Add</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr data-bind="if: $root.config.connectDialog.token">
|
||||||
|
<td></td>
|
||||||
|
<td><select id="token" multiple="multiple" height="5" data-bind="options:tokens, selectedOptions:selectedTokens, valueUpdate: 'afterkeydown', event: { keypress: $root.config.connectDialog.deleteSelectedTokensKey}"></select></td>
|
||||||
|
</tr>
|
||||||
<tr data-bind="if: $root.config.connectDialog.username">
|
<tr data-bind="if: $root.config.connectDialog.username">
|
||||||
<td>Username</td>
|
<td>Username</td>
|
||||||
<td><input id="username" type="text" data-bind="value: username" required></td>
|
<td><input id="username" type="text" data-bind="value: username" required></td>
|
||||||
|
|
35
app/index.js
35
app/index.js
|
@ -52,7 +52,9 @@ function ConnectDialog () {
|
||||||
var self = this
|
var self = this
|
||||||
self.address = ko.observable('')
|
self.address = ko.observable('')
|
||||||
self.port = ko.observable('')
|
self.port = ko.observable('')
|
||||||
self.token = ko.observable('')
|
self.tokenToAdd = ko.observable('')
|
||||||
|
self.selectedTokens = ko.observableArray([])
|
||||||
|
self.tokens = ko.observableArray([])
|
||||||
self.username = ko.observable('')
|
self.username = ko.observable('')
|
||||||
self.password = ko.observable('')
|
self.password = ko.observable('')
|
||||||
self.channelName = ko.observable('')
|
self.channelName = ko.observable('')
|
||||||
|
@ -62,7 +64,25 @@ function ConnectDialog () {
|
||||||
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(), self.channelName())
|
ui.connect(self.username(), self.address(), self.port(), self.tokens(), self.password(), self.channelName())
|
||||||
|
}
|
||||||
|
|
||||||
|
self.addToken = function() {
|
||||||
|
if ((self.tokenToAdd() != "") && (self.tokens.indexOf(self.tokenToAdd()) < 0)) {
|
||||||
|
self.tokens.push(self.tokenToAdd())
|
||||||
|
}
|
||||||
|
self.tokenToAdd("")
|
||||||
|
}
|
||||||
|
|
||||||
|
self.removeSelectedTokensKey = function(data, event) {
|
||||||
|
if (event.keyCode == 46) {
|
||||||
|
sefl.removeSelectedTokens()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.removeSelectedTokens = function() {
|
||||||
|
console.log("gogog")
|
||||||
|
this.tokens.removeAll(this.selectedTokens())
|
||||||
|
this.selectedTokens([])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +352,7 @@ class GlobalBindings {
|
||||||
return '[' + new Date().toLocaleTimeString('en-US') + ']'
|
return '[' + new Date().toLocaleTimeString('en-US') + ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connect = (username, host, port, token, password, channelName = "") => {
|
this.connect = (username, host, port, tokens = [], password, channelName = "") => {
|
||||||
this.resetClient()
|
this.resetClient()
|
||||||
|
|
||||||
this.remoteHost(host)
|
this.remoteHost(host)
|
||||||
|
@ -347,7 +367,8 @@ class GlobalBindings {
|
||||||
// TODO: token
|
// TODO: token
|
||||||
this.connector.connect(`wss://${host}:${port}`, {
|
this.connector.connect(`wss://${host}:${port}`, {
|
||||||
username: username,
|
username: username,
|
||||||
password: password
|
password: password,
|
||||||
|
tokens: tokens
|
||||||
}).done(client => {
|
}).done(client => {
|
||||||
log('Connected!')
|
log('Connected!')
|
||||||
|
|
||||||
|
@ -364,7 +385,9 @@ class GlobalBindings {
|
||||||
// Register all channels, recursively
|
// Register all channels, recursively
|
||||||
const registerChannel = (channel, channelPath) => {
|
const registerChannel = (channel, channelPath) => {
|
||||||
this._newChannel(channel)
|
this._newChannel(channel)
|
||||||
|
console.log(channelPath)
|
||||||
if(channelPath === channelName) {
|
if(channelPath === channelName) {
|
||||||
|
console.log(channel)
|
||||||
client.self.setChannel(channel)
|
client.self.setChannel(channel)
|
||||||
}
|
}
|
||||||
channel.children.forEach(ch => registerChannel(ch, channelPath+"/"+ch.name))
|
channel.children.forEach(ch => registerChannel(ch, channelPath+"/"+ch.name))
|
||||||
|
@ -894,8 +917,8 @@ window.onload = function () {
|
||||||
} else {
|
} else {
|
||||||
useJoinDialog = false
|
useJoinDialog = false
|
||||||
}
|
}
|
||||||
if (queryParams.token) {
|
if (queryParams.tokens) {
|
||||||
ui.connectDialog.token(queryParams.token)
|
ui.connectDialog.tokens(queryParams.tokens.split(","))
|
||||||
}
|
}
|
||||||
if (queryParams.username) {
|
if (queryParams.username) {
|
||||||
ui.connectDialog.username(queryParams.username)
|
ui.connectDialog.username(queryParams.username)
|
||||||
|
|
|
@ -444,7 +444,7 @@ form {
|
||||||
top: calc(50% - 10px);
|
top: calc(50% - 10px);
|
||||||
left: calc(50% - 100px);
|
left: calc(50% - 100px);
|
||||||
}
|
}
|
||||||
.connect-dialog input[type=text] {
|
.connect-dialog input[type=text], select {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
border: 1px $dialog-input-border-color solid;
|
border: 1px $dialog-input-border-color solid;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
Loading…
Reference in a new issue