Skip to content

Commit

Permalink
move "workflowUserAccess" from DashboardResource.scala to WorkflowRes…
Browse files Browse the repository at this point in the history
…ource
  • Loading branch information
GspikeHalo committed Jan 10, 2025
1 parent fa71a10 commit 7873603
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,4 @@ class DashboardResource {

userIdToInfoMap
}

// todo: move this function to WorkflowResource.scala
@GET
@Path("/workflowUserAccess")
def workflowUserAccess(
@QueryParam("wid") wid: UInteger
): util.List[UInteger] = {
val records = context
.select(WORKFLOW_USER_ACCESS.UID)
.from(WORKFLOW_USER_ACCESS)
.where(WORKFLOW_USER_ACCESS.WID.eq(wid))
.fetch()

records.getValues(WORKFLOW_USER_ACCESS.UID)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import edu.uci.ics.texera.dao.jooq.generated.tables.daos.{
WorkflowUserAccessDao
}
import edu.uci.ics.texera.dao.jooq.generated.tables.pojos._
import edu.uci.ics.texera.web.resource.dashboard.SearchQueryBuilder.context
import edu.uci.ics.texera.web.resource.dashboard.hub.workflow.HubWorkflowResource.recordUserActivity
import edu.uci.ics.texera.web.resource.dashboard.user.workflow.WorkflowAccessResource.hasReadAccess
import edu.uci.ics.texera.web.resource.dashboard.user.workflow.WorkflowResource._
Expand Down Expand Up @@ -590,4 +591,18 @@ class WorkflowResource extends LazyLogging {
"Private"
}
}

@GET
@Path("/workflowUserAccess")
def workflowUserAccess(
@QueryParam("wid") wid: UInteger
): util.List[UInteger] = {
val records = context
.select(WORKFLOW_USER_ACCESS.UID)
.from(WORKFLOW_USER_ACCESS)
.where(WORKFLOW_USER_ACCESS.WID.eq(wid))
.fetch()

records.getValues(WORKFLOW_USER_ACCESS.UID)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const WORKFLOW_UPDATENAME_URL = WORKFLOW_BASE_URL + "/update/name";
export const WORKFLOW_UPDATEDESCRIPTION_URL = WORKFLOW_BASE_URL + "/update/description";
export const WORKFLOW_OWNER_URL = WORKFLOW_BASE_URL + "/user-workflow-owners";
export const WORKFLOW_ID_URL = WORKFLOW_BASE_URL + "/user-workflow-ids";
export const WORKFLOW_GET_OWNERS_URL = WORKFLOW_BASE_URL + "/workflowUserAccess";

export const DEFAULT_WORKFLOW_NAME = "Untitled workflow";
export const WORKFLOW_PUBLIC_URL = WORKFLOW_BASE_URL + "/public";
Expand Down Expand Up @@ -204,4 +205,8 @@ export class WorkflowPersistService {
public retrieveWorkflowIDs(): Observable<number[]> {
return this.http.get<number[]>(`${AppSettings.getApiEndpoint()}/${WORKFLOW_ID_URL}`);
}

public getWorkflowOwners(wid: number): Observable<number[]> {
return this.http.get<number[]>(`${AppSettings.getApiEndpoint()}/${WORKFLOW_GET_OWNERS_URL}?wid=${wid}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
WorkflowPersistService,
} from "src/app/common/service/workflow-persist/workflow-persist.service";
import { firstValueFrom } from "rxjs";
import { SearchService } from "../../../service/user/search.service";
import { HubWorkflowDetailComponent } from "../../../../hub/component/workflow/detail/hub-workflow-detail.component";
import { HubWorkflowService } from "../../../../hub/service/workflow/hub-workflow.service";
import { DownloadService } from "src/app/dashboard/service/user/download/download.service";
Expand Down Expand Up @@ -77,7 +76,6 @@ export class ListItemComponent implements OnInit, OnChanges {
refresh = new EventEmitter<void>();

constructor(
private searchService: SearchService,
private modalService: NzModalService,
private workflowPersistService: WorkflowPersistService,
private datasetService: DatasetService,
Expand All @@ -92,7 +90,7 @@ export class ListItemComponent implements OnInit, OnChanges {
if (this.entry.type === "workflow") {
if (typeof this.entry.id === "number") {
this.disableDelete = !this.entry.workflow.isOwner;
this.searchService
this.workflowPersistService
.getWorkflowOwners(this.entry.id)
.pipe(untilDestroyed(this))
.subscribe((data: number[]) => {
Expand Down
5 changes: 0 additions & 5 deletions core/gui/src/app/dashboard/service/user/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { UserInfo } from "../../type/dashboard-entry";
const DASHBOARD_SEARCH_URL = "dashboard/search";
const DASHBOARD_PUBLIC_SEARCH_URL = "dashboard/publicSearch";
const DASHBOARD_USER_INFO_URL = "dashboard/resultsOwnersInfo";
const DASHBOARD_GET_OWNERS_URL = "dashboard/workflowUserAccess";

@Injectable({
providedIn: "root",
Expand Down Expand Up @@ -62,8 +61,4 @@ export class SearchService {
`${AppSettings.getApiEndpoint()}/${DASHBOARD_USER_INFO_URL}?${queryString}`
);
}

public getWorkflowOwners(wid: number): Observable<number[]> {
return this.http.get<number[]>(`${AppSettings.getApiEndpoint()}/${DASHBOARD_GET_OWNERS_URL}?wid=${wid}`);
}
}

0 comments on commit 7873603

Please sign in to comment.