Skip to content

Commit cefa4e1

Browse files
MillenniumFalconMechanicNoopDog
authored andcommitted
Added doc/app title to config. Resolves #1695.
1 parent 5e87c21 commit cefa4e1

File tree

9 files changed

+33
-3
lines changed

9 files changed

+33
-3
lines changed

spa/src/app/app.component.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ViewChild,
1717
ViewContainerRef
1818
} from "@angular/core";
19+
import { Title } from "@angular/platform-browser";
1920
import { Router } from "@angular/router";
2021
import { select, Store } from "@ngrx/store";
2122
import { Subject, BehaviorSubject, combineLatest } from "rxjs";
@@ -59,13 +60,15 @@ export class AppComponent implements OnInit, OnDestroy {
5960
* @param {Store<AppState>} store
6061
* @param {ComponentFactoryResolver} componentFactoryResolver
6162
* @param {Router} router
63+
* @param {Title} titleService
6264
*/
6365
constructor(private configService: ConfigService,
6466
private deviceService: DeviceDetectorService,
6567
@Inject(SITE_CONFIG_SERVICE) private siteConfigService: SiteConfigService,
6668
private store: Store<AppState>,
6769
private componentFactoryResolver: ComponentFactoryResolver,
68-
private router: Router) {
70+
private router: Router,
71+
private titleService: Title) {
6972

7073
this.className = this.configService.getAtlas();
7174
}
@@ -149,6 +152,15 @@ export class AppComponent implements OnInit, OnDestroy {
149152
});
150153
}
151154

155+
/**
156+
* Set document title from config.
157+
*/
158+
private initTitle() {
159+
160+
const title = this.configService.getTitle();
161+
this.titleService.setTitle(title);
162+
}
163+
152164
/**
153165
* Set up header and footer components depending on the site config.
154166
*/
@@ -190,6 +202,7 @@ export class AppComponent implements OnInit, OnDestroy {
190202
*/
191203
public ngOnInit() {
192204

205+
this.initTitle();
193206
this.initViewContainers();
194207
this.initState();
195208
this.loadProjectEditsData();

spa/src/app/config/_ngrx/config.state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class ConfigState {
3030
public static getDefaultState() {
3131

3232
return new ConfigState(
33-
new Config("", "", "", "", "", "", "", ""));
33+
new Config("", "", "", "", "", "", "", "", ""));
3434
}
3535

3636
/**

spa/src/app/config/config.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class Config {
1515
* @param {string} portalURL
1616
* @param {string} projectMetaURL
1717
* @param {string} terraExportURL
18+
* @param {string} title
1819
* @param {string} zendeskURL
1920
*/
2021
constructor(public readonly atlas: string,
@@ -24,5 +25,6 @@ export class Config {
2425
public readonly portalURL: string,
2526
public readonly projectMetaURL: string,
2627
public readonly terraExportURL: string,
28+
public readonly title: string,
2729
public readonly zendeskURL: string) {}
2830
}

spa/src/app/config/config.service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class ConfigService {
2929
protected portalURL: string;
3030
protected projectMetaURL: string;
3131
protected terraExportURL: string;
32+
protected title: string; // Document (application) title
3233
protected store: Store<AppState>;
3334
protected zendeskURL: string;
3435

@@ -208,6 +209,16 @@ export class ConfigService {
208209
return `${basePath}${summaryPath}`;
209210
}
210211

212+
/**
213+
* Returns the document title for the current config.
214+
*
215+
* @returns {string}
216+
*/
217+
public getTitle(): string {
218+
219+
return this.title;
220+
}
221+
211222
/**
212223
* Initialize config on app init. Must return promise here as this method is called during Angular's app
213224
* initialization and we need to resolve the config details before any components are instantiated. The config
@@ -305,6 +316,7 @@ export class ConfigService {
305316
this.portalURL = config.portalURL;
306317
this.projectMetaURL = config.projectMetaURL;
307318
this.terraExportURL = config.terraExportURL;
319+
this.title = config.title;
308320
this.zendeskURL = config.zendeskURL;
309321
this.store.dispatch(new FetchConfigRequestSuccessAction(config));
310322
}

spa/src/environments/environment.cgl-dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const environment = {
66
portalURL: "https://dev.singlecell.gi.ucsc.edu",
77
projectMetaURL: "https://dev.singlecell.gi.ucsc.edu",
88
terraExportURL: "https://bvdp-saturn-dev.appspot.com",
9+
title: "HCA Data Browser",
910
deployment: "cgl-dev",
1011
zendeskURL: "https://support.terra.bio"
1112
};

spa/src/environments/environment.dcp2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const environment = {
66
portalURL: "https://data.humancellatlas.org",
77
projectMetaURL: "https://data.humancellatlas.org",
88
terraExportURL: "https://app.terra.bio",
9+
title: "HCA Data Browser",
910
deployment: "dcp2",
1011
zendeskURL: "https://support.terra.bio"
1112
};

spa/src/environments/environment.lungmap-dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const environment = {
66
portalURL: "https://dev.singlecell.gi.ucsc.edu",
77
projectMetaURL: "https://dev.singlecell.gi.ucsc.edu",
88
terraExportURL: "https://bvdp-saturn-dev.appspot.com",
9+
title: "LungMAP Data Browser",
910
deployment: "lungmap-dev",
1011
zendeskURL: ""
1112
};

spa/src/environments/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const environment = {
66
portalURL: "https://dev.singlecell.gi.ucsc.edu",
77
projectMetaURL: "https://dev.singlecell.gi.ucsc.edu",
88
terraExportURL: "https://bvdp-saturn-dev.appspot.com",
9+
title: "HCA Data Browser",
910
deployment: "local",
1011
zendeskURL: "https://support.terra.bio"
1112
};

spa/src/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>HCA Data Browser</title>
65
<base href="/">
76
<meta name="viewport" content="width=device-width, initial-scale=1">
87
<!-- REPLACE-ME: GOOGLE TAG MANAGER HEAD -->

0 commit comments

Comments
 (0)