mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-28 01:18:26 +00:00
Combine types
This commit is contained in:
parent
33398b0b6b
commit
dae1f990a5
@ -1,4 +0,0 @@
|
||||
export const enum ChartType {
|
||||
Folder = 0,
|
||||
Device
|
||||
}
|
@ -5,7 +5,7 @@ import { FolderService } from 'src/app/services/folder.service';
|
||||
import { DonutChartComponent } from '../donut-chart/donut-chart.component';
|
||||
import { DeviceService } from 'src/app/services/device.service';
|
||||
import Device from 'src/app/device';
|
||||
import { ChartType } from '../../chart';
|
||||
import { Type } from '../../type';
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ import { ChartType } from '../../chart';
|
||||
|
||||
export class ChartComponent implements OnInit {
|
||||
@ViewChild(DonutChartComponent) donutChart: DonutChartComponent;
|
||||
@Input() type: ChartType;
|
||||
@Input() type: Type;
|
||||
title: string;
|
||||
chartID: string;
|
||||
states: { label: string, count: number, color: string }[] = [];
|
||||
@ -29,12 +29,12 @@ export class ChartComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
switch (this.type) {
|
||||
case ChartType.Folder:
|
||||
case Type.Folder:
|
||||
this.title = "Folders";
|
||||
this.chartID = 'foldersChart';
|
||||
this.service = this.folderService;
|
||||
break;
|
||||
case ChartType.Device:
|
||||
case Type.Device:
|
||||
this.title = "Devices";
|
||||
this.chartID = 'devicesChart';
|
||||
this.service = this.deviceServce;
|
||||
@ -55,12 +55,12 @@ export class ChartComponent implements OnInit {
|
||||
let state: string;
|
||||
let color;
|
||||
switch (this.type) {
|
||||
case ChartType.Folder:
|
||||
case Type.Folder:
|
||||
stateType = Folder.getStateType(folder);
|
||||
state = Folder.stateTypeToString(stateType);
|
||||
color = Folder.stateTypeToColor(stateType);
|
||||
break;
|
||||
case ChartType.Device:
|
||||
case Type.Device:
|
||||
stateType = Device.getStateType(folder);
|
||||
state = Device.stateTypeToString(stateType);
|
||||
color = Device.stateTypeToColor(stateType);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { SystemConfigService } from '../services/system-config.service';
|
||||
import { ChartType } from '../chart';
|
||||
import { Type } from '../type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@ -8,8 +8,8 @@ import { ChartType } from '../chart';
|
||||
styleUrls: ['./dashboard.component.scss']
|
||||
})
|
||||
export class DashboardComponent {
|
||||
folderChart: ChartType = ChartType.Folder;
|
||||
deviceChart: ChartType = ChartType.Device;
|
||||
folderChart: Type = Type.Folder;
|
||||
deviceChart: Type = Type.Device;
|
||||
|
||||
constructor(private systemConfigService: SystemConfigService) { }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" value="folders">
|
||||
<mat-button-toggle value="folders" (click)="onSelect(listType.Folders)">Folders</mat-button-toggle>
|
||||
<mat-button-toggle value="devices" (click)="onSelect(listType.Devices)">Devices</mat-button-toggle>
|
||||
<mat-button-toggle value="folders" (click)="onSelect(listType.Folder)">Folders</mat-button-toggle>
|
||||
<mat-button-toggle value="devices" (click)="onSelect(listType.Device)">Devices</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
@ -1,5 +1,5 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { ListType } from '../list-type';
|
||||
import { Type } from '../type';
|
||||
|
||||
|
||||
|
||||
@ -10,20 +10,20 @@ import { ListType } from '../list-type';
|
||||
})
|
||||
|
||||
export class ListToggleComponent implements OnInit {
|
||||
public listType = ListType;
|
||||
@Output() listTypeEvent = new EventEmitter<ListType>();
|
||||
public listType = Type;
|
||||
@Output() listTypeEvent = new EventEmitter<Type>();
|
||||
|
||||
constructor() { }
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
onSelect(t: ListType): void {
|
||||
onSelect(t: Type): void {
|
||||
this.listTypeEvent.emit(t);
|
||||
switch (t) {
|
||||
case ListType.Folders:
|
||||
case Type.Folder:
|
||||
console.log("folder action");
|
||||
break;
|
||||
case ListType.Devices:
|
||||
case Type.Device:
|
||||
console.log("Device action");
|
||||
break;
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
export enum ListType {
|
||||
Folders = 1,
|
||||
Devices,
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
<app-list-toggle (listTypeEvent)="onToggle($event)" class="tui-card-content"></app-list-toggle>
|
||||
</div>
|
||||
<div class="tui-card-content">
|
||||
<app-folder-list *ngIf="currentListType===listType.Folders"></app-folder-list>
|
||||
<app-device-list *ngIf="currentListType===listType.Devices"></app-device-list>
|
||||
<app-folder-list *ngIf="currentListType===listType.Folder"></app-folder-list>
|
||||
<app-device-list *ngIf="currentListType===listType.Device"> </app-device-list>
|
||||
</div>
|
||||
</div>
|
@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ListType } from '../../list-type';
|
||||
import { Type } from '../../type';
|
||||
import { cardElevation } from '../../style';
|
||||
|
||||
|
||||
@ -9,17 +9,18 @@ import { cardElevation } from '../../style';
|
||||
styleUrls: ['./status-list.component.scss']
|
||||
})
|
||||
export class StatusListComponent implements OnInit {
|
||||
currentListType: ListType = ListType.Folders;
|
||||
listType = ListType; // used in html
|
||||
currentListType: Type = Type.Folder;
|
||||
listType = Type; // used in html
|
||||
elevation: string = cardElevation;
|
||||
title: string = 'Status';
|
||||
folderList: Type = Type.Folder;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
onToggle(t: ListType) {
|
||||
onToggle(t: Type) {
|
||||
this.currentListType = t;
|
||||
}
|
||||
}
|
||||
|
4
src/app/type.ts
Normal file
4
src/app/type.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum Type {
|
||||
Folder = 1,
|
||||
Device,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user