mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
111638: Sort processes with creationTime as default field
This commit is contained in:
@@ -15,10 +15,12 @@
|
||||
[getInfoValueMethod]="processOverviewService.timeCreated"/>
|
||||
<ds-process-overview-table
|
||||
[processStatus]="ProcessStatus.COMPLETED"
|
||||
[sortField]="ProcessSortField.endTime"
|
||||
[useAutoRefreshingSearchBy]="true"
|
||||
[getInfoValueMethod]="processOverviewService.timeCompleted"/>
|
||||
<ds-process-overview-table
|
||||
[processStatus]="ProcessStatus.FAILED"
|
||||
[sortField]="ProcessSortField.endTime"
|
||||
[useAutoRefreshingSearchBy]="true"
|
||||
[getInfoValueMethod]="processOverviewService.timeCompleted"/>
|
||||
</div>
|
||||
|
@@ -13,7 +13,7 @@ import { ProcessBulkDeleteService } from './process-bulk-delete.service';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||
import { ProcessOverviewService } from './process-overview.service';
|
||||
import { ProcessOverviewService, ProcessSortField } from './process-overview.service';
|
||||
import { ProcessStatus } from '../processes/process-status.model';
|
||||
|
||||
@Component({
|
||||
@@ -25,7 +25,9 @@ import { ProcessStatus } from '../processes/process-status.model';
|
||||
*/
|
||||
export class ProcessOverviewComponent implements OnInit, OnDestroy {
|
||||
|
||||
// Enums are redeclared here so they can be used in the template
|
||||
protected readonly ProcessStatus = ProcessStatus;
|
||||
protected readonly ProcessSortField = ProcessSortField;
|
||||
|
||||
/**
|
||||
* List of all processes
|
||||
|
@@ -9,6 +9,18 @@ import { RequestParam } from '../../core/cache/models/request-param.model';
|
||||
import { ProcessStatus } from '../processes/process-status.model';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { SortOptions, SortDirection } from '../../core/cache/models/sort-options.model';
|
||||
|
||||
/**
|
||||
* The sortable fields for processes
|
||||
* See [the endpoint documentation]{@link https://github.com/DSpace/RestContract/blob/main/processes-endpoint.md#search-processes-by-property}
|
||||
* for details.
|
||||
*/
|
||||
export enum ProcessSortField {
|
||||
creationTime = 'creationTime',
|
||||
startTime = 'startTime',
|
||||
endTime = 'endTime',
|
||||
}
|
||||
|
||||
/**
|
||||
* Service to manage the processes displayed in the
|
||||
@@ -58,13 +70,16 @@ export class ProcessOverviewService {
|
||||
/**
|
||||
* Map the provided paginationOptions to FindListOptions
|
||||
* @param paginationOptions the PaginationComponentOptions to map
|
||||
* @param sortField the field on which the processes are sorted
|
||||
*/
|
||||
getFindListOptions(paginationOptions: PaginationComponentOptions): FindListOptions {
|
||||
getFindListOptions(paginationOptions: PaginationComponentOptions, sortField: ProcessSortField): FindListOptions {
|
||||
let sortOptions = new SortOptions(sortField, SortDirection.DESC);
|
||||
return Object.assign(
|
||||
new FindListOptions(),
|
||||
{
|
||||
currentPage: paginationOptions.currentPage,
|
||||
elementsPerPage: paginationOptions.pageSize,
|
||||
sort: sortOptions,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||
import { Process } from '../../processes/process.model';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { ProcessOverviewService } from '../process-overview.service';
|
||||
import { ProcessOverviewService, ProcessSortField } from '../process-overview.service';
|
||||
import { ProcessBulkDeleteService } from '../process-bulk-delete.service';
|
||||
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||
@@ -40,6 +40,13 @@ export class ProcessOverviewTableComponent implements OnInit {
|
||||
*/
|
||||
@Input() processStatus: ProcessStatus;
|
||||
|
||||
/**
|
||||
* The field on which the processes in this table are sorted
|
||||
* {@link ProcessSortField.creationTime} by default as every single process has a creation time,
|
||||
* but not every process has a start or end time
|
||||
*/
|
||||
@Input() sortField: ProcessSortField = ProcessSortField.creationTime;
|
||||
|
||||
/**
|
||||
* Whether to use auto refresh for the processes shown in this table.
|
||||
*/
|
||||
@@ -118,7 +125,7 @@ export class ProcessOverviewTableComponent implements OnInit {
|
||||
.pipe(
|
||||
// Map the paginationOptions to findListOptions
|
||||
map((paginationOptions: PaginationComponentOptions) =>
|
||||
this.processOverviewService.getFindListOptions(paginationOptions)),
|
||||
this.processOverviewService.getFindListOptions(paginationOptions, this.sortField)),
|
||||
// Use the findListOptions to retrieve the relevant processes every interval
|
||||
switchMap((findListOptions: FindListOptions) =>
|
||||
this.processOverviewService.getProcessesByProcessStatus(
|
||||
|
Reference in New Issue
Block a user