[CST-4875] Fix imports path

This commit is contained in:
Giuseppe Digilio
2022-01-24 22:42:27 +01:00
parent 6a78c1bcf8
commit 944f605671
7 changed files with 50 additions and 75 deletions

View File

@@ -8,7 +8,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { CoreState } from '../core.reducers'; import { CoreState } from '../core.reducers';
import { DSOChangeAnalyzer } from 'src/app/core/data/dso-change-analyzer.service'; import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
import { Feedback } from './models/feedback.model'; import { Feedback } from './models/feedback.model';
describe('FeedbackDataService', () => { describe('FeedbackDataService', () => {
@@ -85,16 +85,4 @@ describe('FeedbackDataService', () => {
}); });
}); });
describe('createFeedback', () => {
beforeEach(() => {
spyOn(service, 'create');
service.createFeedback(feedbackPayload);
});
it('should call postToEndpoint with the payload', () => {
expect(service.create).toHaveBeenCalledWith(feedbackPayload);
});
});
}); });

View File

@@ -3,17 +3,16 @@ import { Observable } from 'rxjs';
import { DataService } from '../data/data.service'; import { DataService } from '../data/data.service';
import { Feedback } from './models/feedback.model'; import { Feedback } from './models/feedback.model';
import { FEEDBACK } from './models/feedback.resource-type'; import { FEEDBACK } from './models/feedback.resource-type';
import { dataService } from 'src/app/core/cache/builders/build-decorators'; import { dataService } from '../cache/builders/build-decorators';
import { RequestService } from 'src/app/core/data/request.service'; import { RequestService } from '../data/request.service';
import { RemoteDataBuildService } from 'src/app/core/cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { ObjectCacheService } from 'src/app/core/cache/object-cache.service'; import { ObjectCacheService } from '../cache/object-cache.service';
import { HALEndpointService } from 'src/app/core/shared/hal-endpoint.service'; import { HALEndpointService } from '../shared/hal-endpoint.service';
import { NotificationsService } from 'src/app/shared/notifications/notifications.service'; import { NotificationsService } from '../../shared/notifications/notifications.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { DSOChangeAnalyzer } from 'src/app/core/data/dso-change-analyzer.service'; import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
import { getFirstSucceededRemoteData, getRemoteDataPayload } from 'src/app/core/shared/operators'; import { getFirstSucceededRemoteData, getRemoteDataPayload } from '../shared/operators';
import { RemoteData } from 'src/app/core/data/remote-data';
/** /**
* Service for checking and managing the feedback * Service for checking and managing the feedback
@@ -21,41 +20,30 @@ import { RemoteData } from 'src/app/core/data/remote-data';
@Injectable() @Injectable()
@dataService(FEEDBACK) @dataService(FEEDBACK)
export class FeedbackDataService extends DataService<Feedback> { export class FeedbackDataService extends DataService<Feedback> {
protected linkPath = 'feedbacks'; protected linkPath = 'feedbacks';
constructor( constructor(
protected requestService: RequestService, protected requestService: RequestService,
protected rdbService: RemoteDataBuildService, protected rdbService: RemoteDataBuildService,
protected store: Store<any>, protected store: Store<any>,
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
protected halService: HALEndpointService, protected halService: HALEndpointService,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected http: HttpClient, protected http: HttpClient,
protected comparator: DSOChangeAnalyzer<Feedback>, protected comparator: DSOChangeAnalyzer<Feedback>,
) { ) {
super(); super();
} }
/** /**
* Get feedback from its id * Get feedback from its id
* @param uuid string the id of the feedback * @param uuid string the id of the feedback
*/ */
getFeedback(uuid: string): Observable<Feedback> { getFeedback(uuid: string): Observable<Feedback> {
return this.findById(uuid).pipe( return this.findById(uuid).pipe(
getFirstSucceededRemoteData(), getFirstSucceededRemoteData(),
getRemoteDataPayload(), getRemoteDataPayload(),
); );
} }
/**
* Create feedback
* @param payload feedback to be sent
* @return Observable<RemoteData<Feedback>
* server response
*/
createFeedback(payload: Feedback): Observable<RemoteData<Feedback>> {
return this.create(payload);
}
} }

