mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[CST-4875] improvements
This commit is contained in:
@@ -5,21 +5,14 @@ import { FeatureID } from 'src/app/core/data/feature-authorization/feature-id';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract guard for redirecting users to the user agreement page if a certain condition is met
|
* An guard for redirecting users to the feedback page if user is authorized
|
||||||
* That condition is defined by abstract method hasAccepted
|
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export abstract class FeedbackGuard implements CanActivate {
|
export class FeedbackGuard implements CanActivate {
|
||||||
|
|
||||||
constructor(protected router: Router, private authorizationService: AuthorizationDataService) {
|
constructor(private authorizationService: AuthorizationDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* True when the user agreement has been accepted
|
|
||||||
* The user will be redirected to the End User Agreement page if they haven't accepted it before
|
|
||||||
* A redirect URL will be provided with the navigation so the component can redirect the user back to the blocked route
|
|
||||||
* when they're finished accepting the agreement
|
|
||||||
*/
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ export class Feedback extends DSpaceObject {
|
|||||||
public email: string;
|
public email: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ring representing message the user inserted
|
* A string representing message the user inserted
|
||||||
*/
|
*/
|
||||||
@autoserialize
|
@autoserialize
|
||||||
public message: string;
|
public message: string;
|
||||||
|
@@ -19,6 +19,9 @@ import { EPerson } from '../../../core/eperson/models/eperson.model';
|
|||||||
*/
|
*/
|
||||||
export class FeedbackContentComponent implements OnInit {
|
export class FeedbackContentComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form builder created used from the feedback from
|
||||||
|
*/
|
||||||
feedbackForm = this.fb.group({
|
feedbackForm = this.fb.group({
|
||||||
email: ['', [Validators.required, Validators.pattern('^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$')]],
|
email: ['', [Validators.required, Validators.pattern('^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$')]],
|
||||||
message: ['', Validators.required],
|
message: ['', Validators.required],
|
||||||
@@ -34,6 +37,9 @@ export class FeedbackContentComponent implements OnInit {
|
|||||||
private authService: AuthService) {
|
private authService: AuthService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On init check if user is logged in and use its email if so
|
||||||
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.authService.getAuthenticatedUserFromStore().subscribe((user: EPerson) => {
|
this.authService.getAuthenticatedUserFromStore().subscribe((user: EPerson) => {
|
||||||
if (!!user) {
|
if (!!user) {
|
||||||
@@ -42,6 +48,9 @@ export class FeedbackContentComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to create the feedback from form values
|
||||||
|
*/
|
||||||
createFeedback() {
|
createFeedback() {
|
||||||
this.feedbackDataService.createFeedback(this.feedbackForm.value).subscribe((response: Feedback) => {
|
this.feedbackDataService.createFeedback(this.feedbackForm.value).subscribe((response: Feedback) => {
|
||||||
this.notificationsService.success(this.translate.instant('info.feedback.create.success'));
|
this.notificationsService.success(this.translate.instant('info.feedback.create.success'));
|
||||||
|
@@ -11,7 +11,7 @@ import { ThemedPrivacyComponent } from './privacy/themed-privacy.component';
|
|||||||
import { FeedbackComponent } from './feedback/feedback.component';
|
import { FeedbackComponent } from './feedback/feedback.component';
|
||||||
import { FeedbackContentComponent } from './feedback/feedback-content/feedback-content.component';
|
import { FeedbackContentComponent } from './feedback/feedback-content/feedback-content.component';
|
||||||
import { ThemedFeedbackComponent } from './feedback/themed-feedback.component';
|
import { ThemedFeedbackComponent } from './feedback/themed-feedback.component';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { FeedbackGuard } from '../core/feedback/feedback.guard';
|
||||||
|
|
||||||
|
|
||||||
const DECLARATIONS = [
|
const DECLARATIONS = [
|
||||||
@@ -37,7 +37,8 @@ const DECLARATIONS = [
|
|||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
...DECLARATIONS
|
...DECLARATIONS
|
||||||
]
|
],
|
||||||
|
providers: [FeedbackGuard]
|
||||||
})
|
})
|
||||||
export class InfoModule {
|
export class InfoModule {
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user