mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
[TLC-380] Refactor to use new endpoints, better naming
This commit is contained in:
@@ -16,18 +16,13 @@ import { Item } from '../shared/item.model';
|
||||
import { IDENTIFIERS } from '../../shared/object-list/identifier-data/identifier-data.resource-type';
|
||||
import { IdentifierData } from '../../shared/object-list/identifier-data/identifier-data.model';
|
||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||
import { find, map, switchMap } from 'rxjs/operators';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import {ConfigurationProperty} from '../shared/configuration-property.model';
|
||||
import {ConfigurationDataService} from './configuration-data.service';
|
||||
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
import { PostRequest } from './request.models';
|
||||
import { GenericConstructor } from '../shared/generic-constructor';
|
||||
import { ResponseParsingService } from './parsing.service';
|
||||
import { StatusCodeOnlyResponseParsingService } from './status-code-only-response-parsing.service';
|
||||
import { sendRequest } from '../shared/request.operators';
|
||||
import { RestRequest } from './rest-request.model';
|
||||
import { OrcidHistory } from '../orcid/model/orcid-history.model';
|
||||
|
||||
/**
|
||||
* The service handling all REST requests to get item identifiers like handles and DOIs
|
||||
@@ -71,33 +66,20 @@ export class IdentifierDataService extends BaseDataService<IdentifierData> {
|
||||
}
|
||||
|
||||
public registerIdentifier(item: Item, type: string): Observable<RemoteData<any>> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
return this.getEndpoint().pipe(
|
||||
map((endpointURL: string) => {
|
||||
const options: HttpOptions = Object.create({});
|
||||
let headers = new HttpHeaders();
|
||||
headers = headers.append('Content-Type', 'text/uri-list');
|
||||
options.headers = headers;
|
||||
let params = new HttpParams();
|
||||
params = params.append('type', 'doi');
|
||||
params = params.append('type', type);
|
||||
options.params = params;
|
||||
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
const hrefObs = this.getEndpoint();
|
||||
|
||||
hrefObs.pipe(
|
||||
find((href: string) => hasValue(href)),
|
||||
map((href: string) => {
|
||||
|
||||
const request = new PostRequest(requestId, href, item._links.self.href, options);
|
||||
Object.assign(request, {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return StatusCodeOnlyResponseParsingService;
|
||||
}
|
||||
});
|
||||
return request;
|
||||
})
|
||||
).subscribe((request) => {
|
||||
this.requestService.send(request);
|
||||
});
|
||||
|
||||
return this.rdbService.buildFromRequestUUID(requestId);
|
||||
return new PostRequest(requestId, endpointURL, item._links.self.href, options);
|
||||
}),
|
||||
sendRequest(this.requestService),
|
||||
switchMap((request: RestRequest) => this.rdbService.buildFromRequestUUID(request.uuid) as Observable<RemoteData<any>>)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -5,4 +5,4 @@ export const ITEM_EDIT_PUBLIC_PATH = 'public';
|
||||
export const ITEM_EDIT_DELETE_PATH = 'delete';
|
||||
export const ITEM_EDIT_MOVE_PATH = 'move';
|
||||
export const ITEM_EDIT_AUTHORIZATIONS_PATH = 'authorizations';
|
||||
export const ITEM_EDIT_REGISTER_DOI_PATH = 'registerdoi';
|
||||
export const ITEM_EDIT_REGISTER_DOI_PATH = 'register-doi';
|
||||
|
@@ -7,7 +7,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { getFirstSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -20,11 +20,11 @@ import { Identifier } from '../../../shared/object-list/identifier-data/identifi
|
||||
templateUrl: './item-register-doi-component.html'
|
||||
})
|
||||
/**
|
||||
* Component responsible for rendering the Item Registe DOI page
|
||||
* Component responsible for rendering the Item Register DOI page
|
||||
*/
|
||||
export class ItemRegisterDoiComponent extends AbstractSimpleItemActionComponent {
|
||||
|
||||
protected messageKey = 'registerdoi';
|
||||
protected messageKey = 'register-doi';
|
||||
doiToUpdateMessage = 'item.edit.' + this.messageKey + '.to-update';
|
||||
identifiers$: Observable<Identifier[]>;
|
||||
processing = false;
|
||||
@@ -84,10 +84,11 @@ export class ItemRegisterDoiComponent extends AbstractSimpleItemActionComponent
|
||||
this.processing = true;
|
||||
this.identifierDataService.registerIdentifier(this.item, 'doi').subscribe(
|
||||
(response: RemoteData<Item>) => {
|
||||
if (response.hasCompleted) {
|
||||
this.processing = false;
|
||||
//this.router.navigateByUrl(getItemEditRoute(this.item));
|
||||
this.processRestResponse(response);
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -179,7 +179,7 @@ export class ItemStatusComponent implements OnInit {
|
||||
let tmp_operations = [...operations];
|
||||
if (show) {
|
||||
// Push the new Register DOI item operation
|
||||
tmp_operations.push(new ItemOperation('registerDOI', this.getCurrentUrl(item) + '/registerdoi', FeatureID.CanRegisterDOI));
|
||||
tmp_operations.push(new ItemOperation('register-doi', this.getCurrentUrl(item) + '/register-doi', FeatureID.CanRegisterDOI));
|
||||
}
|
||||
// Check authorisations and merge into new operations list
|
||||
observableFrom(tmp_operations).pipe(
|
||||
|
@@ -1942,7 +1942,7 @@
|
||||
|
||||
"item.edit.identifiers.doi.status.MINTED": "Minted (not registered)",
|
||||
|
||||
"item.edit.tabs.status.buttons.register-doi.label": "Register a new or pending identifier",
|
||||
"item.edit.tabs.status.buttons.register-doi.label": "Register a new or pending DOI",
|
||||
|
||||
"item.edit.tabs.status.buttons.register-doi.button": "Register DOI...",
|
||||
|
||||
@@ -1954,7 +1954,7 @@
|
||||
|
||||
"item.edit.register-doi.cancel": "Cancel",
|
||||
|
||||
"item.edit.register-doi.success": "DOI registered successfully. Refresh Item Status page to see new DOI details.",
|
||||
"item.edit.register-doi.success": "DOI queued for registration successfully.",
|
||||
|
||||
"item.edit.register-doi.error": "Error registering DOI",
|
||||
|
||||
|
Reference in New Issue
Block a user