View File

@@ -1,7 +1,7 @@
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree } from '@angular/router'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
import { FeatureID } from 'src/app/core/data/feature-authorization/feature-id'; import { FeatureID } from '../data/feature-authorization/feature-id';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
/** /**
@@ -10,11 +10,11 @@ import { Injectable } from '@angular/core';
@Injectable() @Injectable()
export class FeedbackGuard implements CanActivate { export class FeedbackGuard implements CanActivate {
constructor(private authorizationService: AuthorizationDataService) { constructor(private authorizationService: AuthorizationDataService) {
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> {
return this.authorizationService.isAuthorized(FeatureID.CanSendFeedback); return this.authorizationService.isAuthorized(FeatureID.CanSendFeedback);
} }
} }

View File

@@ -6,5 +6,4 @@ import { ResourceType } from '../../shared/resource-type';
* Needs to be in a separate file to prevent circular * Needs to be in a separate file to prevent circular
* dependencies in webpack. * dependencies in webpack.
*/ */
export const FEEDBACK = new ResourceType('feedback'); export const FEEDBACK = new ResourceType('feedback');

View File

@@ -30,7 +30,7 @@
<input class="form-control" formControlName="page" name="page" type="hidden" [value]="routeService.getPreviousUrl() | async" <input class="form-control" formControlName="page" name="page" type="hidden" [value]="routeService.getPreviousUrl() | async"
/> />
<div class="row py-2"> <div class="row py-2">
<div class="control-group col-sm-12"> <div class="control-group col-sm-12 text-right">
<button [disabled]="!feedbackForm.valid" class="btn btn-primary" name="submit" type="submit">{{ 'info.feedback.send' | translate }}</button> <button [disabled]="!feedbackForm.valid" class="btn btn-primary" name="submit" type="submit">{{ 'info.feedback.send' | translate }}</button>
</div> </div>
</div> </div>

View File

@@ -3,16 +3,16 @@ import { FeedbackDataService } from '../../../core/feedback/feedback-data.servic
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FeedbackFormComponent } from './feedback-form.component'; import { FeedbackFormComponent } from './feedback-form.component';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { NO_ERRORS_SCHEMA, DebugElement } from '@angular/core'; import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { RouteService } from 'src/app/core/services/route.service'; import { RouteService } from '../../../core/services/route.service';
import { routeServiceStub } from 'src/app/shared/testing/route-service.stub'; import { routeServiceStub } from '../../../shared/testing/route-service.stub';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { NotificationsService } from 'src/app/shared/notifications/notifications.service'; import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { NotificationsServiceStub } from 'src/app/shared/testing/notifications-service.stub'; import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
import { AuthService } from 'src/app/core/auth/auth.service'; import { AuthService } from '../../../core/auth/auth.service';
import { AuthServiceStub } from 'src/app/shared/testing/auth-service.stub'; import { AuthServiceStub } from '../../../shared/testing/auth-service.stub';
import { of } from 'rxjs/internal/observable/of'; import { of } from 'rxjs';
import { Feedback } from '../../../core/feedback/models/feedback.model'; import { Feedback } from '../../../core/feedback/models/feedback.model';

View File

@@ -2,11 +2,11 @@ import { RemoteData } from '../../../core/data/remote-data';
import { NoContent } from '../../../core/shared/NoContent.model'; import { NoContent } from '../../../core/shared/NoContent.model';
import { FeedbackDataService } from '../../../core/feedback/feedback-data.service'; import { FeedbackDataService } from '../../../core/feedback/feedback-data.service';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { RouteService } from 'src/app/core/services/route.service'; import { RouteService } from '../../../core/services/route.service';
import { FormBuilder, Validators } from '@angular/forms'; import { FormBuilder, Validators } from '@angular/forms';
import { NotificationsService } from 'src/app/shared/notifications/notifications.service'; import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { AuthService } from 'src/app/core/auth/auth.service'; import { AuthService } from '../../../core/auth/auth.service';
import { EPerson } from '../../../core/eperson/models/eperson.model'; import { EPerson } from '../../../core/eperson/models/eperson.model';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators';