Add reconnect handler and make reboot state better reflected in the notfications
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
/* global asyncForEach:false */
|
||||
/* global angular:false */
|
||||
/* global asyncForEach, angular, $ */
|
||||
|
||||
angular.module('Application').controller('NotificationsController', ['$scope', '$timeout', 'Client', function ($scope, $timeout, Client) {
|
||||
|
||||
@@ -15,16 +14,6 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
$('#rebootModal').modal('show');
|
||||
},
|
||||
|
||||
waitForReboot: function () {
|
||||
if (Client.offline) return $scope.reboot.busy = false; // at this point, we are showing the offline banner
|
||||
|
||||
Client.getStatus(function (error, status) {
|
||||
if (error) return $timeout($scope.reboot.waitForReboot, 5000);
|
||||
|
||||
$scope.reboot.busy = false;
|
||||
});
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.reboot.busy = true;
|
||||
|
||||
@@ -33,8 +22,8 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
|
||||
$('#rebootModal').modal('hide');
|
||||
|
||||
// show "busy" indicator for 5 seconds to show some ui activity
|
||||
$timeout(function () { $scope.reboot.waitForReboot(); }, 5000);
|
||||
// trigger refetch to show offline banner
|
||||
$timeout(function () { Client.getStatus(function () {}); }, 5000);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -45,7 +34,7 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
busy: true,
|
||||
|
||||
refresh: function () {
|
||||
Client.getNotifications(false, 1, 20, function (error, result) {
|
||||
Client.getNotifications(false, 1, 100, function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
// collapse by default
|
||||
@@ -119,4 +108,8 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
Client.onReady(function () {
|
||||
$scope.notifications.refresh();
|
||||
});
|
||||
|
||||
Client.onReconnect(function () {
|
||||
$scope.notifications.refresh();
|
||||
})
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user