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