Skip to content

Commit

Permalink
fix(servers): fix "server updated" check handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Sep 8, 2015
1 parent 1bf2c1a commit 7f829f7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/scripts/opennms/services/Servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,23 @@
return deferred.promise;
};

var sortServers = function(a, b) {
if (a && b) {
return a.name.localeCompare(b.name);
}
return 0;
};

var checkServersUpdated = function(force) {
var oldServers = angular.copy(servers);
oldServers.sort(sortServers);
return getServers().then(function(newServers) {
servers = newServers;
if (force || (angular.toJson(oldServers) !== angular.toJson(newServers))) {
newServers.sort(sortServers);
servers = angular.copy(newServers);
if (force === true || !angular.equals(oldServers, newServers)) {
console.log('Servers.checkServersUpdated: server list has changed.');
console.log('old: ' + angular.toJson(oldServers));
console.log('new: ' + angular.toJson(newServers));
UtilEventBroadcaster.serversUpdated(newServers, oldServers);
$timeout(checkDefaultServerUpdated);
}
Expand All @@ -49,7 +60,7 @@
var oldDefaultServer = defaultServer;
getDefaultServer().then(function(newDefaultServer) {
defaultServer = newDefaultServer;
if (angular.toJson(oldDefaultServer) !== angular.toJson(newDefaultServer)) {
if (!angular.equals(oldDefaultServer, newDefaultServer)) {
UtilEventBroadcaster.defaultServerUpdated(newDefaultServer);
UtilEventBroadcaster.dirty('all');
}
Expand Down

0 comments on commit 7f829f7

Please sign in to comment.