Skip to content

Commit

Permalink
STry and avoid refreshing the perspective list so much to help with #588
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Sep 27, 2013
1 parent 22a392c commit eb092f3
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions hawtio-web/src/main/webapp/app/core/js/navbar.ts
Expand Up @@ -22,22 +22,26 @@ module Core {

$scope.isValid = (nav) => nav && nav.isValid(workspace);

$scope.$watch('perspectiveDetails.perspective', function() {
var perspective = $scope.perspectiveDetails.perspective;
if (perspective) {
console.log("Changed the perspective to " + JSON.stringify(perspective));
$location.search(Perspective.perspectiveSearchId, perspective.id);
reloadPerspective();
$scope.$watch('perspectiveDetails.perspective', (newValue, oldValue) => {
if (angular.toJson(newValue) !== angular.toJson(oldValue)) {
var perspective = $scope.perspectiveDetails.perspective;
if (perspective) {
console.log("Changed the perspective to " + JSON.stringify(perspective));
$location.search(Perspective.perspectiveSearchId, perspective.id);
reloadPerspective();
$scope.topLevelTabs = Perspective.topLevelTabs($location, workspace, jolokia, localStorage);
}
}
});

// when we change the view/selection lets update the hash so links have the latest stuff
$scope.$on('$routeChangeSuccess', function () {
$scope.hash = workspace.hash();

reloadPerspective();
});



/*
$scope.$watch('hash', function() {
console.log("$scope.hash: ", $scope.hash);
Expand Down Expand Up @@ -110,15 +114,21 @@ module Core {
};

function reloadPerspective() {
$scope.perspectives = Perspective.getPerspectives($location, workspace, jolokia, localStorage);

console.log("Current perspectives " + JSON.stringify($scope.perspectives));
var currentId = Perspective.currentPerspectiveId($location, workspace, jolokia, localStorage);
$scope.perspectiveDetails.perspective = $scope.perspectives.find({id: currentId});
console.log("Current perspective ID: " + currentId + " perspective: " + $scope.perspective);
$scope.topLevelTabs = Perspective.topLevelTabs($location, workspace, jolokia, localStorage);
var perspectives = Perspective.getPerspectives($location, workspace, jolokia, localStorage);

if (angular.toJson($scope.perspectives) !== angular.toJson(perspectives)) {
$scope.perspectives = perspectives;

console.log("Current perspectives " + JSON.stringify($scope.perspectives));
var currentId = Perspective.currentPerspectiveId($location, workspace, jolokia, localStorage);
$scope.perspectiveDetails.perspective = $scope.perspectives.find({id: currentId});
console.log("Current perspective ID: " + currentId + " perspective: " + $scope.perspective);
$scope.topLevelTabs = Perspective.topLevelTabs($location, workspace, jolokia, localStorage);

}
}

reloadPerspective();
//reloadPerspective();
}
}

0 comments on commit eb092f3

Please sign in to comment.