Skip to content

Commit 2cb2ffa

Browse files
authored
Merge pull request #57 from Srujithchaithanya1/feature/configFile
fixes Connect All Relevant Features to config files
2 parents bd1de04 + 73968b2 commit 2cb2ffa

File tree

15 files changed

+173
-51
lines changed

15 files changed

+173
-51
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ npm start
1313
## Usage
1414
Reactome has a wide range of features, to explore more of Reactome or get more information visit [the documentation page](https://reactome.org/documentation) or see the ````/documentation```` folder in the root directory.
1515

16+
## Configuration
17+
18+
The application configuration is centralized in TypeScript files under `projects/website-angular/src/config/`. Key configurations include:
19+
20+
- `config.ts`: App-level settings like version, base URLs, and feature flags.
21+
- `environments.ts`: Environment-specific settings (development, production, etc.).
22+
- `api-routes.ts`: API endpoint URLs derived from the current environment.
23+
- `features.ts`: Feature flags for toggling functionality.
24+
- `external-links.ts`: External links, including dynamically constructed release notes.
25+
26+
To update configuration values, edit the respective TS files. For environment-specific builds, consider using Angular's file replacements in `angular.json`.
27+
28+
## Additional Resources
1629

1730
## LICENSE
1831
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)

projects/pathway-browser/src/environments/environment.development.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import { ENVIRONMENTS } from '../../../website-angular/src/config/environments';
2+
3+
const env = ENVIRONMENTS.development;
4+
15
export const environment = {
26
production: true,
3-
host: "../..", // For go back from /beta/PathwayBrowser
4-
s3: "https://download.reactome.org",
5-
gsaServer: "dev",
6-
gtagId: "G-96F1EYHQR3",
7-
preferS3: false,
7+
host: env.host,
8+
s3: env.s3,
9+
gsaServer: env.gsaServer,
10+
gtagId: env.gtagId,
11+
preferS3: env.preferS3
812
};
913

1014
export const CONTENT_SERVICE = `${environment.host}/ContentService`;

projects/pathway-browser/src/environments/environment.production.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import { ENVIRONMENTS } from '../../../website-angular/src/config/environments';
2+
3+
const env = ENVIRONMENTS.production;
4+
15
export const environment = {
26
production: true,
3-
host: "../..", // For go back from /beta/PathwayBrowser
4-
s3: "https://download.reactome.org",
5-
gsaServer: "production",
6-
gtagId: "G-EDHZ92GXZP",
7-
preferS3: true,
8-
7+
host: env.host,
8+
s3: env.s3,
9+
gsaServer: env.gsaServer,
10+
gtagId: env.gtagId,
11+
preferS3: env.preferS3
912
};
1013

1114
export const CONTENT_SERVICE = `${environment.host}/ContentService`;

projects/website-angular/src/app/copyright-footer/copyright-footer.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
33
import { MatIcon } from "@angular/material/icon";
44
import {NavLink} from '../../types/link';
55
import { mapNavOptions } from '../../utils/nav-options-mapper';
6+
import { EXTERNAL_LINKS } from '../../config/external-links'; // NEW import
67

78
@Component({
89
selector: 'app-copyright-footer',
@@ -19,9 +20,7 @@ export class copyrightFooterComponent implements OnInit {
1920
}
2021

2122
loadExternalLinks() {
22-
// Load external links from the JSON file
23-
import('../../config/external-links.json').then((data) => {
24-
this.externalLinks = mapNavOptions(data.default);
25-
});
23+
// Use the new TS constant instead of dynamic JSON import
24+
this.externalLinks = EXTERNAL_LINKS as unknown as Record<string, NavLink>;
2625
}
2726
}

projects/website-angular/src/app/home-page/home-help/home-help.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Component } from '@angular/core';
2-
import { CarouselComponent } from "../../reactome-components/carousel/carousel.component";
3-
import { ButtonComponent } from "../../reactome-components/button/button.component";
4-
import { MatIcon } from "@angular/material/icon";
2+
import { CarouselComponent } from '../../reactome-components/carousel/carousel.component';
3+
import { ButtonComponent } from '../../reactome-components/button/button.component';
4+
import { MatIcon } from '@angular/material/icon';
55
import { mapNavOptions } from '../../../utils/nav-options-mapper';
66
import { ExternalLink, NavOption } from '../../../types/link';
7+
import { EXTERNAL_LINKS } from '../../../config/external-links'; // NEW import
78

