Skip to content

Commit

Permalink
task/WG-288: improve configuration of DesignSafe url (#245)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nathanfranklin authored Jul 22, 2024
1 parent 3855f6a commit 59796c4
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion angular/src/app/app.interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ <h6 id="property-title">Saved Location</h6>

<div *ngIf="activeProject.system_path" style="margin-bottom: 10px">
<span>Path: </span>
<a [href]="dsHref"
><span>{{ activeProject.system_path }}</span></a
>
<a [href]="dsHref" target="_blank">
<span>{{ activeProject.system_path }}</span>
</a>
</div>

<div *ngIf="activeProject.system_id.startsWith('project'); else myData" style="margin-bottom: 20px">
<span>Project: </span>
<a [href]="projectHref">
<a [href]="projectHref" target="_blank">
<span>
{{ activeProject.ds_id }} |
{{ activeProject.title }}
Expand All @@ -113,7 +113,7 @@ <h6 id="property-title">Saved Location</h6>
<ng-template #myData>
<div style="margin-bottom: 20px">
<span>System: </span>
<a [href]="myDataHref">
<a [href]="myDataHref" target="_blank">
<span>My Data</span>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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 + '/';
}
}
Expand Down
4 changes: 2 additions & 2 deletions angular/src/app/services/agave-systems.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AgaveSystemsService {
}

list() {
this.http.get<any>(this.envService.tapisUrl + `v3/systems/?listType=ALL`).subscribe(
this.http.get<any>(this.envService.tapisUrl + `/v3/systems/?listType=ALL`).subscribe(
(resp) => {
this._systems.next(resp.result);
},
Expand All @@ -62,7 +62,7 @@ export class AgaveSystemsService {
this._projects.next([]);
this._loadingProjects.next(false);

this.http.get<DesignSafeProjectCollection>(this.envService.designSafeUrl + `/api/projects/v2/`).subscribe(
this.http.get<DesignSafeProjectCollection>(this.envService.designSafePortalUrl + `/api/projects/v2/`).subscribe(
(resp) => {
const projectSystems = resp.result.map((project) => {
return {
Expand Down
38 changes: 18 additions & 20 deletions angular/src/app/services/env.service.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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');
}
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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/';
Expand Down
2 changes: 1 addition & 1 deletion angular/src/app/services/tapis-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class TapisFilesService {
}

listFiles(system: string, path: string, offset: number, limit: number) {
return this.http.get<any>(this.envService.tapisUrl + `v3/files/ops/${system}/${path}?offset=${offset}&limit=${limit}`);
return this.http.get<any>(this.envService.tapisUrl + `/v3/files/ops/${system}/${path}?offset=${offset}&limit=${limit}`);
}

public getParentPath(path: string): string {
Expand Down
4 changes: 3 additions & 1 deletion angular/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
7 changes: 7 additions & 0 deletions angular/src/environments/environmentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */,
}

0 comments on commit 59796c4

Please sign in to comment.