Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions frontend/src/app/dashboard/type/dashboard-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ import { DashboardFile } from "./dashboard-file.interface";
import { DashboardWorkflow } from "./dashboard-workflow.interface";
import { DashboardProject } from "./dashboard-project.interface";
import { DashboardDataset } from "./dashboard-dataset.interface";
import { isDashboardDataset, isDashboardFile, isDashboardProject, isDashboardWorkflow } from "./type-predicates";
import { DashboardWorkflowComputingUnit } from "../../workspace/types/workflow-computing-unit";
import {
isDashboardDataset,
isDashboardFile,
isDashboardProject,
isDashboardWorkflow,
isDashboardWorkflowComputingUnit,
} from "./type-predicates";
import { EntityType } from "../../hub/service/hub.service";

export interface UserInfo {
Expand Down Expand Up @@ -50,7 +57,14 @@ export class DashboardEntry {
accessibleUserIds: number[];
coverImageUrl?: string;

constructor(public value: DashboardWorkflow | DashboardProject | DashboardFile | DashboardDataset) {
constructor(
public value:
| DashboardWorkflow
| DashboardProject
| DashboardFile
| DashboardDataset
| DashboardWorkflowComputingUnit
) {
if (isDashboardWorkflow(value)) {
this.type = EntityType.Workflow;
this.id = value.workflow.wid;
Expand Down Expand Up @@ -124,6 +138,20 @@ export class DashboardEntry {
this.isLiked = false;
this.accessibleUserIds = [];
this.coverImageUrl = value.dataset.coverImage;
} else if (isDashboardWorkflowComputingUnit(value)) {
this.type = EntityType.ComputingUnit;
this.id = value.computingUnit.cuid;
this.name = value.computingUnit.name;
this.creationTime = value.computingUnit.creationTime;
this.accessLevel = value.accessPrivilege;
this.ownerName = "";
this.ownerGoogleAvatar = "";
this.ownerId = value.computingUnit.uid;
this.viewCount = 0;
this.cloneCount = 0;
this.likeCount = 0;
this.isLiked = false;
this.accessibleUserIds = [];
} else {
throw new Error("Unexpected type in DashboardEntry.");
}
Expand Down Expand Up @@ -182,4 +210,11 @@ export class DashboardEntry {
}
return this.value;
}

get computingUnit(): DashboardWorkflowComputingUnit {
if (!isDashboardWorkflowComputingUnit(this.value)) {
throw new Error("Value is not of type DashboardWorkflowComputingUnit");
}
return this.value;
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/dashboard/type/search-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { DashboardDataset } from "./dashboard-dataset.interface";
import { DashboardEntry } from "./dashboard-entry";

export interface SearchResultItem {
resourceType: "workflow" | "project" | "file" | "dataset";
resourceType: "workflow" | "project" | "file" | "dataset" | "computing-unit";
workflow?: DashboardWorkflow;
project?: DashboardProject;
file?: DashboardFile;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/dashboard/type/type-predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DashboardWorkflow } from "./dashboard-workflow.interface";
import { DashboardProject } from "./dashboard-project.interface";
import { DashboardFile } from "./dashboard-file.interface";
import { DashboardDataset } from "./dashboard-dataset.interface";
import { DashboardWorkflowComputingUnit } from "../../workspace/types/workflow-computing-unit";

export function isDashboardWorkflow(value: any): value is DashboardWorkflow {
return value && typeof value.workflow === "object";
Expand All @@ -37,3 +38,7 @@ export function isDashboardFile(value: any): value is DashboardFile {
export function isDashboardDataset(value: any): value is DashboardDataset {
return value && typeof value.dataset === "object";
}

export function isDashboardWorkflowComputingUnit(value: any): value is DashboardWorkflowComputingUnit {
return value && typeof value.computingUnit === "object";
}
1 change: 1 addition & 0 deletions frontend/src/app/hub/service/hub.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum EntityType {
Dataset = "dataset",
Project = "project",
File = "file",
ComputingUnit = "computing-unit",
}

export enum ActionType {
Expand Down
Loading