From 2cc49fd650e901d8a3e973e22e383e51c386b529 Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Tue, 25 Jun 2024 15:05:26 -0500 Subject: [PATCH 1/7] Rework login to use geoapi for auth --- angular/src/app/app-routing.module.ts | 2 +- angular/src/app/app.interceptors.ts | 52 ++++++------------- angular/src/app/app.module.ts | 7 +-- .../components/callback/callback.component.ts | 2 - angular/src/app/models/models.ts | 13 +++-- .../app/services/authentication.service.ts | 47 +++++++---------- .../src/app/services/notifications.service.ts | 2 - 7 files changed, 47 insertions(+), 78 deletions(-) diff --git a/angular/src/app/app-routing.module.ts b/angular/src/app/app-routing.module.ts index 9e48abbd..7ea77ffc 100644 --- a/angular/src/app/app-routing.module.ts +++ b/angular/src/app/app-routing.module.ts @@ -46,7 +46,7 @@ const routes: Routes = [ }, ], }, - { path: 'callback', component: CallbackComponent }, + { path: 'handle-login', component: CallbackComponent }, { path: 'streetview/callback', component: StreetviewCallbackComponent }, { path: '404', component: NotFoundComponent }, { path: '**', redirectTo: '', pathMatch: 'full' }, diff --git a/angular/src/app/app.interceptors.ts b/angular/src/app/app.interceptors.ts index 85989f18..ba0977fb 100644 --- a/angular/src/app/app.interceptors.ts +++ b/angular/src/app/app.interceptors.ts @@ -1,34 +1,41 @@ import { Injectable } from '@angular/core'; import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http'; +import { Router } from '@angular/router'; import { Observable } from 'rxjs'; import { AuthService } from './services/authentication.service'; import { EnvService } from './services/env.service'; -import { catchError } from 'rxjs/operators'; import { StreetviewAuthenticationService } from './services/streetview-authentication.service'; -import { NotificationsService } from './services/notifications.service'; import { v4 as uuidv4 } from 'uuid'; +import { LOGIN } from './constants/routes'; @Injectable() export class JwtInterceptor implements HttpInterceptor { constructor( + private router: Router, private authSvc: AuthService, private envService: EnvService, private streetviewAuthService: StreetviewAuthenticationService ) {} intercept(request: HttpRequest, next: HttpHandler): Observable> { - // TODO_TAPISV3 put the tapis url in envService const isTargetUrl = request.url.includes(this.envService.tapisUrl) || request.url.includes(this.envService.apiUrl) || request.url.includes(this.envService.designSafeUrl); - if (isTargetUrl && this.authSvc.isLoggedIn()) { - // add tapis token to Geoapi or Tapis requests - request = request.clone({ - setHeaders: { - 'X-Tapis-Token': this.authSvc.userToken.token, - }, - }); + if (isTargetUrl) { + if(this.authSvc.isLoggedInButTokenExpired()){ + // check for an expired user token and get user to relogin if expired + this.router.navigateByUrl(LOGIN + '?to=' + encodeURIComponent(this.router.url)); + } + + if(this.authSvc.isLoggedIn()) { + // add tapis token to Geoapi or Tapis requests + request = request.clone({ + setHeaders: { + 'X-Tapis-Token': this.authSvc.userToken.token, + }, + }); + } } if (request.url.indexOf(this.envService.apiUrl) > -1) { @@ -99,28 +106,3 @@ export class JwtInterceptor implements HttpInterceptor { return request.method === 'GET' && urlPattern.test(request.url); } } - -@Injectable() -export class AuthInterceptor implements HttpInterceptor { - constructor( - private authService: AuthService, - private envService: EnvService, - private streetviewAuthService: StreetviewAuthenticationService, - private notificationService: NotificationsService - ) {} - - intercept(request: HttpRequest, next: HttpHandler): Observable> { - return next.handle(request).pipe( - catchError((err) => { - if (err.status === 401) { - // auto logout if 401 response returned from api - // https://jira.tacc.utexas.edu/browse/DES-1999 - // TODO_TAPISV3 renable these - // this.authService.logout(); - // location.reload(); - } - throw err; - }) - ); - } -} diff --git a/angular/src/app/app.module.ts b/angular/src/app/app.module.ts index a3571191..7b7d6ab8 100644 --- a/angular/src/app/app.module.ts +++ b/angular/src/app/app.module.ts @@ -29,7 +29,7 @@ import { AuthService } from './services/authentication.service'; import { ModalService } from './services/modal.service'; import { EnvService } from './services/env.service'; import { CallbackComponent } from './components/callback/callback.component'; -import { AuthInterceptor, JwtInterceptor } from './app.interceptors'; +import { JwtInterceptor } from './app.interceptors'; import { ModalCreateProjectComponent } from './components/modal-create-project/modal-create-project.component'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { ModalFileBrowserComponent } from './components/modal-file-browser/modal-file-browser.component'; @@ -154,11 +154,6 @@ import { QuestionnaireDetailComponent } from './components/questionnaire-detail/ useClass: JwtInterceptor, multi: true, }, - { - provide: HTTP_INTERCEPTORS, - multi: true, - useClass: AuthInterceptor, - }, { provide: CDK_DRAG_CONFIG, useValue: { diff --git a/angular/src/app/components/callback/callback.component.ts b/angular/src/app/components/callback/callback.component.ts index 02cb46c7..f2dc8623 100644 --- a/angular/src/app/components/callback/callback.component.ts +++ b/angular/src/app/components/callback/callback.component.ts @@ -11,8 +11,6 @@ export class CallbackComponent implements OnInit { constructor(private route: ActivatedRoute, private auth: AuthService) {} ngOnInit() { - const frag = this.route.snapshot.fragment; - const params = new URLSearchParams(frag); const token = this.route.snapshot.queryParams.access_token; const expires_in = this.route.snapshot.queryParams.expires_in; this.auth.setToken(token, expires_in); diff --git a/angular/src/app/models/models.ts b/angular/src/app/models/models.ts index c9b58f7e..64d6b41c 100644 --- a/angular/src/app/models/models.ts +++ b/angular/src/app/models/models.ts @@ -93,19 +93,26 @@ export class AuthToken { this.expires = new Date(expires); } + /** Creates an AuthToken instance from a token and an expiration time in seconds. */ static fromExpiresIn(token: string, expires_in: number) { const expires = new Date(new Date().getTime() + expires_in * 1000); return new AuthToken(token, expires); } + /** - * Checks if the token is expired or not + * Checks if the token is expired or not. + * A 5 minutebuffer is used to consider a token as expired slightly before its actual expiration time. + * @returns {boolean} True if the token is expired, false otherwise. */ public isExpired(): boolean { + const buffer = 300000; // 5 minutes in milliseconds if (this.expires) { - return new Date().getTime() > this.expires.getTime(); + // Subtract buffer from the expiration time and compare with the current time + return (new Date().getTime() > (this.expires.getTime() - buffer)); } else { - return false; + // If expires is not set, consider the token as not expired + return false; // TODO_V3 this affects the streetview token; should be confirmed or refactored. } } } diff --git a/angular/src/app/services/authentication.service.ts b/angular/src/app/services/authentication.service.ts index 01161f2f..67027b30 100644 --- a/angular/src/app/services/authentication.service.ts +++ b/angular/src/app/services/authentication.service.ts @@ -31,31 +31,14 @@ export class AuthService { } public login(requestedUrl: string) { + this.logout() localStorage.setItem(this.getRedirectKeyword(), requestedUrl); - - // First, check if the user has a token in localStorage - const tokenStr = localStorage.getItem(this.getTokenKeyword()); - if (!tokenStr) { - this.redirectToAuthenticator(); - } else { - const token = JSON.parse(tokenStr); - this.userToken = new AuthToken(token.token, new Date(token.expires)); - if (!this.userToken || this.userToken.isExpired()) { - this.logout(); - this.redirectToAuthenticator(); - } - this.getUserInfoFromToken(); - } + this.redirectToAuthenticator(requestedUrl); } - public redirectToAuthenticator() { - const client_id = this.envService.clientId; - const callback = location.origin + this.envService.baseHref + 'callback'; - const state = Math.random().toString(36); - // tslint:disable-next-line:max-line-length - const AUTH_URL_V3 = `${this.envService.tapisUrl}/v3/oauth2/authorize?client_id=${client_id}&response_type=token&redirect_uri=${callback}`; - - window.location.href = AUTH_URL_V3; + public redirectToAuthenticator(requestedUrl: string) { + const GEOAPI_AUTH_URL = `${this.envService.apiUrl}/auth/login?to=${requestedUrl}`; + window.location.href = GEOAPI_AUTH_URL; } /** @@ -71,6 +54,19 @@ export class AuthService { return false; } + /** + * Checks to see if there is a logged in user but token is expired; + */ + public isLoggedInButTokenExpired(): boolean { + const tokenStr = localStorage.getItem(this.getTokenKeyword()); + if (tokenStr) { + const token = JSON.parse(tokenStr); + this.userToken = new AuthToken(token.token, new Date(token.expires)); + return this.userToken && this.userToken.isExpired(); + } + return false; + } + public logout(): void { this.userToken = null; localStorage.removeItem(this.getTokenKeyword()); @@ -93,11 +89,4 @@ export class AuthService { const u = new AuthenticatedUser(decodedJwt['tapis/username']); this._currentUser.next(u); } - - checkLoggedIn(): void { - if (!this.isLoggedIn()) { - this.logout(); - this.redirectToAuthenticator(); - } - } } diff --git a/angular/src/app/services/notifications.service.ts b/angular/src/app/services/notifications.service.ts index df0e84e8..94a3c366 100644 --- a/angular/src/app/services/notifications.service.ts +++ b/angular/src/app/services/notifications.service.ts @@ -29,7 +29,6 @@ export class NotificationsService { } getRecent(): void { - this.authService.checkLoggedIn(); const baseUrl = this.envService.apiUrl + '/notifications/'; const now = new Date(); const then = new Date(now.getTime() - this.TIMEOUT); @@ -75,7 +74,6 @@ export class NotificationsService { } getRecentProgress(): void { - this.authService.checkLoggedIn(); const baseUrl = this.envService.apiUrl + '/notifications/progress'; this.http.get>(baseUrl).subscribe((notes) => { this._progressNotifications.next(notes); From 4fe4269ceee047c308a527deecc81b772dc9c640 Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Tue, 25 Jun 2024 15:57:00 -0500 Subject: [PATCH 2/7] Fix linting issues --- angular/src/app/app.interceptors.ts | 4 ++-- angular/src/app/models/models.ts | 3 +-- .../app/services/authentication.service.ts | 20 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/angular/src/app/app.interceptors.ts b/angular/src/app/app.interceptors.ts index ba0977fb..4401366c 100644 --- a/angular/src/app/app.interceptors.ts +++ b/angular/src/app/app.interceptors.ts @@ -23,12 +23,12 @@ export class JwtInterceptor implements HttpInterceptor { request.url.includes(this.envService.apiUrl) || request.url.includes(this.envService.designSafeUrl); if (isTargetUrl) { - if(this.authSvc.isLoggedInButTokenExpired()){ + if (this.authSvc.isLoggedInButTokenExpired()) { // check for an expired user token and get user to relogin if expired this.router.navigateByUrl(LOGIN + '?to=' + encodeURIComponent(this.router.url)); } - if(this.authSvc.isLoggedIn()) { + if (this.authSvc.isLoggedIn()) { // add tapis token to Geoapi or Tapis requests request = request.clone({ setHeaders: { diff --git a/angular/src/app/models/models.ts b/angular/src/app/models/models.ts index 64d6b41c..1df26e38 100644 --- a/angular/src/app/models/models.ts +++ b/angular/src/app/models/models.ts @@ -99,7 +99,6 @@ export class AuthToken { return new AuthToken(token, expires); } - /** * Checks if the token is expired or not. * A 5 minutebuffer is used to consider a token as expired slightly before its actual expiration time. @@ -109,7 +108,7 @@ export class AuthToken { const buffer = 300000; // 5 minutes in milliseconds if (this.expires) { // Subtract buffer from the expiration time and compare with the current time - return (new Date().getTime() > (this.expires.getTime() - buffer)); + return new Date().getTime() > this.expires.getTime() - buffer; } else { // If expires is not set, consider the token as not expired return false; // TODO_V3 this affects the streetview token; should be confirmed or refactored. diff --git a/angular/src/app/services/authentication.service.ts b/angular/src/app/services/authentication.service.ts index 67027b30..3938ca4f 100644 --- a/angular/src/app/services/authentication.service.ts +++ b/angular/src/app/services/authentication.service.ts @@ -31,7 +31,7 @@ export class AuthService { } public login(requestedUrl: string) { - this.logout() + this.logout(); localStorage.setItem(this.getRedirectKeyword(), requestedUrl); this.redirectToAuthenticator(requestedUrl); } @@ -54,18 +54,18 @@ export class AuthService { return false; } - /** + /** * Checks to see if there is a logged in user but token is expired; */ - public isLoggedInButTokenExpired(): boolean { - const tokenStr = localStorage.getItem(this.getTokenKeyword()); - if (tokenStr) { - const token = JSON.parse(tokenStr); - this.userToken = new AuthToken(token.token, new Date(token.expires)); - return this.userToken && this.userToken.isExpired(); - } - return false; + public isLoggedInButTokenExpired(): boolean { + const tokenStr = localStorage.getItem(this.getTokenKeyword()); + if (tokenStr) { + const token = JSON.parse(tokenStr); + this.userToken = new AuthToken(token.token, new Date(token.expires)); + return this.userToken && this.userToken.isExpired(); } + return false; + } public logout(): void { this.userToken = null; From 5f5a4db8e434387bc0f709190945633709775ea3 Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Wed, 3 Jul 2024 07:58:02 -0500 Subject: [PATCH 3/7] Fix linting --- angular/src/app/models/models.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular/src/app/models/models.ts b/angular/src/app/models/models.ts index 1df26e38..972ecdf4 100644 --- a/angular/src/app/models/models.ts +++ b/angular/src/app/models/models.ts @@ -101,8 +101,8 @@ export class AuthToken { /** * Checks if the token is expired or not. - * A 5 minutebuffer is used to consider a token as expired slightly before its actual expiration time. - * @returns {boolean} True if the token is expired, false otherwise. + * A 5 minute buffer is used to consider a token as expired slightly before its actual expiration time. + * @returns True if the token is expired, false otherwise. */ public isExpired(): boolean { const buffer = 300000; // 5 minutes in milliseconds From f168fd20e0c1cd4e4acc910043eea200adf02268 Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Wed, 3 Jul 2024 07:59:52 -0500 Subject: [PATCH 4/7] Change where we store token in local storage --- angular/src/app/services/authentication.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular/src/app/services/authentication.service.ts b/angular/src/app/services/authentication.service.ts index 3938ca4f..1d0d7101 100644 --- a/angular/src/app/services/authentication.service.ts +++ b/angular/src/app/services/authentication.service.ts @@ -23,7 +23,7 @@ export class AuthService { constructor(private http: HttpClient, private envService: EnvService, private router: Router) {} public getTokenKeyword() { - return `${this.envService.env}HazmapperToken`; + return `${this.envService.env}HazmapperV3Token`; } public getRedirectKeyword() { From a56a15c64856e687a1e76bfed0406bf93d53b7b2 Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Tue, 9 Jul 2024 09:25:29 -0500 Subject: [PATCH 5/7] Configure DesignSafe url --- angular/src/app/app.interceptors.ts | 2 +- .../users-panel/users-panel.component.ts | 2 +- .../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 ++++ 7 files changed, 33 insertions(+), 26 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.ts b/angular/src/app/components/users-panel/users-panel.component.ts index 78278f96..3101660c 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')) { 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..0f500a3c 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..b49ad88d 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 */ +} \ No newline at end of file From 0e17d0d221f85cfd0a1565757e335d72b4fb9216 Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Tue, 9 Jul 2024 09:47:59 -0500 Subject: [PATCH 6/7] Fix links DesignSafe (fixes WG-322) Also makes the page open in a new tab --- .../components/users-panel/users-panel.component.html | 10 +++++----- .../components/users-panel/users-panel.component.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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
Project: - + {{ activeProject.ds_id }} | {{ activeProject.title }} @@ -113,7 +113,7 @@
Saved Location
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 3101660c..02dfac95 100644 --- a/angular/src/app/components/users-panel/users-panel.component.ts +++ b/angular/src/app/components/users-panel/users-panel.component.ts @@ -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 + '/'; } } From 61e7c43c81cc2e1080b3a66d4ac8e41f49938fbf Mon Sep 17 00:00:00 2001 From: Nathan Franklin Date: Tue, 9 Jul 2024 10:52:07 -0500 Subject: [PATCH 7/7] Fix linting issues --- .../app/components/users-panel/users-panel.component.ts | 2 +- angular/src/app/services/env.service.ts | 6 +++--- angular/src/environments/environmentType.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) 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 02dfac95..02736261 100644 --- a/angular/src/app/components/users-panel/users-panel.component.ts +++ b/angular/src/app/components/users-panel/users-panel.component.ts @@ -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/env.service.ts b/angular/src/app/services/env.service.ts index 0f500a3c..80b4774b 100644 --- a/angular/src/app/services/env.service.ts +++ b/angular/src/app/services/env.service.ts @@ -38,10 +38,10 @@ export class EnvService { return 'https://www.designsafe-ci.org'; } else if (backend === DesignSafeEnvironmentType.Next) { return 'https://designsafeci-next.tacc.utexas.edu'; - } else if (backend == DesignSafeEnvironmentType.Dev) { + } else if (backend === DesignSafeEnvironmentType.Dev) { return 'https://designsafeci-dev.tacc.utexas.edu'; } else { - throw new Error("Unsupported DS environment"); + throw new Error('Unsupported DS environment'); } } @@ -116,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._designSafePortalUrl = this.getDesignSafePortalUrl(environment.designSafePortal); + 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'; diff --git a/angular/src/environments/environmentType.ts b/angular/src/environments/environmentType.ts index b49ad88d..698b50af 100644 --- a/angular/src/environments/environmentType.ts +++ b/angular/src/environments/environmentType.ts @@ -7,8 +7,8 @@ export enum EnvironmentType { } export enum DesignSafeEnvironmentType { - Production = 'production', /* https://www.designsafe-ci.org/ */ - Dev = 'dev' /* https://designsafeci-dev.tacc.utexas.edu/ */ , + 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 */ -} \ No newline at end of file + Local = 'local' /* not supported but would be designsafe.dev */, +}