Merge into Main #1
0
src/app/entity-data/entity-data.component.css
Normal file
0
src/app/entity-data/entity-data.component.css
Normal file
60
src/app/entity-data/entity-data.component.html
Normal file
60
src/app/entity-data/entity-data.component.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html5>
|
||||
<main class="grid grid-cols-2 gap-4">
|
||||
<div class="property" *ngIf="hasProperty('name')">
|
||||
<p>Name</p>
|
||||
<input required placeholder="entity name" type="text"[ngModel]="entity_name" (ngModelChange)="entity_name = $event"/>
|
||||
</div>
|
||||
<div class="property" *ngIf="hasProperty('uniq_id')">
|
||||
<p>Uniqe ID</p>
|
||||
<div class="flex-row flex gap-2">
|
||||
<input type="text" [ngModel]="entity_uniq_id" (ngModelChange)="entity_uniq_id = $event"/>
|
||||
<button class="randomButton" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dice-3" viewBox="0 0 16 16">
|
||||
<path d="M13 1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2zM3 0a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3V3a3 3 0 0 0-3-3z"/>
|
||||
<path d="M5.5 4a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m8 8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m-4-4a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="property" *ngIf="hasProperty('cmd_t')">
|
||||
<p>Command Topic</p>
|
||||
<input placeholder="command/topic" type="text" [ngModel]="entity_cmd_t" (ngModelChange)="entity_cmd_t = $event" /> <!-- (input)="lock_auto_topic(); update('entity_cmd_t', $event)"-->
|
||||
</div>
|
||||
<div class="property" *ngIf="hasProperty('bri_cmd_t')">
|
||||
<p>Brightness Command Topic</p>
|
||||
<input placeholder="brightness/command/topic" type="text" [ngModel]="entity_bri_cmd_t" (ngModelChange)="entity_bri_cmd_t = $event" /> <!--(ngModelChange)="lock_auto_topic(); update('entity_bri_cmd_t', $event)"-->
|
||||
</div>
|
||||
<div class="property !flex-row" *ngIf="hasProperty('pl_off') || hasProperty('pl_on')">
|
||||
<div *ngIf="hasProperty('pl_on')">
|
||||
<p>Payload on</p>
|
||||
<input placeholder="1" type="text" [ngModel]="entity_pl_on" (ngModelChange)="entity_pl_on = $event"/>
|
||||
</div>
|
||||
<div *ngIf="hasProperty('pl_off')">
|
||||
<p>Payload off</p>
|
||||
<input placeholder="0" type="text" [ngModel]="entity_pl_off" (ngModelChange)="entity_pl_off = $event"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="property" *ngIf="hasProperty('unit_of_meas')">
|
||||
<p>Unit of meassurement</p>
|
||||
<input placeholder="°C" type="text" [ngModel]="entity_unit_of_meas" (ngModelChange)="entity_unit_of_meas = $event"/>
|
||||
</div>
|
||||
<div class="property" *ngIf="hasProperty('val_tpl')">
|
||||
<p>Value Template</p>
|
||||
<input type="text" [ngModel]="entity_val_tpl" (ngModelChange)="entity_val_tpl = $event"/>
|
||||
</div>
|
||||
<div class="property bg-mySecondary" *ngIf="hasProperty('dev_cla')">
|
||||
<p>Device Class</p>
|
||||
<select [ngModel]="basemodel.getProperty('dev_cla').value" (ngModelChange)="entity_dev_cla =$event">
|
||||
<option *ngFor="let choice of basemodel.getProperty('dev_cla').choices" value="{{basemodel.getProperty('dev_cla').choices.indexOf(choice)}}">{{choice}}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="property" *ngIf="hasProperty('stat_t')">
|
||||
<p>State Topic</p>
|
||||
<div class="flex-row flex gap-2">
|
||||
<input placeholder="state/topic" type="text" [ngModel]="basemodel.getProperty('stat_t')" (ngModelChange)="basemodel.stat_t= $event" /> <!--(ngModelChange)="lock_auto_topic(); update('stat_t', $event)"-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
23
src/app/entity-data/entity-data.component.spec.ts
Normal file
23
src/app/entity-data/entity-data.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EntityDataComponent } from './entity-data.component';
|
||||
|
||||
describe('EntityDataComponent', () => {
|
||||
let component: EntityDataComponent;
|
||||
let fixture: ComponentFixture<EntityDataComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [EntityDataComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(EntityDataComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
152
src/app/entity-data/entity-data.component.ts
Normal file
152
src/app/entity-data/entity-data.component.ts
Normal file
@@ -0,0 +1,152 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { MQTTEntity } from '../_models/mqtt_base';
|
||||
import { EntityService } from '../_services/entity.service';
|
||||
import { GeneratorService } from '../_services/generator.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entity-data',
|
||||
templateUrl: './entity-data.component.html',
|
||||
styleUrl: './entity-data.component.css',
|
||||
})
|
||||
export class EntityDataComponent {
|
||||
@Input() entity_type: number = 0;
|
||||
@Input() basemodel!: MQTTEntity;
|
||||
constructor(
|
||||
private entityService: EntityService,
|
||||
private generatorService: GeneratorService
|
||||
) {
|
||||
if (generatorService.selected_entity) {
|
||||
this.basemodel = generatorService.selected_entity;
|
||||
}
|
||||
}
|
||||
|
||||
_entity_name: string = '';
|
||||
_entity_uniq_id: string = '';
|
||||
_entity_stat_t: string = '';
|
||||
_entity_cmd_t: string = '';
|
||||
_entity_bri_cmd_t: string = '';
|
||||
_entity_pl_off: string = '';
|
||||
_entity_pl_on: string = '';
|
||||
_entity_unit_of_meas: string = '';
|
||||
_entity_val_tpl: string = '';
|
||||
_entity_dev_cla: string = '';
|
||||
|
||||
get entity_name() {
|
||||
let base = this.basemodel.getProperty('name');
|
||||
if (base == '') {
|
||||
this.basemodel.setProperty('name', this._entity_name);
|
||||
return this._entity_name;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
set entity_name(data: string) {
|
||||
this._entity_name = data;
|
||||
this.basemodel.setProperty('name', data);
|
||||
}
|
||||
|
||||
get entity_uniq_id() {
|
||||
let base = this.basemodel.getProperty('uniq_id');
|
||||
if (base == '') {
|
||||
this.basemodel.setProperty('uniq_id', this._entity_uniq_id);
|
||||
return this._entity_uniq_id;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
set entity_uniq_id(data: string) {
|
||||
this._entity_uniq_id = data;
|
||||
this.basemodel.setProperty('uniq_id', data);
|
||||
}
|
||||
|
||||
get entity_stat_t() {
|
||||
let base = this.basemodel.getProperty('stat_t');
|
||||
if (base == 'state/topic') {
|
||||
this.basemodel.setProperty('stat_t', this._entity_stat_t);
|
||||
return this._entity_stat_t;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
set entity_stat_t(data: string) {
|
||||
this._entity_stat_t = data;
|
||||
this.basemodel.setProperty('stat_t', data);
|
||||
}
|
||||
|
||||
get entity_cmd_t() {
|
||||
let base = this.basemodel.getProperty('cmd_t');
|
||||
if (base == 'command/topic') {
|
||||
this.basemodel.setProperty('cmd_t', this._entity_cmd_t);
|
||||
return this._entity_cmd_t;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
set entity_cmd_t(data: string) {
|
||||
this._entity_cmd_t = data;
|
||||
this.basemodel.setProperty('cmd_t', data);
|
||||
}
|
||||
|
||||
get entity_bri_cmd_t() {
|
||||
let base = this.basemodel.getProperty('bri_cmd_t');
|
||||
if (base == 'brightness/command/topic') {
|
||||
this.basemodel.setProperty('bri_cmd_t', this._entity_bri_cmd_t);
|
||||
return this._entity_bri_cmd_t;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
set entity_bri_cmd_t(data: string) {
|
||||
this._entity_bri_cmd_t = data;
|
||||
this.basemodel.setProperty('bri_cmd_t', data);
|
||||
}
|
||||
|
||||
get entity_pl_off() {
|
||||
return this._entity_pl_off;
|
||||
}
|
||||
|
||||
set entity_pl_off(data: string) {
|
||||
this._entity_pl_off = data;
|
||||
this.basemodel.setProperty('pl_off', data);
|
||||
}
|
||||
|
||||
get entity_pl_on() {
|
||||
return this._entity_pl_on;
|
||||
}
|
||||
|
||||
set entity_pl_on(data: string) {
|
||||
this._entity_pl_on = data;
|
||||
this.basemodel.setProperty('pl_on', data);
|
||||
}
|
||||
|
||||
get entity_unit_of_meas() {
|
||||
return this._entity_unit_of_meas;
|
||||
}
|
||||
|
||||
set entity_unit_of_meas(data: string) {
|
||||
this._entity_unit_of_meas = data;
|
||||
this.basemodel.setProperty('unit_of_meas', data);
|
||||
}
|
||||
|
||||
get entity_val_tpl() {
|
||||
return this._entity_val_tpl;
|
||||
}
|
||||
|
||||
set entity_val_tpl(data: string) {
|
||||
this._entity_val_tpl = data;
|
||||
this.basemodel.setProperty('val_tpl', data);
|
||||
}
|
||||
|
||||
get entity_dev_cla() {
|
||||
return this._entity_dev_cla;
|
||||
}
|
||||
|
||||
set entity_dev_cla(data: string) {
|
||||
this._entity_dev_cla = data;
|
||||
this.basemodel.setProperty('dev_cla', data);
|
||||
}
|
||||
|
||||
hasProperty(property: string) {
|
||||
return this.basemodel.attrs.has(property);
|
||||
}
|
||||
}
|
||||
0
src/app/entity-output/entity-output.component.css
Normal file
0
src/app/entity-output/entity-output.component.css
Normal file
1
src/app/entity-output/entity-output.component.html
Normal file
1
src/app/entity-output/entity-output.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<p>entity-output works!</p>
|
||||
23
src/app/entity-output/entity-output.component.spec.ts
Normal file
23
src/app/entity-output/entity-output.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EntityOutputComponent } from './entity-output.component';
|
||||
|
||||
describe('EntityOutputComponent', () => {
|
||||
let component: EntityOutputComponent;
|
||||
let fixture: ComponentFixture<EntityOutputComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [EntityOutputComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(EntityOutputComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
10
src/app/entity-output/entity-output.component.ts
Normal file
10
src/app/entity-output/entity-output.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entity-output',
|
||||
templateUrl: './entity-output.component.html',
|
||||
styleUrl: './entity-output.component.css'
|
||||
})
|
||||
export class EntityOutputComponent {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user