Skip to content

Commit

Permalink
Merge remote-tracking branch 'aoe-web-frontend/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
hsalokor committed Nov 25, 2024
2 parents a55ebbe + 5fdb533 commit 708676a
Show file tree
Hide file tree
Showing 48 changed files with 883 additions and 398 deletions.
2 changes: 1 addition & 1 deletion aoe-web-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aoe-web-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aoe-web-frontend",
"version": "6.2.22",
"version": "6.4.1",
"description": "Client SPA for the Library of Open Educational Resources",
"author": "CSC - IT Center for Science Ltd.",
"contributors": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'app-manage-materials',
Expand Down
13 changes: 7 additions & 6 deletions aoe-web-frontend/src/app/admin/model/educational-level.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export interface EducationalLevel {
key: string;
value: string;
children: [
{
key: string;
value: string;
},
];
children: EducationalLevelChild[];
}

export interface EducationalLevelChild {
key: string;
value: string;
disabled?: boolean;
}
1 change: 0 additions & 1 deletion aoe-web-frontend/src/app/admin/model/notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NotificationType } from '@admin/model/enumeration/NotificationType';
import { SafeHtml } from '@angular/platform-browser';

export interface Notification {
Expand Down
4 changes: 2 additions & 2 deletions aoe-web-frontend/src/app/admin/services/admin.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Observable, Subject, throwError } from 'rxjs';
import { environment } from '../../../environments/environment';
import { environment } from '@environments/environment';
import { catchError } from 'rxjs/operators';
import {
AoeUser,
Expand Down
39 changes: 26 additions & 13 deletions aoe-web-frontend/src/app/admin/services/koodisto.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http
import { BehaviorSubject, Observable, of, Subject, throwError } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';

import { EducationalLevel, EducationalSubject } from '../model';
import { environment } from '../../../environments/environment';
import { EducationalLevel, EducationalSubject, EducationalLevelChild } from '@admin/model';
import { environment } from '@environments/environment';
import { Organization } from '@admin/model/organization';
import { catchError, filter, map, tap } from 'rxjs/operators';
import { catchError, map, tap } from 'rxjs/operators';

@Injectable({
providedIn: 'root',
Expand All @@ -21,18 +21,21 @@ export class KoodistoService {
'Content-Type': 'application/json',
}),
};
private educationalLevelsBehaviorSubject: BehaviorSubject<EducationalLevel[]> = new BehaviorSubject<
EducationalLevel[]
private educationalLevelsBehaviorSubject: BehaviorSubject<EducationalLevel[] | null> = new BehaviorSubject<
EducationalLevel[] | null
>(null);
private educationalSubjectsBehaviorSubject: BehaviorSubject<EducationalSubject[]> = new BehaviorSubject<
EducationalSubject[]
private educationalSubjectsBehaviorSubject: BehaviorSubject<EducationalSubject[] | null> = new BehaviorSubject<
EducationalSubject[] | null
>(null);
private organizationsBehaviorSubject: BehaviorSubject<Organization[] | null> = new BehaviorSubject<
Organization[] | null
>(null);
private organizationsBehaviorSubject: BehaviorSubject<Organization[]> = new BehaviorSubject<Organization[]>(null);

public educationalLevels$: Observable<EducationalLevel[]> = this.educationalLevelsBehaviorSubject.asObservable();
public educationalSubjects$: Observable<EducationalSubject[]> =
public educationalLevels$: Observable<EducationalLevel[] | null> =
this.educationalLevelsBehaviorSubject.asObservable();
public educationalSubjects$: Observable<EducationalSubject[] | null> =
this.educationalSubjectsBehaviorSubject.asObservable();
public organizations$: Observable<Organization[]> = this.organizationsBehaviorSubject.asObservable();
public organizations$: Observable<Organization[] | null> = this.organizationsBehaviorSubject.asObservable();

constructor(private http: HttpClient, private translate: TranslateService) {
this.lang = this.translate.currentLang;
Expand All @@ -42,7 +45,7 @@ export class KoodistoService {
switch (error.status) {
case 404:
subject$.next([]);
break;
return throwError('Resource not found; please try again later.');
default:
console.error(error);
return throwError('Something bad happened; please try again later.');
Expand All @@ -56,7 +59,17 @@ export class KoodistoService {
map((educationalLevels: EducationalLevel[]) =>
educationalLevels.filter((educationalLevel: EducationalLevel): boolean => educationalLevel !== null),
),
tap((educationalLevels: EducationalLevel[]) => this.educationalLevelsBehaviorSubject.next(educationalLevels)),
tap((educationalLevels: EducationalLevel[]) =>
this.educationalLevelsBehaviorSubject.next(
educationalLevels.map((level: EducationalLevel) => ({
...level,
children: level.children.map((child: EducationalLevelChild) => ({
...child,
disabled: false,
})),
})),
),
),
catchError((err: any) => of(err)),
);
}
Expand Down
41 changes: 22 additions & 19 deletions aoe-web-frontend/src/app/components/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { Subscription } from 'rxjs';
import { environment } from '../../../environments/environment';
import { textInputValidator } from './../../shared/shared.module';
import { environment } from '@environments/environment';
import { textInputValidator } from '@shared/shared.module';
import { KoodistoService } from '@services/koodisto.service';
import { SearchService } from '@services/search.service';
import { SubjectFilter } from '@models/koodisto/subject-filter';
import { SearchParams } from '@models/search/search-params';
import { EducationalLevel } from '@models/koodisto/educational-level';
Expand All @@ -22,17 +21,16 @@ import { validatorParams } from '@constants/validator-params';
styleUrls: ['./search.component.scss'],
})
export class SearchComponent implements OnInit, OnDestroy {
searchForm: FormGroup;
educationalLevelSubscription: Subscription;
educationalLevels: EducationalLevel[];
educationalSubjectSubscription: Subscription;
educationalSubjects: SubjectFilter[];
learningResourceTypeSubscription: Subscription;
learningResourceTypes: LearningResourceType[];
searchForm: FormGroup = new FormGroup({});
educationalLevelSubscription = new Subscription();
educationalLevels: EducationalLevel[] = [];
educationalSubjectSubscription = new Subscription();
educationalSubjects: SubjectFilter[] = [];
learningResourceTypeSubscription = new Subscription();
learningResourceTypes: LearningResourceType[] = [];
resultsPerPage = 15;

constructor(
private searchSvc: SearchService,
private fb: FormBuilder,
private router: Router,
private koodistoProxySvc: KoodistoService,
Expand All @@ -56,7 +54,7 @@ export class SearchComponent implements OnInit, OnDestroy {
}),
});

