Matteo Scandolo | d62ea79 | 2016-12-22 14:02:28 -0800 | [diff] [blame^] | 1 | import {IModelStoreService} from '../../datasources/stores/model.store'; |
| 2 | import {IXosAuthService} from '../../datasources/rest/auth.rest'; |
| 3 | class DashboardController { |
| 4 | static $inject = ['$state', 'ModelStore', 'AuthService']; |
| 5 | |
| 6 | public nodes: number; |
| 7 | public slices: number; |
| 8 | public instances: number; |
| 9 | |
| 10 | constructor( |
| 11 | private $state: ng.ui.IStateService, |
| 12 | private store: IModelStoreService, |
| 13 | private auth: IXosAuthService |
| 14 | ) { |
| 15 | |
| 16 | if (!this.auth.isAuthenticated()) { |
| 17 | this.$state.go('login'); |
| 18 | } |
| 19 | else { |
| 20 | // this.store.query('node') |
| 21 | // .subscribe((event) => { |
| 22 | // console.log(`node`, event); |
| 23 | // this.nodes = event.length; |
| 24 | // }); |
| 25 | this.store.query('slice') |
| 26 | .subscribe((event) => { |
| 27 | // console.log('slice', event); |
| 28 | this.slices = event.length; |
| 29 | }); |
| 30 | // this.store.query('instance') |
| 31 | // .subscribe((event) => { |
| 32 | // console.log('isntance', event); |
| 33 | // this.instances = event.length; |
| 34 | // }); |
| 35 | this.instances = 0; |
| 36 | this.nodes = 2; |
| 37 | this.slices = 3; |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | export const xosDashboard: angular.IComponentOptions = { |
| 43 | template: require('./dashboard.html'), |
| 44 | controllerAs: 'vm', |
| 45 | controller: DashboardController |
| 46 | }; |