ADD: auto_topic switch
This commit is contained in:
@@ -16,6 +16,7 @@ export class GeneratorService {
|
||||
@Input() device_id: string = "";
|
||||
@Input() device_standalone: boolean = false;
|
||||
@Input() upperTopic: string = "";
|
||||
@Input() auto_topic: number = 2;
|
||||
updateObserver: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,4 @@
|
||||
padding: .25rem .75rem;
|
||||
border-radius: 1rem;
|
||||
/* width: 100%; */
|
||||
}
|
||||
|
||||
.buttonOff path{
|
||||
fill:#535353;
|
||||
}
|
||||
@@ -36,22 +36,31 @@ export class EntityComponent {
|
||||
@Input() entity_val_tpl: string = "";
|
||||
@Input() entity_dev_cla: string = "";
|
||||
|
||||
updateStateTopic() {
|
||||
if (!this.auto_stat_t) return
|
||||
this.state_topic = ""
|
||||
if (this.generatorService.upperTopic != "") this.state_topic += this.generatorService.upperTopic + "/";
|
||||
if (this.entity_type != 0) this.state_topic += entity_types[this.entity_type][0] + "/"
|
||||
if (this.generatorService.device_name != "") this.state_topic += this.generatorService.device_name + "/"
|
||||
if (this.entity_name != "" && this.entity_uniq_id != "") this.state_topic += this.entity_name + "_" + this.entity_uniq_id + "/stat"
|
||||
else if (this.entity_name != "") this.state_topic += this.entity_name + "/stat"
|
||||
this.state_topic = this.state_topic.toLocaleLowerCase();
|
||||
update() {
|
||||
if (this.generatorService.auto_topic == 2) {
|
||||
this.state_topic = this.updateTopic('stat');
|
||||
this.entity_cmd_t = this.updateTopic('cmd');
|
||||
this.entity_bri_cmd_t = this.updateTopic('bri_cmd');
|
||||
}
|
||||
}
|
||||
|
||||
basemodelProperty(property: string) {
|
||||
if (this.basemodel?.hasOwnProperty(property)) console.log(property)
|
||||
return this.basemodel?.stat_t
|
||||
updateTopic(topic: string) {
|
||||
let topic_str = join(
|
||||
'/',
|
||||
this.generatorService.upperTopic,
|
||||
entity_types[this.entity_type][0],
|
||||
this.generatorService.device_name,
|
||||
this.display_name,
|
||||
topic
|
||||
).toLowerCase();
|
||||
return topic_str;
|
||||
}
|
||||
|
||||
// basemodelProperty(property: string) {
|
||||
// if (this.basemodel?.hasOwnProperty(property)) console.log(property)
|
||||
// return this.basemodel?.stat_t
|
||||
// }
|
||||
|
||||
select_type(event: unknown) {
|
||||
let ent_type = entity_types[event as keyof typeof entity_types]
|
||||
let ent_class = ent_type[1];
|
||||
@@ -64,7 +73,7 @@ export class EntityComponent {
|
||||
}
|
||||
|
||||
lockStateTopic(event: any) {
|
||||
this.auto_stat_t = false;
|
||||
this.generatorService.auto_topic = 1;
|
||||
}
|
||||
|
||||
create_entity() {
|
||||
|
||||
@@ -2,4 +2,27 @@
|
||||
background: #9D9D9D;
|
||||
border-radius: 1rem;
|
||||
padding: 1rem .8rem ;
|
||||
}
|
||||
|
||||
.customCheckboxContainer{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
.customCheckboxContainer input[type="radio"]{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.customCheckbox{
|
||||
width: 100%;
|
||||
padding: .25rem 0;
|
||||
text-align: center;
|
||||
background: #B3B3B3;
|
||||
transition: background .25s ease-in-out, color .25s ease-in-out;
|
||||
}
|
||||
|
||||
.customCheckboxContainer input:checked + label{
|
||||
background: var(--accent);
|
||||
color: var(--secondary);
|
||||
}
|
||||
@@ -23,6 +23,16 @@
|
||||
<p>Bereich</p>
|
||||
<input type="text" [ngModel]="generatorService.upperTopic"
|
||||
(ngModelChange)="generatorService.upperTopic = $event; generatorService.update()" />
|
||||
<p>Automatische Topics</p>
|
||||
<div class="customCheckboxContainer">
|
||||
<input [ngModel]="auto_topic" (ngModelChange)="auto_topic=$event" id="auto_topic_0" type="radio" name="auto_topic" value="2">
|
||||
<label class="customCheckbox" for="auto_topic_0">Alles</label>
|
||||
<input [ngModel]="auto_topic" (ngModelChange)="auto_topic=$event" id="auto_topic_1" type="radio" name="auto_topic" value="1">
|
||||
<label class="customCheckbox" for="auto_topic_1">Änderungen übernehmen</label>
|
||||
<input [ngModel]="auto_topic" (ngModelChange)="auto_topic=$event" id="auto_topic_2" type="radio" name="auto_topic" value="0">
|
||||
<label class="customCheckbox" for="auto_topic_2">Aus</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,18 @@ export class GeneratorComponent {
|
||||
readonly useObject = Object;
|
||||
readonly useRandomString = randomString;
|
||||
|
||||
set auto_topic(value: number) {
|
||||
this.generatorService.auto_topic = value;
|
||||
console.log(this.generatorService.auto_topic);
|
||||
}
|
||||
|
||||
get auto_topic(): string {
|
||||
return String(this.generatorService.auto_topic);
|
||||
}
|
||||
|
||||
log(event:any){
|
||||
console.log(Number(event));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user