mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
refactor translations mapping
This commit is contained in:
@@ -8,7 +8,10 @@
|
|||||||
<div *ngFor="let key of notifyMessageKeys">
|
<div *ngFor="let key of notifyMessageKeys">
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<div class="font-weight-bold col">{{ key + '.notify-detail-modal' | translate}}</div>
|
<div class="font-weight-bold col">{{ key + '.notify-detail-modal' | translate}}</div>
|
||||||
<div class="col text-right">{{ notifyMessage[key] | translate }}</div>
|
<div class="col text-right">{{
|
||||||
|
('notify-detail-modal.' + notifyMessage[key] | translate) !== ('notify-detail-modal.' + notifyMessage[key]) ?
|
||||||
|
('notify-detail-modal.' + notifyMessage[key] | translate) :
|
||||||
|
notifyMessage[key]}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
<div>{{ message.activityStreamType }}</div>
|
<div>{{ message.activityStreamType }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>{{ message.queueStatusLabel | translate}}</div>
|
<div>{{ 'notify-detail-modal.' + message.queueStatusLabel | translate }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
|
@@ -13,7 +13,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
import { RouterStub } from '../../../shared/testing/router.stub';
|
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { of as observableOf, of } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { AdminNotifyMessage, QueueStatusMap } from '../models/admin-notify-message.model';
|
import { AdminNotifyMessage } from '../models/admin-notify-message.model';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/admin-notify-detail-modal.component';
|
import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/admin-notify-detail-modal.component';
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
@@ -75,13 +75,6 @@ export const mockAdminNotifyMessages = [
|
|||||||
'relatedItem': 'test coar demo'
|
'relatedItem': 'test coar demo'
|
||||||
}
|
}
|
||||||
] as unknown as AdminNotifyMessage[];
|
] as unknown as AdminNotifyMessage[];
|
||||||
|
|
||||||
export const mockUnformattedAdminNotifyMessages = mockAdminNotifyMessages.map(
|
|
||||||
message => ({
|
|
||||||
...message,
|
|
||||||
queueStatusLabel: Object.keys(QueueStatusMap)[Object.values(QueueStatusMap).indexOf(message.queueStatusLabel as unknown as QueueStatusMap)]
|
|
||||||
})
|
|
||||||
) as unknown as AdminNotifyMessage[];
|
|
||||||
describe('AdminNotifySearchResultComponent', () => {
|
describe('AdminNotifySearchResultComponent', () => {
|
||||||
let component: AdminNotifySearchResultComponent;
|
let component: AdminNotifySearchResultComponent;
|
||||||
let fixture: ComponentFixture<AdminNotifySearchResultComponent>;
|
let fixture: ComponentFixture<AdminNotifySearchResultComponent>;
|
||||||
|
@@ -2,7 +2,7 @@ import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
|||||||
import { AdminNotifySearchResult } from '../models/admin-notify-message-search-result.model';
|
import { AdminNotifySearchResult } from '../models/admin-notify-message-search-result.model';
|
||||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||||
import { Context } from '../../../core/shared/context.model';
|
import { Context } from '../../../core/shared/context.model';
|
||||||
import { AdminNotifyMessage, QueueStatusMap } from '../models/admin-notify-message.model';
|
import { AdminNotifyMessage } from '../models/admin-notify-message.model';
|
||||||
import {
|
import {
|
||||||
tabulatableObjectsComponent
|
tabulatableObjectsComponent
|
||||||
} from '../../../shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator';
|
} from '../../../shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator';
|
||||||
@@ -32,7 +32,7 @@ import { DatePipe } from '@angular/common';
|
|||||||
})
|
})
|
||||||
export class AdminNotifySearchResultComponent extends TabulatableResultListElementsComponent<PaginatedList<AdminNotifySearchResult>, AdminNotifySearchResult> implements OnInit, OnDestroy{
|
export class AdminNotifySearchResultComponent extends TabulatableResultListElementsComponent<PaginatedList<AdminNotifySearchResult>, AdminNotifySearchResult> implements OnInit, OnDestroy{
|
||||||
public messagesSubject$: BehaviorSubject<AdminNotifyMessage[]> = new BehaviorSubject([]);
|
public messagesSubject$: BehaviorSubject<AdminNotifyMessage[]> = new BehaviorSubject([]);
|
||||||
public reprocessStatus = QueueStatusMap.QUEUE_STATUS_QUEUED_FOR_RETRY;
|
public reprocessStatus = 'QUEUE_STATUS_QUEUED_FOR_RETRY';
|
||||||
//we check on one type of config to render specific table headers
|
//we check on one type of config to render specific table headers
|
||||||
public isInbound: boolean;
|
public isInbound: boolean;
|
||||||
|
|
||||||
|
@@ -6,16 +6,6 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
|||||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||||
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
|
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
export enum QueueStatusMap {
|
|
||||||
QUEUE_STATUS_PROCESSED = 'notify-queue-status.processed',
|
|
||||||
QUEUE_STATUS_FAILED = 'notify-queue-status.processed',
|
|
||||||
QUEUE_STATUS_UNMAPPED_ACTION = 'notify-queue-status.unmapped_action',
|
|
||||||
QUEUE_STATUS_QUEUED_FOR_RETRY = 'notify-queue-status.queue_retry',
|
|
||||||
QUEUE_STATUS_PROCESSING = 'notify-queue-status.processing',
|
|
||||||
QUEUE_STATUS_QUEUED = 'notify-queue-status.queued',
|
|
||||||
QUEUE_STATUS_UNTRUSTED = 'notify-queue-status.untrusted',
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* A message that includes admin notify info
|
* A message that includes admin notify info
|
||||||
*/
|
*/
|
||||||
|
@@ -14,9 +14,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.u
|
|||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { RequestEntryState } from '../../../core/data/request-entry-state.model';
|
import { RequestEntryState } from '../../../core/data/request-entry-state.model';
|
||||||
import {
|
import {
|
||||||
mockAdminNotifyMessages,
|
mockAdminNotifyMessages} from '../admin-notify-search-result/admin-notify-search-result.component.spec';
|
||||||
mockUnformattedAdminNotifyMessages
|
|
||||||
} from '../admin-notify-search-result/admin-notify-search-result.component.spec';
|
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { deepClone } from 'fast-json-patch';
|
import { deepClone } from 'fast-json-patch';
|
||||||
import { AdminNotifyMessage } from '../models/admin-notify-message.model';
|
import { AdminNotifyMessage } from '../models/admin-notify-message.model';
|
||||||
@@ -54,7 +52,7 @@ describe('AdminNotifyMessagesService test', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockMessages = deepClone(mockUnformattedAdminNotifyMessages);
|
mockMessages = deepClone(mockAdminNotifyMessages);
|
||||||
objectCache = {} as ObjectCacheService;
|
objectCache = {} as ObjectCacheService;
|
||||||
notificationsService = {} as NotificationsService;
|
notificationsService = {} as NotificationsService;
|
||||||
responseCacheEntry = new RequestEntry();
|
responseCacheEntry = new RequestEntry();
|
||||||
@@ -96,11 +94,6 @@ describe('AdminNotifyMessagesService test', () => {
|
|||||||
expect(service).toBeDefined();
|
expect(service).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should format message labels', () => {
|
|
||||||
const formattedMessage = service.formatMessageLabels(mockMessages[0]);
|
|
||||||
expect(formattedMessage).toEqual(mockAdminNotifyMessages[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get details for messages', (done) => {
|
it('should get details for messages', (done) => {
|
||||||
service.getDetailedMessages(mockMessages).pipe(take(1)).subscribe((detailedMessages) => {
|
service.getDetailedMessages(mockMessages).pipe(take(1)).subscribe((detailedMessages) => {
|
||||||
expect(detailedMessages[0].ldnService).toEqual(testLdnServiceName);
|
expect(detailedMessages[0].ldnService).toEqual(testLdnServiceName);
|
||||||
|
@@ -8,7 +8,7 @@ import {HALEndpointService} from '../../../core/shared/hal-endpoint.service';
|
|||||||
import {NotificationsService} from '../../../shared/notifications/notifications.service';
|
import {NotificationsService} from '../../../shared/notifications/notifications.service';
|
||||||
import { BehaviorSubject, from, Observable, of, scan } from 'rxjs';
|
import { BehaviorSubject, from, Observable, of, scan } from 'rxjs';
|
||||||
import { ADMIN_NOTIFY_MESSAGE } from '../models/admin-notify-message.resource-type';
|
import { ADMIN_NOTIFY_MESSAGE } from '../models/admin-notify-message.resource-type';
|
||||||
import { AdminNotifyMessage, QueueStatusMap } from '../models/admin-notify-message.model';
|
import { AdminNotifyMessage } from '../models/admin-notify-message.model';
|
||||||
import { map, mergeMap, switchMap, tap } from 'rxjs/operators';
|
import { map, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||||
import { getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
import { LdnServicesService } from '../../admin-ldn-services/ldn-services-data/ldn-services-data.service';
|
import { LdnServicesService } from '../../admin-ldn-services/ldn-services-data/ldn-services-data.service';
|
||||||
@@ -41,21 +41,13 @@ export class AdminNotifyMessagesService extends IdentifiableDataService<AdminNot
|
|||||||
super('messages', requestService, rdbService, objectCache, halService);
|
super('messages', requestService, rdbService, objectCache, halService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map labels to readable info for user
|
|
||||||
* @param message the message to which map the labels
|
|
||||||
*/
|
|
||||||
public formatMessageLabels(message: AdminNotifyMessage): AdminNotifyMessage {
|
|
||||||
message.queueStatusLabel = QueueStatusMap[message.queueStatusLabel];
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add detailed information to each message
|
* Add detailed information to each message
|
||||||
* @param messages the messages to which add detailded info
|
* @param messages the messages to which add detailded info
|
||||||
*/
|
*/
|
||||||
public getDetailedMessages(messages: AdminNotifyMessage[]): Observable<AdminNotifyMessage[]> {
|
public getDetailedMessages(messages: AdminNotifyMessage[]): Observable<AdminNotifyMessage[]> {
|
||||||
return from(messages.map(message => this.formatMessageLabels(message))).pipe(
|
return from(messages).pipe(
|
||||||
mergeMap(message =>
|
mergeMap(message =>
|
||||||
message.target || message.origin ? this.ldnServicesService.findById((message.target || message.origin).toString()).pipe(
|
message.target || message.origin ? this.ldnServicesService.findById((message.target || message.origin).toString()).pipe(
|
||||||
getAllSucceededRemoteDataPayload(),
|
getAllSucceededRemoteDataPayload(),
|
||||||
@@ -88,7 +80,6 @@ export class AdminNotifyMessagesService extends IdentifiableDataService<AdminNot
|
|||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
getAllSucceededRemoteDataPayload(),
|
getAllSucceededRemoteDataPayload(),
|
||||||
).pipe(
|
).pipe(
|
||||||
map(reprocessedMessage => this.formatMessageLabels(reprocessedMessage)),
|
|
||||||
mergeMap((newMessage) => messageSubject.pipe(
|
mergeMap((newMessage) => messageSubject.pipe(
|
||||||
map(messages => {
|
map(messages => {
|
||||||
const messageToUpdate = messages.find(currentMessage => currentMessage.id === message.id);
|
const messageToUpdate = messages.find(currentMessage => currentMessage.id === message.id);
|
||||||
|
@@ -3519,7 +3519,51 @@
|
|||||||
|
|
||||||
"search.filters.filter.coar_notify_type.placeholder": "COAR notify type",
|
"search.filters.filter.coar_notify_type.placeholder": "COAR notify type",
|
||||||
|
|
||||||
"search.filters.filter.notification_type.placeholder": "Notification type",
|
"search.filters.filter.notification_type.placeholder": "Notification",
|
||||||
|
|
||||||
|
"search.filters.coar_notify_type.coar-notify:ReviewAction": "Review action",
|
||||||
|
|
||||||
|
"notify-detail-modal.coar-notify:ReviewAction": "Review action",
|
||||||
|
|
||||||
|
"search.filters.coar_notify_type.coar-notify:EndorsementAction": "Endorsement action",
|
||||||
|
|
||||||
|
"notify-detail-modal.coar-notify:EndorsementAction": "Endorsement action",
|
||||||
|
|
||||||
|
"search.filters.coar_notify_type.coar-notify:IngestAction": "Ingest action",
|
||||||
|
|
||||||
|
"notify-detail-modal.coar-notify:IngestAction": "Ingest action",
|
||||||
|
|
||||||
|
"search.filters.coar_notify_type.coar-notify:RelationshipAction": "Relationship action",
|
||||||
|
|
||||||
|
"notify-detail-modal.coar-notify:RelationshipAction": "Relationship action",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_QUEUED": "Queued",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_QUEUED": "Queued",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_QUEUED_FOR_RETRY": "Queued for retry",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_QUEUED_FOR_RETRY": "Queued for retry",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_PROCESSING": "Processing",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_PROCESSING": "Processing",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_PROCESSED": "Processed",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_PROCESSED": "Processed",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_FAILED": "Failed",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_FAILED": "Failed",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_UNTRUSTED": "Untrusted",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_UNTRUSTED": "Untrusted",
|
||||||
|
|
||||||
|
"search.filters.queue_status.QUEUE_STATUS_UNMAPPED_ACTION": "Unmapped Action",
|
||||||
|
|
||||||
|
"notify-detail-modal.QUEUE_STATUS_UNMAPPED_ACTION": "Unmapped Action",
|
||||||
|
|
||||||
"sorting.queue_last_start_time.DESC": "Last started queue Descending",
|
"sorting.queue_last_start_time.DESC": "Last started queue Descending",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user