Allow deeplinking into the mail view

This commit is contained in:
Johannes Zellner
2021-11-19 15:45:16 +01:00
parent 9d97391c54
commit 611c5de9f3
3 changed files with 27 additions and 7 deletions
+5 -5
View File
@@ -309,8 +309,8 @@
<br/>
<uib-tabset>
<uib-tab index="0" heading="{{ 'email.incoming.tabTitle' | tr }}">
<uib-tabset active="activeTab">
<uib-tab index="'mailboxes'" select="setView('mailboxes')" heading="{{ 'email.incoming.tabTitle' | tr }}">
<div class="card card-large" style="margin-bottom: 15px;">
<h4>{{ 'email.incoming.title' | tr }}</h4>
@@ -477,7 +477,7 @@
</div>
</uib-tab>
<uib-tab index="1" heading="{{ 'email.outbound.tabTitle' | tr }}">
<uib-tab index="'outbound'" select="setView('outbound')" heading="{{ 'email.outbound.tabTitle' | tr }}">
<div class="card card-large" style="margin-bottom: 15px;">
<h4>{{ 'email.outbound.title' | tr }} <sup><a ng-href="https://docs.cloudron.io/email/#relay-outbound-mails" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></h4>
@@ -576,7 +576,7 @@
</div>
</uib-tab>
<uib-tab index="2" heading="{{ 'email.settings.tabTitle' | tr }}">
<uib-tab index="'settings'" select="setView('settings')" heading="{{ 'email.settings.tabTitle' | tr }}">
<div class="card card-large" style="margin-bottom: 15px;">
<h4>{{ 'email.masquerading.title' | tr }}</h4>
@@ -627,7 +627,7 @@
</div>
</uib-tab>
<uib-tab index="3" heading="{{ 'email.status.tabTitle' | tr }}">
<uib-tab index="'status'" select="setView('status')" heading="{{ 'email.status.tabTitle' | tr }}">
<!-- nothing to show if incoming mail is disabled and using a relay -->
<div class="card card-large" style="margin-bottom: 15px;" ng-hide="!domain.mailConfig.enabled && domain.mailConfig.relay.provider !== 'cloudron-smtp'">
<div class="row">
+21 -1
View File
@@ -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;
});
});