IGNITE-4728 Web Console: Saved last succeeded state and redirect to it on reload.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/70d0f991 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/70d0f991 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/70d0f991 Branch: refs/heads/ignite-5658 Commit: 70d0f9918c708cb117e69163cc7b7c119c9a693c Parents: 23f26af Author: Dmitriy Shabalin <dshaba...@gridgain.com> Authored: Thu Jul 20 15:08:20 2017 +0700 Committer: Andrey Novikov <anovi...@gridgain.com> Committed: Thu Jul 20 15:08:20 2017 +0700 ---------------------------------------------------------------------- modules/web-console/frontend/app/app.js | 14 ++++++++++++++ .../frontend/app/modules/states/errors.state.js | 6 ++++-- .../frontend/app/modules/states/signin.state.js | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/70d0f991/modules/web-console/frontend/app/app.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js index c707810..dc5c6e9 100644 --- a/modules/web-console/frontend/app/app.js +++ b/modules/web-console/frontend/app/app.js @@ -289,6 +289,20 @@ angular $root.$on('$stateChangeStart', () => { _.forEach(angular.element('.modal'), (m) => angular.element(m).scope().$hide()); }); + + if (!$root.IgniteDemoMode) { + $root.$on('$stateChangeSuccess', (event, {name, unsaved}, params) => { + try { + if (unsaved) + localStorage.removeItem('lastStateChangeSuccess'); + else + localStorage.setItem('lastStateChangeSuccess', JSON.stringify({name, params})); + } + catch (ignored) { + // No-op. + } + }); + } }]) .run(['$rootScope', '$http', '$state', 'IgniteMessages', 'User', 'IgniteNotebookData', ($root, $http, $state, Messages, User, Notebook) => { // eslint-disable-line no-shadow http://git-wip-us.apache.org/repos/asf/ignite/blob/70d0f991/modules/web-console/frontend/app/modules/states/errors.state.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/states/errors.state.js b/modules/web-console/frontend/app/modules/states/errors.state.js index e816ff8..e3d4d41 100644 --- a/modules/web-console/frontend/app/modules/states/errors.state.js +++ b/modules/web-console/frontend/app/modules/states/errors.state.js @@ -31,13 +31,15 @@ angular templateUrl: templateNotFoundPage, metaTags: { title: 'Page not found' - } + }, + unsaved: true }) .state('403', { url: '/403', templateUrl: templateNotAuthorizedPage, metaTags: { title: 'Not authorized' - } + }, + unsaved: true }); }]); http://git-wip-us.apache.org/repos/asf/ignite/blob/70d0f991/modules/web-console/frontend/app/modules/states/signin.state.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/states/signin.state.js b/modules/web-console/frontend/app/modules/states/signin.state.js index 5155bde..b7be51d 100644 --- a/modules/web-console/frontend/app/modules/states/signin.state.js +++ b/modules/web-console/frontend/app/modules/states/signin.state.js @@ -33,7 +33,15 @@ angular resolve: { user: ['$state', 'User', ($state, User) => { return User.read() - .then(() => $state.go('base.configuration.tabs')) + .then(() => { + try { + const {name, params} = JSON.parse(localStorage.getItem('lastStateChangeSuccess')); + + $state.go(name, params); + } catch (ignored) { + $state.go('base.configuration.tabs'); + } + }) .catch(() => {}); }] },