Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Store the last accessed page on a route change in the current perspec…
…tive to help with addressing #588
  • Loading branch information
gashcrumb committed Sep 27, 2013
1 parent a393dde commit 22a392c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions hawtio-web/src/main/webapp/app/core/js/helpers.ts
Expand Up @@ -860,6 +860,22 @@ module Core {
});
}


export function extractHashURL(url:string) {
var parts = url.split('#');
if (parts.length === 0) {
return url;
}
var answer:string = parts[1];
if (parts.length > 1) {
var remaining = parts.last(parts.length - 2);
remaining.forEach((part) => {
answer = answer + "#" + part;
});
}
return answer;
}

export function getBasicAuthHeader(username, password) {
var authInfo = username + ":" + password;
authInfo = btoa(authInfo);
Expand Down
Expand Up @@ -6,8 +6,23 @@ module Perspective {
when('/perspective/defaultPage', {templateUrl: 'app/perspective/html/defaultPage.html',
controller: Perspective.DefaultPageController});
}).
run(($location:ng.ILocationService, workspace:Workspace, viewRegistry, layoutFull) => {
run(($location:ng.ILocationService, workspace:Workspace, viewRegistry, layoutFull, $rootScope, jolokia, localStorage) => {

viewRegistry['perspective'] = layoutFull;

$rootScope.$on('$locationChangeStart', (event, newRoute, oldRoute) => {

var perspectives = Perspective.getPerspectives($location, workspace, jolokia, localStorage);
var currentId = Perspective.currentPerspectiveId($location, workspace, jolokia, localStorage);

var perspective = perspectives.find({id: currentId});

if (perspective) {
Core.pathSet(perspective, ['lastPage'], Core.extractHashURL(oldRoute));
}
});


});

hawtioPluginLoader.addModule(pluginName);
Expand Down

0 comments on commit 22a392c

Please sign in to comment.