Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webui settings #3075

Merged
merged 37 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fec62c6
Adding skeleton for Job Detail page. Temp available at HOST:PORT/jobd…
XandraMcC Nov 27, 2023
d931433
Allow running the Web UI detached / in dev mode
simonwo Nov 27, 2023
3c5098f
Show jobs table in date order and with relative dates.
simonwo Nov 27, 2023
30b2932
Docker parameters should be separated by spaces at least.
simonwo Nov 27, 2023
5758e35
Make jobs table more closely match design
simonwo Nov 27, 2023
5e86670
Space out action buttons and add contrast.
simonwo Nov 27, 2023
bc75372
Refactor sidebar to be Bacalhau branded
simonwo Nov 27, 2023
d48140e
Replace new color icons + fixed jobs table css
XandraMcC Nov 28, 2023
19161e0
Merge branch 'deploy-web-ui' into webui-job-detail
XandraMcC Nov 28, 2023
a4ed0fb
Adding containers to Job Detail page
XandraMcC Nov 28, 2023
dc585d9
Adding routing for Job Detail page
XandraMcC Nov 28, 2023
ce9150b
Add JobInfo component with some data
XandraMcC Nov 28, 2023
539e5c8
Merge branch 'main' into webui-job-detail
XandraMcC Nov 28, 2023
a667c90
Creation of Table reusable component & new API call for job executions
XandraMcC Nov 29, 2023
d962bd7
Merge branch 'main' into webui-job-detail
XandraMcC Nov 29, 2023
6c95b02
Add styling to svgs so they appear in UI
XandraMcC Nov 29, 2023
7a5d1db
Adding execution data and rejigging layout of job detail page
XandraMcC Nov 30, 2023
b72eef9
Refactoring and styling
XandraMcC Nov 30, 2023
3813d67
Merge branch 'main' into webui-job-detail
XandraMcC Dec 1, 2023
a35b5ae
Dispalying individual execution data in GUI
XandraMcC Dec 1, 2023
430e062
refactor - still infinite looping
XandraMcC Dec 2, 2023
06d2fe9
finishing off job detail page
XandraMcC Dec 4, 2023
65157af
Merge branch 'main' into webui-job-detail
XandraMcC Dec 4, 2023
0816e1c
Merge branch 'main' into webui-job-detail
XandraMcC Dec 4, 2023
e6926b4
fix lint error
XandraMcC Dec 4, 2023
ee03bf7
linting
XandraMcC Dec 4, 2023
3c1d36d
Updating Moment & cleaning up code
XandraMcC Dec 5, 2023
cb44f38
A few stragglers
XandraMcC Dec 5, 2023
3c7411d
Merge branch 'main' into webui-job-detail
XandraMcC Dec 5, 2023
29b0853
Fixing as per comments on PR
XandraMcC Dec 5, 2023
400ca34
Merge branch 'main' into webui-job-detail
XandraMcC Dec 5, 2023
be389dd
Merge branch 'webui-job-detail' of https://github.com/bacalhau-projec…
XandraMcC Dec 5, 2023
0d16f2e
Styling + adding jobs options to settings
XandraMcC Dec 5, 2023
1551cd4
Merge branch 'main' into webui-settings
XandraMcC Dec 7, 2023
98d6b2c
Adding ability to change jobs table in settings
XandraMcC Dec 11, 2023
659ae62
Merge branch 'main' into webui-settings
XandraMcC Dec 11, 2023
e2c6025
Merge branch 'main' into webui-settings
XandraMcC Dec 11, 2023
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
11 changes: 10 additions & 1 deletion webui/src/components/ActionButton/ActionButton.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@
cursor: pointer;
display: flex;
column-gap: 1ch;
align-items: center
align-items: center;

&:hover {
background-color: rgba($light-blue, .7);
}
}

.viewIcon {
width: 18px;
height: 18px;
}

