Restore WebUI breadcrumbs

- Update paths to svg images
 - Restore sections concept
 - Tested with local cluster
This commit is contained in:
Patrick Reilly
2015-05-15 11:18:17 -07:00
parent 967495659b
commit 75d062b89d
23 changed files with 1013 additions and 334 deletions

View File

@@ -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);
}
});
}
}
]);