From 59796c4504496675f33e3d268dc73b3bd75de6fb Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Mon, 22 Jul 2024 23:45:49 +0200 Subject: [PATCH] task/WG-288: improve configuration of DesignSafe url (#245) * Rework login to use geoapi for auth * Fix linting issues * Fix linting * Change where we store token in local storage * Configure DesignSafe url * Fix links DesignSafe (fixes WG-322) Also makes the page open in a new tab * Fix linting issues --- angular/src/app/app.interceptors.ts | 2 +- .../users-panel/users-panel.component.html | 10 ++--- .../users-panel/users-panel.component.ts | 4 +- .../src/app/services/agave-systems.service.ts | 4 +- angular/src/app/services/env.service.ts | 38 +++++++++---------- .../src/app/services/tapis-files.service.ts | 2 +- angular/src/environments/environment.ts | 4 +- angular/src/environments/environmentType.ts | 7 ++++ 8 files changed, 39 insertions(+), 32 deletions(-) diff --git a/angular/src/app/app.interceptors.ts b/angular/src/app/app.interceptors.ts index 4401366c..bcf2a65f 100644 --- a/angular/src/app/app.interceptors.ts +++ b/angular/src/app/app.interceptors.ts @@ -21,7 +21,7 @@ export class JwtInterceptor implements HttpInterceptor { const isTargetUrl = request.url.includes(this.envService.tapisUrl) || request.url.includes(this.envService.apiUrl) || - request.url.includes(this.envService.designSafeUrl); + request.url.includes(this.envService.designSafePortalUrl); if (isTargetUrl) { if (this.authSvc.isLoggedInButTokenExpired()) { // check for an expired user token and get user to relogin if expired diff --git a/angular/src/app/components/users-panel/users-panel.component.html b/angular/src/app/components/users-panel/users-panel.component.html index 1711cf66..f670ab95 100644 --- a/angular/src/app/components/users-panel/users-panel.component.html +++ b/angular/src/app/components/users-panel/users-panel.component.html @@ -95,14 +95,14 @@
Saved Location
Path: - {{ activeProject.system_path }} + + {{ activeProject.system_path }} +
Project: - + {{ activeProject.ds_id }} | {{ activeProject.title }} @@ -113,7 +113,7 @@
Saved Location
System: - + My Data
diff --git a/angular/src/app/components/users-panel/users-panel.component.ts b/angular/src/app/components/users-panel/users-panel.component.ts index 78278f96..02736261 100644 --- a/angular/src/app/components/users-panel/users-panel.component.ts +++ b/angular/src/app/components/users-panel/users-panel.component.ts @@ -43,7 +43,7 @@ export class UsersPanelComponent implements OnInit { this.agaveSystemsService.list(); combineLatest([this.projectsService.activeProject, this.agaveSystemsService.projects]).subscribe(([activeProject, dsProjects]) => { if (activeProject) { - const portalUrl = this.envService.portalUrl + 'data/browser/'; + const portalUrl = this.envService.designSafePortalUrl + '/data/browser/'; this.activeProject = this.agaveSystemsService.getProjectMetadata([activeProject], dsProjects)[0]; if (activeProject.system_id) { if (activeProject.system_id.startsWith('project')) { @@ -52,7 +52,7 @@ export class UsersPanelComponent implements OnInit { this.projectHref = portalUrl + 'projects/' + activeProject.ds_id + '/'; } } else { - this.myDataHref = portalUrl + 'tapis/' + activeProject.system_id; + this.myDataHref = portalUrl + 'tapis/' + activeProject.system_id + '/'; this.dsHref = this.myDataHref + activeProject.system_path + '/'; } } diff --git a/angular/src/app/services/agave-systems.service.ts b/angular/src/app/services/agave-systems.service.ts index b5282809..ba08d71c 100644 --- a/angular/src/app/services/agave-systems.service.ts +++ b/angular/src/app/services/agave-systems.service.ts @@ -46,7 +46,7 @@ export class AgaveSystemsService { } list() { - this.http.get(this.envService.tapisUrl + `v3/systems/?listType=ALL`).subscribe( + this.http.get(this.envService.tapisUrl + `/v3/systems/?listType=ALL`).subscribe( (resp) => { this._systems.next(resp.result); }, @@ -62,7 +62,7 @@ export class AgaveSystemsService { this._projects.next([]); this._loadingProjects.next(false); - this.http.get(this.envService.designSafeUrl + `/api/projects/v2/`).subscribe( + this.http.get(this.envService.designSafePortalUrl + `/api/projects/v2/`).subscribe( (resp) => { const projectSystems = resp.result.map((project) => { return { diff --git a/angular/src/app/services/env.service.ts b/angular/src/app/services/env.service.ts index 8fce10a3..80b4774b 100644 --- a/angular/src/app/services/env.service.ts +++ b/angular/src/app/services/env.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@angular/core'; import { environment } from '../../environments/environment'; -import { EnvironmentType } from '../../environments/environmentType'; +import { EnvironmentType, DesignSafeEnvironmentType } from '../../environments/environmentType'; @Injectable({ providedIn: 'root' }) export class EnvService { private _env: EnvironmentType; private _apiUrl: string; - private _portalUrl: string; + private _designSafePortalUrl: string; private _taggitUrl: string; private _jwt?: string; private _clientId: string; @@ -30,16 +30,18 @@ export class EnvService { } get tapisUrl(): string { - return 'https://designsafe.tapis.io/'; + return 'https://designsafe.tapis.io'; } - private getPortalUrl(backend: EnvironmentType): string { - if (backend === EnvironmentType.Production) { - return 'https://www.designsafe-ci.org/'; - } else if (backend === EnvironmentType.Experimental) { - return 'https://designsafeci-next.tacc.utexas.edu/'; + private getDesignSafePortalUrl(backend: DesignSafeEnvironmentType): string { + if (backend === DesignSafeEnvironmentType.Production) { + return 'https://www.designsafe-ci.org'; + } else if (backend === DesignSafeEnvironmentType.Next) { + return 'https://designsafeci-next.tacc.utexas.edu'; + } else if (backend === DesignSafeEnvironmentType.Dev) { + return 'https://designsafeci-dev.tacc.utexas.edu'; } else { - return 'https://designsafeci-dev.tacc.utexas.edu/'; + throw new Error('Unsupported DS environment'); } } @@ -71,12 +73,8 @@ export class EnvService { return this._baseHref; } - get designSafeUrl(): string { - return 'https://designsafeci-next.tacc.utexas.edu'; - } - - get portalUrl(): string { - return this._portalUrl; + get designSafePortalUrl(): string { + return this._designSafePortalUrl; } get taggitUrl(): string { @@ -118,7 +116,7 @@ export class EnvService { if (/^localhost/.test(hostname) || /^hazmapper.local/.test(hostname)) { this._env = EnvironmentType.Local; this._apiUrl = this.getApiUrl(environment.backend); - this._portalUrl = this.getPortalUrl(EnvironmentType.Experimental); + this._designSafePortalUrl = this.getDesignSafePortalUrl(environment.designSafePortal); // TODO: Currently taggit is hosted on same port 4200 // Have to change port on taggit or hazmapper (requires adding callbackUrl to that port) this._taggitUrl = 'http://localhost:4200/taggit'; @@ -148,7 +146,7 @@ export class EnvService { this._env = EnvironmentType.Staging; this._apiUrl = this.getApiUrl(this.env); this._taggitUrl = origin + '/taggit-staging'; - this._portalUrl = this.getPortalUrl(this.env); + this._designSafePortalUrl = this.getDesignSafePortalUrl(DesignSafeEnvironmentType.Dev); this._clientId = 'hazmapper.staging'; this._baseHref = '/staging/'; this._streetviewEnv.secrets = { @@ -166,7 +164,7 @@ export class EnvService { this._env = EnvironmentType.Dev; this._apiUrl = this.getApiUrl(this.env); this._taggitUrl = origin + '/taggit-dev'; - this._portalUrl = this.getPortalUrl(this.env); + this._designSafePortalUrl = this.getDesignSafePortalUrl(DesignSafeEnvironmentType.Dev); this._clientId = 'hazmapper.dev'; this._baseHref = '/dev/'; this._streetviewEnv.secrets = { @@ -184,7 +182,7 @@ export class EnvService { this._env = EnvironmentType.Experimental; this._apiUrl = this.getApiUrl(this.env); this._taggitUrl = origin + '/taggit-exp'; - this._portalUrl = this.getPortalUrl(this.env); + this._designSafePortalUrl = this.getDesignSafePortalUrl(DesignSafeEnvironmentType.Next); this._clientId = 'hazmapper.experimental'; this._baseHref = '/exp/'; this._streetviewEnv.secrets = { @@ -201,7 +199,7 @@ export class EnvService { } else if (/^hazmapper.tacc.utexas.edu/.test(hostname)) { this._env = EnvironmentType.Production; this._apiUrl = this.getApiUrl(this.env); - this._portalUrl = this.getPortalUrl(this.env); + this._designSafePortalUrl = this.getDesignSafePortalUrl(DesignSafeEnvironmentType.Production); this._taggitUrl = origin + '/taggit'; this._clientId = 'hazmapper.prod'; this._baseHref = '/hazmapper/'; diff --git a/angular/src/app/services/tapis-files.service.ts b/angular/src/app/services/tapis-files.service.ts index 65e3984c..a6b93ae1 100644 --- a/angular/src/app/services/tapis-files.service.ts +++ b/angular/src/app/services/tapis-files.service.ts @@ -20,7 +20,7 @@ export class TapisFilesService { } listFiles(system: string, path: string, offset: number, limit: number) { - return this.http.get(this.envService.tapisUrl + `v3/files/ops/${system}/${path}?offset=${offset}&limit=${limit}`); + return this.http.get(this.envService.tapisUrl + `/v3/files/ops/${system}/${path}?offset=${offset}&limit=${limit}`); } public getParentPath(path: string): string { diff --git a/angular/src/environments/environment.ts b/angular/src/environments/environment.ts index 5e7f677d..6fdbd48f 100644 --- a/angular/src/environments/environment.ts +++ b/angular/src/environments/environment.ts @@ -3,16 +3,18 @@ // The list of file replacements can be found in `angular.json`. import { jwt as devJWT } from './jwt'; -import { EnvironmentType } from '../environments/environmentType'; +import { DesignSafeEnvironmentType, EnvironmentType } from '../environments/environmentType'; export interface AppEnvironment { jwt?: string; backend: EnvironmentType; + designSafePortal: DesignSafeEnvironmentType; production: boolean; } export const environment: AppEnvironment = { backend: EnvironmentType.Local, + designSafePortal: DesignSafeEnvironmentType.Next, jwt: devJWT, production: false, }; diff --git a/angular/src/environments/environmentType.ts b/angular/src/environments/environmentType.ts index b83972c8..698b50af 100644 --- a/angular/src/environments/environmentType.ts +++ b/angular/src/environments/environmentType.ts @@ -5,3 +5,10 @@ export enum EnvironmentType { Experimental = 'experimental' /* i.e. experimental.geoapi-services.tacc.utexas.edu*/, Local = 'local', } + +export enum DesignSafeEnvironmentType { + Production = 'production' /* https://www.designsafe-ci.org/ */, + Dev = 'dev' /* https://designsafeci-dev.tacc.utexas.edu/ */, + Next = 'experimental' /* https://designsafeci-next.tacc.utexas.edu/ */, + Local = 'local' /* not supported but would be designsafe.dev */, +}