Dashboard search
This commit is contained in:
parent
8133080e9c
commit
ea0aa3e00a
@ -1,6 +1,11 @@
|
||||
<div class="verticalScroll">
|
||||
<app-device-list [list]="deviceList.list"></app-device-list>
|
||||
<app-tunable-list [list]="tunableList.list"></app-tunable-list>
|
||||
<app-shutter-list [list]="shutterList.list"></app-shutter-list>
|
||||
<div class="emptyBox" *ngIf="deviceList.list.length === 0 && tunableList.list.length === 0 && shutterList.list.length === 0">- Nichts -</div>
|
||||
<div class="flexBox">
|
||||
<div class="flexBoxFixed">
|
||||
<app-search [(search)]="search" (doSearch)="refresh()"></app-search>
|
||||
</div>
|
||||
<div class="flexBoxRest verticalScroll">
|
||||
<app-device-list [list]="deviceList.list"></app-device-list>
|
||||
<app-tunable-list [list]="tunableList.list"></app-tunable-list>
|
||||
<app-shutter-list [list]="shutterList.list"></app-shutter-list>
|
||||
<div class="emptyBox" *ngIf="deviceList.list.length === 0 && tunableList.list.length === 0 && shutterList.list.length === 0">- Nichts -</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -12,6 +12,10 @@ import {TunableListComponent} from '../Tunable/tunable-list/tunable-list.compone
|
||||
import {ShutterListComponent} from '../Shutter/shutter-list/shutter-list.component';
|
||||
import {Subscription, timer} from 'rxjs';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {SearchComponent} from '../shared/search/search.component';
|
||||
import {DeviceFilter} from '../Device/DeviceFilter';
|
||||
import {TunableFilter} from '../Tunable/TunableFilter';
|
||||
import {ShutterFilter} from '../Shutter/ShutterFilter';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@ -22,6 +26,8 @@ import {NgIf} from '@angular/common';
|
||||
TunableListComponent,
|
||||
ShutterListComponent,
|
||||
NgIf,
|
||||
SearchComponent,
|
||||
|
||||
],
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrl: './dashboard.component.less'
|
||||
@ -42,19 +48,27 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
|
||||
protected shuttersShouldBeOpen: boolean = false;
|
||||
|
||||
protected search: string = '';
|
||||
|
||||
private readonly deviceFilter: DeviceFilter = new DeviceFilter();
|
||||
|
||||
private readonly shutterFilter: ShutterFilter = new ShutterFilter();
|
||||
|
||||
private readonly tunableFilter: TunableFilter = new TunableFilter();
|
||||
|
||||
constructor(
|
||||
protected readonly deviceService: DeviceService,
|
||||
protected readonly tunableService: TunableService,
|
||||
protected readonly shutterService: ShutterService,
|
||||
protected readonly tunableService: TunableService,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.newDate();
|
||||
this.subs.push(timer(5000, 5000).subscribe(() => this.newDate()));
|
||||
this.subs.push(this.deviceList = new CrudLiveList(this.deviceService, true, device => device.stateProperty?.state?.value === true));
|
||||
this.subs.push(this.tunableList = new CrudLiveList(this.tunableService, true, tunable => tunable.stateProperty?.state?.value === true));
|
||||
this.subs.push(this.shutterList = new CrudLiveList(this.shutterService, true, shutter => this.shutterFilter(shutter)));
|
||||
this.subs.push(this.deviceList = new CrudLiveList(this.deviceService, true, device => device.stateProperty?.state?.value === true, next => this.deviceService.filter(this.deviceFilter, next)));
|
||||
this.subs.push(this.shutterList = new CrudLiveList(this.shutterService, true, shutter => this.shutterFilter2(shutter), next => this.shutterService.filter(this.shutterFilter, next)));
|
||||
this.subs.push(this.tunableList = new CrudLiveList(this.tunableService, true, tunable => tunable.stateProperty?.state?.value === true, next => this.tunableService.filter(this.tunableFilter, next)));
|
||||
}
|
||||
|
||||
private newDate() {
|
||||
@ -67,7 +81,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
this.subs.forEach(sub => sub.unsubscribe());
|
||||
}
|
||||
|
||||
private shutterFilter(shutter: Shutter) {
|
||||
private shutterFilter2(shutter: Shutter) {
|
||||
if (this.shuttersShouldBeOpen) {
|
||||
return shutter.positionProperty?.state?.value !== 0;
|
||||
} else {
|
||||
@ -75,4 +89,13 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.deviceFilter.search = this.search;
|
||||
this.deviceList.refresh();
|
||||
this.tunableFilter.search = this.search;
|
||||
this.tunableList.refresh();
|
||||
this.shutterFilter.search = this.search;
|
||||
this.shutterList.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user