group states by name and color for chart

This commit is contained in:
Edi Cziszter 2022-02-18 12:02:15 +02:00
parent d0896e8f2c
commit 09d70dda7d
5 changed files with 38 additions and 20 deletions

View File

@ -111,7 +111,7 @@ export class DossierStatesListingScreenComponent extends ListingComponent<Dossie
try {
const dossierStates = this.dossierStateService.all.filter(d => d.dossierTemplateId === this.#dossierTemplateId);
this.#setStatesCount(dossierStates);
this.chartData = this.dossierStateService.all.map(state => {
this.chartData = dossierStates.map(state => {
return { value: state.dossierCount, label: state.name, key: state.name, color: state.color };
});

View File

@ -229,7 +229,7 @@ export class ConfigService {
filterGroups.push({
slug: 'statusFilters',
label: this._translateService.instant('filters.status'),
label: this._translateService.instant('filters.documents-status'),
icon: 'red:status',
filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]),
checker: keyChecker('workflowStatus'),

View File

@ -3,7 +3,7 @@ import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/si
import { FilterService, mapEach } from '@iqser/common-ui';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { combineLatest, Observable } from 'rxjs';
import { Dossier, DossierStats, FileCountPerWorkflowStatus, StatusSorter } from '@red/domain';
import { DossierStats, FileCountPerWorkflowStatus, StatusSorter } from '@red/domain';
import { workflowFileStatusTranslations } from '../../../../translations/file-status-translations';
import { TranslateChartService } from '@services/translate-chart.service';
import { filter, map, switchMap } from 'rxjs/operators';
@ -11,6 +11,12 @@ import { DossierStatsService } from '@services/entity-services/dossier-stats.ser
import { DossierStateService } from '../../../../../../services/entity-services/dossier-state.service';
import { TranslateService } from '@ngx-translate/core';
interface DossierStatusChartConfig {
readonly value: number;
readonly label: string;
readonly color: string;
}
@Component({
selector: 'redaction-dossiers-listing-details',
templateUrl: './dossiers-listing-details.component.html',
@ -36,23 +42,35 @@ export class DossiersListingDetailsComponent {
map(stats => this._toChartData(stats)),
);
this.dossiersChartData$ = this.dossiersService.all$.pipe(switchMap(dossiers => this._toDossierChartData(dossiers)));
this.dossiersChartData$ = this.dossiersService.all$.pipe(switchMap(dossiers => this._toDossierChartData()));
}
private async _toDossierChartData(dossiers: Dossier[]): Promise<DoughnutChartConfig[]> {
const config: DoughnutChartConfig[] = [];
this._dossierStateService.all.forEach(state => {
state.dossierCount = this.dossiersService.getCountWithState(state.dossierStatusId);
config.push({ value: state.dossierCount, label: state.name, color: state.color });
});
const notAssignedLength = this.dossiersService.all.length - config.map(v => v.value).reduce((acc, val) => acc + val, 0);
config.push({
private async _toDossierChartData(): Promise<DoughnutChartConfig[]> {
this._dossierStateService.all.forEach(
state => (state.dossierCount = this.dossiersService.getCountWithState(state.dossierStatusId)),
);
const configArray = [
...this._dossierStateService.all
.reduce((acc, s) => {
const key = s.name + '-' + s.color;
const item = acc.get(key) ?? Object.assign({}, { value: 0, label: s.name, color: s.color });
item.value += s.dossierCount;
return acc.set(key, item);
}, new Map<string, DoughnutChartConfig>())
.values(),
];
const notAssignedLength = this.dossiersService.all.length - configArray.map(v => v.value).reduce((acc, val) => acc + val, 0);
configArray.push({
value: notAssignedLength,
label: this._translateService.instant('edit-dossier-dialog.general-info.form.dossier-status.placeholder'),
color: '#E2E4E9',
});
// TODO: deleted dossiers count should come with stats
return config;
return configArray;
}
private _toChartData(stats: DossierStats[]) {

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://rosa1.iqser.cloud/redaction-gateway-v1",
"API_URL": "https://dev-04.iqser.cloud/redaction-gateway-v1",
"APP_NAME": "RedactManager",
"AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40",
@ -17,7 +17,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://rosa1.iqser.cloud/auth/realms/redaction",
"OAUTH_URL": "https://dev-04.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/3.0"

View File

@ -733,7 +733,6 @@
"assign-approver": "Assign Approver",
"assign-me": "Assign To Me",
"assign-reviewer": "Assign User",
"import-redactions": "Import redactions from other file",
"bulk": {
"delete": "Delete Documents",
"reanalyse": "Analyze Documents"
@ -781,6 +780,7 @@
"edit": "Edit Dossier",
"upload-document": "Upload Document"
},
"import-redactions": "Import redactions from other file",
"new-rule": {
"toast": {
"actions": {
@ -1289,13 +1289,13 @@
},
"filters": {
"assigned-people": "Assignee(s)",
"documents-status": "Documents Status",
"dossier-status": "Dossier Status",
"dossier-templates": "Dossier Templates",
"empty": "Empty",
"filter-by": "Filter:",
"needs-work": "Workload",
"people": "Dossier Member(s)",
"documents-status": "Documents Status",
"dossier-status": "Dossier Status"
"people": "Dossier Member(s)"
},
"general-config-screen": {
"actions": {