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