Skip to content

Commit

Permalink
Merge fix from 'usnistgov/integration' into rel/1.3.X (view metadata,…
Browse files Browse the repository at this point in the history
… homepage)
  • Loading branch information
RayPlante committed Apr 13, 2020
2 parents e33484b + d055560 commit c9192d6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
8 changes: 4 additions & 4 deletions angular/src/app/landing/landing.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@
Visit Home Page
</button>
</span>
<ng-template #visitHomeOnServer>Visit Home Page</ng-template>
<ng-template #visitHomeOnServer><a href="{{record.landingPage}}">Visit Home Page</a></ng-template>
</span>
</div>
</div>

<div class="ui-g">
<div class="ui-g-12 ui-md-12 ui-lg-12 ui-sm-12">
<div [hidden]="metadata">
<div [hidden]="showMetadata">
<app-description [record]="record" [inBrowser]="inBrowser"></app-description>
</div>
<app-topic [record]="record" [inBrowser]="inBrowser"></app-topic>
<app-keyword [record]="record" [inBrowser]="inBrowser"></app-keyword>
<p></p>
<description-resources [record]="record" [files]="files"
[metadata]="metadata" [inBrowser]="inBrowser" [ediid]="ediid" [editEnabled]="editEnabled"></description-resources>
[metadata]="showMetadata" [inBrowser]="inBrowser" [ediid]="ediid" [editEnabled]="editEnabled"></description-resources>
<metadata-detail [record]="record" [serviceApi]="serviceApi" [inBrowser]="inBrowser"
[metadata]="metadata">
[metadata]="showMetadata">
</metadata-detail>
</div>
<div *ngIf="record.length !== 0 && inBrowser">
Expand Down
15 changes: 15 additions & 0 deletions angular/src/app/landing/landing.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,19 @@ describe('LandingComponent', () => {
let el = cmpel.querySelector("h2");
expect(el.textContent).toContain(nrd.title);
});

it("can detect PDR landing pages", function() {
setupComponent();
expect(component.displayHomePageLink()).toBeTruthy();
component.record.landingPage = "https://data.nist.gov/od/id/mds2-111";
expect(component.displayHomePageLink()).toBeFalsy();
component.record.landingPage = "https://testdata.nist.gov/od/id/EBC9DB05EDEA5B0EE043065706812DF81";
expect(component.displayHomePageLink()).toBeFalsy();
component.record.landingPage = "https://oardev.nist.gov/od/id/EBC9DB05EDEA5B0EE043065706812DF81";
expect(component.displayHomePageLink()).toBeFalsy();
component.record.landingPage = "https://localhost/od/id/EBC9DB05EDEA5B0EE043065706812DF81";
expect(component.displayHomePageLink()).toBeFalsy();
component.record.landingPage = "https://www.nist.gov/data"
expect(component.displayHomePageLink()).toBeTruthy();
});
});
13 changes: 5 additions & 8 deletions angular/src/app/landing/landing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export class LandingComponent implements OnInit, OnChanges {
isCopied: boolean = false;
distdownload: string = '';
serviceApi: string = '';
metadata: boolean = false;
private files: TreeNode[] = [];
pdrApi: string = '';
isResultAvailable: boolean = true;
Expand All @@ -134,6 +133,9 @@ export class LandingComponent implements OnInit, OnChanges {
@Input() requestId: string = null; // the ID used in the URL to access this page
@Input() inBrowser: boolean = false;

// this will be removed in the next restructure iteration
@Input() showMetadata: boolean = false;

ediid: string = null;

/**
Expand Down Expand Up @@ -204,7 +206,7 @@ export class LandingComponent implements OnInit, OnChanges {
}

viewmetadata() {
this.metadata = true;
this.showMetadata = true;
this.similarResources = false;
}

Expand Down Expand Up @@ -458,12 +460,7 @@ export class LandingComponent implements OnInit, OnChanges {
if (this.record.landingPage == null || this.record.landingPage == undefined) {
return false;
}
var url = 'od/id/' + this.ediid;
if (this.record.landingPage.search(url) > -1) {
return false;
} else {
return true;
}
return (this.record.landingPage.search(/^https?:\/\/[\w\.\-]+\/od\/id\//) < 0)
}

visitHomePage(url: string, event, title) {
Expand Down
3 changes: 2 additions & 1 deletion angular/src/app/landing/landingpage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<!-- landing page content -->
<div class="ui-g-10 ui-md-10 ui-lg-10 ui-sm-12">

<app-landing [record]="md" [inBrowser]="inBrowser" [requestId]="reqId"></app-landing>
<app-landing [record]="md" [inBrowser]="inBrowser" [requestId]="reqId"
[showMetadata]="showMetadata"></app-landing>

</div>

Expand Down
4 changes: 4 additions & 0 deletions angular/src/app/landing/landingpage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export class LandingPageComponent implements OnInit, AfterViewInit {
citationVisible: boolean = false;
editEnabled: boolean = false;

// this will be removed in next restructure
showMetadata = false;

/**
* create the component.
* @param route the requested URL path to be fulfilled with this view
Expand Down Expand Up @@ -186,6 +189,7 @@ export class LandingPageComponent implements OnInit, AfterViewInit {
}

goToSection(sectionId: string) {
this.showMetadata = (sectionId == "metadata");
if (sectionId)
this.router.navigate(['/od/id/', this.reqId], { fragment: sectionId });
else
Expand Down

0 comments on commit c9192d6

Please sign in to comment.