Merge pull request #6 from Arkaroo/master

Implement server password support
This commit is contained in:
Jonas Herzig 2017-05-02 19:17:02 +02:00 committed by GitHub
commit 8a5b16ee51
3 changed files with 28 additions and 7 deletions

View file

@ -20,8 +20,8 @@
<div class="loading-circle" data-bind="css: { loaded: true }"></div> <div class="loading-circle" data-bind="css: { loaded: true }"></div>
</div> </div>
<div id="container" style="display: none" data-bind="visible: true"> <div id="container" style="display: none" data-bind="visible: true">
<!-- ko with: connectDialog --> <!-- ko with: connectDialog -->
<div class="connect-dialog" data-bind="visible: visible"> <div class="connect-dialog" data-bind="visible: visible">
<div class="dialog-header"> <div class="dialog-header">
Connect to Server Connect to Server
</div> </div>
@ -43,6 +43,10 @@
<td>Username</td> <td>Username</td>
<td><input id="username" type="text" data-bind="value: username"></td> <td><input id="username" type="text" data-bind="value: username"></td>
</tr> </tr>
<tr>
<td>Password</td>
<td><input id="password" type="password" data-bind="value: password"></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

@ -27,12 +27,13 @@ function ConnectDialog () {
self.port = ko.observable('443') self.port = ko.observable('443')
self.token = ko.observable('') self.token = ko.observable('')
self.username = ko.observable('') self.username = ko.observable('')
self.password = ko.observable('')
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()) ui.connect(self.username(), self.address(), self.port(), self.token(), self.password())
} }
} }
@ -81,7 +82,7 @@ class GlobalBindings {
return '[' + new Date().toLocaleTimeString('en-US') + ']' return '[' + new Date().toLocaleTimeString('en-US') + ']'
} }
this.connect = (username, host, port, token) => { this.connect = (username, host, port, token, password) => {
this.resetClient() this.resetClient()
log('Connecting to server ', host) log('Connecting to server ', host)
@ -89,12 +90,12 @@ class GlobalBindings {
// TODO: token // TODO: token
mumbleConnect(`wss://${host}:${port}`, { mumbleConnect(`wss://${host}:${port}`, {
username: username, username: username,
password: password,
codecs: CodecsBrowser codecs: CodecsBrowser
}).done(client => { }).done(client => {
log('Connected!') log('Connected!')
this.client = client this.client = client
// Prepare for connection errors // Prepare for connection errors
client.on('error', function (err) { client.on('error', function (err) {
log('Connection error:', err) log('Connection error:', err)
@ -139,7 +140,11 @@ class GlobalBindings {
}) })
} }
}, err => { }, err => {
log('Connection error:', err) if (err.type == 4) {
log('Connection error: invalid server password')
} else {
log('Connection error:', err)
}
}) })
} }
@ -434,6 +439,9 @@ window.onload = function () {
if (queryParams.username) { if (queryParams.username) {
ui.connectDialog.username(queryParams.username) ui.connectDialog.username(queryParams.username)
} }
if (queryParams.password) {
ui.connectDialog.password(queryParams.password)
}
ko.applyBindings(ui) ko.applyBindings(ui)
} }

View file

@ -233,7 +233,7 @@ form {
.connect-dialog { .connect-dialog {
position: absolute; position: absolute;
width: 300px; width: 300px;
height: 197px; height: 227px;
top: calc(50% - 100px); top: calc(50% - 100px);
left: calc(50% - 150px); left: calc(50% - 150px);
background-color: #eee; background-color: #eee;
@ -250,3 +250,12 @@ form {
padding: 2px; padding: 2px;
width: calc(100% - 8px); width: calc(100% - 8px);
} }
.connect-dialog input[type=password] {
font-size: 15px;
border: 1px gray solid;
border-radius: 3px;
background-color: white;
color: black;
padding: 2px;
width: calc(100% - 8px);
}