this.educationalLevelSubscription = this.koodistoProxySvc.educationalLevels$.subscribe(
this.educationalLevelSubscription = this.koodistoProxySvc.educationalLevelsEnabled$.subscribe(
(levels: EducationalLevel[]) => {
this.educationalLevels = levels;
},
Expand Down Expand Up @@ -106,7 +104,9 @@ export class SearchComponent implements OnInit, OnDestroy {

educationLevelChange(): void {
if (this.educationalLevelsCtrl.value.length > 0) {
const educationLevelKeys = this.educationalLevelsCtrl.value?.map((level) => level.key);
const educationLevelKeys = this.educationalLevelsCtrl.value?.map(
(level: Record<string, string | number>) => level.key,
);

this.educationalSubjects = this.educationalSubjects.filter((subject: SubjectFilter) =>
educationLevelKeys.includes(subject.key),
Expand All @@ -119,23 +119,23 @@ export class SearchComponent implements OnInit, OnDestroy {
setUsedFilters(): void {
const usedFilters: UsedFilter[] = [];

this.educationalLevelsCtrl.value?.forEach((level) => {
this.educationalLevelsCtrl.value?.forEach((level: Record<string | number, string>) => {
usedFilters.push({
key: level.key,
value: level.value,
type: 'educationalLevels',
});
});

this.educationalSubjectsCtrl.value?.forEach((subject) => {
this.educationalSubjectsCtrl.value?.forEach((subject: Record<string | number, string>) => {
usedFilters.push({
key: subject.key.toString(),
value: subject.value,
type: 'educationalSubjects',
});
});

this.learningResourceTypesCtrl.value?.forEach((type) => {
this.learningResourceTypesCtrl.value?.forEach((type: Record<string | number, string>) => {
usedFilters.push({
key: type.key,
value: type.value,
Expand Down Expand Up @@ -170,10 +170,13 @@ export class SearchComponent implements OnInit, OnDestroy {
};

searchParams.keywords = this.keywordsCtrl.value;
searchParams.filters.educationalLevels = this.educationalLevelsCtrl.value?.map((level) => level.key) ?? [];
searchParams.filters.educationalLevels =
this.educationalLevelsCtrl.value?.map((level: Record<string | number, string>) => level.key) ?? [];
searchParams.filters.educationalSubjects =
this.educationalSubjectsCtrl.value?.map((subject) => subject.key.toString()) ?? [];
searchParams.filters.learningResourceTypes = this.learningResourceTypesCtrl.value?.map((type) => type.key) ?? [];
this.educationalSubjectsCtrl.value?.map((subject: Record<string | number, string>) => subject.key.toString()) ??
[];
searchParams.filters.learningResourceTypes =
this.learningResourceTypesCtrl.value?.map((type: Record<string | number, string>) => type.key) ?? [];
searchParams.sort = sortOptions.relevance.value;
searchParams.from = 0;
searchParams.size = this.resultsPerPage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Component, Input } from '@angular/core';
import { SearchParams } from '@models/search/search-params';
import { environment } from '../../../environments/environment';
import { environment } from '@environments/environment';
import { Router } from '@angular/router';
import { UsedFilter } from '@models/search/used-filter';

Expand Down
2 changes: 2 additions & 0 deletions aoe-web-frontend/src/app/constants/educational-level-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const educationalLevelKeys = {
'a2a70a14-b150-4f37-9e20-2bbb71731807',
'14fe3b08-8516-4999-946b-96eb90c2d563',
],
preparatoryEducation: ['64a427b5-3a25-43e4-b976-ccf3f0539b95'],
upperSecondary: ['94f79e1e-10e6-483d-b651-27521f94f7bf', 'fd362a80-9662-48b8-acd1-d8cef520530c'],
vocational: [
'010c6689-5021-4d8e-8c02-68a27cc5a87b',
Expand All @@ -19,6 +20,7 @@ export const educationalLevelKeys = {
'bc25d0e7-3c68-49a1-9329-239dae01fab7',
'087dd008-16db-46e7-b0ee-5cd76c64e990',
'67900499-2356-45a4-b830-3021e73398bc',
'427511b0-7071-46f9-a946-3c4c18d4223c',
],
higherEducation: [
'e5a48ada-3de0-4246-9b8f-32d4ff68e22f',
Expand Down
2 changes: 2 additions & 0 deletions aoe-web-frontend/src/app/constants/koodisto-sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const koodistoSources = {
basicStudySubjects: 'basicStudySubjects',
basicStudyObjectives: 'basicStudyObjectives',
basicStudyContents: 'basicStudyContents',
preparatoryEducationSubjects: 'preparatoryEducationSubjects',
preparatoryEducationObjectives: 'preparatoryEducationObjectives',
upperSecondarySubjects: 'upperSecondarySchoolSubjects',
upperSecondaryObjectives: 'upperSecondarySchoolObjectives',
upperSecondarySubjectsOld: 'upperSecondarySchoolSubjectsOld',
Expand Down
2 changes: 2 additions & 0 deletions aoe-web-frontend/src/app/models/alignment-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface AlignmentObjects {
basicStudySubjects: AlignmentObjectExtended[];
basicStudyObjectives: AlignmentObjectExtended[];
basicStudyContents: AlignmentObjectExtended[];
preparatoryEducationSubjects: AlignmentObjectExtended[];
preparatoryEducationObjectives: AlignmentObjectExtended[];
upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[];
upperSecondarySchoolCoursesOld: AlignmentObjectExtended[];
upperSecondarySchoolObjectives: AlignmentObjectExtended[];
Expand Down
16 changes: 9 additions & 7 deletions aoe-web-frontend/src/app/models/collections/collection-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,37 @@ export interface CollectionForm {
];
earlyChildhoodEducationSubjects: AlignmentObjectExtended[];
earlyChildhoodEducationObjectives: AlignmentObjectExtended[];
earlyChildhoodEducationFramework: string;
earlyChildhoodEducationFramework?: string;
prePrimaryEducationSubjects: AlignmentObjectExtended[];
prePrimaryEducationObjectives: AlignmentObjectExtended[];
prePrimaryEducationFramework: string;
prePrimaryEducationFramework?: string;
basicStudySubjects: AlignmentObjectExtended[];
basicStudyObjectives: AlignmentObjectExtended[];
basicStudyContents: AlignmentObjectExtended[];
basicStudyFramework: string;
basicStudyFramework?: string;
preparatoryEducationSubjects: AlignmentObjectExtended[];
preparatoryEducationObjectives: AlignmentObjectExtended[];
currentUpperSecondarySchoolSelected: boolean;
newUpperSecondarySchoolSelected: boolean;
upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[];
upperSecondarySchoolCoursesOld: AlignmentObjectExtended[];
upperSecondarySchoolObjectives: AlignmentObjectExtended[];
upperSecondarySchoolFramework: string;
upperSecondarySchoolFramework?: string;
upperSecondarySchoolSubjectsNew: AlignmentObjectExtended[];
upperSecondarySchoolModulesNew: AlignmentObjectExtended[];
upperSecondarySchoolObjectivesNew: AlignmentObjectExtended[];
upperSecondarySchoolContentsNew: AlignmentObjectExtended[];
newUpperSecondarySchoolFramework: string;
newUpperSecondarySchoolFramework?: string;
vocationalDegrees: AlignmentObjectExtended[];
vocationalUnits: AlignmentObjectExtended[];
subjectOfCommonUnit: AlignmentObjectExtended[];
vocationalRequirements: AlignmentObjectExtended[];
vocationalEducationFramework: string;
vocationalEducationFramework?: string;
selfMotivatedEducationSubjects: AlignmentObjectExtended[];
selfMotivatedEducationObjectives: AlignmentObjectExtended[];
scienceBranches: AlignmentObjectExtended[];
scienceBranchObjectives: AlignmentObjectExtended[];
higherEducationFramework: string;
higherEducationFramework?: string;
// materials
materials: CollectionFormMaterial[];
materialsAndHeadings: CollectionFormMaterialAndHeading[];
Expand Down
16 changes: 9 additions & 7 deletions aoe-web-frontend/src/app/models/collections/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,35 @@ export interface Collection {
];
earlyChildhoodEducationSubjects: AlignmentObjectExtended[];
earlyChildhoodEducationObjectives: AlignmentObjectExtended[];
earlyChildhoodEducationFramework: string;
earlyChildhoodEducationFramework?: string;
prePrimaryEducationSubjects: AlignmentObjectExtended[];
prePrimaryEducationObjectives: AlignmentObjectExtended[];
prePrimaryEducationFramework: string;
prePrimaryEducationFramework?: string;
basicStudySubjects: AlignmentObjectExtended[];
basicStudyObjectives: AlignmentObjectExtended[];
basicStudyContents: AlignmentObjectExtended[];
basicStudyFramework: string;
basicStudyFramework?: string;
preparatoryEducationSubjects?: AlignmentObjectExtended[];
preparatoryEducationObjectives?: AlignmentObjectExtended[];
upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[];
upperSecondarySchoolCoursesOld: AlignmentObjectExtended[];
upperSecondarySchoolObjectives: AlignmentObjectExtended[];
upperSecondarySchoolFramework: string;
upperSecondarySchoolFramework?: string;
upperSecondarySchoolSubjectsNew: AlignmentObjectExtended[];
upperSecondarySchoolModulesNew: AlignmentObjectExtended[];
upperSecondarySchoolObjectivesNew: AlignmentObjectExtended[];
upperSecondarySchoolContentsNew: AlignmentObjectExtended[];
newUpperSecondarySchoolFramework: string;
newUpperSecondarySchoolFramework?: string;
vocationalDegrees: AlignmentObjectExtended[];
vocationalUnits: AlignmentObjectExtended[];
subjectOfCommonUnit: AlignmentObjectExtended[];
vocationalRequirements: AlignmentObjectExtended[];
vocationalEducationFramework: string;
vocationalEducationFramework?: string;
selfMotivatedEducationSubjects: AlignmentObjectExtended[];
selfMotivatedEducationObjectives: AlignmentObjectExtended[];
scienceBranches: AlignmentObjectExtended[];
scienceBranchObjectives: AlignmentObjectExtended[];
higherEducationFramework: string;
higherEducationFramework?: string;
authors: string[];
thumbnail: string;
}
2 changes: 2 additions & 0 deletions aoe-web-frontend/src/app/models/educational-material-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export interface EducationalMaterialForm {
basicStudyObjectives?: AlignmentObjectExtended[];
basicStudyContents?: AlignmentObjectExtended[];
basicStudyFramework?: string;
preparatoryEducationSubjects?: AlignmentObjectExtended[];
preparatoryEducationObjectives?: AlignmentObjectExtended[];
upperSecondarySchoolSubjectsOld?: AlignmentObjectExtended[];
upperSecondarySchoolCoursesOld?: AlignmentObjectExtended[];
suitsAllUpperSecondarySubjects?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions aoe-web-frontend/src/app/models/educational-material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export interface EducationalMaterial {
basicStudyObjectives: AlignmentObjectExtended[];
basicStudyContents: AlignmentObjectExtended[];
suitsAllBasicStudySubjects: boolean;
preparatoryEducationSubjects?: AlignmentObjectExtended[];
preparatoryEducationObjectives?: AlignmentObjectExtended[];
upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[];
upperSecondarySchoolFrameworks: string[];
upperSecondarySchoolCoursesOld: AlignmentObjectExtended[];
Expand Down
13 changes: 7 additions & 6 deletions aoe-web-frontend/src/app/models/koodisto/educational-level.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export interface EducationalLevel {
key: string;
value: string;
children: [
{
key: string;
value: string;
},
];
children: EducationalLevelChild[];
}

export interface EducationalLevelChild {
key: string;
value: string;
disabled?: boolean;
}
Loading

0 comments on commit 708676a

Please sign in to comment.