syncthing/next-gen-gui/src/app/lists/status-list/status-list.component.ts

48 lines
1.3 KiB
TypeScript
Raw Normal View History

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