Allow deeplinking of domains into email view
This commit is contained in:
@@ -74,6 +74,9 @@ app.config(['$routeProvider', function ($routeProvider) {
|
|||||||
}).when('/email', {
|
}).when('/email', {
|
||||||
controller: 'EmailController',
|
controller: 'EmailController',
|
||||||
templateUrl: 'views/email.html?<%= revision %>'
|
templateUrl: 'views/email.html?<%= revision %>'
|
||||||
|
}).when('/email/:domain', {
|
||||||
|
controller: 'EmailController',
|
||||||
|
templateUrl: 'views/email.html?<%= revision %>'
|
||||||
}).when('/settings', {
|
}).when('/settings', {
|
||||||
controller: 'SettingsController',
|
controller: 'SettingsController',
|
||||||
templateUrl: 'views/settings.html?<%= revision %>'
|
templateUrl: 'views/settings.html?<%= revision %>'
|
||||||
|
|||||||
@@ -231,7 +231,7 @@
|
|||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<h1>
|
<h1>
|
||||||
Email
|
Email
|
||||||
<select class="form-control pull-right" style="display: inline-block; width: 200px;" ng-model="selectedDomain" ng-options="a.domain for a in domains" ng-change="refreshDomain()"></select>
|
<select class="form-control pull-right" style="display: inline-block; width: 200px;" ng-model="selectedDomain" ng-options="a.domain for a in domains" ng-change="selectDomain()"></select>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -474,6 +474,10 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.selectDomain = function () {
|
||||||
|
$location.path('/email/' + $scope.selectedDomain.domain, false);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.refreshDomain = function () {
|
$scope.refreshDomain = function () {
|
||||||
$scope.refreshBusy = true;
|
$scope.refreshBusy = true;
|
||||||
|
|
||||||
@@ -556,6 +560,8 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
|||||||
};
|
};
|
||||||
|
|
||||||
Client.onReady(function () {
|
Client.onReady(function () {
|
||||||
|
var domain = $location.path().slice('/email/'.length);
|
||||||
|
|
||||||
Client.getUsers(function (error, users) {
|
Client.getUsers(function (error, users) {
|
||||||
if (error) return console.error('Unable to get user listing.', error);
|
if (error) return console.error('Unable to get user listing.', error);
|
||||||
|
|
||||||
@@ -569,14 +575,39 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
|||||||
if (error) return console.error('Unable to get domain listing.', error);
|
if (error) return console.error('Unable to get domain listing.', error);
|
||||||
|
|
||||||
$scope.domains = domains;
|
$scope.domains = domains;
|
||||||
$scope.selectedDomain = $scope.domains[0];
|
$scope.selectedDomain = domains.find(function (d) { return d.domain === domain; });
|
||||||
|
|
||||||
$scope.refreshDomain();
|
if (!$scope.selectedDomain) {
|
||||||
|
$location.path('/email/' + domains[0].domain, false);
|
||||||
|
} else {
|
||||||
|
$scope.refreshDomain();
|
||||||
|
}
|
||||||
|
|
||||||
$scope.ready = true;
|
$scope.ready = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function hashChangeListener() {
|
||||||
|
if (!$scope.ready) return;
|
||||||
|
|
||||||
|
// event listener is called from DOM not angular, need to use $apply
|
||||||
|
$scope.$apply(function () {
|
||||||
|
var domain = $location.path().slice('/email/'.length);
|
||||||
|
$scope.selectedDomain = $scope.domains.find(function (d) { return d.domain === domain; });
|
||||||
|
|
||||||
|
if (!$scope.selectedDomain) {
|
||||||
|
$location.path('/email/' + $scope.domains[0].domain, false);
|
||||||
|
} else {
|
||||||
|
$scope.refreshDomain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('hashchange', hashChangeListener);
|
||||||
|
|
||||||
|
$scope.$on('$destroy', function handler() {
|
||||||
|
window.removeEventListener('hashchange', hashChangeListener);
|
||||||
});
|
});
|
||||||
|
|
||||||
// setup all the dialog focus handling
|
// setup all the dialog focus handling
|
||||||
|
|||||||
Reference in New Issue
Block a user