From 8cb2f9c273035a7ab0d029abf86bdba671f99e37 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Wed, 16 Oct 2024 23:46:19 -0700 Subject: [PATCH 01/12] quick fix --- .../component/dashboard.component.ts | 10 +-- .../user/filters/filters.component.html | 2 +- .../user/filters/filters.component.ts | 72 ++++++++++++++----- .../component/user/search/search.component.ts | 12 +++- 4 files changed, 72 insertions(+), 24 deletions(-) diff --git a/core/gui/src/app/dashboard/component/dashboard.component.ts b/core/gui/src/app/dashboard/component/dashboard.component.ts index 3fcb8e9c393..637d3de6a92 100644 --- a/core/gui/src/app/dashboard/component/dashboard.component.ts +++ b/core/gui/src/app/dashboard/component/dashboard.component.ts @@ -36,7 +36,11 @@ export class DashboardComponent implements OnInit { private route: ActivatedRoute, private googleAuthService: GoogleAuthService, private notificationService: NotificationService - ) { + ) {} + + ngOnInit(): void { + this.isCollpased = false; + this.userService .userChanged() .pipe(untilDestroyed(this)) @@ -45,10 +49,6 @@ export class DashboardComponent implements OnInit { this.isAdmin = this.userService.isAdmin(); this.cdr.detectChanges(); }); - } - - ngOnInit(): void { - this.isCollpased = false; if (!this.isLogin) { this.googleAuthService.googleAuthInit(document.getElementById("googleButton")); diff --git a/core/gui/src/app/dashboard/component/user/filters/filters.component.html b/core/gui/src/app/dashboard/component/user/filters/filters.component.html index e5ccfa64752..8fc4539e4f7 100644 --- a/core/gui/src/app/dashboard/component/user/filters/filters.component.html +++ b/core/gui/src/app/dashboard/component/user/filters/filters.component.html @@ -55,7 +55,7 @@ { + // this.isLogin = this.userService.isLogin(); + // this.cdr.detectChanges(); + // if (this.isLogin) { + // return this.userProjectService.getProjectList() as Observable; + // } else { + // return of([] as DashboardProject[]); + // } + // }) + // ) + // .subscribe((userProjectsList: DashboardProject[]) => { + // if (userProjectsList != null && userProjectsList.length > 0) { + // // map project ID to project object + // this.userProjectsMap = new Map(userProjectsList.map(userProject => [userProject.pid, userProject])); + // // store the projects containing these workflows + // this.userProjectsDropdown = userProjectsList.map(proj => { + // return { pid: proj.pid, name: proj.name, checked: false }; + // }); + // this.userProjectsLoaded = true; + // } + // }); + // } + constructor( private userService: UserService, private operatorMetadataService: OperatorMetadataService, private notificationService: NotificationService, private userProjectService: UserProjectService, - private workflowPersistService: WorkflowPersistService - ) { + private workflowPersistService: WorkflowPersistService, + private cdr: ChangeDetectorRef, + ) {} + + ngOnInit(): void { + this.setupUserProject(); + this.searchParameterBackendSetup(); + } + + private setupUserProject(): void { this.userService .userChanged() .pipe( - // eslint-disable-next-line rxjs/no-unsafe-takeuntil - untilDestroyed(this), switchMap(() => { this.isLogin = this.userService.isLogin(); + this.cdr.detectChanges(); if (this.isLogin) { return this.userProjectService.getProjectList() as Observable; } else { return of([] as DashboardProject[]); } - }) + }), + untilDestroyed(this) ) .subscribe((userProjectsList: DashboardProject[]) => { - if (userProjectsList != null && userProjectsList.length > 0) { - // map project ID to project object + if (userProjectsList && userProjectsList.length > 0) { this.userProjectsMap = new Map(userProjectsList.map(userProject => [userProject.pid, userProject])); - // store the projects containing these workflows - this.userProjectsDropdown = userProjectsList.map(proj => { - return { pid: proj.pid, name: proj.name, checked: false }; - }); + this.userProjectsDropdown = userProjectsList.map(proj => ({ + pid: proj.pid, + name: proj.name, + checked: false, + })); this.userProjectsLoaded = true; } }); } - ngOnInit(): void { - this.searchParameterBackendSetup(); - } - /** * Backend calls for Workflow IDs, Owners, and Operators in saved workflow component */ diff --git a/core/gui/src/app/dashboard/component/user/search/search.component.ts b/core/gui/src/app/dashboard/component/user/search/search.component.ts index 19da6548e91..91630b0bfc4 100644 --- a/core/gui/src/app/dashboard/component/user/search/search.component.ts +++ b/core/gui/src/app/dashboard/component/user/search/search.component.ts @@ -1,4 +1,4 @@ -import { Component, AfterViewInit, ViewChild } from "@angular/core"; +import { Component, AfterViewInit, ViewChild, ChangeDetectorRef } from "@angular/core"; import { DashboardEntry, UserInfo } from "../../../type/dashboard-entry"; import { SearchService } from "../../../service/user/search.service"; import { FiltersComponent } from "../filters/filters.component"; @@ -23,6 +23,7 @@ export class SearchComponent implements AfterViewInit { private isLogin = this.userService.isLogin(); private includePublic = true; currentUid = this.userService.getCurrentUser()?.uid; + searchKeywords: string[] = []; selectedType: "project" | "workflow" | "dataset" | null = null; lastSelectedType: "project" | "workflow" | "dataset" | null = null; @@ -47,7 +48,9 @@ export class SearchComponent implements AfterViewInit { private location: Location, private searchService: SearchService, private userService: UserService, - private activatedRoute: ActivatedRoute + private activatedRoute: ActivatedRoute, + private cdr: ChangeDetectorRef + ) { this.userService .userChanged() @@ -66,6 +69,11 @@ export class SearchComponent implements AfterViewInit { this.updateMasterFilterList(); } }); + + setTimeout(() => { + this.searchKeywords = this.filters.getSearchKeywords(); + this.cdr.detectChanges(); + }, 0); } async search(): Promise { From 0db905dafb76b71a9a4520d6938630d8c4944bc2 Mon Sep 17 00:00:00 2001 From: shenghao fu <2318002579@qq.com> Date: Thu, 17 Oct 2024 14:50:36 -0700 Subject: [PATCH 02/12] quick fix --- .../workflow/detail/hub-workflow-detail.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts b/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts index 1c5252a4d79..4a66d80ef37 100644 --- a/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts +++ b/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts @@ -141,7 +141,9 @@ export class HubWorkflowDetailComponent implements AfterViewInit, OnDestroy, OnI ngOnDestroy() { if (this.workflowPersistService.isWorkflowPersistEnabled()) { const workflow = this.workflowActionService.getWorkflow(); - this.workflowPersistService.persistWorkflow(workflow).pipe(untilDestroyed(this)).subscribe(); + if(this.isLogin){ + this.workflowPersistService.persistWorkflow(workflow).pipe(untilDestroyed(this)).subscribe(); + } } this.codeEditorViewRef.clear(); From df98226210ada43184617acb27986bc8b22ba0df Mon Sep 17 00:00:00 2001 From: shenghao fu <2318002579@qq.com> Date: Thu, 17 Oct 2024 14:54:27 -0700 Subject: [PATCH 03/12] quick fix --- .../user/filters/filters.component.ts | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/core/gui/src/app/dashboard/component/user/filters/filters.component.ts b/core/gui/src/app/dashboard/component/user/filters/filters.component.ts index 84e72591c82..becb8581d04 100644 --- a/core/gui/src/app/dashboard/component/user/filters/filters.component.ts +++ b/core/gui/src/app/dashboard/component/user/filters/filters.component.ts @@ -66,42 +66,6 @@ export class FiltersComponent implements OnInit { public userProjectsLoaded: boolean = false; // tracks whether all DashboardProjectInterface information has been loaded (ready to render project colors) public searchCriteria: string[] = ["owner", "id", "ctime", "mtime", "operator", "project"]; - // constructor( - // private userService: UserService, - // private operatorMetadataService: OperatorMetadataService, - // private notificationService: NotificationService, - // private userProjectService: UserProjectService, - // private workflowPersistService: WorkflowPersistService, - // private cdr: ChangeDetectorRef, - // ) { - // this.userService - // .userChanged() - // .pipe( - // // eslint-disable-next-line rxjs/no-unsafe-takeuntil - // untilDestroyed(this), - // switchMap(() => { - // this.isLogin = this.userService.isLogin(); - // this.cdr.detectChanges(); - // if (this.isLogin) { - // return this.userProjectService.getProjectList() as Observable; - // } else { - // return of([] as DashboardProject[]); - // } - // }) - // ) - // .subscribe((userProjectsList: DashboardProject[]) => { - // if (userProjectsList != null && userProjectsList.length > 0) { - // // map project ID to project object - // this.userProjectsMap = new Map(userProjectsList.map(userProject => [userProject.pid, userProject])); - // // store the projects containing these workflows - // this.userProjectsDropdown = userProjectsList.map(proj => { - // return { pid: proj.pid, name: proj.name, checked: false }; - // }); - // this.userProjectsLoaded = true; - // } - // }); - // } - constructor( private userService: UserService, private operatorMetadataService: OperatorMetadataService, From 12cedf68b688739eae543690568948ddb6e12b38 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Thu, 17 Oct 2024 21:48:36 -0700 Subject: [PATCH 04/12] fix forum 404 --- .../gui/src/app/dashboard/component/dashboard.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/gui/src/app/dashboard/component/dashboard.component.ts b/core/gui/src/app/dashboard/component/dashboard.component.ts index 637d3de6a92..788fe2a7c09 100644 --- a/core/gui/src/app/dashboard/component/dashboard.component.ts +++ b/core/gui/src/app/dashboard/component/dashboard.component.ts @@ -65,7 +65,10 @@ export class DashboardComponent implements OnInit { this.router.navigateByUrl(this.route.snapshot.queryParams["returnUrl"] || "/dashboard/user/workflow") ); } - if (!document.cookie.includes("flarum_remember") && this.isLogin) { + + if (window.location.hostname === "localhost") { + console.warn("Skipping forum authentication in local environment."); + } else if (!document.cookie.includes("flarum_remember") && this.isLogin) { this.flarumService .auth() .pipe(untilDestroyed(this)) @@ -74,7 +77,7 @@ export class DashboardComponent implements OnInit { document.cookie = `flarum_remember=${response.token};path=/`; }, error: (err: unknown) => { - if ((err as HttpErrorResponse).status == 404) { + if ((err as HttpErrorResponse).status === 404) { this.displayForum = false; } else { this.flarumService From 65d7b347f19969fabfb8483959d0bacb5d810f41 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Thu, 17 Oct 2024 23:02:51 -0700 Subject: [PATCH 05/12] fix NG0100 in search.component.ts --- .../app/dashboard/component/user/search/search.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/gui/src/app/dashboard/component/user/search/search.component.ts b/core/gui/src/app/dashboard/component/user/search/search.component.ts index 91630b0bfc4..95dcf945ec1 100644 --- a/core/gui/src/app/dashboard/component/user/search/search.component.ts +++ b/core/gui/src/app/dashboard/component/user/search/search.component.ts @@ -68,12 +68,10 @@ export class SearchComponent implements AfterViewInit { this.searchParam = keyword; this.updateMasterFilterList(); } - }); - setTimeout(() => { this.searchKeywords = this.filters.getSearchKeywords(); this.cdr.detectChanges(); - }, 0); + }); } async search(): Promise { From 4a5e90a6fda10b6c8c98aa55b47fb681b9ca91d0 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Fri, 18 Oct 2024 16:17:53 -0700 Subject: [PATCH 06/12] fix forum error --- .../dashboard/DashboardResource.scala | 23 +++++++++- .../component/dashboard.component.ts | 44 +++++++++++-------- .../service/user/flarum/flarum.service.ts | 17 +++++++ 3 files changed, 65 insertions(+), 19 deletions(-) diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala index 78080b80eb6..658f6d1e3dc 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala @@ -11,11 +11,13 @@ import io.dropwizard.auth.Auth import org.jooq.{Field, OrderField} import javax.ws.rs._ -import javax.ws.rs.core.MediaType +import javax.ws.rs.core.{MediaType, Response} import org.jooq.types.UInteger +import java.net.{HttpURLConnection, URL} import java.util import scala.jdk.CollectionConverters._ +import scala.util.{Failure, Success, Try} object DashboardResource { case class DashboardClickableFileEntry( resourceType: String, @@ -216,4 +218,23 @@ class DashboardResource { records.getValues(WORKFLOW_USER_ACCESS.UID) } + + @GET + @Path("/forumHealth") + @Produces(Array(MediaType.APPLICATION_JSON)) + def forumHealthCheck(): Response = { + val forumApiUrl = sys.env.getOrElse("FORUM_API_URL", "http://localhost:4200/forum/api/token") + + val isForumAvailable = Try { + val connection = new URL(forumApiUrl).openConnection().asInstanceOf[HttpURLConnection] + connection.setConnectTimeout(5000) + connection.setReadTimeout(5000) + connection.setRequestMethod("GET") + connection.connect() + connection.getResponseCode == 200 + }.getOrElse(false) + + val status = Map("forumAvailable" -> isForumAvailable) + Response.ok(status).build() + } } diff --git a/core/gui/src/app/dashboard/component/dashboard.component.ts b/core/gui/src/app/dashboard/component/dashboard.component.ts index 788fe2a7c09..235f19bcf94 100644 --- a/core/gui/src/app/dashboard/component/dashboard.component.ts +++ b/core/gui/src/app/dashboard/component/dashboard.component.ts @@ -66,28 +66,36 @@ export class DashboardComponent implements OnInit { ); } - if (window.location.hostname === "localhost") { - console.warn("Skipping forum authentication in local environment."); - } else if (!document.cookie.includes("flarum_remember") && this.isLogin) { + if (!document.cookie.includes("flarum_remember") && this.isLogin) { this.flarumService - .auth() + .checkForumHealth() .pipe(untilDestroyed(this)) - .subscribe({ - next: (response: any) => { - document.cookie = `flarum_remember=${response.token};path=/`; - }, - error: (err: unknown) => { - if ((err as HttpErrorResponse).status === 404) { - this.displayForum = false; - } else { - this.flarumService - .register() - .pipe(untilDestroyed(this)) - .subscribe(() => this.ngOnInit()); - } - }, + .subscribe((isHealthy: boolean) => { + if (!isHealthy) { + return; + } + + this.flarumService + .auth() + .pipe(untilDestroyed(this)) + .subscribe({ + next: (response: any) => { + document.cookie = `flarum_remember=${response.token};path=/`; + }, + error: (err: unknown) => { + if ((err as HttpErrorResponse).status === 404) { + this.displayForum = false; + } else { + this.flarumService + .register() + .pipe(untilDestroyed(this)) + .subscribe(() => this.ngOnInit()); + } + }, + }); }); } + this.router.events.pipe(untilDestroyed(this)).subscribe(() => { this.checkRoute(); }); diff --git a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts index 9853912893c..dd327960c2b 100644 --- a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts +++ b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts @@ -2,6 +2,8 @@ import { Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { UserService } from "../../../../common/service/user/user.service"; import { AppSettings } from "../../../../common/app-setting"; +import { catchError, map } from "rxjs/operators"; +import { Observable, of } from "rxjs"; @Injectable({ providedIn: "root", @@ -23,4 +25,19 @@ export class FlarumService { { headers: { "Content-Type": "application/json" }, withCredentials: true } ); } + + checkForumHealth(): Observable { + return this.http + .get<{ forumAvailable: boolean }>(`${AppSettings.getApiEndpoint()}/dashboard/forumHealth`) + .pipe( + map((response) => { + // console.log("Health check response:", response); + return response.forumAvailable; + }), + catchError((error: unknown) => { + // console.warn("Forum health check failed:", error); + return of(false); + }) + ); + } } From 43cfef18cdcbf25ac769fde651bf4468d9199ce2 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Fri, 18 Oct 2024 18:28:38 -0700 Subject: [PATCH 07/12] quick fix --- .../app/dashboard/component/user/filters/filters.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/gui/src/app/dashboard/component/user/filters/filters.component.html b/core/gui/src/app/dashboard/component/user/filters/filters.component.html index 8fc4539e4f7..eca513c7fe0 100644 --- a/core/gui/src/app/dashboard/component/user/filters/filters.component.html +++ b/core/gui/src/app/dashboard/component/user/filters/filters.component.html @@ -165,7 +165,7 @@ Date: Fri, 18 Oct 2024 18:52:48 -0700 Subject: [PATCH 08/12] fix NG0100 in filter component --- .../user/filters/filters.component.html | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/core/gui/src/app/dashboard/component/user/filters/filters.component.html b/core/gui/src/app/dashboard/component/user/filters/filters.component.html index eca513c7fe0..484cf4acc36 100644 --- a/core/gui/src/app/dashboard/component/user/filters/filters.component.html +++ b/core/gui/src/app/dashboard/component/user/filters/filters.component.html @@ -15,8 +15,7 @@ + nzTheme="outline"> @@ -42,8 +41,7 @@ + nzTheme="outline"> @@ -69,8 +67,7 @@ + nzType="user"> @@ -104,8 +101,7 @@ + nzType="ordered-list"> @@ -138,8 +134,7 @@ + nzTheme="outline"> @@ -179,8 +174,7 @@ + nzTheme="outline"> From 353e0cc3c2e713d737de49df413411d0c9c30d7a Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Fri, 18 Oct 2024 20:26:27 -0700 Subject: [PATCH 09/12] fix NG0100 in list item --- .../component/user/list-item/list-item.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts b/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts index 8d227f9598c..8b74d3376dc 100644 --- a/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts +++ b/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts @@ -7,7 +7,7 @@ import { OnChanges, SimpleChanges, ViewChild, - ElementRef, + ElementRef, ChangeDetectorRef, } from "@angular/core"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { NzModalService } from "ng-zorro-antd/modal"; @@ -68,7 +68,8 @@ export class ListItemComponent implements OnInit, OnChanges { private modalService: NzModalService, private workflowPersistService: WorkflowPersistService, private modal: NzModalService, - private downloadService: DownloadService + private downloadService: DownloadService, + private cdr: ChangeDetectorRef ) {} initializeEntry() { @@ -82,6 +83,7 @@ export class ListItemComponent implements OnInit, OnChanges { } else { this.entryLink = [this.ROUTER_WORKFLOW_DETAIL_BASE_URL, String(this.entry.id)]; } + setTimeout(() => this.cdr.detectChanges(), 0); }); } // this.entryLink = this.ROUTER_WORKFLOW_BASE_URL + "/" + this.entry.id; From a07773a5bbcab7b23b1eabec062f7ca24933c24d Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Fri, 18 Oct 2024 20:30:34 -0700 Subject: [PATCH 10/12] fmt fix --- .../dashboard/DashboardResource.scala | 2 +- .../user/filters/filters.component.ts | 2 +- .../user/list-item/list-item.component.ts | 3 ++- .../component/user/search/search.component.ts | 1 - .../service/user/flarum/flarum.service.ts | 22 +++++++++---------- .../detail/hub-workflow-detail.component.ts | 2 +- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala index 658f6d1e3dc..259066e225c 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala @@ -17,7 +17,7 @@ import org.jooq.types.UInteger import java.net.{HttpURLConnection, URL} import java.util import scala.jdk.CollectionConverters._ -import scala.util.{Failure, Success, Try} +import scala.util.Try object DashboardResource { case class DashboardClickableFileEntry( resourceType: String, diff --git a/core/gui/src/app/dashboard/component/user/filters/filters.component.ts b/core/gui/src/app/dashboard/component/user/filters/filters.component.ts index becb8581d04..d192e285e05 100644 --- a/core/gui/src/app/dashboard/component/user/filters/filters.component.ts +++ b/core/gui/src/app/dashboard/component/user/filters/filters.component.ts @@ -72,7 +72,7 @@ export class FiltersComponent implements OnInit { private notificationService: NotificationService, private userProjectService: UserProjectService, private workflowPersistService: WorkflowPersistService, - private cdr: ChangeDetectorRef, + private cdr: ChangeDetectorRef ) {} ngOnInit(): void { diff --git a/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts b/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts index 8b74d3376dc..480f4c3f9b9 100644 --- a/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts +++ b/core/gui/src/app/dashboard/component/user/list-item/list-item.component.ts @@ -7,7 +7,8 @@ import { OnChanges, SimpleChanges, ViewChild, - ElementRef, ChangeDetectorRef, + ElementRef, + ChangeDetectorRef, } from "@angular/core"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { NzModalService } from "ng-zorro-antd/modal"; diff --git a/core/gui/src/app/dashboard/component/user/search/search.component.ts b/core/gui/src/app/dashboard/component/user/search/search.component.ts index 95dcf945ec1..69e189c8a62 100644 --- a/core/gui/src/app/dashboard/component/user/search/search.component.ts +++ b/core/gui/src/app/dashboard/component/user/search/search.component.ts @@ -50,7 +50,6 @@ export class SearchComponent implements AfterViewInit { private userService: UserService, private activatedRoute: ActivatedRoute, private cdr: ChangeDetectorRef - ) { this.userService .userChanged() diff --git a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts index dd327960c2b..4e1dfdbc607 100644 --- a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts +++ b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts @@ -27,17 +27,15 @@ export class FlarumService { } checkForumHealth(): Observable { - return this.http - .get<{ forumAvailable: boolean }>(`${AppSettings.getApiEndpoint()}/dashboard/forumHealth`) - .pipe( - map((response) => { - // console.log("Health check response:", response); - return response.forumAvailable; - }), - catchError((error: unknown) => { - // console.warn("Forum health check failed:", error); - return of(false); - }) - ); + return this.http.get<{ forumAvailable: boolean }>(`${AppSettings.getApiEndpoint()}/dashboard/forumHealth`).pipe( + map(response => { + // console.log("Health check response:", response); + return response.forumAvailable; + }), + catchError((error: unknown) => { + // console.warn("Forum health check failed:", error); + return of(false); + }) + ); } } diff --git a/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts b/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts index 4a66d80ef37..3276b14266a 100644 --- a/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts +++ b/core/gui/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts @@ -141,7 +141,7 @@ export class HubWorkflowDetailComponent implements AfterViewInit, OnDestroy, OnI ngOnDestroy() { if (this.workflowPersistService.isWorkflowPersistEnabled()) { const workflow = this.workflowActionService.getWorkflow(); - if(this.isLogin){ + if (this.isLogin) { this.workflowPersistService.persistWorkflow(workflow).pipe(untilDestroyed(this)).subscribe(); } } From 154b7e94028a499c882f92637f38730931af91b7 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Sat, 19 Oct 2024 20:33:25 -0700 Subject: [PATCH 11/12] remove forum health check --- .../dashboard/DashboardResource.scala | 23 +---------- .../component/dashboard.component.ts | 41 +++++++------------ .../service/user/flarum/flarum.service.ts | 13 ------ 3 files changed, 16 insertions(+), 61 deletions(-) diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala index 259066e225c..78080b80eb6 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/DashboardResource.scala @@ -11,13 +11,11 @@ import io.dropwizard.auth.Auth import org.jooq.{Field, OrderField} import javax.ws.rs._ -import javax.ws.rs.core.{MediaType, Response} +import javax.ws.rs.core.MediaType import org.jooq.types.UInteger -import java.net.{HttpURLConnection, URL} import java.util import scala.jdk.CollectionConverters._ -import scala.util.Try object DashboardResource { case class DashboardClickableFileEntry( resourceType: String, @@ -218,23 +216,4 @@ class DashboardResource { records.getValues(WORKFLOW_USER_ACCESS.UID) } - - @GET - @Path("/forumHealth") - @Produces(Array(MediaType.APPLICATION_JSON)) - def forumHealthCheck(): Response = { - val forumApiUrl = sys.env.getOrElse("FORUM_API_URL", "http://localhost:4200/forum/api/token") - - val isForumAvailable = Try { - val connection = new URL(forumApiUrl).openConnection().asInstanceOf[HttpURLConnection] - connection.setConnectTimeout(5000) - connection.setReadTimeout(5000) - connection.setRequestMethod("GET") - connection.connect() - connection.getResponseCode == 200 - }.getOrElse(false) - - val status = Map("forumAvailable" -> isForumAvailable) - Response.ok(status).build() - } } diff --git a/core/gui/src/app/dashboard/component/dashboard.component.ts b/core/gui/src/app/dashboard/component/dashboard.component.ts index 235f19bcf94..637d3de6a92 100644 --- a/core/gui/src/app/dashboard/component/dashboard.component.ts +++ b/core/gui/src/app/dashboard/component/dashboard.component.ts @@ -65,37 +65,26 @@ export class DashboardComponent implements OnInit { this.router.navigateByUrl(this.route.snapshot.queryParams["returnUrl"] || "/dashboard/user/workflow") ); } - if (!document.cookie.includes("flarum_remember") && this.isLogin) { this.flarumService - .checkForumHealth() + .auth() .pipe(untilDestroyed(this)) - .subscribe((isHealthy: boolean) => { - if (!isHealthy) { - return; - } - - this.flarumService - .auth() - .pipe(untilDestroyed(this)) - .subscribe({ - next: (response: any) => { - document.cookie = `flarum_remember=${response.token};path=/`; - }, - error: (err: unknown) => { - if ((err as HttpErrorResponse).status === 404) { - this.displayForum = false; - } else { - this.flarumService - .register() - .pipe(untilDestroyed(this)) - .subscribe(() => this.ngOnInit()); - } - }, - }); + .subscribe({ + next: (response: any) => { + document.cookie = `flarum_remember=${response.token};path=/`; + }, + error: (err: unknown) => { + if ((err as HttpErrorResponse).status == 404) { + this.displayForum = false; + } else { + this.flarumService + .register() + .pipe(untilDestroyed(this)) + .subscribe(() => this.ngOnInit()); + } + }, }); } - this.router.events.pipe(untilDestroyed(this)).subscribe(() => { this.checkRoute(); }); diff --git a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts index 4e1dfdbc607..3bc8ef191ef 100644 --- a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts +++ b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts @@ -25,17 +25,4 @@ export class FlarumService { { headers: { "Content-Type": "application/json" }, withCredentials: true } ); } - - checkForumHealth(): Observable { - return this.http.get<{ forumAvailable: boolean }>(`${AppSettings.getApiEndpoint()}/dashboard/forumHealth`).pipe( - map(response => { - // console.log("Health check response:", response); - return response.forumAvailable; - }), - catchError((error: unknown) => { - // console.warn("Forum health check failed:", error); - return of(false); - }) - ); - } } From cc11c2a978e616f153f7045ecaa156e0cb7cc44f Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Sat, 19 Oct 2024 20:35:38 -0700 Subject: [PATCH 12/12] quick fix --- .../gui/src/app/dashboard/service/user/flarum/flarum.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts index 3bc8ef191ef..9853912893c 100644 --- a/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts +++ b/core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts @@ -2,8 +2,6 @@ import { Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { UserService } from "../../../../common/service/user/user.service"; import { AppSettings } from "../../../../common/app-setting"; -import { catchError, map } from "rxjs/operators"; -import { Observable, of } from "rxjs"; @Injectable({ providedIn: "root",