mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-25 18:09:10 +00:00
Restore WebUI breadcrumbs
- Update paths to svg images - Restore sections concept - Tested with local cluster
This commit is contained in:
@@ -14,3 +14,58 @@ var app = angular.module('kubernetesApp', [
|
||||
'kubernetesApp.services',
|
||||
'angular.filter'
|
||||
].concat(componentNamespaces));
|
||||
|
||||
app.factory('menu', [
|
||||
'$location',
|
||||
'$rootScope',
|
||||
'sections',
|
||||
function($location, $rootScope, sections) {
|
||||
|
||||
var self;
|
||||
|
||||
$rootScope.$on('$locationChangeSuccess', onLocationChange);
|
||||
|
||||
return self = {
|
||||
|
||||
sections: sections,
|
||||
|
||||
setSections: function(_sections) { this.sections = _sections; },
|
||||
selectSection: function(section) { self.openedSection = section; },
|
||||
toggleSelectSection: function(section) {
|
||||
self.openedSection = (self.openedSection === section ? null : section);
|
||||
},
|
||||
isSectionSelected: function(section) { return self.openedSection === section; },
|
||||
selectPage: function(section, page) {
|
||||
page && page.url && $location.path(page.url);
|
||||
self.currentSection = section;
|
||||
self.currentPage = page;
|
||||
},
|
||||
isPageSelected: function(page) { return self.currentPage === page; }
|
||||
};
|
||||
|
||||
function onLocationChange() {
|
||||
var path = $location.path();
|
||||
|
||||
var matchPage = function(section, page) {
|
||||
if (path === page.url) {
|
||||
self.selectSection(section);
|
||||
self.selectPage(section, page);
|
||||
}
|
||||
};
|
||||
|
||||
sections.forEach(function(section) {
|
||||
if (section.children) {
|
||||
section.children.forEach(function(childSection) {
|
||||
if (childSection.pages) {
|
||||
childSection.pages.forEach(function(page) { matchPage(childSection, page); });
|
||||
}
|
||||
});
|
||||
} else if (section.pages) {
|
||||
section.pages.forEach(function(page) { matchPage(section, page); });
|
||||
} else if (section.type === 'link') {
|
||||
matchPage(section, section);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user