From fe62183cd914a7834c6d6a94d487e2e13e212251 Mon Sep 17 00:00:00 2001 From: Zaran Date: Sun, 15 Apr 2012 05:54:46 -0700 Subject: CSS improvements, first steps on angular * disable the connect form when connected * add a disconnect button when connected * add a research field to filter the contact list (not working) Thinks I want to understand: * how to share a variable between several scopes * could StropheSrv be an attribute of the connect scope ? if yes, we can call it directly and avoid wrapping it (this is the third level of wrapping around libStrophe...) --- alias-angular/app/js/controllers.js | 9 +++++++++ alias-angular/app/js/services.js | 3 +++ 2 files changed, 12 insertions(+) (limited to 'alias-angular/app/js') diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js index d487fdf..162f794 100644 --- a/alias-angular/app/js/controllers.js +++ b/alias-angular/app/js/controllers.js @@ -2,23 +2,32 @@ /* App Controllers */ function ConnectCtl($scope, StropheSrv, $log, $rootScope) { + $scope.status = ""; function connect_callback(status){ if ( status == Strophe.Status.CONNECTING ) { $log.log('Strophe is connecting.'); + $scope.status = "Connecting"; } else if ( status == Strophe.Status.CONNFAIL ) { $log.log('Strophe failed to connect.'); + $scope.status = "Failed"; } else if ( status == Strophe.Status.DISCONNECTING ) { $log.log('Strophe is disconnecting.'); + $scope.status = "Disconnecting"; } else if ( status == Strophe.Status.DISCONNECTED ) { $log.log('Strophe is disconnected.'); + $scope.status = "Disconnected"; } else if ( status == Strophe.Status.CONNECTED ) { $log.log('Strophe is connected.'); + $scope.status = "Connected"; $rootScope.$broadcast('connected', true); } }; $scope.login = function () { StropheSrv.login($scope.username, $scope.password, connect_callback); }; + $scope.disconnect = function() { + StropheSrv.disconnect(); + }; } ConnectCtl.$inject = ['$scope', 'StropheSrv', '$log', '$rootScope']; diff --git a/alias-angular/app/js/services.js b/alias-angular/app/js/services.js index 091a4fa..68e1537 100644 --- a/alias-angular/app/js/services.js +++ b/alias-angular/app/js/services.js @@ -20,6 +20,9 @@ angular.module('Alias.services', [], function($provide) { }, send: function(stanza) { $rootScope.$apply(connection.send(stanza)); + }, + disconnect: function() { + connection.disconnect("disconnect"); } }; }]); -- cgit v1.2.3-70-g09d2