mirror of
https://github.com/benjamin-wilson/public-pool-ui.git
synced 2025-10-10 16:32:30 +02:00
expand table by default
This commit is contained in:
@@ -74,10 +74,9 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<p-table #dataTable [rowHover]="true" groupRowsBy="name" dataKey="name" rowGroupMode="subheader"
|
||||||
|
[value]="clientInfo.workers" [expandedRowKeys]="expandedRows$ | async"
|
||||||
<p-table [rowHover]="true" groupRowsBy="name" dataKey="name" rowGroupMode="subheader"
|
[tableStyle]="{ 'min-width': '50rem' }">
|
||||||
[value]="clientInfo.workers" [tableStyle]="{ 'min-width': '50rem' }">
|
|
||||||
|
|
||||||
|
|
||||||
<ng-template pTemplate="header">
|
<ng-template pTemplate="header">
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { AfterViewInit, Component, ViewChild } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { Table } from 'primeng/table';
|
||||||
import { map, Observable, shareReplay } from 'rxjs';
|
import { map, Observable, shareReplay } from 'rxjs';
|
||||||
|
|
||||||
import { HashSuffixPipe } from '../../pipes/hash-suffix.pipe';
|
import { HashSuffixPipe } from '../../pipes/hash-suffix.pipe';
|
||||||
@@ -11,7 +12,7 @@ import { ClientService } from '../../services/client.service';
|
|||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
styleUrls: ['./dashboard.component.scss']
|
styleUrls: ['./dashboard.component.scss']
|
||||||
})
|
})
|
||||||
export class DashboardComponent {
|
export class DashboardComponent implements AfterViewInit {
|
||||||
|
|
||||||
public address: string;
|
public address: string;
|
||||||
|
|
||||||
@@ -22,6 +23,10 @@ export class DashboardComponent {
|
|||||||
|
|
||||||
public networkInfo$: Observable<any>;
|
public networkInfo$: Observable<any>;
|
||||||
|
|
||||||
|
@ViewChild('dataTable') dataTable!: Table;
|
||||||
|
|
||||||
|
public expandedRows$: Observable<any>;
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private clientService: ClientService,
|
private clientService: ClientService,
|
||||||
@@ -30,6 +35,8 @@ export class DashboardComponent {
|
|||||||
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.networkInfo$ = this.appService.getNetworkInfo();
|
this.networkInfo$ = this.appService.getNetworkInfo();
|
||||||
|
|
||||||
this.address = this.route.snapshot.params['address'];
|
this.address = this.route.snapshot.params['address'];
|
||||||
@@ -37,6 +44,13 @@ export class DashboardComponent {
|
|||||||
shareReplay({ refCount: true, bufferSize: 1 })
|
shareReplay({ refCount: true, bufferSize: 1 })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.expandedRows$ = this.clientInfo$.pipe(map((info: any) => {
|
||||||
|
|
||||||
|
return info.workers.reduce((pre: any, cur: any) => { pre[cur.name] = true; return pre; }, {});
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const documentStyle = getComputedStyle(document.documentElement);
|
const documentStyle = getComputedStyle(document.documentElement);
|
||||||
const textColor = documentStyle.getPropertyValue('--text-color');
|
const textColor = documentStyle.getPropertyValue('--text-color');
|
||||||
@@ -138,6 +152,11 @@ export class DashboardComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public getSessionCount(name: string, workers: any[]) {
|
public getSessionCount(name: string, workers: any[]) {
|
||||||
const workersByName = workers.filter(w => w.name == name);
|
const workersByName = workers.filter(w => w.name == name);
|
||||||
return workersByName.length;
|
return workersByName.length;
|
||||||
|
Reference in New Issue
Block a user