Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 1 | /// <reference path="../../typings/index.d.ts"/> |
| 2 | import {Component, OnInit} from '@angular/core'; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 3 | import {StyleConfig} from './config/style.config'; |
| 4 | import {CoreService} from './services/rest/core.service'; |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 5 | import {InstanceStore} from './services/stores/instance.store'; |
| 6 | import {IInstance} from './interfaces/instance.interface'; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 7 | |
| 8 | @Component({ |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 9 | selector: 'xos-app', |
| 10 | template: require('./hello.html'), |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 11 | providers: [CoreService, InstanceStore], |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 12 | }) |
Matteo Scandolo | 5e5c12b | 2016-12-05 16:17:52 -0800 | [diff] [blame] | 13 | export class HelloComponent implements OnInit { |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 14 | |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 15 | // declare class properties |
| 16 | public hello: string; |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 17 | public instances: IInstance[]; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 18 | |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 19 | constructor( |
| 20 | private coreService: CoreService, |
| 21 | private instanceStore: InstanceStore |
| 22 | ) { |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 23 | this.hello = `Hello ${StyleConfig.projectName}!`; |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 24 | this.instances = []; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | ngOnInit() { |
| 28 | console.log('on init'); |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 29 | this.instanceStore.query() |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 30 | .subscribe( |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 31 | instances => { |
| 32 | console.log(instances); |
| 33 | this.instances = instances; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 34 | }, |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame^] | 35 | err => { |
| 36 | console.warn(err); |
| 37 | } |
Matteo Scandolo | 5e5c12b | 2016-12-05 16:17:52 -0800 | [diff] [blame] | 38 | ); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 39 | } |
| 40 | } |