diff --git a/explore/src/app/fos/fos.component.html b/explore/src/app/fos/fos.component.html index b8e77672..024a7780 100644 --- a/explore/src/app/fos/fos.component.html +++ b/explore/src/app/fos/fos.component.html @@ -36,107 +36,93 @@ -
-
-
-
+
+
+
- -
-
Search results for:
- - - {{keyword}} - - - - - -
-
- +
-
+ - - -
- -
-

- - -

-
-
-

- - -

-
- - -
-
-
-
-
- -
+ +

No results were found.

diff --git a/explore/src/app/fos/fos.component.ts b/explore/src/app/fos/fos.component.ts index dc588ea3..5bcd2765 100644 --- a/explore/src/app/fos/fos.component.ts +++ b/explore/src/app/fos/fos.component.ts @@ -12,6 +12,7 @@ import {Location} from "@angular/common"; import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service"; import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service"; +import {debounceTime, distinctUntilChanged} from "rxjs/operators"; @Component({ selector: 'fos', @@ -25,10 +26,10 @@ export class FosComponent implements OnInit, OnDestroy { public fos: any[] = []; public fosOptions: string[] = []; - public index: number = 0; + public activeSection: string; public keywordControl: FormControl; - public keyword: string = null; + public keyword: string; public viewResults = []; @@ -60,17 +61,21 @@ export class FosComponent implements OnInit, OnDestroy { this.updateUrl(this.url); this.updateTitle(this.pageTitle); this.updateDescription(this.pageDescription); - this.keywordControl = this.fb.control(''); this.httpClient.get(properties.domain+'/assets/vocabulary/fos.json').subscribe(data => { this.fos = data['fos']; this.convertFosToOptions(); - this.subscriptions.push(this.route.queryParams.subscribe(params => { - if(params.keyword) { - this.keywordControl.setValue(params.keyword); - this.keyword = this.keywordControl.value; - this.findMatches(); + this.subscriptions.push(this.route.fragment.subscribe(fragment => { + if(fragment) { + this.activeSection = fragment; + } else { + this.activeSection = this.fos[0].id; } })); + this.keywordControl = this.fb.control(''); + this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => { + this.keyword = value; + this.findMatches(this.keyword); + })); }); } @@ -79,19 +84,6 @@ export class FosComponent implements OnInit, OnDestroy { sub.unsubscribe(); } } - - changeDisplayedFos(i) { - this.index = i; - } - - onSubmit() { - if(this.keywordControl.value) { - this.keyword = this.keywordControl.value; - // TODO: router.navigate(); - this.location.go(window.location.pathname + '?keyword=' + this.keyword); - this.findMatches(); - } - } convertFosToOptions() { this.fosOptions = []; @@ -110,14 +102,14 @@ export class FosComponent implements OnInit, OnDestroy { }); } - findMatches() { + findMatches(value: string) { this.viewResults = JSON.parse(JSON.stringify(this.fos)); let matchLevel1: boolean = false; let matchLevel2: boolean = false; // 1st level search if(this.viewResults.length) { this.viewResults = this.viewResults.filter(item => { - if(item.id.includes(this.keyword.toLowerCase())) { + if(item.id.includes(value?.toLowerCase())) { matchLevel1 = true; } else { matchLevel1 = false; @@ -125,14 +117,14 @@ export class FosComponent implements OnInit, OnDestroy { // // 2nd level search if(item.children?.length && !matchLevel1) { item.children = item.children.filter(subItem => { - if(subItem.id.includes(this.keyword.toLowerCase())) { + if(subItem.id.includes(value?.toLowerCase())) { matchLevel2 = true; } else { matchLevel2 = false; } // 3rd level search if(subItem.children?.length && !matchLevel2) { - subItem.children = subItem.children.filter(subSubItem => subSubItem.id.includes(this.keyword.toLowerCase())); + subItem.children = subItem.children.filter(subSubItem => subSubItem.id.includes(value?.toLowerCase())); } return subItem.children?.length > 0 || matchLevel2; }); @@ -150,12 +142,6 @@ export class FosComponent implements OnInit, OnDestroy { } } - clearKeyword() { - this.keyword = null; - this.keywordControl.setValue(''); - this.location.go(window.location.pathname); - } - public urlEncodeAndQuote(str: string): string { return StringUtils.quote(StringUtils.URIEncode(str)); } diff --git a/explore/src/app/openaireLibrary b/explore/src/app/openaireLibrary index 9ac7ed93..d6c54949 160000 --- a/explore/src/app/openaireLibrary +++ b/explore/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 9ac7ed93d4420cf904609b1fbfbe341cc4ae8836 +Subproject commit d6c54949df4c0106ad0f290fcc1c245a9324015d diff --git a/explore/src/environments/environment.ts b/explore/src/environments/environment.ts index e4260d95..af794914 100644 --- a/explore/src/environments/environment.ts +++ b/explore/src/environments/environment.ts @@ -65,7 +65,7 @@ export let properties: EnvProperties = { cacheUrl: "http://dl170.madgik.di.uoa.gr:3000/get?url=", - adminToolsAPIURL: "http://duffy.di.uoa.gr:8080/uoa-admin-tools/", + adminToolsAPIURL: "http://duffy.di.uoa.gr:19280/uoa-admin-tools/", adminToolsCommunity: "openaire", datasourcesAPI: "https://beta.services.openaire.eu/openaire/ds/api/",