diff --git a/dmp-frontend/src/app/core/model/configuration-models/extended-internal-status.model.ts b/dmp-frontend/src/app/core/model/configuration-models/extended-internal-status.model.ts deleted file mode 100644 index 674b419c2..000000000 --- a/dmp-frontend/src/app/core/model/configuration-models/extended-internal-status.model.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { InternalStatus } from "@annotation-service/core/enum/internal-status.enum"; - -export class ExtendedInternalStatus { - - private _extendedInternalStatustems: ExtendedInternalStatusItem[]; - get extendedInternalStatustems(): ExtendedInternalStatusItem[] { - return this._extendedInternalStatustems; - } - - public static parseValue(value: any): ExtendedInternalStatus { - const extendedInternalStatusObj: ExtendedInternalStatus = new ExtendedInternalStatus(); - - extendedInternalStatusObj._extendedInternalStatustems = []; - for (let item of value) { - const extendedInternalStatusItemObj: ExtendedInternalStatusItem = ExtendedInternalStatusItem.parseValue(item); - extendedInternalStatusObj._extendedInternalStatustems.push(extendedInternalStatusItemObj); - } - - return extendedInternalStatusObj; - } - - getIcon(status?: InternalStatus): string { - const extendedInternalStatus = this.extendedInternalStatustems?.find(s => s.InternalStatus == status); - - return extendedInternalStatus?.icon == null || extendedInternalStatus?.icon == '' ? 'animation' : extendedInternalStatus?.icon; - } -} - -export class ExtendedInternalStatusItem { - private _internalStatus: InternalStatus; - get InternalStatus(): InternalStatus { - return this._internalStatus; - } - - private _icon: string; - get icon(): string { - return this._icon; - } - - public static parseValue(value: any): ExtendedInternalStatusItem { - const obj: ExtendedInternalStatusItem = new ExtendedInternalStatusItem(); - obj._internalStatus = value.internalStatus; - obj._icon = value.icon; - return obj; - } -} diff --git a/dmp-frontend/src/app/core/model/configuration-models/status-icon.model.ts b/dmp-frontend/src/app/core/model/configuration-models/status-icon.model.ts new file mode 100644 index 000000000..32daaab64 --- /dev/null +++ b/dmp-frontend/src/app/core/model/configuration-models/status-icon.model.ts @@ -0,0 +1,26 @@ +import { InternalStatus } from "@annotation-service/core/enum/internal-status.enum"; + +export class StatusIcon { + private _internalStatus: InternalStatus; + get InternalStatus(): InternalStatus { + return this._internalStatus; + } + + private _icon: string; + get icon(): string { + return this._icon; + } + + private _id: string; + get id(): string { + return this._id; + } + + public static parseValue(value: any): StatusIcon { + const obj: StatusIcon = new StatusIcon(); + obj._internalStatus = value.internalStatus; + obj._icon = value.icon; + obj._id = value.id; + return obj; + } +} diff --git a/dmp-frontend/src/app/core/services/configuration/configuration.service.ts b/dmp-frontend/src/app/core/services/configuration/configuration.service.ts index 19a0e8689..d1e8c1c9a 100644 --- a/dmp-frontend/src/app/core/services/configuration/configuration.service.ts +++ b/dmp-frontend/src/app/core/services/configuration/configuration.service.ts @@ -13,7 +13,7 @@ import { AuthProviders } from '@app/core/model/configuration-models/auth-provide import { AnalyticsProviders } from '@app/core/model/configuration-models/analytics-providers.model'; import { CssColorsTenantConfiguration } from '@app/core/model/tenant-configuaration/tenant-configuration'; import { Sidebar } from '@app/core/model/configuration-models/sidebar.model'; -import { ExtendedInternalStatus } from '@app/core/model/configuration-models/extended-internal-status.model'; +import { StatusIcon } from '@app/core/model/configuration-models/status-icon.model'; @Injectable({ providedIn: 'root', @@ -123,9 +123,14 @@ export class ConfigurationService extends BaseComponent { return this._notificationServiceEnabled; } - private _extendedInternalStatus: ExtendedInternalStatus; - get extendedInternalStatus(): ExtendedInternalStatus { - return this._extendedInternalStatus; + private _statusIcons: StatusIcon[]; + get statusIcons(): StatusIcon[] { + return this._statusIcons; + } + + private _defaultStatusIcon: string; + get defaultStatusIcon(): string { + return this._defaultStatusIcon || 'animation'; } private _annotationServiceAddress: string; @@ -269,7 +274,9 @@ export class ConfigurationService extends BaseComponent { if (config.annotation_service) { this._annotationServiceEnabled = config.annotation_service.enabled; this._annotationServiceAddress = config.annotation_service.address; - this._extendedInternalStatus = ExtendedInternalStatus.parseValue(config.annotation_service.extendedInternalStatus); + this._statusIcons = []; + config.annotation_service?.statusIcons?.forEach(statusIcon => this._statusIcons.push(StatusIcon.parseValue(statusIcon))); + this._defaultStatusIcon = config.annotation_service.defaultStatusIcon; } this._inAppNotificationsCountInterval = config.inAppNotificationsCountInterval; this._newReleaseNotificationExpires = config.newReleaseNotification?.expires; diff --git a/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html b/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html index 7a69df663..148692bf0 100644 --- a/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html +++ b/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.html @@ -114,7 +114,7 @@ [ngClass]="{'selected': status?.id == getAnnotationStatusFormControl(annotationStatusFormGroup.get('annotationsStatusArray'), getParentAnnotation(thread).id).get('statusId')?.value}" (click)="setAnnotationStatus(annotationStatusFormGroup?.get('annotationsStatusArray'), getParentAnnotation(thread).id, status?.id); persistAnnotationStatus(annotationStatusFormGroup.get('annotationsStatusArray'), getParentAnnotation(thread).id)" > - {{getStatusIcon(status?.internalStatus)}} + {{getStatusIcon(status)}} diff --git a/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.ts b/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.ts index d2c46d433..320aa4bf9 100644 --- a/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.ts +++ b/dmp-frontend/src/app/ui/annotations/annotation-dialog-component/annotation-dialog.component.ts @@ -205,8 +205,20 @@ export class AnnotationDialogComponent extends BaseComponent { return !isNullOrUndefined(text) && text.length !== 0 && text !== ''; } - getStatusIcon(status?: InternalStatus): string { - return this.configurationService.extendedInternalStatus?.getIcon(status); + getStatusIcon(status: Status): string { + let icon = this.configurationService.defaultStatusIcon; + + if (status) { + if (status.internalStatus != null) { + const statusConfiguration = this.configurationService.statusIcons?.find(s => s.InternalStatus == status.internalStatus); + if (statusConfiguration?.icon != null && statusConfiguration?.icon != '') icon = statusConfiguration?.icon; + } else if (status.id) { + const statusConfiguration = this.configurationService.statusIcons?.find(s => s.id == status.id.toString()); + if (statusConfiguration?.icon != null && statusConfiguration?.icon != '') icon = statusConfiguration?.icon; + } + } + + return icon } public isFormValid(value: any) { diff --git a/dmp-frontend/src/assets/config/config.json b/dmp-frontend/src/assets/config/config.json index 9ad7ce281..450fe485c 100644 --- a/dmp-frontend/src/assets/config/config.json +++ b/dmp-frontend/src/assets/config/config.json @@ -27,12 +27,17 @@ "annotation_service": { "enabled": true, "address": "http://localhost:8087/api/", - "extendedInternalStatus": [ + "statusIcons": [ { "internalStatus": "0", "icon": "check" + }, + { + "id": "948fdf9c-6b84-467c-884b-5323c5ea15d7", + "icon": "done_all" } - ] + ], + "defaultStatusIcon": "animation" }, "logging": { "enabled": true,