Dinamically generate views for CORE Models
Change-Id: Ib1d042f366f916c2ba8513ee62014e7256ceb53d
diff --git a/src/app/core/nav/nav.html b/src/app/core/nav/nav.html
index 6256369..2bcdadd 100644
--- a/src/app/core/nav/nav.html
+++ b/src/app/core/nav/nav.html
@@ -1,7 +1,8 @@
<div class="nav">
<ul>
- <li ng-repeat="route in vm.routes" ui-sref-active="active">
- <a ui-sref="{{route.state}}">{{route.label}}</a>
+ <li ng-repeat="route in vm.routes" ui-sref-active="active" ng-class="vm.isRouteActive(route)">
+ <a ng-if="route.state" ui-sref="{{route.state}}">{{route.label}}</a>
+ <a ng-if="route.url" href="#/{{route.url}}">{{route.label}}</a>
</li>
</ul>
</div>
diff --git a/src/app/core/nav/nav.scss b/src/app/core/nav/nav.scss
index 8591c15..5c2c85c 100644
--- a/src/app/core/nav/nav.scss
+++ b/src/app/core/nav/nav.scss
@@ -2,8 +2,9 @@
display: flex;
flex: 1;
flex-direction: column;
- flex-basis: 10%;
+ flex-basis: 15%;
background: darken(grey, 10);
+ overflow-y: scroll;
ul {
list-style: none;
diff --git a/src/app/core/nav/nav.ts b/src/app/core/nav/nav.ts
index 82d9d64..d83f859 100644
--- a/src/app/core/nav/nav.ts
+++ b/src/app/core/nav/nav.ts
@@ -1,32 +1,19 @@
import './nav.scss';
-
-export interface INavItem {
- label: string;
- state: string;
-}
+import {IXosNavigationService, IXosNavigationRoute} from '../services/navigation';
class NavCtrl {
- public routes: INavItem[];
+ static $inject = ['$state', 'NavigationService'];
+ public routes: IXosNavigationRoute[];
- constructor() {
- this.routes = [
- {
- label: 'Home',
- state: 'xos.dashboard'
- },
- {
- label: 'Instances',
- state: 'xos.instances'
- },
- {
- label: 'Slices',
- state: 'xos.slices'
- },
- {
- label: 'Nodes',
- state: 'xos.nodes'
- }
- ];
+ constructor(
+ private $state: angular.ui.IStateService,
+ private navigationService: IXosNavigationService
+ ) {
+ this.routes = this.navigationService.query();
+ }
+
+ isRouteActive(route: IXosNavigationRoute) {
+ return this.$state.current.url === route.url ? 'active' : '';
}
}