ngFor approach works, non-local mqtt broker doesn't work so far
This commit is contained in:
@ -1,58 +1,17 @@
|
|||||||
|
|
||||||
<mat-tab-group>
|
<mat-tab-group>
|
||||||
<mat-tab label="Licht">
|
<mat-tab label="Licht">
|
||||||
<mat-accordion>
|
<mat-accordion>
|
||||||
<mat-expansion-panel>
|
<mat-expansion-panel *ngFor="let room of configuration.switches">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>
|
<mat-panel-title>
|
||||||
Wohnzimmer
|
{{room.room}}
|
||||||
</mat-panel-title>
|
</mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header >
|
||||||
<ledbutton2 topic="led/test1" label="Küche Deckenlampe"></ledbutton2>
|
<ledbutton2 *ngFor="let switch of room.switches" [topic]="switch.topic" [label]="switch.label"></ledbutton2>
|
||||||
<ledbutton2 topic="led/test2" label="Keller normal"></ledbutton2>
|
<p class="clear"></p>
|
||||||
<ledbutton2 topic="led/test3" label="Keller hell"></ledbutton2>
|
</mat-expansion-panel>
|
||||||
<ledbutton2 topic="led/test4" label="test4"></ledbutton2>
|
</mat-accordion>
|
||||||
<ledbutton2 topic="led/test1" label="Küche Deckenlampe"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test2" label="Keller normal"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test3" label="Keller hell"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test4" label="test4"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test1" label="Küche Deckenlampe"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test2" label="Keller normal"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test3" label="Keller hell"></ledbutton2>
|
|
||||||
<ledbutton2 topic="led/test4" label="test4"></ledbutton2>
|
|
||||||
<p class="clear"></p>
|
|
||||||
</mat-expansion-panel>
|
|
||||||
<mat-expansion-panel>
|
|
||||||
<mat-expansion-panel-header>
|
|
||||||
<mat-panel-title>
|
|
||||||
Esszimmer
|
|
||||||
</mat-panel-title>
|
|
||||||
</mat-expansion-panel-header>
|
|
||||||
<table id="maintable">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<ledbutton2 topic="led/test1" label="Küche Deckenlampe"></ledbutton2>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<ledbutton2 topic="led/test2" label="Keller normal"></ledbutton2>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<ledbutton2 topic="led/test3" label="Keller hell"></ledbutton2>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<ledbutton2 topic="led/test4" label="test4"></ledbutton2>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</mat-expansion-panel>
|
|
||||||
</mat-accordion>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<mat-tab label="Fenster">
|
<mat-tab label="Fenster">
|
||||||
<ledbox topic="led/test4" label="test4"></ledbox>
|
<ledbox topic="led/test4" label="test4"></ledbox>
|
||||||
|
@ -1,10 +1,72 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { MqttclientService } from './mqttclient.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.css']
|
styleUrls: ['./app.component.css']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit {
|
||||||
title = 'app';
|
title = 'app';
|
||||||
|
private topic : string = 'smartclient/configuration'
|
||||||
|
configuration : any = {
|
||||||
|
'switches': [
|
||||||
|
{
|
||||||
|
'room': 'Wohnzimmer',
|
||||||
|
'switches': [
|
||||||
|
{
|
||||||
|
'label': 'kleine Lampe',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/SmallLight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'große Lampe',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/LargeLight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Sterne',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/Stars'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Stehlampe',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/LivingRoom/StandLight'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'room': 'Esszimmer',
|
||||||
|
'switches': [
|
||||||
|
{
|
||||||
|
'label': 'kleine Lampe',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/SmallLight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Stehlampe',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/StandLight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Schranklicht',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/CupboardLight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Naehkaestchenlicht',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/NaehkaestchenLight'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Regallicht',
|
||||||
|
'topic': 'dispatcher_ng/items/Gnd/DiningRoom/ShelfLight'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private mqttclientService : MqttclientService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.mqttclientService.register(this.topic, (message: string) => {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export class LedButtonGroup2Component implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.actionTopic = this.topicPre + '/state'
|
this.actionTopic = this.topicPre + '/state'
|
||||||
this.feedbackTopic = this.topicPre + '/feedback'
|
this.feedbackTopic = this.topicPre + '/state/feedback'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export class MqttclientService {
|
|||||||
private callbacks : Map<string, callbackFunc> = new Map()
|
private callbacks : Map<string, callbackFunc> = new Map()
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.mqttClient = Mqtt.connect('ws://localhost:9001')
|
this.mqttClient = Mqtt.connect('ws://mqttbroker:9001')
|
||||||
this.mqttClient.on('connect', () => {
|
this.mqttClient.on('connect', () => {
|
||||||
console.log('MQTT connected')
|
console.log('MQTT connected')
|
||||||
this.callbacks.forEach((value: callbackFunc, key: string) => {
|
this.callbacks.forEach((value: callbackFunc, key: string) => {
|
||||||
|
Reference in New Issue
Block a user