.actionButton:active {
Expand Down
2 changes: 1 addition & 1 deletion webui/src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

interface CheckboxProps {
checked: boolean;
checked: boolean | undefined;
onChange: () => void;
label?: string;
}
Expand Down
50 changes: 32 additions & 18 deletions webui/src/context/TableSettingsContext.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
// src/context/TableSettingsContext.tsx
import React, { useState, useContext, useEffect, ReactNode } from "react";

// Combined table settings interface
export interface TableSettings {
showNodeId: boolean;
showName: boolean;
showType: boolean;
showEnv: boolean;
showInputs: boolean;
showOutputs: boolean;
showVersion: boolean;
showAction: boolean;
// Jobs Table
showJobId?: boolean;
showJobName?: boolean;
showCreated?: boolean;
showProgram?: boolean;
showJobType?: boolean;
showLabel?: boolean;
showStatus?: boolean;
// Nodes Table
showNodeId?: boolean;
showNodeName?: boolean;
showNodeType?: boolean;
showEnv?: boolean;
showInputs?: boolean;
showOutputs?: boolean;
showVersion?: boolean;
showAction?: boolean;
Comment on lines +13 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added customisable columns so that we could get more node details available in the table. Currently we're missing labels and capacity. Could you (add a new ticket to) add those in plz?

}

interface TableSettingsContextType {
settings: TableSettings;
// eslint-disable-next-line no-unused-vars
toggleSetting: (_key: keyof TableSettings) => void;
toggleSetting: (key: keyof TableSettings) => void;
}

const defaultState: TableSettings = {
// Jobs Table
showJobId: true,
showJobName: true,
showCreated: true,
showProgram: true,
showJobType: true,
showLabel: true,
showStatus: true,
// Nodes Table
showNodeId: true,
showName: true,
showType: true,
showNodeName: true,
showNodeType: true,
showEnv: true,
showInputs: true,
showOutputs: true,
showVersion: true,
showAction: true,
};

const defaultContextValue: TableSettingsContextType = {
const TableSettingsContext = React.createContext<TableSettingsContextType>({
settings: defaultState,
toggleSetting: () => {},
};

const TableSettingsContext =
React.createContext<TableSettingsContextType>(defaultContextValue);
});

export const TableSettingsProvider: React.FC<{ children: ReactNode }> = ({
children,
Expand Down
1 change: 0 additions & 1 deletion webui/src/pages/JobDetail/JobDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const JobDetail: React.FC = () => {
}

const manyExecutions = jobExData.length > 1;

const executionsData = {
headers: [
"Execution ID",
Expand Down
88 changes: 54 additions & 34 deletions webui/src/pages/JobsDashboard/JobsTable/JobsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useContext } from "react";
import Moment from "react-moment";
import styles from "./JobsTable.module.scss";
import ProgramSummary from "./ProgramSummary/ProgramSummary";
Expand All @@ -10,6 +10,7 @@ import {
getShortenedJobID,
} from "../../../helpers/helperFunctions";
import { Job, ParsedJobData } from "../../../helpers/jobInterfaces";
import TableSettingsContext from "../../../context/TableSettingsContext";

interface TableProps {
data: Job[];
Expand Down Expand Up @@ -62,50 +63,69 @@ function createLabelArray(label: { [key: string]: string }): string[] {
}

const JobsTable: React.FC<TableProps> = ({ data }) => {
const { settings } = useContext(TableSettingsContext);
const parsedData = parseData(data);

return (
<div className={styles.tableContainer}>
<table>
<thead>
<tr>
<th className={styles.jobID}>Job ID</th>
<th>Name</th>
<th className={styles.dateCreated}>Created</th>
<th>Program</th>
<th>Job Type</th>
<th>Label</th>
<th>Status</th>
<th>Action</th>
{settings.showJobId && <th className={styles.jobID}>Job ID</th>}
{settings.showJobName && <th>Name</th>}
{settings.showCreated && (
<th className={styles.dateCreated}>Created</th>
)}
{settings.showProgram && <th>Program</th>}
{settings.showJobType && <th>Job Type</th>}
{settings.showLabel && <th>Label</th>}
{settings.showStatus && <th>Status</th>}
</tr>
</thead>
<tbody>
{parsedData.map((jobData, index) => (
<tr key={index}>
<td className={styles.id}>{jobData.id}</td>
<td className={styles.name}>{jobData.name}</td>
<td className={styles.dateCreated}>
<Moment fromNow withTitle>
{jobData.createdAt}
</Moment>
</td>
<td className={styles.program}>
<ProgramSummary data={jobData.tasks} />
</td>
<td className={styles.jobType}>{jobData.jobType}</td>
<td className={styles.label}>
{jobData.label.map((label) => (
<Label text={label} color={"lavender"} />
))}
</td>
<td className={styles.status}>
<Label
text={jobData.status}
color={labelColorMap[jobData.status.toLowerCase()]}
/>
</td>
<td className={styles.action}>
<ActionButton text="View" to="/JobDetail" id={jobData.longId} />
</td>
{settings.showJobId && (
<td className={styles.id}>{jobData.id}</td>
)}
{settings.showJobName && (
<td className={styles.name}>{jobData.name}</td>
)}
{settings.showCreated && (
<td className={styles.dateCreated}>
<Moment fromNow withTitle>
{jobData.createdAt}
</Moment>
</td>
)}
{settings.showProgram && (
<td className={styles.program}>
<ProgramSummary data={jobData.tasks} />
</td>
)}
{settings.showJobType && (
<td className={styles.jobType}>{jobData.jobType}</td>
)}
{settings.showLabel && (
<td className={styles.label}>{jobData.label}</td>
)}
{settings.showStatus && (
<td className={styles.status}>
<Label
text={jobData.status}
color={labelColorMap[jobData.status.toLowerCase()]}
/>
</td>
)}
{settings.showAction && (
<td className={styles.action}>
<ActionButton
text="View"
to="/JobDetail"
id={jobData.longId}
/>
</td>
)}
</tr>
))}
</tbody>
Expand Down
8 changes: 4 additions & 4 deletions webui/src/pages/NodesDashboard/NodesTable/NodesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const NodesTable: React.FC<TableProps> = ({ data }) => {
<thead>
<tr>
{settings.showNodeId && <th>Node ID</th>}
{settings.showName && <th>Name</th>}
{settings.showType && <th>Type</th>}
{settings.showNodeName && <th>Name</th>}
{settings.showNodeType && <th>Type</th>}
{settings.showEnv && <th>Environment</th>}
{settings.showInputs && <th>Inputs From</th>}
{settings.showOutputs && <th>Outputs</th>}
Expand All @@ -51,10 +51,10 @@ const NodesTable: React.FC<TableProps> = ({ data }) => {
{settings.showNodeId && (
<td className={styles.id}>{nodeData.id}</td>
)}
{settings.showName && (
{settings.showNodeName && (
<td className={styles.name}>{nodeData.name}</td>
)}
{settings.showType && (
{settings.showNodeType && (
<td className={styles.type}>{nodeData.type}</td>
)}
{settings.showEnv && (
Expand Down
28 changes: 28 additions & 0 deletions webui/src/pages/Settings/Settings.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@import '../../styles/variables';

.checkboxGroup {
display: flex;
align-items: center;
margin-bottom: 10px;

label {
margin-left: 10px;
font-size: 16px;
color: #333;
}
}

.saveButton {
padding: 5px 15px;
background-color: rgba($light-blue, .5);
color: $text-color-dark;
border: none;
border-radius: 20px;
cursor: pointer;
font-size: 14px;

&:hover {
background-color: rgba($light-blue, .7);
}
}

94 changes: 52 additions & 42 deletions webui/src/pages/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import {
useTableSettings,
TableSettings,
} from "../../context/TableSettingsContext";
import styles from "./Settings.module.scss";
import Layout from "../../layout/Layout";
import Checkbox from "../../components/Checkbox/Checkbox";
import Container from "../../components/Container/Container";

const Settings = () => {
const { settings, toggleSetting } = useTableSettings();
Expand All @@ -24,53 +26,61 @@ const Settings = () => {
localStorage.setItem("tableSettings", JSON.stringify(tempSettings));
}
});
window.alert("Settings updated");
};

const jobsOptions: { label: string; key: keyof TableSettings }[] = [
{ label: "Job ID", key: "showJobId" },
{ label: "Name", key: "showJobName" },
{ label: "Created", key: "showCreated" },
{ label: "Program", key: "showProgram" },
{ label: "Job Type", key: "showJobType" },
{ label: "Label", key: "showLabel" },
{ label: "Status", key: "showStatus" },
];
Comment on lines +32 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a similar technique to avoid hard-coding the TableSettingsContext i.e. not have to list each config as a separate variable?


const nodesOptions: { label: string; key: keyof TableSettings }[] = [
{ label: "Node ID", key: "showNodeId" },
{ label: "Name", key: "showNodeName" },
{ label: "Type", key: "showNodeType" },
{ label: "Environment", key: "showEnv" },
{ label: "Inputs In", key: "showInputs" },
{ label: "Outputs", key: "showOutputs" },
{ label: "Version", key: "showVersion" },
];

return (
<Layout pageTitle="Settings">
{/* Jobs Dashboard Settings */}
<Container title={"Jobs Dashboard Settings"}>
{jobsOptions.map(({ label, key }) => (
<div className={styles.checkboxGroup}>
<Checkbox
label={label}
checked={tempSettings[key]}
onChange={() => handleToggle(key)}
/>
</div>
))}
<button onClick={handleSave} className={styles.saveButton}>
Save
</button>
</Container>
{/* Node Dashboard Settings */}
<h3>Nodes Dashboard Settings:</h3>
<Checkbox
label="Node ID"
checked={tempSettings.showNodeId}
onChange={() => handleToggle("showNodeId")}
/>
<Checkbox
label="Name"
checked={tempSettings.showName}
onChange={() => handleToggle("showName")}
/>
<Checkbox
label="Type"
checked={tempSettings.showType}
onChange={() => handleToggle("showType")}
/>
<Checkbox
label="Environment"
checked={tempSettings.showEnv}
onChange={() => handleToggle("showEnv")}
/>
<Checkbox
label="Inputs In"
checked={tempSettings.showInputs}
onChange={() => handleToggle("showInputs")}
/>
<Checkbox
label="Outputs"
checked={tempSettings.showOutputs}
onChange={() => handleToggle("showOutputs")}
/>
<Checkbox
label="Version"
checked={tempSettings.showVersion}
onChange={() => handleToggle("showVersion")}
/>
{/* <Checkbox
label="Action"
checked={tempSettings.showAction}
onChange={() => handleToggle("showAction")}
/> */}
<button onClick={handleSave}>Save</button>
<Container title={"Nodes Dashboard Settings"}>
{nodesOptions.map(({ label, key }) => (
<div className={styles.checkboxGroup}>
<Checkbox
label={label}
checked={tempSettings[key]}
onChange={() => handleToggle(key)}
/>
</div>
))}
<button onClick={handleSave} className={styles.saveButton}>
Save
</button>
</Container>
</Layout>
);
};
Expand Down