Skip to content

Commit 5c0f2a8

Browse files
committed
feat: customizable footer message
1 parent 446b310 commit 5c0f2a8

21 files changed

Lines changed: 93 additions & 38 deletions

src/app/app-config.service.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ describe("AppConfigService", () => {
3838
accessDataHref: "test-access",
3939
accessInstructions: "test-instructions",
4040
scicatBaseUrl: "test-scicat",
41-
showLogoBanner: true,
4241
logoBanner: "test-logo",
4342
lbBaseUrl: "test-lb",
4443
statusMessage: "test-status",
@@ -65,7 +64,6 @@ describe("AppConfigService", () => {
6564
accessDataHref: "test-access",
6665
accessInstructions: "test-instructions",
6766
scicatBaseUrl: "test-scicat",
68-
showLogoBanner: true,
6967
logoBanner: "test-logo",
7068
lbBaseUrl: "test-lb",
7169
};

src/app/app-config.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export interface AppConfig {
1717
accessDataHref: string;
1818
accessInstructions: string;
1919
scicatBaseUrl: string;
20-
showLogoBanner: boolean;
2120
logoBanner: string | null;
2221
logoWidth?: string;
2322
retrieveToEmail: RetrieveDestinations | undefined;
2423
lbBaseUrl: string | null;
2524
statusMessage: string;
2625
statusCode: "INFO" | "WARN" | "NONE";
2726
contactEmail: string;
27+
footerMessage?: FooterMessage;
2828
}
2929

3030
export class RetrieveDestinations {
@@ -34,6 +34,16 @@ export class RetrieveDestinations {
3434
confirmMessage: string | undefined;
3535
}
3636

37+
export interface FooterMessage {
38+
text: string;
39+
links: FooterMessageLink[];
40+
}
41+
42+
export interface FooterMessageLink {
43+
label: string;
44+
url: string;
45+
}
46+
3747
@Injectable({ providedIn: "root" })
3848
export class AppConfigService {
3949
private appConfig: AppConfig = {} as AppConfig;

src/app/app.component.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
<router-outlet></router-outlet>
1616

1717
<footer class="footer">
18-
<mat-toolbar class="logo-banner" *ngIf="config.showLogoBanner">
19-
<img src="../assets/{{ config.logoBanner }}" width="{{ config.logoWidth }}" alt="logo_banner" />
20-
</mat-toolbar>
21-
2218
<address *ngIf="config.contactEmail">
2319
If you have any questions or need help, please contact <a href="mailto:{{ config.contactEmail }}">{{
2420
config.contactEmail }}</a>.
2521
</address>
22+
23+
<div class="footer-links" *ngIf="config.footerMessage as footerMessage">
24+
<span *ngIf="footerMessage.text">{{ footerMessage.text }} </span>
25+
<ng-container *ngFor="let link of footerMessage.links; let last = last">
26+
<a [href]="link.url">{{ link.label }}</a><span *ngIf="!last"> | </span>
27+
</ng-container>
28+
</div>
2629
</footer>

src/app/app.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
background-color: var(--theme-primary-default-contrast);
2222
}
2323

24-
address {
24+
.footer-links, address {
2525
font-size: 16px;
2626
padding: 0.5em;
2727
background-color: whitesmoke;

src/app/app.component.spec.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ describe("AppComponent", () => {
3030
expect(app).toBeTruthy();
3131
});
3232

33-
it(`should have as title 'ESS Public Data Repository test'`, () => {
33+
it("should set the title from the configured facility", () => {
3434
const fixture = TestBed.createComponent(AppComponent);
3535
const app = fixture.componentInstance;
36-
expect(app.title).toEqual("ESS Public Data Repository test");
36+
expect(app.title).toEqual("THE_FACILITY Public Data Repository test");
3737
});
3838

3939
it(`should test app config values'`, fakeAsync(() => {
4040
const fixture = TestBed.createComponent(AppComponent);
4141
const app = fixture.componentInstance;
4242
fixture.detectChanges();
43-
expect(app.config.scicatBaseUrl).toEqual("https://scicat.esss.se");
44-
expect(app.config.lbBaseUrl).toEqual("https://scicat.esss.se/api");
45-
expect(LoopBackConfig.getPath()).toEqual("https://scicat.esss.se/api");
43+
expect(app.config.scicatBaseUrl).toEqual("https://example.com/scicat");
44+
expect(app.config.lbBaseUrl).toEqual("https://example.com/api");
45+
expect(LoopBackConfig.getPath()).toEqual("https://example.com/api");
4646
}));
4747

4848
it(`should navigate to home when clicking the title'`, () => {
@@ -58,4 +58,25 @@ describe("AppComponent", () => {
5858
titleEl.nativeElement.click();
5959
expect(navigateSpy).toHaveBeenCalledWith(["/"]);
6060
});
61+
62+
it("should render footer message links from config", () => {
63+
const fixture = TestBed.createComponent(AppComponent);
64+
fixture.detectChanges();
65+
66+
const footerLinks = fixture.debugElement.query(By.css(".footer-links"));
67+
const anchors = footerLinks.queryAll(By.css("a"));
68+
69+
expect(footerLinks.nativeElement.textContent).toContain(
70+
"For more information visit:",
71+
);
72+
expect(anchors.length).toBe(2);
73+
expect(anchors[0].nativeElement.textContent).toBe("Data policy");
74+
expect(anchors[0].nativeElement.href).toBe(
75+
"https://example.com/data-policy",
76+
);
77+
expect(anchors[1].nativeElement.textContent).toBe("Documentation");
78+
expect(anchors[1].nativeElement.href).toBe(
79+
"https://example.com/documentation",
80+
);
81+
});
6182
});

src/app/publisheddata-details/publisheddata-details.component.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("PublisheddataDetailsComponent", () => {
2424
let component: PublisheddataDetailsComponent;
2525
let fixture: ComponentFixture<PublisheddataDetailsComponent>;
2626

27-
const scicatBaseUrl = "https://scicat.esss.se";
27+
const scicatBaseUrl = "https://example.com/scicat";
2828

2929
beforeEach(waitForAsync(() => {
3030
TestBed.configureTestingModule({
@@ -87,8 +87,7 @@ describe("PublisheddataDetailsComponent", () => {
8787
});
8888

8989
it("should return true if dataDescription is URL", () => {
90-
const dataDescription =
91-
"https://github.com/ess-dmsc/ess_file_formats/wiki/NeXus";
90+
const dataDescription = "https://example.com/dataset-description";
9291

9392
const isUrl = component.isUrl(dataDescription);
9493

src/app/shared/MockStubs.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,32 @@ export class MockAppConfigService extends AppConfigService {
107107
production: false,
108108
accessDataHref: "someurl",
109109
directMongoAccess: true,
110-
facility: "ess",
110+
facility: "the_facility",
111111
accessInstructions:
112112
"Instructions: Login with brightness username and password",
113-
scicatBaseUrl: "https://scicat.esss.se",
114-
lbBaseUrl: "https://scicat.esss.se/api",
113+
scicatBaseUrl: "https://example.com/scicat",
114+
lbBaseUrl: "https://example.com/api",
115115
retrieveToEmail: {
116116
option: "URLs",
117117
username: "lp_service",
118118
title: "An email",
119119
confirmMessage: "aMessage",
120120
},
121-
showLogoBanner: true,
122121
oaiProviderRoute: null,
123122
logoBanner: "",
123+
footerMessage: {
124+
text: "For more information visit:",
125+
links: [
126+
{
127+
label: "Data policy",
128+
url: "https://example.com/data-policy",
129+
},
130+
{
131+
label: "Documentation",
132+
url: "https://example.com/documentation",
133+
},
134+
],
135+
},
124136
};
125137

126138
async loadAppConfig(): Promise<void> {}

src/assets/config.example.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@
88
"oaiProviderRoute": "http://localhost:3001",
99
"production": false,
1010
"scicatBaseUrl": "http://localhost",
11-
"showLogoBanner": true,
1211
"statusCode": "INFO",
1312
"statusMessage": "This is a customizable status message",
14-
"contactEmail": "support@scicat.eu"
15-
}
13+
"contactEmail": "support@scicat.eu",
14+
"footerMessage": {
15+
"text": "For more information visit:",
16+
"links": [
17+
{
18+
"label": "Data policy",
19+
"url": "https://example.com/data-policy"
20+
},
21+
{
22+
"label": "Documentation",
23+
"url": "https://example.com/documentation"
24+
}
25+
]
26+
}
27+
}

src/environments/environment.development.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ export const environment = {
1515
oaiProviderRoute: "https://doi2.psi.ch/oaipmh/Publication",
1616
production: true,
1717
scicatBaseUrl: null,
18-
showLogoBanner: false,
1918
};

src/environments/environment.dmsc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ export const environment = {
1313
oaiProviderRoute: null,
1414
production: false,
1515
scicatBaseUrl: "https://scicat.esss.se",
16-
showLogoBanner: true,
1716
};

0 commit comments

Comments
 (0)