Allow deeplinking of domains into email view
This commit is contained in:
@@ -74,6 +74,9 @@ app.config(['$routeProvider', function ($routeProvider) {
|
||||
}).when('/email', {
|
||||
controller: 'EmailController',
|
||||
templateUrl: 'views/email.html?<%= revision %>'
|
||||
}).when('/email/:domain', {
|
||||
controller: 'EmailController',
|
||||
templateUrl: 'views/email.html?<%= revision %>'
|
||||
}).when('/settings', {
|
||||
controller: 'SettingsController',
|
||||
templateUrl: 'views/settings.html?<%= revision %>'
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
<div class="text-left">
|
||||
<h1>
|
||||
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>
|
||||
</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.refreshBusy = true;
|
||||
|
||||
@@ -556,6 +560,8 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
};
|
||||
|
||||
Client.onReady(function () {
|
||||
var domain = $location.path().slice('/email/'.length);
|
||||
|
||||
Client.getUsers(function (error, users) {
|
||||
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);
|
||||
|
||||
$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;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user