feat(frontend): show endpoint.name in page title (#4363)

* feat(frontend): show endpoint.name in page title

* feat(frontend): show endpoint.name in page title - use rootscope for defaultTitle
pull/4409/head
Tim van den Eijnden 2020-10-16 11:28:46 +02:00 committed by GitHub
parent bb5c2c2875
commit 74429d6d46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -16,6 +16,7 @@ angular.module('portainer').run([
EndpointProvider.initialize(); EndpointProvider.initialize();
$rootScope.$state = $state; $rootScope.$state = $state;
$rootScope.defaultTitle = document.title;
// Workaround to prevent the loading bar from going backward // Workaround to prevent the loading bar from going backward
// https://github.com/chieffancypants/angular-loading-bar/issues/273 // https://github.com/chieffancypants/angular-loading-bar/issues/273

View File

@ -1,4 +1,5 @@
angular.module('portainer.app').controller('SidebarController', [ angular.module('portainer.app').controller('SidebarController', [
'$rootScope',
'$q', '$q',
'$scope', '$scope',
'$transitions', '$transitions',
@ -7,7 +8,7 @@ angular.module('portainer.app').controller('SidebarController', [
'Authentication', 'Authentication',
'UserService', 'UserService',
'EndpointProvider', 'EndpointProvider',
function ($q, $scope, $transitions, StateManager, Notifications, Authentication, UserService, EndpointProvider) { function ($rootScope, $q, $scope, $transitions, StateManager, Notifications, Authentication, UserService, EndpointProvider) {
function checkPermissions(memberships) { function checkPermissions(memberships) {
var isLeader = false; var isLeader = false;
angular.forEach(memberships, function (membership) { angular.forEach(memberships, function (membership) {
@ -52,6 +53,10 @@ angular.module('portainer.app').controller('SidebarController', [
$transitions.onEnter({}, async () => { $transitions.onEnter({}, async () => {
$scope.showStacks = await shouldShowStacks(); $scope.showStacks = await shouldShowStacks();
if ($scope.applicationState.endpoint.name) {
document.title = `${$rootScope.defaultTitle} | ${$scope.applicationState.endpoint.name}`;
}
}); });
}, },
]); ]);