diff --git a/explore/src/app/fos/fos.component.html b/explore/src/app/fos/fos.component.html index 5c3c01dd..38d9ad17 100644 --- a/explore/src/app/fos/fos.component.html +++ b/explore/src/app/fos/fos.component.html @@ -7,7 +7,7 @@
-

Fields of Science and Technology.

+

Fields of Science.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
@@ -21,40 +21,80 @@
- +
-
- +
+
-
-
-
-
- - {{item.id}} - + +
+
Search results for '{{keyword}}'
+ + + + {{keyword}} + + + + +
+
+ +
+
+ +
+
+

{{fos[index].id}}

+
+
+
+
+

{{child.id}}

+
+ {{subChild.id}} +
+
+
+
-
-
-

{{fos[index].id}}

-
-
-
-
-

{{child.id}}

-
- {{subChild.id}} +
+ + +
+ +
+

{{item.id}}

+
+
+

{{subItem.id}}

+
+ {{subSubItem.id}}
-
-
+
+ + +
+

No results were found.

+
+
-
+
\ No newline at end of file diff --git a/explore/src/app/fos/fos.component.ts b/explore/src/app/fos/fos.component.ts index 8bb4145c..53882acb 100644 --- a/explore/src/app/fos/fos.component.ts +++ b/explore/src/app/fos/fos.component.ts @@ -1,10 +1,12 @@ import {HttpClient} from "@angular/common/http"; -import {Component, OnDestroy, OnInit} from "@angular/core"; +import {Component, OnDestroy, OnInit, ViewChild} from "@angular/core"; import {Subscription} from "rxjs"; import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component"; import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties"; import {properties} from "src/environments/environment"; +import { FormBuilder, FormControl } from "@angular/forms"; +import { isTemplateExpression } from "typescript"; @Component({ selector: 'fos', @@ -15,6 +17,17 @@ export class FosComponent implements OnInit, OnDestroy { public fos: any = []; public index: number = 0; + + public keywordControl: FormControl; + public keyword: string = null; + + public matchLevel1: boolean = false; + public matchLevel2: boolean = false; + public matchLevel3: boolean = false; + public level1Results = []; + public level2Results = []; + public level3Results = []; + properties: EnvProperties = properties; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'FOS'}]; @@ -22,13 +35,15 @@ export class FosComponent implements OnInit, OnDestroy { subscriptions: Subscription[] = []; constructor( - private httpClient: HttpClient + private httpClient: HttpClient, + private fb: FormBuilder ) {} ngOnInit() { this.httpClient.get('/assets/vocabulary/fos.json').subscribe(data => { this.fos = data['fos']; }); + this.keywordControl = this.fb.control(''); } public ngOnDestroy() { @@ -39,6 +54,71 @@ export class FosComponent implements OnInit, OnDestroy { changeDisplayedFos(i) { this.index = i; - // console.log(this.fos[this.index]); + } + + onSubmit() { + this.matchLevel1 = false; + this.matchLevel2 = false; + this.matchLevel3 = false; + if(this.keywordControl.value) { + this.keyword = this.keywordControl.value; + // console.log(this.keyword); + this.keywordControl.setValue(''); + // logic to find matches in all 3 levels through nested loops? + this.findMatches(); + } + } + + findMatches() { + console.log(this.keyword); + this.level1Results = []; + this.level2Results = []; + this.level3Results = []; + // 1st level search + if(this.fos.length) { + this.fos.forEach(item => { + if(item.id.includes(this.keyword)) { + console.log('1st level match: ' + item.id); + this.matchLevel1 = true; + this.level1Results.push(item); + // 2nd level search + if(item.children.length) { + item.children.forEach(subItem => { + if(subItem.id.includes(this.keyword)) { + console.log('2nd level match: ' + subItem.id); + this.matchLevel2 = true; + this.level2Results.push(subItem); + // 3rd level search + if(subItem.children.length){ + subItem.children.forEach(subSubItem => { + if(subSubItem.id.includes(this.keyword)) { + console.log('3rd level match: ' + subSubItem.id); + this.matchLevel3 = true; + this.level3Results.push(subSubItem); + } + }) + } + } + }); + } + } + }); + console.log(this.level1Results); + console.log(this.level2Results); + console.log(this.level3Results); + } + + // filtering + // if(this.fos.length) { + // const level1Matches = this.fos.filter(item => item.id.includes(this.keyword)); + // console.log(level1Matches); + // } + } + + clearKeyword() { + this.keyword = null; + this.matchLevel1 = false; + this.matchLevel2 = false; + this.matchLevel3 = false; } } \ No newline at end of file diff --git a/explore/src/app/fos/fos.module.ts b/explore/src/app/fos/fos.module.ts index 55b9acef..2673f856 100644 --- a/explore/src/app/fos/fos.module.ts +++ b/explore/src/app/fos/fos.module.ts @@ -7,11 +7,14 @@ import {BreadcrumbsModule} from "../openaireLibrary/utils/breadcrumbs/breadcrumb import {FosRoutingModule} from './fos-routing.module'; import {FosComponent} from './fos.component'; +import {IconsModule} from "../openaireLibrary/utils/icons/icons.module"; +import {SearchInputModule} from "../openaireLibrary/sharedComponents/search-input/search-input.module"; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, - FosRoutingModule, BreadcrumbsModule + FosRoutingModule, BreadcrumbsModule, IconsModule, + SearchInputModule ], declarations: [ FosComponent diff --git a/explore/src/app/openaireLibrary b/explore/src/app/openaireLibrary index 0c5483ac..95e382fc 160000 --- a/explore/src/app/openaireLibrary +++ b/explore/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 0c5483ac9b0c0f7d1902ab4dbec51d14495e956a +Subproject commit 95e382fc6273017c4739bf4e3a9603d720f3c253 diff --git a/explore/src/app/sdg/sdg.component.html b/explore/src/app/sdg/sdg.component.html index b5980226..72b39bf2 100644 --- a/explore/src/app/sdg/sdg.component.html +++ b/explore/src/app/sdg/sdg.component.html @@ -34,7 +34,15 @@
diff --git a/explore/src/assets/explore-assets/fos-hero-img.svg b/explore/src/assets/explore-assets/fos-hero-img.svg new file mode 100644 index 00000000..64b8ab87 --- /dev/null +++ b/explore/src/assets/explore-assets/fos-hero-img.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/explore/src/assets/openaire-theme b/explore/src/assets/openaire-theme index e552bc1f..09341b18 160000 --- a/explore/src/assets/openaire-theme +++ b/explore/src/assets/openaire-theme @@ -1 +1 @@ -Subproject commit e552bc1f3041ff03719538a7abf08aa04d2a4182 +Subproject commit 09341b18896d4582455a99ef50944bd544bb10df