diff --git a/src/app/api-utils.ts b/src/app/api-utils.ts index fa2d54bda..50d0a874d 100644 --- a/src/app/api-utils.ts +++ b/src/app/api-utils.ts @@ -6,5 +6,4 @@ export const deviceID = (): String => { } export const apiURL: String = '/' - export const apiRetry: number = 3; \ No newline at end of file diff --git a/src/app/charts/chart/chart.component.ts b/src/app/charts/chart/chart.component.ts index dd7beb3fe..f719e5a30 100644 --- a/src/app/charts/chart/chart.component.ts +++ b/src/app/charts/chart/chart.component.ts @@ -45,24 +45,20 @@ export class ChartComponent implements OnInit { ngAfterViewInit() { let totalCount: number = 0; this.service.getAll().subscribe( - folder => { + t => { // Count the number of folders and set chart totalCount++; this.donutChart.count = totalCount; // Get StateType and convert to string - let stateType; - let state: string; + const stateType = t.stateType; + const state = t.state; let color; switch (this.type) { case Type.Folder: - stateType = Folder.getStateType(folder); - state = Folder.stateTypeToString(stateType); - color = Folder.stateTypeToColor(stateType); + color = Folder.stateTypeToColor(t.stateType); break; case Type.Device: - stateType = Device.getStateType(folder); - state = Device.stateTypeToString(stateType); color = Device.stateTypeToColor(stateType); break; } diff --git a/src/app/device.ts b/src/app/device.ts index 42a889a30..4a285b069 100644 --- a/src/app/device.ts +++ b/src/app/device.ts @@ -3,7 +3,8 @@ import { colors } from './style'; interface Device { deviceID: string; name: string; - state: Device.StateType; + stateType: Device.StateType; + state: string; paused: boolean; connected: boolean; completion: number; @@ -70,7 +71,7 @@ namespace Device { export function getStateType(d: Device): StateType { // StateType Unknown is set in DeviceService - if (d.state === StateType.Unknown) { + if (d.stateType === StateType.Unknown) { return StateType.Unknown; } diff --git a/src/app/folder.ts b/src/app/folder.ts index fb8169e64..c3330f0ff 100644 --- a/src/app/folder.ts +++ b/src/app/folder.ts @@ -6,8 +6,11 @@ interface Folder { label: string; devices: Device[]; status: Folder.Status; + stateType: Folder.StateType; + state: string; paused: boolean; completion: number; + path: string; } namespace Folder { diff --git a/src/app/list-toggle/list-toggle.component.html b/src/app/list-toggle/list-toggle.component.html index f360d7f5d..51c58f0fb 100644 --- a/src/app/list-toggle/list-toggle.component.html +++ b/src/app/list-toggle/list-toggle.component.html @@ -1,4 +1,4 @@ - + Folders Devices \ No newline at end of file diff --git a/src/app/lists/device-list/device-list-datasource.ts b/src/app/lists/device-list/device-list-datasource.ts deleted file mode 100644 index 94007cacd..000000000 --- a/src/app/lists/device-list/device-list-datasource.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { DataSource } from '@angular/cdk/collections'; -import { MatPaginator } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; - -import { map } from 'rxjs/operators'; -import { Observable, of as observableOf, merge, Subject } from 'rxjs'; -import Device from '../../device'; -import { SystemConfigService } from '../../services/system-config.service'; - -/** - * Data source for the DeviceList view. This class should - * encapsulate all logic for fetching and manipulating the displayed data - * (including sorting, pagination, and filtering). - */ -export class DeviceListDataSource extends DataSource { - data: Device[]; - dataSubject: Subject; - paginator: MatPaginator; - sort: MatSort; - - constructor(private systemConfigService: SystemConfigService) { - super(); - } - - /** - * Connect this data source to the table. The table will only update when - * the returned stream emits new items. - * @returns A stream of the items to be rendered. - */ - connect(): Observable { - // Combine everything that affects the rendered data into one update - // st - const dataMutations = [ - this.dataSubject, - observableOf(this.data), - this.paginator.page, - this.sort.sortChange - ]; - - return merge(...dataMutations).pipe(map(() => { - return this.getPagedData(this.getSortedData([...this.data])); - })); - } - - /** - * Called when the table is being destroyed. Use this function, to clean up - * any open connections or free any held resources that were set up during connect. - */ - disconnect() { } - - /** - * Paginate the data (client-side). If you're using server-side pagination, - * this would be replaced by requesting the appropriate data from the server. - */ - private getPagedData(data: Device[]) { - const startIndex = this.paginator.pageIndex * this.paginator.pageSize; - return data.splice(startIndex, this.paginator.pageSize); - } - - /** - * Sort the data (client-side). If you're using server-side sorting, - * this would be replaced by requesting the appropriate data from the server. - */ - private getSortedData(data: Device[]) { - if (!this.sort.active || this.sort.direction === '') { - return data; - } - - return data.sort((a, b) => { - const isAsc = this.sort.direction === 'asc'; - switch (this.sort.active) { - case 'name': return compare(a.name, b.name, isAsc); - case 'id': return compare(+a.deviceID, +b.deviceID, isAsc); - default: return 0; - } - }); - } -} - -function compare(a: string | number, b: string | number, isAsc: boolean) { - return (a < b ? -1 : 1) * (isAsc ? 1 : -1); -} \ No newline at end of file diff --git a/src/app/lists/device-list/device-list.component.html b/src/app/lists/device-list/device-list.component.html index 7500bd3c4..2b2fdd055 100644 --- a/src/app/lists/device-list/device-list.component.html +++ b/src/app/lists/device-list/device-list.component.html @@ -11,6 +11,12 @@ {{row.name}} + + + State + {{row.state}} + + diff --git a/src/app/lists/device-list/device-list.component.ts b/src/app/lists/device-list/device-list.component.ts index f29dc59d5..6f601f305 100644 --- a/src/app/lists/device-list/device-list.component.ts +++ b/src/app/lists/device-list/device-list.component.ts @@ -18,7 +18,7 @@ export class DeviceListComponent implements AfterViewInit, OnInit { dataSource: MatTableDataSource; /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */ - displayedColumns = ['id', 'name']; + displayedColumns = ['id', 'name', 'state']; constructor(private systemConfigService: SystemConfigService) { }; diff --git a/src/app/lists/folder-list/folder-list.component.html b/src/app/lists/folder-list/folder-list.component.html index d4bee42e4..292726959 100644 --- a/src/app/lists/folder-list/folder-list.component.html +++ b/src/app/lists/folder-list/folder-list.component.html @@ -9,12 +9,24 @@ {{row.id}} - + Name {{row.label}} + + + Path + {{row.path}} + + + + + State + {{row.state}} + + diff --git a/src/app/lists/folder-list/folder-list.component.ts b/src/app/lists/folder-list/folder-list.component.ts index cae3ba900..07936f81d 100644 --- a/src/app/lists/folder-list/folder-list.component.ts +++ b/src/app/lists/folder-list/folder-list.component.ts @@ -23,7 +23,7 @@ export class FolderListComponent implements AfterViewInit, OnInit { } /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */ - displayedColumns = ['id', 'label']; + displayedColumns = ['id', 'label', 'path', 'state']; constructor(private systemConfigService: SystemConfigService) { }; diff --git a/src/app/lists/status-list/status-list.component.html b/src/app/lists/status-list/status-list.component.html index 8783944a5..986deb682 100644 --- a/src/app/lists/status-list/status-list.component.html +++ b/src/app/lists/status-list/status-list.component.html @@ -1,7 +1,7 @@
{{title | uppercase}}
- +
diff --git a/src/app/lists/status-list/status-list.component.scss b/src/app/lists/status-list/status-list.component.scss index e69de29bb..213f72723 100644 --- a/src/app/lists/status-list/status-list.component.scss +++ b/src/app/lists/status-list/status-list.component.scss @@ -0,0 +1,7 @@ +.tui-card-toggle { + padding: 16px 16px 0 16px; +} + +.tui-card-content { + padding-top: 0; +} \ No newline at end of file diff --git a/src/app/services/device.service.ts b/src/app/services/device.service.ts index f2a37d33f..6894fa6a7 100644 --- a/src/app/services/device.service.ts +++ b/src/app/services/device.service.ts @@ -35,7 +35,7 @@ export class DeviceService { if (this.sysConns.connections[device.deviceID] === undefined) { console.log(this.sysConns.connections) console.log("connections undefined", device.deviceID); - device.state = Device.StateType.Unknown; + device.stateType = Device.StateType.Unknown; } else { // Set connected device.connected = this.sysConns.connections[device.deviceID].connected; @@ -49,6 +49,8 @@ export class DeviceService { this.dbCompletionService.getDeviceCompletion(device.deviceID).subscribe( c => { device.completion = c.completion; + device.stateType = Device.getStateType(device); + device.state = Device.stateTypeToString(device.stateType); observer.next(device); // recursively get the status of the next folder diff --git a/src/app/services/folder.service.ts b/src/app/services/folder.service.ts index 8726d83bd..0c433f757 100644 --- a/src/app/services/folder.service.ts +++ b/src/app/services/folder.service.ts @@ -26,6 +26,8 @@ export class FolderService { this.dbStatusService.getFolderStatus(folder.id).subscribe( status => { folder.status = status; + folder.stateType = Folder.getStateType(folder); + folder.state = Folder.stateTypeToString(folder.stateType); observer.next(folder); // recursively get the status of the next folder diff --git a/src/styles.scss b/src/styles.scss index 08d859424..53fde9226 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -52,11 +52,10 @@ $tech-ui-typography: mat-typography-config( // Be sure that you only ever include this mixin once! @include mat-core($tech-ui-typography); - // Define the palettes for your theme using the Material Design palettes available in palette.scss // (imported above). For each palette, you can optionally specify a default, lighter, and darker // hue. Available color palettes: https://material.io/design/color/ -$tech-ui-primary: mat-palette($mat-indigo); +$tech-ui-primary: mat-palette($mat-blue); $tech-ui-accent: mat-palette($mat-blue, A200, A100, A400); // The warn palette is optional (defaults to red). @@ -93,4 +92,8 @@ html, body { .tui-card-content { padding: 16px; -} \ No newline at end of file +} + +.tui-button-toggle .mat-button-toggle-appearance-standard .mat-button-toggle-label-content { + line-height: 34px; +}