blob: 8757cc30d5d2789b9507bbc72a6a2ce734cedbf8 [file] [log] [blame]
Matteo Scandolo43ffb672016-12-02 14:49:58 -08001/// <reference path="../../typings/index.d.ts"/>
2import {Component, OnInit} from '@angular/core';
Matteo Scandolo43ffb672016-12-02 14:49:58 -08003import {StyleConfig} from './config/style.config';
4import {CoreService} from './services/rest/core.service';
Matteo Scandolo0f77c502016-12-06 16:46:00 -08005import {InstanceStore} from './services/stores/instance.store';
6import {IInstance} from './interfaces/instance.interface';
Matteo Scandolod819c922016-12-02 14:06:14 -08007
8@Component({
Matteo Scandolo43ffb672016-12-02 14:49:58 -08009 selector: 'xos-app',
10 template: require('./hello.html'),
Matteo Scandolo0f77c502016-12-06 16:46:00 -080011 providers: [CoreService, InstanceStore],
Matteo Scandolod819c922016-12-02 14:06:14 -080012})
Matteo Scandolo5e5c12b2016-12-05 16:17:52 -080013export class HelloComponent implements OnInit {
Matteo Scandolod819c922016-12-02 14:06:14 -080014
Matteo Scandolo43ffb672016-12-02 14:49:58 -080015 // declare class properties
16 public hello: string;
Matteo Scandolo0f77c502016-12-06 16:46:00 -080017 public instances: IInstance[];
Matteo Scandolo43ffb672016-12-02 14:49:58 -080018
Matteo Scandolo0f77c502016-12-06 16:46:00 -080019 constructor(
20 private coreService: CoreService,
21 private instanceStore: InstanceStore
22 ) {
Matteo Scandolo43ffb672016-12-02 14:49:58 -080023 this.hello = `Hello ${StyleConfig.projectName}!`;
Matteo Scandolo0f77c502016-12-06 16:46:00 -080024 this.instances = [];
Matteo Scandolo43ffb672016-12-02 14:49:58 -080025 }
26
27 ngOnInit() {
28 console.log('on init');
Matteo Scandolo0f77c502016-12-06 16:46:00 -080029 this.instanceStore.query()
Matteo Scandolo43ffb672016-12-02 14:49:58 -080030 .subscribe(
Matteo Scandolo0f77c502016-12-06 16:46:00 -080031 instances => {
32 console.log(instances);
33 this.instances = instances;
Matteo Scandolo43ffb672016-12-02 14:49:58 -080034 },
Matteo Scandolo0f77c502016-12-06 16:46:00 -080035 err => {
36 console.warn(err);
37 }
Matteo Scandolo5e5c12b2016-12-05 16:17:52 -080038 );
Matteo Scandolod819c922016-12-02 14:06:14 -080039 }
40}