mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
CST-11012 notify info component updated with guards and services (needs cleanup)
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<ng-container *ngIf="coarLdnEnabled; else notAllowed">
|
<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>
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
<p [innerHTML]="('coar-notify-support.message-moderation.content' | translate)"></p>
|
<p [innerHTML]="('coar-notify-support.message-moderation.content' | translate)"></p>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #notAllowed>
|
<ng-template #notAllowed>
|
||||||
<p>Disabled</p>
|
<p>Disabled {{coarLdnEnabled}}{{coarLdnEnabled | json}}</p>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { AuthorizationDataService } from '../../data/feature-authorization/authorization-data.service';
|
import { NotifyInfoService } from './notify-info.service';
|
||||||
import { FeatureID } from '../../data/feature-authorization/feature-id';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-notify-info',
|
selector: 'ds-notify-info',
|
||||||
@@ -12,13 +12,13 @@ export class NotifyInfoComponent implements OnInit {
|
|||||||
coarLdnEnabled: boolean;
|
coarLdnEnabled: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authorizationService: AuthorizationDataService,
|
public notifyInfoService: NotifyInfoService,
|
||||||
) {
|
) { }
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.authorizationService.isAuthorized(FeatureID.CoarLdnEnabled).subscribe(enabled => {
|
this.coarLdnEnabled = this.notifyInfoService.isCoarConfigEnabled();
|
||||||
this.coarLdnEnabled = enabled;
|
console.log(this.coarLdnEnabled);
|
||||||
});
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NotifyInfoGuard } from './notify-info.guard';
|
||||||
|
|
||||||
|
describe('NotifyInfoGuard', () => {
|
||||||
|
let guard: NotifyInfoGuard;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
guard = TestBed.inject(NotifyInfoGuard);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(guard).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
15
src/app/core/coar-notify/notify-info/notify-info.guard.ts
Normal file
15
src/app/core/coar-notify/notify-info/notify-info.guard.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class NotifyInfoGuard implements CanActivate {
|
||||||
|
canActivate(
|
||||||
|
route: ActivatedRouteSnapshot,
|
||||||
|
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NotifyInfoService } from './notify-info.service';
|
||||||
|
|
||||||
|
describe('NotifyInfoService', () => {
|
||||||
|
let service: NotifyInfoService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(NotifyInfoService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
24
src/app/core/coar-notify/notify-info/notify-info.service.ts
Normal file
24
src/app/core/coar-notify/notify-info/notify-info.service.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { getFirstSucceededRemoteData } from '../../shared/operators';
|
||||||
|
import { ConfigurationDataService } from '../../data/configuration-data.service';
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class NotifyInfoService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private configService: ConfigurationDataService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
isCoarConfigEnabled(): boolean {
|
||||||
|
this.configService.findByPropertyName('coar-notify.enabled').pipe(
|
||||||
|
getFirstSucceededRemoteData()
|
||||||
|
);
|
||||||
|
if (!getFirstSucceededRemoteData()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -877,7 +877,7 @@
|
|||||||
|
|
||||||
"coar-notify-support.message-moderation.title": "Message Moderation",
|
"coar-notify-support.message-moderation.title": "Message Moderation",
|
||||||
|
|
||||||
"coar-notify-support.message-moderation.content": "To ensure a secure and productive environment, all incoming LDN messages are moderated. If you are planning to exchange information with us, kindly reach out via our dedicated Feedback form. You can access the Feedback form by clicking <a href=\"/feedback\">here</a>.",
|
"coar-notify-support.message-moderation.content": "To ensure a secure and productive environment, all incoming LDN messages are moderated. If you are planning to exchange information with us, kindly reach out via our dedicated Feedback form. You can access the Feedback form by clicking <a href=\"info/feedback\">here</a>.",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,6 +32,7 @@ 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.
|
||||||
@@ -50,6 +51,7 @@ 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,
|
||||||
@@ -95,6 +97,7 @@ 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();
|
||||||
@@ -142,6 +145,10 @@ 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