Update to Angular 16 #16

Merged
k.triantafyllou merged 66 commits from angular-16 into develop 2023-10-30 10:57:26 +01:00
2 changed files with 27 additions and 38 deletions
Showing only changes of commit f160aaa000 - Show all commits

View File

@ -2,12 +2,9 @@ import {Component, Input, ViewChild} from '@angular/core';
import {Router} from '@angular/router';
import {ContextsService} from './service/contexts.service';
import {ClaimEntity, ShowOptions} from './claimHelper.class';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Subscriber} from "rxjs";
import {OpenaireEntities} from "../../utils/properties/searchFields";
import {CommunityService} from "../../connect/community/community.service";
import {CommunitiesService} from "../../connect/communities/communities.service";
declare var UIkit: any;
@ -167,10 +164,6 @@ export class ClaimContextSearchFormComponent {
}
getCommunities() {
if (!Session.isLoggedIn()) {
this.saveStateAndRedirectLogin();
} else {
this.loading = true;
this.subscriptions.push(this._contextService.getPublicCommunitiesByState().subscribe(
data => {
@ -203,18 +196,14 @@ export class ClaimContextSearchFormComponent {
this.error = true;
}
));
}
}
getCategories() {
this.loading = true;
// this.categories=[];
if (this.selectedCommunityId != '0') {
if (!Session.isLoggedIn()) {
this.saveStateAndRedirectLogin();
} else {
if (this.categories[this.selectedCommunityId]) {
this.loading = false;
if(this.categories[this.selectedCommunityId].length > 0){
@ -242,7 +231,7 @@ export class ClaimContextSearchFormComponent {
}
));
}
}
}
displaySubcategory(id) {
@ -255,9 +244,6 @@ export class ClaimContextSearchFormComponent {
}
browseConcepts(categoryId) {
if (!Session.isLoggedIn()) {
this.saveStateAndRedirectLogin();
} else {
if (this.conceptsClass[categoryId] != null) {
this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId];
return;
@ -285,8 +271,6 @@ export class ClaimContextSearchFormComponent {
this.conceptsCategoryLoading[categoryId] = false;
}
));
}
}
browseSubConcepts(categoryId, conceptId) {
@ -308,24 +292,6 @@ export class ClaimContextSearchFormComponent {
}
saveStateAndRedirectLogin() {
if (this.results != null) {
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
}
if (this.sources != null) {
localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
}
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
}
private static handleError(message: string, error) {
console.error("Claim context search form (component): " + message, error);
}

View File

@ -16,6 +16,8 @@ import {OpenaireEntities} from "../../utils/properties/searchFields";
import {StringUtils} from "../../utils/string-utils.class";
import {RouterHelper} from "../../utils/routerHelper.class";
import { Location } from '@angular/common';
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
import {UserManagementService} from "../../services/user-management.service";
@Component({
selector: 'linking-generic',
@ -51,12 +53,17 @@ export class LinkingGenericComponent {
constructor (private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
private _meta: Meta, private _title: Title, private _piwikService:PiwikService,
private seoService: SEOService, private helper: HelperService, private cdr: ChangeDetectorRef,
private location: Location) {
private location: Location, private userManagementService: UserManagementService) {
}
subscriptions = [];
ngOnInit() {
if(this.breadcrumbs.length === 0) {
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
if (!user) {
this.saveStateAndRedirectLogin();
}
}));
if(this.breadcrumbs.length === 0) {
this.breadcrumbs.push({name: 'home', route: '/'});
this.breadcrumbs.push({name: "Link", route: null});
}
@ -211,4 +218,20 @@ export class LinkingGenericComponent {
this.location.back();
}
}
saveStateAndRedirectLogin() {
if (this.results != null) {
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
}
if (this.sources != null) {
localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
}
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
}