mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
refactor, add date formatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, DatePipe } from '@angular/common';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component';
|
import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component';
|
||||||
import { AdminNotifyDashboardRoutingModule } from './admin-notify-dashboard-routing.module';
|
import { AdminNotifyDashboardRoutingModule } from './admin-notify-dashboard-routing.module';
|
||||||
@@ -28,7 +28,8 @@ import { AdminNotifyMessagesService } from './services/admin-notify-messages.ser
|
|||||||
SearchPageModule,
|
SearchPageModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AdminNotifyMessagesService
|
AdminNotifyMessagesService,
|
||||||
|
DatePipe
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AdminNotifyDashboardComponent,
|
AdminNotifyDashboardComponent,
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
<div class="modal-body p-4">
|
<div class="modal-body p-4">
|
||||||
<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-sm">{{ key + '.notify-detail-modal' | translate}}</div>
|
<div class="font-weight-bold col">{{ key + '.notify-detail-modal' | translate}}</div>
|
||||||
<div class="text-truncate col-sm text-right">{{ notifyMessage[key] | translate }}</div>
|
<div class="col text-right">{{ notifyMessage[key] | translate }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -12,8 +12,8 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let message of (messagesSubject$ | async)">
|
<tr *ngFor="let message of (messagesSubject$ | async)">
|
||||||
<td>
|
<td class="text-nowrap">
|
||||||
<div>{{ message.queueLastStartTime }}</div>
|
<div>{{ message.queueLastStartTime | date:"YYYY/MM/d hh:mm:ss" }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a [routerLink]="'/items/' + (isInbound ? message.context : message.object)">{{ message.relatedItem }}</a>
|
<a [routerLink]="'/items/' + (isInbound ? message.context : message.object)">{{ message.relatedItem }}</a>
|
||||||
|
@@ -18,6 +18,7 @@ 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';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component';
|
||||||
|
import { DatePipe } from "@angular/common";
|
||||||
|
|
||||||
|
|
||||||
export const mockAdminNotifyMessages = [
|
export const mockAdminNotifyMessages = [
|
||||||
@@ -136,6 +137,7 @@ describe('AdminNotifySearchResultComponent', () => {
|
|||||||
{ provide: RequestService, useValue: requestService },
|
{ provide: RequestService, useValue: requestService },
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbService },
|
{ provide: RemoteDataBuildService, useValue: rdbService },
|
||||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: searchConfigService },
|
{ provide: SEARCH_CONFIG_SERVICE, useValue: searchConfigService },
|
||||||
|
DatePipe
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
@@ -16,6 +16,7 @@ import { BehaviorSubject, Subscription } from 'rxjs';
|
|||||||
import { AdminNotifyMessagesService } from '../services/admin-notify-messages.service';
|
import { AdminNotifyMessagesService } from '../services/admin-notify-messages.service';
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component';
|
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component';
|
||||||
|
import { DatePipe } from "@angular/common";
|
||||||
|
|
||||||
@tabulatableObjectsComponent(PaginatedList<AdminNotifySearchResult>, ViewMode.Table, Context.CoarNotify)
|
@tabulatableObjectsComponent(PaginatedList<AdminNotifySearchResult>, ViewMode.Table, Context.CoarNotify)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -42,8 +43,22 @@ export class AdminNotifySearchResultComponent extends TabulatableResultListEleme
|
|||||||
*/
|
*/
|
||||||
private subs: Subscription[] = [];
|
private subs: Subscription[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys to be formatted as date
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
private dateTypeKeys: string[] = ['queueLastStartTime', 'queueTimeout']
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format for the date values
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
private dateFormat: string = 'YYYY/MM/d hh:mm:ss'
|
||||||
|
|
||||||
constructor(private modalService: NgbModal,
|
constructor(private modalService: NgbModal,
|
||||||
private adminNotifyMessagesService: AdminNotifyMessagesService,
|
private adminNotifyMessagesService: AdminNotifyMessagesService,
|
||||||
|
private datePipe: DatePipe,
|
||||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
|
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -72,13 +87,10 @@ export class AdminNotifySearchResultComponent extends TabulatableResultListEleme
|
|||||||
const modalRef = this.modalService.open(AdminNotifyDetailModalComponent);
|
const modalRef = this.modalService.open(AdminNotifyDetailModalComponent);
|
||||||
const messageToOpen = {...message};
|
const messageToOpen = {...message};
|
||||||
// we delete not necessary or not readable keys
|
// we delete not necessary or not readable keys
|
||||||
if (this.isInbound) {
|
delete messageToOpen.target;
|
||||||
delete messageToOpen.target;
|
delete messageToOpen.object;
|
||||||
delete messageToOpen.object;
|
delete messageToOpen.context;
|
||||||
} else {
|
delete messageToOpen.origin;
|
||||||
delete messageToOpen.context;
|
|
||||||
delete messageToOpen.origin;
|
|
||||||
}
|
|
||||||
delete messageToOpen._links;
|
delete messageToOpen._links;
|
||||||
delete messageToOpen.metadata;
|
delete messageToOpen.metadata;
|
||||||
delete messageToOpen.thumbnail;
|
delete messageToOpen.thumbnail;
|
||||||
@@ -87,6 +99,12 @@ export class AdminNotifySearchResultComponent extends TabulatableResultListEleme
|
|||||||
delete messageToOpen.queueStatus;
|
delete messageToOpen.queueStatus;
|
||||||
|
|
||||||
const messageKeys = Object.keys(messageToOpen);
|
const messageKeys = Object.keys(messageToOpen);
|
||||||
|
messageKeys.forEach(key => {
|
||||||
|
if(this.dateTypeKeys.includes(key)) {
|
||||||
|
messageToOpen[key] = this.datePipe.transform(messageToOpen[key], this.dateFormat);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
modalRef.componentInstance.notifyMessage = messageToOpen;
|
modalRef.componentInstance.notifyMessage = messageToOpen;
|
||||||
modalRef.componentInstance.notifyMessageKeys = messageKeys;
|
modalRef.componentInstance.notifyMessageKeys = messageKeys;
|
||||||
}
|
}
|
||||||
|
@@ -3587,6 +3587,10 @@
|
|||||||
|
|
||||||
"notify-queue-status.untrusted": "Untrusted",
|
"notify-queue-status.untrusted": "Untrusted",
|
||||||
|
|
||||||
|
"ldnService.notify-detail-modal": "LDN Service",
|
||||||
|
|
||||||
|
"relatedItem.notify-detail-modal": "Related Item",
|
||||||
|
|
||||||
"orgunit.listelement.badge": "Repository Item",
|
"orgunit.listelement.badge": "Repository Item",
|
||||||
|
|
||||||
"orgunit.listelement.no-title": "Untitled",
|
"orgunit.listelement.no-title": "Untitled",
|
||||||
|
Reference in New Issue
Block a user