Skip to content

Commit

Permalink
merge devel to qa. v1.40
Browse files Browse the repository at this point in the history
  • Loading branch information
konolak committed Jan 21, 2025
1 parent 3f0f6be commit b78603d
Show file tree
Hide file tree
Showing 42 changed files with 2,338 additions and 342 deletions.
1 change: 0 additions & 1 deletion src/app/mydata/components/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ export class ProfileComponent implements OnInit, OnDestroy {

for (const delay of delays) {
await lastValueFrom(timer(delay));
console.log("polling profile");

response = await lastValueFrom(this.updatePerson());

Expand Down
14 changes: 8 additions & 6 deletions src/app/mydata/services/orcid-account-linking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class OrcidAccoungLinkingService {
/*
* Get hash. For more explanation, see comments of function getOrcidLink()
*/
async getHash(nonce, sessionState, clientId) {
const input = nonce + sessionState + clientId + 'orcid';
async getHash(nonce, sid, clientId) {
const input = nonce + sid + clientId + 'orcid';
const encoder = new TextEncoder();
const data = encoder.encode(input);
const sha256 = await crypto.subtle.digest('SHA-256', data);
Expand Down Expand Up @@ -105,7 +105,7 @@ export class OrcidAccoungLinkingService {
* This is a random string that your application must generate
* hash:
* This is a Base64 URL encoded hash.
* This hash is generated by Base64 URL encoding a SHA_256 hash of nonce + session_state (from token) + azp (from token) + provider
* This hash is generated by Base64 URL encoding a SHA_256 hash of nonce + sid (from token) + azp (from token) + provider
* Basically you are hashing the random nonce, the user session id, the client id, and the identity provider alias you want to access.
*/
async getOrcidLink() {
Expand All @@ -126,14 +126,16 @@ export class OrcidAccoungLinkingService {
// azp: Authorized party - the party to which the ID Token was issued
const clientId = idTokenPayload.azp;

// Get property 'session_state' from ID token.
const sessionState = idTokenPayload.session_state;
// Get property 'sid' from ID token.
// 2024-12-31: use 'sid' instead of 'session_state'
// https://www.keycloak.org/docs/latest/release_notes/index.html#lightweight-access-token-to-be-even-more-lightweight
const sid = idTokenPayload.sid;

// Get nonce
const nonce = this.getNonce();

// Get hash
const hash = await this.getHash(nonce, sessionState, clientId);
const hash = await this.getHash(nonce, sid, clientId);

// Return ORCID account linking URL
return this.getUrl(keycloakUrl, clientId, redirectUrl, nonce, hash);
Expand Down
1 change: 0 additions & 1 deletion src/app/mydata/services/search-portal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class SearchPortalService {
sortSettings: { active: string; direction: string }
) {
let sortField: string;

switch (sortSettings.active) {
case 'year': {
sortField = this.getDefaultSortField(groupId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { FundingCallFilterService } from '@portal/services/filters/funding-call-
import { StaticDataService } from '@portal/services/static-data.service';
import { FilterConfigType } from 'src/types';
import { ActiveFiltersListComponent } from '../../../../shared/components/active-filters-list/active-filters-list.component';
import { ProjectFilterService } from '@portal/services/filters/project-filter.service';

@Component({
selector: 'app-active-filters',
Expand Down Expand Up @@ -112,6 +113,7 @@ export class ActiveFiltersComponent
private infrastructureFilters: InfrastructureFilterService,
private organizationFilters: OrganizationFilterService,
private fundingCallFilters: FundingCallFilterService,
private projectFilters: ProjectFilterService,
private newsFilters: NewsFilterService,
private settingsService: SettingsService,
@Inject(PLATFORM_ID) private platformId: object,
Expand Down Expand Up @@ -153,6 +155,9 @@ export class ActiveFiltersComponent
case 'news':
this.filtersConfig = this.newsFilters.filterData;
break;
case 'projects':
this.filtersConfig = this.projectFilters.filterData;
break;

default:
break;
Expand All @@ -167,17 +172,17 @@ export class ActiveFiltersComponent
this.translationFlag = false;
const errorMsg = 'error translating filter';

this.queryParams = this.filterService.filters.subscribe((filter) => {
this.queryParams = this.filterService.filters.subscribe((allFilters) => {
// Get from & to year values from filter list
this.fromYear = parseInt(filter.fromYear[0]?.slice(1), 10);
this.toYear = parseInt(filter.toYear[0]?.slice(1), 10);
const years = filter.year.map((item) => parseInt(item, 10));
this.fromYear = parseInt(allFilters.fromYear[0]?.slice(1), 10);
this.toYear = parseInt(allFilters.toYear[0]?.slice(1), 10);
const years = allFilters.year.map((item) => parseInt(item, 10));
let yearWarning = false;

if (this.fromYear && this.toYear) {
// Check if years missing between range and add warning flag
if (
filter.year.filter(
allFilters.year.filter(
(item) => this.fromYear <= item && item <= this.toYear
).length !==
this.toYear - this.fromYear + 1
Expand All @@ -186,14 +191,14 @@ export class ActiveFiltersComponent
}
} else if (this.fromYear) {
if (
filter.year.filter((item) => this.fromYear <= item).length !==
allFilters.year.filter((item) => this.fromYear <= item).length !==
Math.max(...years) - this.fromYear + 1
) {
yearWarning = true;
}
} else if (this.toYear) {
if (
filter.year.filter((item) => this.toYear >= item).length !==
allFilters.year.filter((item) => this.toYear >= item).length !==
this.toYear + 1 - Math.min(...years)
) {
yearWarning = true;
Expand All @@ -202,21 +207,20 @@ export class ActiveFiltersComponent

// Reset active filter so push doesn't duplicate
this.activeFilters = [];
const newFilters = {};
const filtersFromAllCategories = {};

// Merge and format arrays
Object.keys(filter).forEach((key) => {
newFilters[key] = filter[key].map((val) => {
Object.keys(allFilters).forEach((key) => {
filtersFromAllCategories[key] = allFilters[key].map((val) => {
return {
category: key,
value: val,
translation: this.translations[val] || val,
};
});
this.activeFilters.push(...newFilters[key]);
this.activeFilters.push(...filtersFromAllCategories[key]);
});
const tab = this.tabChangeService.tab;

// Subscribe to aggregation data and shape to get corresponding values
this.filterResponse = this.searchService
.getAllFilters(tab)
Expand Down Expand Up @@ -254,6 +258,10 @@ export class ActiveFiltersComponent
this.response = this.newsFilters.shapeData(response);
break;
}
case 'projects': {
this.response = this.projectFilters.shapeData(response);
break;
}
}

if (response) {
Expand Down Expand Up @@ -302,7 +310,7 @@ export class ActiveFiltersComponent
}

if (val.category === 'date') {
const dateString = filter.date ? filter.date[0] : '';
const dateString = allFilters.date ? allFilters.date[0] : '';
const startDate = dateString?.split('|')[0];
const endDate = dateString?.split('|')[1];
const startDateString = startDate
Expand Down Expand Up @@ -502,7 +510,7 @@ export class ActiveFiltersComponent
if (val.category === 'organization' && source.organization) {
// Funding organization name
if (tab === 'fundings') {
setTimeout((t) => {
setTimeout(() => {
if (source.organization.funded.sectorName.buckets) {
source.organization.funded.sectorName.buckets.forEach(
(sector) => {
Expand All @@ -521,7 +529,7 @@ export class ActiveFiltersComponent
}, 1);
// Dataset & persons organization name
} else if (tab === 'datasets' || tab === 'persons') {
setTimeout((t) => {
setTimeout(() => {
if (source.organization.sectorName.buckets) {
source.organization.sectorName.buckets.forEach(
(sector) => {
Expand All @@ -540,7 +548,7 @@ export class ActiveFiltersComponent
}, 1);
// Infrastructure organization name
} else if (tab === 'infrastructures') {
setTimeout((t) => {
setTimeout(() => {
if (source.organization.sector.buckets) {
source.organization.sector.buckets.forEach((sector) => {
if (sector.subData.find((x) => x.key === val.value)) {
Expand Down Expand Up @@ -585,9 +593,23 @@ export class ActiveFiltersComponent
}
});
}
} else {
} else if (tab === 'projects') {
if (source.organizations?.organization?.buckets){
source.organizations.organization.buckets.forEach(
(bucket) => {
if (bucket.key === val.value) {
const foundIndex = this.activeFilters.findIndex(
(x) => x.value === val.value
);
this.activeFilters[foundIndex].translation = bucket.translation;
}
}
);
}
}
else {
// Common usage e.g. in publications, persons, datasets
setTimeout((t) => {
setTimeout(() => {
if (source.organization.sectorName.buckets) {
source.organization.sectorName.buckets.forEach(
(sector) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ <h3 class="header" *ngIf="!mobile && !showButton">
</mat-expansion-panel>
<!-- Items with single checkbox -->
<div class="single-checkbox" *ngFor="let item of currentSingleFilter">
{{item.field}}
<div class="row single">
<div class="col">
<div
Expand Down
117 changes: 63 additions & 54 deletions src/app/portal/components/results/filters/filters.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { InfrastructureFilterService } from 'src/app/portal/services/filters/inf
import { OrganizationFilterService } from 'src/app/portal/services/filters/organization-filter.service';
import { NewsFilterService } from 'src/app/portal/services/filters/news-filter.service';
import { faSlidersH, faPlus, faMinus } from '@fortawesome/free-solid-svg-icons';
import { isPlatformBrowser, DOCUMENT, NgTemplateOutlet, NgIf, NgFor, NgClass } from '@angular/common';
import { isPlatformBrowser, DOCUMENT, NgTemplateOutlet, NgIf, NgFor, NgClass, JsonPipe } from '@angular/common';
import { DataService } from 'src/app/portal/services/data.service';
import { FundingCallFilterService } from '@portal/services/filters/funding-call-filter.service';
import { AppSettingsService } from '@shared/services/app-settings.service';
Expand All @@ -58,47 +58,49 @@ import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle } fr
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { SecondaryButtonComponent } from '../../../../shared/components/buttons/secondary-button/secondary-button.component';
import { ProjectFilterService } from '@portal/services/filters/project-filter.service';

@Component({
selector: 'app-filters',
templateUrl: './filters.component.html',
styleUrls: ['./filters.component.scss'],
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [
SecondaryButtonComponent,
NgTemplateOutlet,
NgIf,
MatProgressSpinner,
FontAwesomeModule,
NgFor,
MatExpansionPanel,
MatExpansionPanelHeader,
NgClass,
MatExpansionPanelTitle,
TooltipModule,
MatSlideToggle,
MatFormField,
MatLabel,
MatSelect,
MatOption,
MatInput,
MatDatepickerInput,
MatDatepickerToggle,
MatSuffix,
MatIcon,
MatDatepickerToggleIcon,
MatDatepicker,
MatSelectionList,
MatListOption,
MatButton,
RouterLink,
DialogComponent,
ThousandSeparatorPipe,
FilterItemPipe,
ReplaceSpacePipe,
ConvertToArrayPipe,
],
selector: 'app-filters',
templateUrl: './filters.component.html',
styleUrls: ['./filters.component.scss'],
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [
SecondaryButtonComponent,
NgTemplateOutlet,
NgIf,
MatProgressSpinner,
FontAwesomeModule,
NgFor,
MatExpansionPanel,
MatExpansionPanelHeader,
NgClass,
MatExpansionPanelTitle,
TooltipModule,
MatSlideToggle,
MatFormField,
MatLabel,
MatSelect,
MatOption,
MatInput,
MatDatepickerInput,
MatDatepickerToggle,
MatSuffix,
MatIcon,
MatDatepickerToggleIcon,
MatDatepicker,
MatSelectionList,
MatListOption,
MatButton,
RouterLink,
DialogComponent,
ThousandSeparatorPipe,
FilterItemPipe,
ReplaceSpacePipe,
ConvertToArrayPipe,
JsonPipe
]
})
export class FiltersComponent implements OnInit, OnDestroy, OnChanges {
@Input() responseData: any;
Expand Down Expand Up @@ -170,6 +172,7 @@ export class FiltersComponent implements OnInit, OnDestroy, OnChanges {
private infrastructureFilters: InfrastructureFilterService,
private organizationFilters: OrganizationFilterService,
private fundingCallFilters: FundingCallFilterService,
private projectFilters: ProjectFilterService,
private newsFilters: NewsFilterService,
@Inject(PLATFORM_ID) private platformId: object,
private dataService: DataService,
Expand All @@ -192,8 +195,8 @@ export class FiltersComponent implements OnInit, OnDestroy, OnChanges {
this.filterHeading = this.headingText
? this.headingText
: this.filterOrigin === 'news'
? this.filterNewsHeader
: this.filterSearchHeader;
? this.filterNewsHeader
: this.filterSearchHeader;

// Visualisation click filtering
this.visualFilterSub = this.dataService.newFilter.subscribe((f) =>
Expand Down Expand Up @@ -286,6 +289,12 @@ export class FiltersComponent implements OnInit, OnDestroy, OnChanges {
this.fundingCallFilters.shapeData(this.responseData);
break;
}
case 'projects': {
this.currentFilter = this.projectFilters.filterData;
this.currentSingleFilter = this.projectFilters.singleFilterData;
this.projectFilters.shapeData(this.responseData);
break;
}
case 'news': {
this.currentFilter = this.newsFilters.filterData;
// this.currentSingleFilter = this.newsFilters.singleFilterData;
Expand Down Expand Up @@ -444,13 +453,13 @@ export class FiltersComponent implements OnInit, OnDestroy, OnChanges {
if (event.value) {
this.toYear
? source.map((x) =>
x.key >= event.value && x.key <= this.toYear
? selected.push(x.key.toString())
: null
)
x.key >= event.value && x.key <= this.toYear
? selected.push(x.key.toString())
: null
)
: source.map((x) =>
x.key >= event.value ? selected.push(x.key.toString()) : null
);
x.key >= event.value ? selected.push(x.key.toString()) : null
);
} else {
source.map((x) =>
x.key <= this.toYear ? selected.push(x.key.toString()) : null
Expand All @@ -463,13 +472,13 @@ export class FiltersComponent implements OnInit, OnDestroy, OnChanges {
if (event.value) {
this.fromYear
? source.map((x) =>
x.key <= event.value && x.key >= this.fromYear
? selected.push(x.key.toString())
: null
)
x.key <= event.value && x.key >= this.fromYear
? selected.push(x.key.toString())
: null
)
: source.map((x) =>
x.key <= event.value ? selected.push(x.key.toString()) : null
);
x.key <= event.value ? selected.push(x.key.toString()) : null
);
} else {
source.map((x) =>
x.key >= this.fromYear ? selected.push(x.key.toString()) : null
Expand Down
Loading

0 comments on commit b78603d

Please sign in to comment.