From a3fefef1e054e9739a80c53de4ad2eb020e3a528 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 26 Nov 2020 22:18:51 +0200 Subject: [PATCH] linked dictionary page to data --- .../simple-doughnut-chart.component.html | 2 ++ .../simple-doughnut-chart.component.ts | 30 +++++++++++-------- .../dictionary-listing-screen.component.html | 2 +- .../dictionary-listing-screen.component.ts | 25 +++++++++++++--- .../src/assets/styles/red-text-styles.scss | 4 +++ libs/red-ui-http/src/lib/model/typeValue.ts | 1 + 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/apps/red-ui/src/app/components/simple-doughnut-chart/simple-doughnut-chart.component.html b/apps/red-ui/src/app/components/simple-doughnut-chart/simple-doughnut-chart.component.html index d512d9a4b..ad26509e7 100644 --- a/apps/red-ui/src/app/components/simple-doughnut-chart/simple-doughnut-chart.component.html +++ b/apps/red-ui/src/app/components/simple-doughnut-chart/simple-doughnut-chart.component.html @@ -2,6 +2,7 @@
- 300 + {{ dict.entries?.length }}
diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts index 6bae3e722..f71f2c955 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.ts @@ -1,9 +1,11 @@ import { Component, OnInit } from '@angular/core'; import { DoughnutChartConfig } from '../../../components/simple-doughnut-chart/simple-doughnut-chart.component'; -import { TypeValue } from '@redaction/red-ui-http'; +import { DictionaryControllerService, TypeValue } from '@redaction/red-ui-http'; import { SortingOption, SortingService } from '../../../utils/sorting.service'; import { DialogService } from '../../../dialogs/dialog.service'; import { AppStateService } from '../../../state/app-state.service'; +import { tap } from 'rxjs/operators'; +import { forkJoin } from 'rxjs'; @Component({ selector: 'redaction-dictionary-listing-screen', @@ -18,13 +20,28 @@ export class DictionaryListingScreenComponent implements OnInit { constructor( private readonly _dialogService: DialogService, private readonly _sortingService: SortingService, + private readonly _dictionaryControllerService: DictionaryControllerService, private readonly _appStateService: AppStateService ) {} ngOnInit(): void { this._appStateService.reset(); - const dicts = this._appStateService.dictionaryData; - this.dictionaries = Object.keys(dicts).map((key) => dicts[key]); + const appStateDictionaryData = this._appStateService.dictionaryData; + this.dictionaries = Object.keys(appStateDictionaryData) + .map((key) => appStateDictionaryData[key]) + .filter((d) => !d.virtual); + const dataObs = []; + this.dictionaries.forEach((item) => { + const observable = this._dictionaryControllerService.getDictionaryForType(item.type).pipe( + tap((values) => { + item.entries = values.entries ? values.entries : []; + }) + ); + dataObs.push(observable); + }); + forkJoin(dataObs).subscribe(() => { + this._calculateData(); + }); this._calculateData(); } @@ -32,7 +49,7 @@ export class DictionaryListingScreenComponent implements OnInit { this.chartData = []; for (const dict of this.dictionaries) { this.chartData.push({ - value: 100, + value: dict.entries ? dict.entries.length : 0, color: dict.hexColor, label: dict.label, key: dict.type diff --git a/apps/red-ui/src/assets/styles/red-text-styles.scss b/apps/red-ui/src/assets/styles/red-text-styles.scss index 0ef33ee75..deaae2a09 100644 --- a/apps/red-ui/src/assets/styles/red-text-styles.scss +++ b/apps/red-ui/src/assets/styles/red-text-styles.scss @@ -70,3 +70,7 @@ a { color: $primary; opacity: 1; } + +.no-wrap { + white-space: nowrap; +} diff --git a/libs/red-ui-http/src/lib/model/typeValue.ts b/libs/red-ui-http/src/lib/model/typeValue.ts index 42356824f..9882a2c97 100644 --- a/libs/red-ui-http/src/lib/model/typeValue.ts +++ b/libs/red-ui-http/src/lib/model/typeValue.ts @@ -34,4 +34,5 @@ export interface TypeValue { isDefaultFilter?: boolean; virtual?: boolean; label?: string; + entries?: string[]; }