Change collapsing dashboard into 3 levels.

This commit is contained in:
softsimon
2020-10-27 16:34:27 +07:00
parent 91f9bb3e5f
commit 2ac8608620
4 changed files with 23 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
<div class="container-xl mt-2">
<div class="row row-cols-1 row-cols-md-2" *ngIf="{ value: (mempoolInfoData$ | async) } as mempoolInfoData">
<ng-template [ngIf]="collapsed" [ngIfElse]="expanded">
<ng-template [ngIf]="collapseLevel === 'three'" [ngIfElse]="expanded">
<div class="col mb-4">
<div class="card text-center">
<div class="card-body">
@@ -68,6 +68,7 @@
</div>
</div>
</div>
<ng-template [ngIf]="collapseLevel === 'one'">
<div class="col mb-4">
<div class="card text-center">
<div class="card-body">
@@ -122,9 +123,15 @@
</div>
</div>
</ng-template>
</ng-template>
</div>
<button type="button" class="btn btn-secondary btn-sm d-block mx-auto" (click)="toggleCollapsed()">{{ collapsed ? 'Expand' : 'Collapse' }}</button>
<button type="button" class="btn btn-secondary btn-sm d-block mx-auto" (click)="toggleCollapsed()">
<div [ngSwitch]="collapseLevel">
<fa-icon *ngSwitchCase="'three'" [icon]="['fas', 'angle-down']" [fixedWidth]="true" title="Collapse"></fa-icon>
<fa-icon *ngSwitchDefault [icon]="['fas', 'angle-up']" [fixedWidth]="true" title="Expand"></fa-icon>
</div>
</button>
<br>

View File

@@ -43,7 +43,7 @@ interface MempoolStatsData {
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DashboardComponent implements OnInit {
collapsed = true;
collapseLevel: string;
network$: Observable<string>;
mempoolBlocksData$: Observable<MempoolBlocksData>;
mempoolInfoData$: Observable<MempoolInfoData>;
@@ -69,7 +69,7 @@ export class DashboardComponent implements OnInit {
this.seoService.resetTitle();
this.websocketService.want(['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
this.network$ = merge(of(''), this.stateService.networkChanged$);
this.collapsed = this.storageService.getValue('dashboard-collapsed') === 'true' || false;
this.collapseLevel = this.storageService.getValue('dashboard-collapsed') || 'one';
this.mempoolInfoData$ = combineLatest([
this.stateService.mempoolInfo$,
@@ -223,7 +223,13 @@ export class DashboardComponent implements OnInit {
}
toggleCollapsed() {
this.collapsed = !this.collapsed;
this.storageService.setValue('dashboard-collapsed', this.collapsed);
if (this.collapseLevel === 'one') {
this.collapseLevel = 'two';
} else if (this.collapseLevel === 'two') {
this.collapseLevel = 'three';
} else {
this.collapseLevel = 'one';
}
this.storageService.setValue('dashboard-collapsed', this.collapseLevel);
}
}