mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
CST-11012 Notify info component has been completed with working guard and service
This commit is contained in:
@@ -4,19 +4,13 @@
|
||||
<title>{{ 'coar-notify-support.title' | translate }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<ng-container *ngIf="coarLdnEnabled; else notAllowed">
|
||||
<p>{{coarLdnEnabled}}{{coarLdnEnabled | json}}</p>
|
||||
<h1>{{ 'coar-notify-support.title' | translate }}</h1>
|
||||
<p [innerHTML]="('coar-notify-support-title.content' | translate)"></p>
|
||||
<h1>{{ 'coar-notify-support.title' | translate }}</h1>
|
||||
<p [innerHTML]="('coar-notify-support-title.content' | translate)"></p>
|
||||
|
||||
<h2>{{ 'coar-notify-support.ldn-inbox.title' | translate }}</h2>
|
||||
<p [innerHTML]="('coar-notify-support.ldn-inbox.content' | translate)"></p>
|
||||
<h2>{{ 'coar-notify-support.ldn-inbox.title' | translate }}</h2>
|
||||
<p [innerHTML]="('coar-notify-support.ldn-inbox.content' | translate)"></p>
|
||||
|
||||
<h2>{{ 'coar-notify-support.message-moderation.title' | translate }}</h2>
|
||||
<p [innerHTML]="('coar-notify-support.message-moderation.content' | translate)"></p>
|
||||
</ng-container>
|
||||
<ng-template #notAllowed>
|
||||
<p>Disabled {{coarLdnEnabled}}{{coarLdnEnabled | json}}</p>
|
||||
</ng-template>
|
||||
<h2>{{ 'coar-notify-support.message-moderation.title' | translate }}</h2>
|
||||
<p [innerHTML]="('coar-notify-support.message-moderation.content' | translate)"></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { NotifyInfoService } from './notify-info.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'ds-notify-info',
|
||||
templateUrl: './notify-info.component.html',
|
||||
@@ -16,9 +15,9 @@ export class NotifyInfoComponent implements OnInit {
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.coarLdnEnabled = this.notifyInfoService.isCoarConfigEnabled();
|
||||
console.log(this.coarLdnEnabled);
|
||||
}
|
||||
this.notifyInfoService.isCoarConfigEnabled().subscribe(value => {
|
||||
this.coarLdnEnabled = value;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,30 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { NotifyInfoService } from './notify-info.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotifyInfoGuard implements CanActivate {
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
return true;
|
||||
}
|
||||
constructor(
|
||||
private notifyInfoService: NotifyInfoService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
return this.notifyInfoService.isCoarConfigEnabled().pipe(
|
||||
map(coarLdnEnabled => {
|
||||
if (coarLdnEnabled) {
|
||||
return true;
|
||||
} else {
|
||||
return this.router.parseUrl('/404');
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +1,25 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { getFirstSucceededRemoteData } from '../../shared/operators';
|
||||
import { ConfigurationDataService } from '../../data/configuration-data.service';
|
||||
|
||||
import { map, Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotifyInfoService {
|
||||
|
||||
constructor(
|
||||
private configService: ConfigurationDataService,
|
||||
) {
|
||||
}
|
||||
constructor(
|
||||
private configService: ConfigurationDataService,
|
||||
) {}
|
||||
|
||||
isCoarConfigEnabled(): boolean {
|
||||
this.configService.findByPropertyName('coar-notify.enabled').pipe(
|
||||
getFirstSucceededRemoteData()
|
||||
);
|
||||
if (!getFirstSucceededRemoteData()) {
|
||||
return true;
|
||||
isCoarConfigEnabled(): Observable<boolean> {
|
||||
return this.configService.findByPropertyName('coar-notify.enabled').pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
map(response => {
|
||||
const booleanArrayValue = response.payload.values;
|
||||
const coarConfigEnabled = booleanArrayValue.length > 0 ? booleanArrayValue[0] === 'true' : false;
|
||||
return coarConfigEnabled;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -81,10 +81,10 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="notify-enabled">
|
||||
<div class="notify-enabled" [hidden]="!coarLdnEnabled">
|
||||
<a class="coar-notify-support-route" routerLink="info/coar-notify-support">
|
||||
<img class="n-coar" src="assets/images/n-coar.png" [attr.alt]="'menu.header.image.logo' | translate" />
|
||||
This site support the COAR Notify protocol
|
||||
<img class="n-coar" src="assets/images/n-coar.png" [attr.alt]="'menu.header.image.logo' | translate" />
|
||||
This site supports the COAR Notify protocol
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -2,6 +2,7 @@ import { Component, Optional } from '@angular/core';
|
||||
import { hasValue } from '../shared/empty.util';
|
||||
import { KlaroService } from '../shared/cookies/klaro.service';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-footer',
|
||||
@@ -17,8 +18,15 @@ export class FooterComponent {
|
||||
showTopFooter = false;
|
||||
showPrivacyPolicy = environment.info.enablePrivacyStatement;
|
||||
showEndUserAgreement = environment.info.enableEndUserAgreement;
|
||||
coarLdnEnabled: boolean; // Add this line
|
||||
|
||||
constructor(@Optional() private cookies: KlaroService) {
|
||||
constructor(
|
||||
@Optional() private cookies: KlaroService,
|
||||
private notifyInfoService: NotifyInfoService
|
||||
) {
|
||||
this.notifyInfoService.isCoarConfigEnabled().subscribe(coarLdnEnabled => {
|
||||
this.coarLdnEnabled = coarLdnEnabled;
|
||||
});
|
||||
}
|
||||
|
||||
showCookieSettings() {
|
||||
|
@@ -9,6 +9,7 @@ import { FeedbackGuard } from '../core/feedback/feedback.guard';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { COAR_NOTIFY_SUPPORT } from '../app-routing-paths';
|
||||
import { NotifyInfoComponent } from '../core/coar-notify/notify-info/notify-info.component';
|
||||
import { NotifyInfoGuard } from '../core/coar-notify/notify-info/notify-info.guard';
|
||||
|
||||
|
||||
const imports = [
|
||||
@@ -27,8 +28,7 @@ const imports = [
|
||||
component: NotifyInfoComponent,
|
||||
resolve: { breadcrumb: I18nBreadcrumbResolver },
|
||||
data: { title: 'info.coar-notify-support.title', breadcrumbKey: 'info.coar-notify-support' },
|
||||
// TODO: create authGuard for COAR_NOTIFY
|
||||
// canActivate: [FeedbackGuard]
|
||||
canActivate: [NotifyInfoGuard]
|
||||
}
|
||||
])
|
||||
];
|
||||
|
@@ -32,8 +32,6 @@ import { logStartupMessage } from '../../../startup-message';
|
||||
import { MenuService } from '../../app/shared/menu/menu.service';
|
||||
import { RootDataService } from '../../app/core/data/root-data.service';
|
||||
import { firstValueFrom, Subscription } from 'rxjs';
|
||||
import { NotifyInfoService } from '../../app/core/coar-notify/notify-info/notify-info.service';
|
||||
|
||||
/**
|
||||
* Performs client-side initialization.
|
||||
*/
|
||||
@@ -51,7 +49,6 @@ export class BrowserInitService extends InitService {
|
||||
protected localeService: LocaleService,
|
||||
protected angulartics2DSpace: Angulartics2DSpace,
|
||||
protected googleAnalyticsService: GoogleAnalyticsService,
|
||||
protected notifyInfoService: NotifyInfoService,
|
||||
protected metadata: MetadataService,
|
||||
protected breadcrumbsService: BreadcrumbsService,
|
||||
protected klaroService: KlaroService,
|
||||
@@ -97,7 +94,6 @@ export class BrowserInitService extends InitService {
|
||||
this.initI18n();
|
||||
this.initAngulartics();
|
||||
this.initGoogleAnalytics();
|
||||
this.retrieveCoarConfig();
|
||||
this.initRouteListeners();
|
||||
this.themeService.listenForThemeChanges(true);
|
||||
this.trackAuthTokenExpiration();
|
||||
@@ -145,10 +141,6 @@ export class BrowserInitService extends InitService {
|
||||
this.googleAnalyticsService.addTrackingIdToPage();
|
||||
}
|
||||
|
||||
protected retrieveCoarConfig() {
|
||||
this.notifyInfoService.isCoarConfigEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* During an external authentication flow invalidate the SSR transferState
|
||||
* data in the cache. This allows the app to fetch fresh content.
|
||||
|
Reference in New Issue
Block a user