mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 21:13:07 +00:00
54472: Notification errors
This commit is contained in:
@@ -27,7 +27,8 @@ export class CollectionDataService extends ComColDataService<NormalizedCollectio
|
|||||||
protected cds: CommunityDataService,
|
protected cds: CommunityDataService,
|
||||||
protected objectCache: ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected authService: AuthService
|
protected authService: AuthService,
|
||||||
|
protected notificationsService: NotificationsService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,7 @@ class TestService extends ComColDataService<NormalizedTestObject, any> {
|
|||||||
protected objectCache: ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected authService: AuthService,
|
protected authService: AuthService,
|
||||||
|
protected notificationsService: NotificationsService,
|
||||||
protected linkPath: string
|
protected linkPath: string
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
@@ -16,6 +16,7 @@ import { RemoteData } from './remote-data';
|
|||||||
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { PaginatedList } from './paginated-list';
|
import { PaginatedList } from './paginated-list';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CommunityDataService extends ComColDataService<NormalizedCommunity, Community> {
|
export class CommunityDataService extends ComColDataService<NormalizedCommunity, Community> {
|
||||||
@@ -30,7 +31,8 @@ export class CommunityDataService extends ComColDataService<NormalizedCommunity,
|
|||||||
protected store: Store<CoreState>,
|
protected store: Store<CoreState>,
|
||||||
protected objectCache: ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected authService: AuthService
|
protected authService: AuthService,
|
||||||
|
protected notificationsService: NotificationsService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
|
|||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { FindAllOptions } from './request.models';
|
import { FindAllOptions } from './request.models';
|
||||||
import { SortOptions, SortDirection } from '../cache/models/sort-options.model';
|
import { SortOptions, SortDirection } from '../cache/models/sort-options.model';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
|
||||||
const LINK_NAME = 'test'
|
const LINK_NAME = 'test'
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ class TestService extends DataService<NormalizedTestObject, any> {
|
|||||||
protected rdbService: RemoteDataBuildService,
|
protected rdbService: RemoteDataBuildService,
|
||||||
protected store: Store<CoreState>,
|
protected store: Store<CoreState>,
|
||||||
protected linkPath: string,
|
protected linkPath: string,
|
||||||
protected halService: HALEndpointService
|
protected halService: HALEndpointService,
|
||||||
|
protected notificationsService: NotificationsService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -41,6 +43,7 @@ describe('DataService', () => {
|
|||||||
const requestService = {} as RequestService;
|
const requestService = {} as RequestService;
|
||||||
const halService = {} as HALEndpointService;
|
const halService = {} as HALEndpointService;
|
||||||
const rdbService = {} as RemoteDataBuildService;
|
const rdbService = {} as RemoteDataBuildService;
|
||||||
|
const notificationsService = {} as NotificationsService;
|
||||||
const store = {} as Store<CoreState>;
|
const store = {} as Store<CoreState>;
|
||||||
const endpoint = 'https://rest.api/core';
|
const endpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
@@ -51,7 +54,8 @@ describe('DataService', () => {
|
|||||||
rdbService,
|
rdbService,
|
||||||
store,
|
store,
|
||||||
LINK_NAME,
|
LINK_NAME,
|
||||||
halService
|
halService,
|
||||||
|
notificationsService
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,10 +28,12 @@ import {
|
|||||||
import { ResponseCacheEntry } from '../cache/response-cache.reducer';
|
import { ResponseCacheEntry } from '../cache/response-cache.reducer';
|
||||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
import { DSOSuccessResponse, GenericSuccessResponse } from '../cache/response-cache.models';
|
import { DSOSuccessResponse, ErrorResponse, GenericSuccessResponse } from '../cache/response-cache.models';
|
||||||
import { AuthService } from '../auth/auth.service';
|
import { AuthService } from '../auth/auth.service';
|
||||||
import { Collection } from '../shared/collection.model';
|
import { Collection } from '../shared/collection.model';
|
||||||
import { Community } from '../shared/community.model';
|
import { Community } from '../shared/community.model';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { NotificationOptions } from '../../shared/notifications/models/notification-options.model';
|
||||||
|
|
||||||
export abstract class DataService<TNormalized extends NormalizedObject, TDomain> {
|
export abstract class DataService<TNormalized extends NormalizedObject, TDomain> {
|
||||||
protected abstract responseCache: ResponseCacheService;
|
protected abstract responseCache: ResponseCacheService;
|
||||||
@@ -41,6 +43,7 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
|||||||
protected abstract linkPath: string;
|
protected abstract linkPath: string;
|
||||||
protected abstract halService: HALEndpointService;
|
protected abstract halService: HALEndpointService;
|
||||||
protected abstract authService: AuthService;
|
protected abstract authService: AuthService;
|
||||||
|
protected abstract notificationsService: NotificationsService;
|
||||||
|
|
||||||
public abstract getScopedEndpoint(scope: string): Observable<string>
|
public abstract getScopedEndpoint(scope: string): Observable<string>
|
||||||
|
|
||||||
@@ -140,6 +143,13 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
|||||||
const payload$ = request$.pipe(
|
const payload$ = request$.pipe(
|
||||||
map((request: RestRequest) => request.href),
|
map((request: RestRequest) => request.href),
|
||||||
getResponseFromSelflink(this.responseCache),
|
getResponseFromSelflink(this.responseCache),
|
||||||
|
map((response: ResponseCacheEntry) => {
|
||||||
|
if (!response.response.isSuccessful && response.response instanceof ErrorResponse) {
|
||||||
|
const errorResponse: ErrorResponse = response.response;
|
||||||
|
this.notificationsService.error('Server Error:', errorResponse.errorMessage, new NotificationOptions(-1));
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}),
|
||||||
filterSuccessfulResponses(),
|
filterSuccessfulResponses(),
|
||||||
map((entry: ResponseCacheEntry) => entry.response),
|
map((entry: ResponseCacheEntry) => entry.response),
|
||||||
map((response: GenericSuccessResponse<TDomain>) => response.payload),
|
map((response: GenericSuccessResponse<TDomain>) => response.payload),
|
||||||
|
@@ -11,6 +11,7 @@ import { DataService } from './data.service';
|
|||||||
import { RemoteData } from './remote-data';
|
import { RemoteData } from './remote-data';
|
||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import { AuthService } from '../auth/auth.service';
|
import { AuthService } from '../auth/auth.service';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
|
||||||
/* tslint:disable:max-classes-per-file */
|
/* tslint:disable:max-classes-per-file */
|
||||||
class DataServiceImpl extends DataService<NormalizedDSpaceObject, DSpaceObject> {
|
class DataServiceImpl extends DataService<NormalizedDSpaceObject, DSpaceObject> {
|
||||||
@@ -22,7 +23,8 @@ class DataServiceImpl extends DataService<NormalizedDSpaceObject, DSpaceObject>
|
|||||||
protected rdbService: RemoteDataBuildService,
|
protected rdbService: RemoteDataBuildService,
|
||||||
protected store: Store<CoreState>,
|
protected store: Store<CoreState>,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected authService: AuthService) {
|
protected authService: AuthService,
|
||||||
|
protected notificationsService: NotificationsService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +50,9 @@ export class DSpaceObjectDataService {
|
|||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
protected rdbService: RemoteDataBuildService,
|
protected rdbService: RemoteDataBuildService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected authService: AuthService) {
|
protected authService: AuthService,
|
||||||
this.dataService = new DataServiceImpl(null, requestService, rdbService, null, halService, authService);
|
protected notificationsService: NotificationsService) {
|
||||||
|
this.dataService = new DataServiceImpl(null, requestService, rdbService, null, halService, authService, notificationsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
findById(uuid: string): Observable<RemoteData<DSpaceObject>> {
|
findById(uuid: string): Observable<RemoteData<DSpaceObject>> {
|
||||||
|
@@ -29,7 +29,8 @@ export class ItemDataService extends DataService<NormalizedItem, Item> {
|
|||||||
protected store: Store<CoreState>,
|
protected store: Store<CoreState>,
|
||||||
private bs: BrowseService,
|
private bs: BrowseService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected authService: AuthService) {
|
protected authService: AuthService,
|
||||||
|
protected notificationsService: NotificationsService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user