From e1b6d15bd5569d4579c2f6884515017a080617b8 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Tue, 21 Aug 2018 11:56:09 +0200 Subject: [PATCH] start heating controller, don't remember angular syntax, can't continue for the moment --- src/app/app.component.html | 2 +- src/app/app.module.ts | 4 +- .../heating-controller.component.spec.ts | 25 +++++++++++ .../heating-controller.component.ts | 45 +++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/app/heating-controller/heating-controller.component.spec.ts create mode 100644 src/app/heating-controller/heating-controller.component.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index 29ebc9f..2ee0a3e 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -27,7 +27,7 @@

- + diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5bda57f..284e062 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -16,6 +16,7 @@ import { LedButtonGroupComponent } from './led-button-group/led-button-group.com import { NumberFieldComponent } from './number-field/number-field.component'; import { LedButtonGroup2Component } from './led-button-group2/led-button-group2.component'; import { LedBoxComponent } from './led-box/led-box.component'; +import { HeatingControllerComponent } from './heating-controller/heating-controller.component'; @NgModule({ @@ -26,7 +27,8 @@ import { LedBoxComponent } from './led-box/led-box.component'; LedButtonGroupComponent, NumberFieldComponent, LedButtonGroup2Component, - LedBoxComponent + LedBoxComponent, + HeatingControllerComponent ], imports: [ BrowserModule, diff --git a/src/app/heating-controller/heating-controller.component.spec.ts b/src/app/heating-controller/heating-controller.component.spec.ts new file mode 100644 index 0000000..4ebca03 --- /dev/null +++ b/src/app/heating-controller/heating-controller.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HeatingControllerComponent } from './heating-controller.component'; + +describe('HeatingControllerComponent', () => { + let component: HeatingControllerComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ HeatingControllerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HeatingControllerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/heating-controller/heating-controller.component.ts b/src/app/heating-controller/heating-controller.component.ts new file mode 100644 index 0000000..c947638 --- /dev/null +++ b/src/app/heating-controller/heating-controller.component.ts @@ -0,0 +1,45 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { MqttclientService } from '../mqttclient.service' + +@Component({ + selector: 'heatingcontroller', + template: ` +
+ {{label}}
+ + + +
+ +
+ ` + +}) +export class HeatingControllerComponent implements OnInit { + @Input() topic : string = 'invalid' + @Input() label : string = 'invalid' + + constructor(private mqttclientService : MqttclientService) { } + + ngOnInit() { + } + + clickOn() { + console.log(`click on for ${this.topic}`) + this.mqttclientService.publish(this.topic, "ON") + } + + clickAbsent() { + console.log(`click absent for ${this.topic}`) + this.mqttclientService.publish(this.topic, "ABSENT") + } + + clickOff() { + console.log(`click off for ${this.topic}`) + this.mqttclientService.publish(this.topic, "OFF") + } + +} +