fixes on annotation service status-icons configuration

This commit is contained in:
Sofia Papacharalampous 2024-07-04 12:12:19 +03:00
parent 194887d9ab
commit cad0c34434
6 changed files with 60 additions and 56 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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 { AnalyticsProviders } from '@app/core/model/configuration-models/analytics-providers.model';
import { CssColorsTenantConfiguration } from '@app/core/model/tenant-configuaration/tenant-configuration'; import { CssColorsTenantConfiguration } from '@app/core/model/tenant-configuaration/tenant-configuration';
import { Sidebar } from '@app/core/model/configuration-models/sidebar.model'; 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({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -123,9 +123,14 @@ export class ConfigurationService extends BaseComponent {
return this._notificationServiceEnabled; return this._notificationServiceEnabled;
} }
private _extendedInternalStatus: ExtendedInternalStatus; private _statusIcons: StatusIcon[];
get extendedInternalStatus(): ExtendedInternalStatus { get statusIcons(): StatusIcon[] {
return this._extendedInternalStatus; return this._statusIcons;
}
private _defaultStatusIcon: string;
get defaultStatusIcon(): string {
return this._defaultStatusIcon || 'animation';
} }
private _annotationServiceAddress: string; private _annotationServiceAddress: string;
@ -269,7 +274,9 @@ export class ConfigurationService extends BaseComponent {
if (config.annotation_service) { if (config.annotation_service) {
this._annotationServiceEnabled = config.annotation_service.enabled; this._annotationServiceEnabled = config.annotation_service.enabled;
this._annotationServiceAddress = config.annotation_service.address; 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._inAppNotificationsCountInterval = config.inAppNotificationsCountInterval;
this._newReleaseNotificationExpires = config.newReleaseNotification?.expires; this._newReleaseNotificationExpires = config.newReleaseNotification?.expires;

View File

@ -114,7 +114,7 @@
[ngClass]="{'selected': status?.id == getAnnotationStatusFormControl(annotationStatusFormGroup.get('annotationsStatusArray'), getParentAnnotation(thread).id).get('statusId')?.value}" [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)" (click)="setAnnotationStatus(annotationStatusFormGroup?.get('annotationsStatusArray'), getParentAnnotation(thread).id, status?.id); persistAnnotationStatus(annotationStatusFormGroup.get('annotationsStatusArray'), getParentAnnotation(thread).id)"
> >
<mat-icon>{{getStatusIcon(status?.internalStatus)}}</mat-icon> <mat-icon>{{getStatusIcon(status)}}</mat-icon>
</button> </button>
</div> </div>
</div> </div>

View File

@ -205,8 +205,20 @@ export class AnnotationDialogComponent extends BaseComponent {
return !isNullOrUndefined(text) && text.length !== 0 && text !== ''; return !isNullOrUndefined(text) && text.length !== 0 && text !== '';
} }
getStatusIcon(status?: InternalStatus): string { getStatusIcon(status: Status): string {
return this.configurationService.extendedInternalStatus?.getIcon(status); 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) { public isFormValid(value: any) {

View File

@ -27,12 +27,17 @@
"annotation_service": { "annotation_service": {
"enabled": true, "enabled": true,
"address": "http://localhost:8087/api/", "address": "http://localhost:8087/api/",
"extendedInternalStatus": [ "statusIcons": [
{ {
"internalStatus": "0", "internalStatus": "0",
"icon": "check" "icon": "check"
},
{
"id": "948fdf9c-6b84-467c-884b-5323c5ea15d7",
"icon": "done_all"
} }
] ],
"defaultStatusIcon": "animation"
}, },
"logging": { "logging": {
"enabled": true, "enabled": true,