mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 14:33:03 +00:00
fixed relative/absolute paths
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { DataService } from "./data.service";
|
||||
import { Collection } from "../shared/collection.model";
|
||||
import { ObjectCacheService } from "../cache/object-cache.service";
|
||||
@@ -8,6 +8,7 @@ import { NormalizedCollection } from "../cache/models/normalized-collection.mode
|
||||
import { CoreState } from "../core.reducers";
|
||||
import { RequestService } from "./request.service";
|
||||
import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service";
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from "../../../config";
|
||||
|
||||
@Injectable()
|
||||
export class CollectionDataService extends DataService<NormalizedCollection, Collection> {
|
||||
@@ -18,9 +19,10 @@ export class CollectionDataService extends DataService<NormalizedCollection, Col
|
||||
protected responseCache: ResponseCacheService,
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected store: Store<CoreState>
|
||||
protected store: Store<CoreState>,
|
||||
@Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig
|
||||
) {
|
||||
super(NormalizedCollection);
|
||||
super(NormalizedCollection, EnvConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { DataService } from "./data.service";
|
||||
import { Community } from "../shared/community.model";
|
||||
import { ObjectCacheService } from "../cache/object-cache.service";
|
||||
@@ -8,6 +8,7 @@ import { NormalizedCommunity } from "../cache/models/normalized-community.model"
|
||||
import { CoreState } from "../core.reducers";
|
||||
import { RequestService } from "./request.service";
|
||||
import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service";
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from "../../../config";
|
||||
|
||||
@Injectable()
|
||||
export class CommunityDataService extends DataService<NormalizedCommunity, Community> {
|
||||
@@ -18,9 +19,10 @@ export class CommunityDataService extends DataService<NormalizedCommunity, Commu
|
||||
protected responseCache: ResponseCacheService,
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected store: Store<CoreState>
|
||||
protected store: Store<CoreState>,
|
||||
@Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig
|
||||
) {
|
||||
super(NormalizedCommunity);
|
||||
super(NormalizedCommunity, EnvConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,9 @@ import { CoreState } from "../core.reducers";
|
||||
import { RequestService } from "./request.service";
|
||||
import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service";
|
||||
import { GenericConstructor } from "../shared/generic-constructor";
|
||||
import { Inject } from "@angular/core";
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from "../../../config";
|
||||
import { RESTURLCombiner } from "../url-combiner/rest-url-combiner";
|
||||
|
||||
export abstract class DataService<TNormalized extends CacheableObject, TDomain> {
|
||||
protected abstract objectCache: ObjectCacheService;
|
||||
@@ -19,7 +22,10 @@ export abstract class DataService<TNormalized extends CacheableObject, TDomain>
|
||||
protected abstract store: Store<CoreState>;
|
||||
protected abstract endpoint: string;
|
||||
|
||||
constructor(private normalizedResourceType: GenericConstructor<TNormalized>) {
|
||||
constructor(
|
||||
private normalizedResourceType: GenericConstructor<TNormalized>,
|
||||
protected EnvConfig: GlobalConfig
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +34,7 @@ export abstract class DataService<TNormalized extends CacheableObject, TDomain>
|
||||
if (hasValue(scopeID)) {
|
||||
result += `?scope=${scopeID}`
|
||||
}
|
||||
return result;
|
||||
return new RESTURLCombiner(this.EnvConfig, result).toString();
|
||||
}
|
||||
|
||||
findAll(scopeID?: string): RemoteData<Array<TDomain>> {
|
||||
@@ -40,7 +46,7 @@ export abstract class DataService<TNormalized extends CacheableObject, TDomain>
|
||||
}
|
||||
|
||||
protected getFindByIDHref(resourceID): string {
|
||||
return `${this.endpoint}/${resourceID}`;
|
||||
return new RESTURLCombiner(this.EnvConfig, `${this.endpoint}/${resourceID}`).toString();
|
||||
}
|
||||
|
||||
findById(id: string): RemoteData<TDomain> {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { DataService } from "./data.service";
|
||||
import { Item } from "../shared/item.model";
|
||||
import { ObjectCacheService } from "../cache/object-cache.service";
|
||||
@@ -8,6 +8,7 @@ import { CoreState } from "../core.reducers";
|
||||
import { NormalizedItem } from "../cache/models/normalized-item.model";
|
||||
import { RequestService } from "./request.service";
|
||||
import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service";
|
||||
import { GLOBAL_CONFIG, GlobalConfig } from "../../../config";
|
||||
|
||||
@Injectable()
|
||||
export class ItemDataService extends DataService<NormalizedItem, Item> {
|
||||
@@ -18,8 +19,9 @@ export class ItemDataService extends DataService<NormalizedItem, Item> {
|
||||
protected responseCache: ResponseCacheService,
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected store: Store<CoreState>
|
||||
protected store: Store<CoreState>,
|
||||
@Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig
|
||||
) {
|
||||
super(NormalizedItem);
|
||||
super(NormalizedItem, EnvConfig);
|
||||
}
|
||||
}
|
||||
|
@@ -18,15 +18,15 @@ export class DSpaceRESTv2Service {
|
||||
/**
|
||||
* Performs a request to the REST API with the `get` http method.
|
||||
*
|
||||
* @param relativeURL
|
||||
* A URL, relative to the basepath of the rest api
|
||||
* @param absoluteURL
|
||||
* A URL
|
||||
* @param options
|
||||
* A RequestOptionsArgs object, with options for the http call.
|
||||
* @return {Observable<string>}
|
||||
* An Observablse<string> containing the response from the server
|
||||
*/
|
||||
get(relativeURL: string, options?: RequestOptionsArgs): Observable<DSpaceRESTV2Response> {
|
||||
return this.http.get(new RESTURLCombiner(this.EnvConfig, relativeURL).toString(), options)
|
||||
get(absoluteURL: string, options?: RequestOptionsArgs): Observable<DSpaceRESTV2Response> {
|
||||
return this.http.get(absoluteURL, options)
|
||||
.map(res => ({ payload: res.json(), statusCode: res.statusText }))
|
||||
.catch(err => {
|
||||
console.log('Error: ', err);
|
||||
|
Reference in New Issue
Block a user