Better connection / password error handling

This commit is contained in:
Tor Hveem 2014-02-14 09:14:55 -05:00 committed by David Cormier
parent e68e7dd01d
commit 0f44465faa
3 changed files with 18 additions and 4 deletions

View file

@ -60,11 +60,15 @@
<input type="text" class="form-control monospace" id="host" ng-model="host" placeholder="Address">
<input type="text" class="form-control monospace" id="port" ng-model="port" placeholder="9001">
</div>
<label class="control-label" for="password">WeeChat relay password</label>
<input type="password" class="form-control monospace" id="password" ng-model="password" placeholder="Password">
<div class="alert alert-danger" ng-show="passwordError">
Error: wrong password
</div>
<label class="control-label" for="password">WeeChat relay password</label>
<input type="password" class="form-control monospace" id="password" ng-model="password" placeholder="Password">
<div class="checkbox">
<label class="control-label" for="savepassword">
<input type="checkbox" id="savepassword" ng-model="savepassword">

View file

@ -263,6 +263,8 @@ function($rootScope,
]).then(
null,
function() {
// Connection got closed, lets check if we ever was connected successfully
if(!$rootScope.waseverconnected)
$rootScope.passwordError = true;
}
);
@ -310,12 +312,19 @@ function($rootScope,
};
var onmessage = function(event) {
// If we recieve a message from WeeChat it means that
// password was OK. Store that result and check for it
// in the failure handler.
$rootScope.waseverconnected = true;
}
var onclose = function () {
/*
* Handles websocket disconnection
*/
$log.info("Disconnected from relay");
failCallbacks('disconnection');
$rootScope.connected = false;
$rootScope.$apply();
@ -345,6 +354,7 @@ function($rootScope,
'binaryType': "arraybuffer",
'onopen': onopen,
'onclose': onclose,
'onmessage': onmessage,
'onerror': onerror,
});
@ -518,7 +528,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.buffers = models.model.buffers;
$scope.activeBuffer = models.getActiveBuffer;
$rootScope.commands = [];
$rootScope.waseverconnected = false;
$rootScope.models = models;

View file

@ -106,7 +106,7 @@ function($rootScope, $q) {
// otherwise emit it
$rootScope.$emit('onMessage', message);
}
$rootScope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type);
$rootScope.$apply();
};