Skip to content

Commit

Permalink
Topics, keywords - bubbles; Filters layout changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanlin2018 committed Aug 9, 2024
1 parent 5da7f50 commit d981521
Show file tree
Hide file tree
Showing 19 changed files with 943 additions and 202 deletions.
22 changes: 14 additions & 8 deletions angular/src/app/_helpers/fakeBackendInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class FakeBackendInterceptor implements HttpInterceptor {
const sampleData: any = require('../../assets/sample-data/semi-conductors.json');
// const sampleCollection: any = require('../../assets/sample-data/semiconductors-collection.json');
const sampleCollection: any = require('../../assets/sample-data/semiconductor-realdata.json');

const pdr0_0002: any = require('../../assets/sample-data/pdr0-0002-new.json');

const sampleCollection2: any = require('../../assets/sample-data/collectionTestData.json');

Expand Down Expand Up @@ -64,15 +66,15 @@ export class FakeBackendInterceptor implements HttpInterceptor {
return of(new HttpResponse({ status: 200, body: fields }));
}

if (request.url.indexOf('isPartOf') > -1 && request.url.indexOf('pdr0-0002') > -1 && request.method === 'GET') {
console.log("Getting semiconductors collections.....")
return of(new HttpResponse({ status: 200, body: sampleCollection }));
}
// if (request.url.indexOf('isPartOf') > -1 && request.url.indexOf('pdr0-0002') > -1 && request.method === 'GET') {
// console.log("Getting semiconductors collections.....")
// return of(new HttpResponse({ status: 200, body: sampleCollection }));
// }

if (request.url.indexOf('pdr0-0002') > -1 && request.method === 'GET') {
console.log("Getting semiconductors.....")
return of(new HttpResponse({ status: 200, body: sampleData }));
}
// if (request.url.indexOf('pdr0-0002') > -1 && request.method === 'GET') {
// console.log("Getting semiconductors.....")
// return of(new HttpResponse({ status: 200, body: sampleData }));
// }

if (request.url.indexOf('usagemetrics/files') > -1 && request.method === 'GET')
{
Expand Down Expand Up @@ -153,6 +155,10 @@ export class FakeBackendInterceptor implements HttpInterceptor {
return of(new HttpResponse({ status: 200, body: sampleCollection2 }));
}

if (request.url.indexOf('oardev.nist.gov/od/id/pdr0-0002') > -1 && request.method === 'GET') {
console.log("Getting CHIPS pdr0-0002.....")
return of(new HttpResponse({ status: 200, body: pdr0_0002 }));
}

// return 401 not authorised if token is null or invalid
// if (request.url.indexOf('auth/_perm/') > -1 && request.method === 'GET') {
Expand Down
24 changes: 17 additions & 7 deletions angular/src/app/landing/filters/filters.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<i class="faa faa-spinner faa-spin faa-stack-2x" [style.color]="defaultColor" aria-hidden="true"></i>
</div>

<div style="padding-left: -1em;" *ngIf="isActive && !searching">
<div style="padding-left: -1em;padding-right: -2em;" *ngIf="isActive && !searching">
<!-- Loop through all themes -->
<div *ngFor="let key of collectionOrder">
<app-taxonomy [collectionThemesTree]="allCollections[key].theme?.collectionThemesTree" [collection]="key"
[backgroundColor]="lighterColor" [defaultColor]="defaultColor"
<app-taxonomy [collectionThemesTree]="allCollections[key].theme?.collectionThemesTree" [collection]="key" [isCollection]="true"
[backgroundColor]="lighterColor" [defaultColor]="defaultColor" [collectionNodeExpanded]="true"
(filterString)="updateFilterString($event, key)">
</app-taxonomy>
</div>
Expand All @@ -39,6 +39,11 @@
<div style="width: 100%;">
<div [@expandOptions]="MoreOptionsDisplayed ? 'collapsed':'expanded'">
<!-- Type of Resource -->
<app-taxonomy [collectionThemesTree]="resourceTypeTree" collection="@type" [isCollection]="false"
[backgroundColor]="lighterColor" [defaultColor]="defaultColor" [collectionNodeExpanded]="false"
(filterString)="updateFilterString($event, '@type')">
</app-taxonomy>
<!--
<div class="filter-checkbox bottom-line">
<p-tree [value]="resourceTypeTree" selectionMode="checkbox" [style]="ResourceTypeStyle"
[(selection)]="selectedResourceTypeNode" (onNodeUnselect)="filterResults()"
Expand All @@ -57,16 +62,21 @@
</div>
</ng-template>
</p-tree>
</div>
</div> -->

<!-- Components (Record has) -->
<div class="filter-checkbox bottom-line" *ngIf="componentsTree.length > 0">
<p-tree [value]="componentsTree" selectionMode="checkbox" [style]="recordHasStyle"
<app-taxonomy [collectionThemesTree]="componentsTree" collection="components.@type" [isCollection]="false"
[backgroundColor]="lighterColor" [defaultColor]="defaultColor" [collectionNodeExpanded]="false"
(filterString)="updateFilterString($event, 'components.@type')">
</app-taxonomy>

<!-- <p-tree [value]="componentsTree" selectionMode="checkbox" [style]="recordHasStyle"
[(selection)]="selectedComponentsNode" (onNodeUnselect)="filterResults()"
(onNodeSelect)="filterResults()">
<ng-template let-node pTemplate="default">
<div class="text-nowrap" data-toggle="tooltip" [title]="filterTooltip(node)">
<span *ngIf="node.label.split('---')[1] !=''; else header3">
<span *ngIf="node.count > 0; else header3">
{{node.label.split("---")[0]}}&nbsp;</span>
<ng-template #header3>
<span><b> {{node.label.split("---")[0]}}&nbsp;</b></span>
Expand All @@ -77,7 +87,7 @@
{{node.count}}</span>
</div>
</ng-template>
</p-tree>
</p-tree> -->
</div>
</div>
</div>
Expand Down
195 changes: 105 additions & 90 deletions angular/src/app/landing/filters/filters.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,107 @@ export class FiltersComponent implements OnInit {
this.filterResults();
}


/**
* Form the filter string and refresh the result page
*/
filterResults() {
let lFilterString: string = "";
this.selectedThemes = [];
this.selectedComponents = [];
this.selectedResourceType = [];
let componentSelected: boolean = false;
let resourceTypesSelected: boolean = false;
let compType = '';
let resourceType = '';

// Resource type
// if (this.selectedResourceTypeNode.length > 0) {
// lFilterString += "@type=";

// for (let res of this.selectedResourceTypeNode) {
// if (res && typeof res.data !== 'undefined' && res.data !== 'undefined') {
// resourceTypesSelected = true;
// this.selectedResourceType.push(res.data);
// resourceType += res.data[0] + ',';

// lFilterString += res.data[0].replace(/\s/g, "") + ",";
// }
// }

// lFilterString = this.removeEndingComma(lFilterString);
// }

if(this.filterStrings["@type"]) {
if(lFilterString != '') lFilterString += "&";
lFilterString += this.filterStrings["@type"];
lFilterString = this.removeEndingComma(lFilterString);
}

for(let col of this.collectionOrder) {
if(this.filterStrings[col]) {
if(lFilterString != '') lFilterString += "&";
lFilterString += this.filterStrings[col];
lFilterString = this.removeEndingComma(lFilterString);
}
}

// Record has
// if (this.selectedComponentsNode.length > 0) {
// if(lFilterString != '') lFilterString += "&";

// lFilterString += "components.@type=";

// for (let comp of this.selectedComponentsNode) {
// if (comp != 'undefined' && typeof comp.data !== 'undefined' && comp.data !== 'undefined') {
// componentSelected = true;
// this.selectedComponents.push(comp.data);
// compType += comp.data[0] + ',';

// lFilterString += comp.data[0].replace(/\s/g, "") + ",";
// }
// }
// }

if(this.filterStrings["components.@type"]) {
if(lFilterString != '') lFilterString += "&";
lFilterString += this.filterStrings["components.@type"];
lFilterString = this.removeEndingComma(lFilterString);
}

// lFilterString = this.removeEndingComma(lFilterString);

// Authors and contributors
if (this.selectedAuthor.length > 0) {
if(lFilterString != '') lFilterString += "&";

lFilterString += "contactPoint.fn=";

for (let author of this.selectedAuthor) {
lFilterString += author + ",";
}
}

lFilterString = this.removeEndingComma(lFilterString);

// Keywords
if (this.selectedKeywords.length > 0) {
if(lFilterString != '') lFilterString += "&";

lFilterString += "keyword=";
for (let keyword of this.selectedKeywords) {
lFilterString += this.suggestedKeywordsLkup[keyword] + ",";
}
}

lFilterString = this.removeEndingComma(lFilterString);
if(!lFilterString) lFilterString = "NoFilter";

// console.log('lFilterString', lFilterString);
this.filterString.emit(lFilterString);
}


/**
* If search value changed, clear the filters and refresh the search result.
* @param changes - changed detected
Expand Down Expand Up @@ -385,7 +486,7 @@ export class FiltersComponent implements OnInit {
compNoData = true;
this.componentsWithCount = [];
this.componentsTree = [{
label: 'Record has -',
label: 'Record has',
"expanded": true,
children: this.componentsWithCount,
}];
Expand Down Expand Up @@ -430,14 +531,14 @@ export class FiltersComponent implements OnInit {


this.resourceTypeTree = [{
label: 'Type of Resource -',
label: 'Type of Resource',
"expanded": false,
children: this.resourceTypesWithCount
}];

if (!compNoData) {
this.componentsTree = [{
label: 'Record has -',
label: 'Record has',
"expanded": false,
children: this.componentsWithCount,
}];
Expand Down Expand Up @@ -468,92 +569,6 @@ export class FiltersComponent implements OnInit {
this.searching = false;
}

/**
* Form the filter string and refresh the result page
*/
filterResults() {
let lFilterString: string = "";
this.selectedThemes = [];
this.selectedComponents = [];
this.selectedResourceType = [];
let componentSelected: boolean = false;
let resourceTypesSelected: boolean = false;
let compType = '';
let resourceType = '';

// Resource type
if (this.selectedResourceTypeNode.length > 0) {
lFilterString += "@type=";

for (let res of this.selectedResourceTypeNode) {
if (res && typeof res.data !== 'undefined' && res.data !== 'undefined') {
resourceTypesSelected = true;
this.selectedResourceType.push(res.data);
resourceType += res.data + ',';

lFilterString += res.data.replace(/\s/g, "") + ",";
}
}

lFilterString = this.removeEndingComma(lFilterString);
}

for(let col of this.collectionOrder) {
if(this.filterStrings[col]) {
lFilterString += this.filterStrings[col];
lFilterString = this.removeEndingComma(lFilterString);
}
}

// Record has
if (this.selectedComponentsNode.length > 0) {
if(lFilterString != '') lFilterString += "&";

lFilterString += "components.@type=";

for (let comp of this.selectedComponentsNode) {
if (comp != 'undefined' && typeof comp.data !== 'undefined' && comp.data !== 'undefined') {
componentSelected = true;
this.selectedComponents.push(comp.data);
compType += comp.data + ',';

lFilterString += comp.data.replace(/\s/g, "") + ",";
}
}
}

lFilterString = this.removeEndingComma(lFilterString);

// Authors and contributors
if (this.selectedAuthor.length > 0) {
if(lFilterString != '') lFilterString += "&";

lFilterString += "contactPoint.fn=";

for (let author of this.selectedAuthor) {
lFilterString += author + ",";
}
}

lFilterString = this.removeEndingComma(lFilterString);

// Keywords
if (this.selectedKeywords.length > 0) {
if(lFilterString != '') lFilterString += "&";

lFilterString += "keyword=";
for (let keyword of this.selectedKeywords) {
lFilterString += this.suggestedKeywordsLkup[keyword] + ",";
}
}

lFilterString = this.removeEndingComma(lFilterString);
if(!lFilterString) lFilterString = "NoFilter";

console.log('lFilterString', lFilterString);
this.filterString.emit(lFilterString);
}

/**
* Remove the ending comma of the given string
* @param inputrString
Expand Down Expand Up @@ -976,7 +991,7 @@ export class FiltersComponent implements OnInit {
allThemes[Collections.FORENSICS].push({ label: topicLabel, value: data });
allThemesArray[Collections.FORENSICS].push(topicLabel);
}
}else{
}else if(topic['scheme'].indexOf(this.taxonomyURI[Collections.DEFAULT]) >= 0){
topicLabel = topics[0];

if (allThemesArray[Collections.DEFAULT].indexOf(topicLabel) < 0) {
Expand Down
4 changes: 4 additions & 0 deletions angular/src/app/landing/keyword/keyword.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.ind {
padding-left: 0px;
}
.ind:first-line {padding-left:0px !important;}
Loading

0 comments on commit d981521

Please sign in to comment.