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