diff --git a/src/js/index.js b/src/js/index.js index a3744e761..d16ad0921 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -84,7 +84,7 @@ app.config(['$routeProvider', function ($routeProvider) { }).when('/emails-eventlog', { controller: 'EmailsEventlogController', templateUrl: 'views/emails-eventlog.html?<%= revision %>' - }).when('/email/:domain', { + }).when('/email/:domain/:view?', { controller: 'EmailController', templateUrl: 'views/email.html?<%= revision %>' }).when('/notifications', { diff --git a/src/views/email.html b/src/views/email.html index a62aedb50..752ee2eca 100644 --- a/src/views/email.html +++ b/src/views/email.html @@ -309,8 +309,8 @@
- - + +

{{ 'email.incoming.title' | tr }}

@@ -477,7 +477,7 @@
- +

{{ 'email.outbound.title' | tr }}

@@ -576,7 +576,7 @@
- +

{{ 'email.masquerading.title' | tr }}

@@ -627,7 +627,7 @@
- +
diff --git a/src/views/email.js b/src/views/email.js index 4b5df796d..c6791db57 100644 --- a/src/views/email.js +++ b/src/views/email.js @@ -4,12 +4,31 @@ /* global $ */ /* global async */ -angular.module('Application').controller('EmailController', ['$scope', '$location', '$translate', '$timeout', '$routeParams', 'Client', function ($scope, $location, $translate, $timeout, $routeParams, Client) { +angular.module('Application').controller('EmailController', ['$scope', '$location', '$translate', '$timeout', '$route', '$routeParams', 'Client', function ($scope, $location, $translate, $timeout, $route, $routeParams, Client) { Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); }); + // Avoid full reload on path change + // https://stackoverflow.com/a/22614334 + // reloadOnUrl: false in $routeProvider did not work! + var lastRoute = $route.current; + $scope.$on('$locationChangeSuccess', function (/* event */) { + if (lastRoute.$$route.originalPath === $route.current.$$route.originalPath) { + $route.current = lastRoute; + } + }); + var domainName = $routeParams.domain; if (!domainName) return $location.path('/email'); + $scope.setView = function (view, setAlways) { + if (!setAlways && !$scope.ready) return; + if ($scope.view === view) return; + + $route.updateParams({ view: view }); + $scope.view = view; + $scope.activeTab = view; + }; + $scope.ready = false; $scope.refreshBusy = true; $scope.client = Client; @@ -803,6 +822,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio }, function iteratorDone(error) { if (error) return console.error(error); + $scope.setView($routeParams.view || 'mailboxes', true /* always set */); $scope.ready = true; }); });