blob: 04eb5753bb44e84deea3ad2f44adcf404cb48262 [file] [log] [blame]
Matteo Scandolof2c3ed62016-12-15 14:32:50 -08001export interface IXosNavigationRoute {
2 label: string;
3 state?: string;
4 url?: string;
5}
6
7export interface IXosNavigationService {
8 query(): IXosNavigationRoute[];
9 add(route: IXosNavigationRoute): void;
10}
11
12export class NavigationService {
13 private routes: IXosNavigationRoute[];
14
15 constructor() {
16 this.routes = [
17 {
18 label: 'Home',
19 state: 'xos.dashboard'
20 }
21 ];
22 }
23
24 query() {
25 return this.routes;
26 }
27
28 add(route: IXosNavigationRoute) {
Matteo Scandoloa4a47112016-12-16 10:06:13 -080029 if (angular.isDefined(route.state) && angular.isDefined(route.url)) {
30 throw new Error('[XosNavigation] You can\'t provide both state and url');
31 }
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080032 this.routes.push(route);
33 }
34}