2020-04-02 20:00:09 +02:00
|
|
|
import { Component, ViewChild, AfterViewInit, ChangeDetectorRef } from '@angular/core';
|
2020-04-02 02:43:54 +02:00
|
|
|
import { StType } from '../../type';
|
2020-03-19 20:17:38 +01:00
|
|
|
import { cardElevation } from '../../style';
|
2020-04-02 02:43:54 +02:00
|
|
|
import { FilterService } from 'src/app/services/filter.service';
|
|
|
|
import { ListToggleComponent } from 'src/app/list-toggle/list-toggle.component';
|
2020-03-12 02:22:43 +01:00
|
|
|
|
2020-03-11 16:01:11 +01:00
|
|
|
|
2020-03-11 03:51:50 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'app-status-list',
|
|
|
|
templateUrl: './status-list.component.html',
|
|
|
|
styleUrls: ['./status-list.component.scss']
|
|
|
|
})
|
2020-04-02 02:43:54 +02:00
|
|
|
export class StatusListComponent {
|
|
|
|
@ViewChild(ListToggleComponent) toggle: ListToggleComponent;
|
|
|
|
currentListType: StType = StType.Folder;
|
|
|
|
listType = StType; // used in html
|
2020-03-19 20:17:38 +01:00
|
|
|
elevation: string = cardElevation;
|
2020-03-30 20:44:52 +02:00
|
|
|
title: string = 'Status';
|
2020-03-11 03:51:50 +01:00
|
|
|
|
2020-04-02 20:00:09 +02:00
|
|
|
constructor(
|
|
|
|
private filterService: FilterService,
|
|
|
|
private cdr: ChangeDetectorRef,
|
|
|
|
) { }
|
2020-03-11 03:51:50 +01:00
|
|
|
|
2020-04-02 02:43:54 +02:00
|
|
|
ngAfterViewInit() {
|
|
|
|
// Listen for filter changes from other components
|
|
|
|
this.filterService.filterChanged$.subscribe(
|
|
|
|
input => {
|
|
|
|
this.currentListType = input.type;
|
|
|
|
|
|
|
|
switch (input.type) {
|
|
|
|
case StType.Folder:
|
2020-04-02 17:50:57 +02:00
|
|
|
this.toggle.group.value = "folders";
|
2020-04-02 02:43:54 +02:00
|
|
|
break;
|
|
|
|
case StType.Device:
|
2020-04-02 17:50:57 +02:00
|
|
|
this.toggle.group.value = "devices";
|
2020-04-02 02:43:54 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2020-04-02 20:00:09 +02:00
|
|
|
|
|
|
|
this.cdr.detectChanges(); // manually detect changes
|
2020-03-11 03:51:50 +01:00
|
|
|
}
|
|
|
|
|
2020-04-02 02:43:54 +02:00
|
|
|
onToggle(t: StType) {
|
2020-03-19 23:05:04 +01:00
|
|
|
this.currentListType = t;
|
2020-03-12 02:22:43 +01:00
|
|
|
}
|
2020-03-11 03:51:50 +01:00
|
|
|
}
|