89
@Component({
910
selector: 'app-home-help',
@@ -31,10 +32,9 @@ export class HomeHelpComponent {
3132
}
3233

3334
loadExternalLinks() {
34-
import('../../../config/external-links.json').then((data) => {
35-
this.externalLinks = mapNavOptions(data.default);
36-
this.releaseNotesLink = this.externalLinks['releaseNotes']?.link || '';
37-
this.feedbackLink = this.externalLinks['feedback']?.link || '';
38-
});
35+
// Use the new TS constant instead of dynamic JSON import
36+
this.externalLinks = EXTERNAL_LINKS as unknown as Record<string, ExternalLink>;
37+
this.releaseNotesLink = this.externalLinks['releaseNotes']?.link || '';
38+
this.feedbackLink = this.externalLinks['feedback']?.link || '';
3939
}
4040
}

projects/website-angular/src/app/home-page/home-related/home-related.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component } from '@angular/core';
22
import {ExternalLink} from '../../../types/link';
33
import { mapNavOptions } from '../../../utils/nav-options-mapper';
4+
import { EXTERNAL_LINKS } from '../../../config/external-links'; // NEW import
45

56
@Component({
67
selector: 'app-home-related',
@@ -17,8 +18,7 @@ export class HomeRelatedComponent {
1718
}
1819

1920
loadExternalLinks() {
20-
import('../../../config/external-links.json').then((data) => {
21-
this.externalLinks = mapNavOptions(data.default);
22-
});
21+
// Use the new TS constant instead of dynamic JSON import
22+
this.externalLinks = EXTERNAL_LINKS as unknown as Record<string, ExternalLink>;
2323
}
2424
}

projects/website-angular/src/app/home-page/home-stats/home-stats.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, inject } from '@angular/core';
22
import { MatIcon } from "@angular/material/icon";
33
import { CarouselComponent } from "../../reactome-components/carousel/carousel.component";
44
import { StatsService } from '../../../services/stats.service';
5+
import { APP_CONFIG } from '../../../config/config'; // NEW import
56

67
interface Stats {
78
human_pathways: number;
@@ -39,11 +40,10 @@ export class HomeStatsComponent {
3940
}
4041

4142
getVersionAndDate () {
42-
import('../../../config/config.json').then((data) => {
43-
this.version = data.default.version.releaseNumber;
44-
this.releaseDate = new Date(data.default.version.releaseDate);
45-
this.fetchStats();
46-
});
43+
// Use APP_CONFIG instead of dynamic JSON import
44+
this.version = APP_CONFIG.version.releaseNumber;
45+
this.releaseDate = new Date(APP_CONFIG.version.releaseDate);
46+
this.fetchStats();
4747
}
4848

4949
fetchStats () {

projects/website-angular/src/app/home-page/home-why-reactome/home-why-reactome.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component } from '@angular/core';
22
import {ExternalLink, NavOption} from '../../../types/link';
33
import { mapNavOptions } from '../../../utils/nav-options-mapper';
4+
import { EXTERNAL_LINKS } from '../../../config/external-links'; // NEW import
45

56
@Component({
67
selector: 'app-home-why-reactome',
@@ -19,9 +20,8 @@ export class HomeWhyReactomeComponent {
1920
}
2021

2122
loadExternalLinks() {
22-
import('../../../config/external-links.json').then((data) => {
23-
this.externalLinks = mapNavOptions(data.default);
24-
});
23+
// Use the new TS constant instead of dynamic JSON import
24+
this.externalLinks = EXTERNAL_LINKS as unknown as Record<string, ExternalLink>;
2525
}
2626

2727
loadNavOptions() {

projects/website-angular/src/app/navigation-bar/navigation-bar.component.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormsModule } from '@angular/forms';
77
import { mapNavOptions } from '../../utils/nav-options-mapper';
88
import { NavLink, NavOption } from '../../types/link';
99
import { DarkService } from '../../../../pathway-browser/src/app/services/dark.service';
10+
import { APP_CONFIG } from '../../config/config'; // NEW import
1011

1112
@Component({
1213
standalone: true,
@@ -43,12 +44,9 @@ export class NavigationBarComponent implements OnInit, AfterViewInit {
4344
}
4445

4546
loadNavOptions() {
46-
Promise.all([
47-
import('../../config/nav-options.json'),
48-
import('../../config/config.json')
49-
]).then(([navData, configData]) => {
47+
import('../../config/nav-options.json').then((navData) => {
5048
this.navOptions = mapNavOptions(navData.default);
51-
this.resolveExternalLinks(configData.default.baseUrl);
49+
this.resolveExternalLinks(APP_CONFIG.baseUrl);
5250
});
5351
}
5452

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { getEnv } from './environments';
2+
3+
const env = getEnv(process.env['APP_ENV'] || (typeof window !== 'undefined' && (window as any).__APP_ENV) || undefined);
4+
5+
export const API_ROUTES = {
6+
CONTENT_SERVICE: `${env.host}/ContentService`,
7+
ANALYSIS_SERVICE: `${env.host}/AnalysisService`,
8+
EXPERIMENT_SERVICE: `${env.host}/experiment`,
9+
RESTFUL_API: `${env.host}/ReactomeRESTfulAPI/RESTfulWS`,
10+
DOWNLOAD: `${env.host}/download/current`,
11+
OVERLAYS: `${env.host}/overlays`,
12+
CONTENT_DETAIL: `${env.host}/content/detail`,
13+
CONTENT_QUERY: `${env.host}/content/query`
14+
} as const;

0 commit comments

Comments
 (0)