mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
[TLC-380] WIP trying new routing / create flow
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
@@ -16,9 +16,18 @@ import { Item } from '../shared/item.model';
|
|||||||
import { IDENTIFIERS } from '../../shared/object-list/identifier-data/identifier-data.resource-type';
|
import { IDENTIFIERS } from '../../shared/object-list/identifier-data/identifier-data.resource-type';
|
||||||
import { IdentifierData } from '../../shared/object-list/identifier-data/identifier-data.model';
|
import { IdentifierData } from '../../shared/object-list/identifier-data/identifier-data.model';
|
||||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||||
import { map } from 'rxjs/operators';
|
import { find, map, switchMap } from 'rxjs/operators';
|
||||||
import {ConfigurationProperty} from '../shared/configuration-property.model';
|
import {ConfigurationProperty} from '../shared/configuration-property.model';
|
||||||
import {ConfigurationDataService} from './configuration-data.service';
|
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
|
* The service handling all REST requests to get item identifiers like handles and DOIs
|
||||||
@@ -60,4 +69,35 @@ export class IdentifierDataService extends BaseDataService<IdentifierData> {
|
|||||||
map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : [])
|
map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : [])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public registerIdentifier(item: Item, type: string): Observable<RemoteData<any>> {
|
||||||
|
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');
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -233,7 +233,7 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the endpoint for an item's bundles
|
* Get the endpoint for an item's identifiers
|
||||||
* @param itemId
|
* @param itemId
|
||||||
*/
|
*/
|
||||||
public getIdentifiersEndpoint(itemId: string): Observable<string> {
|
public getIdentifiersEndpoint(itemId: string): Observable<string> {
|
||||||
@@ -264,6 +264,10 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
|
|||||||
return this.rdbService.buildFromRequestUUID(requestId);
|
return this.rdbService.buildFromRequestUUID(requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the endpoint to move the item
|
* Get the endpoint to move the item
|
||||||
* @param itemId
|
* @param itemId
|
||||||
|
@@ -82,13 +82,13 @@ export class ItemRegisterDoiComponent extends AbstractSimpleItemActionComponent
|
|||||||
*/
|
*/
|
||||||
registerDoi() {
|
registerDoi() {
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
this.itemDataService.registerDOI(this.item.id).pipe(getFirstCompletedRemoteData()).subscribe(
|
this.identifierDataService.registerIdentifier(this.item, 'doi').subscribe(
|
||||||
(response: RemoteData<Item>) => {
|
(response: RemoteData<Item>) => {
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
//this.router.navigateByUrl(getItemEditRoute(this.item));
|
//this.router.navigateByUrl(getItemEditRoute(this.item));
|
||||||
this.processRestResponse(response);
|
this.processRestResponse(response);
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user