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

HPCC-31542 List Workunits Functionality #19659

Merged
merged 1 commit into from
Apr 10, 2025
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
177 changes: 162 additions & 15 deletions esp/src/src-react/components/Sasha.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import * as React from "react";
import { Dropdown, TextField, PrimaryButton } from "@fluentui/react";
import { Dropdown, TextField, PrimaryButton, Stack, Checkbox } from "@fluentui/react";
import nlsHPCC from "src/nlsHPCC";
import { SashaService } from "@hpcc-js/comms";
import { scopedLogger } from "@hpcc-js/util";
import { SashaService, WsSasha } from "@hpcc-js/comms";

interface SashaProps {}
const logger = scopedLogger("src-react/components/Sasha.tsx");

interface SashaProps { }

export const Sasha: React.FunctionComponent<SashaProps> = () => {
const [selectedOption, setSelectedOption] = React.useState("");
const [wuid, setWuid] = React.useState("");
const [cluster, setCluster] = React.useState("");
const [owner, setOwner] = React.useState("");
const [jobName, setJobName] = React.useState("");
const [stateFilter, setStateFilter] = React.useState("");
const [fromDate, setFromDate] = React.useState("");
const [toDate, setToDate] = React.useState("");
const [beforeWU, setBeforeWU] = React.useState("");
const [afterWU, setAfterWU] = React.useState("");
const [outputFields, setOutputFields] = React.useState("");
const [archived, setArchived] = React.useState(false);
const [online, setOnline] = React.useState(false);
const [includeDT, setIncludeDT] = React.useState(false);
const [descending, setDescending] = React.useState(false);

const [result, setResult] = React.useState("");

// Create an instance of SashaService (adjust baseUrl if needed)
const sashaService = new SashaService({ baseUrl: "" });

const handleOptionChange = (event: React.FormEvent<HTMLDivElement>, option: any) => {
Expand Down Expand Up @@ -46,11 +62,53 @@ export const Sasha: React.FunctionComponent<SashaProps> = () => {
case "archiveDFUWorkUnit":
// Implement archiveDFUWorkUnit function call
break;
case "backupECLWorkUnit":
// Implement backupECLWorkUnit function call
case "listECLWorkunit":
sashaService.ListWU({
WUType: WsSasha.WUTypes.ECL,
Wuid: wuid,
Cluster: cluster,
Owner: owner,
JobName: jobName,
State: stateFilter,
FromDate: fromDate,
ToDate: toDate,
Archived: archived,
Online: online,
IncludeDT: includeDT,
BeforeWU: beforeWU,
AfterWU: afterWU,
MaxNumberWUs: 500,
Descending: descending,
OutputFields: outputFields
})
.then(response => {
setResult(response.Result);
})
.catch(err => logger.error(err));
break;
case "backupDFUWorkUnit":
// Implement backupDFUWorkUnit function call
case "listDFUWorkunit":
sashaService.ListWU({
WUType: WsSasha.WUTypes.DFU,
Wuid: wuid,
Cluster: cluster,
Owner: owner,
JobName: jobName,
State: stateFilter,
FromDate: fromDate,
ToDate: toDate,
Archived: archived,
Online: online,
IncludeDT: includeDT,
BeforeWU: beforeWU,
AfterWU: afterWU,
MaxNumberWUs: 500,
Descending: descending,
OutputFields: outputFields
})
.then(response => {
setResult(response.Result);
})
.catch(err => logger.error(err));
break;
default:
console.log("Invalid option selected");
Expand All @@ -74,22 +132,111 @@ export const Sasha: React.FunctionComponent<SashaProps> = () => {
{ key: "restoreDFUWorkUnit", text: nlsHPCC.RestoreDFUWorkunit },
{ key: "archiveECLWorkUnit", text: nlsHPCC.ArchiveECLWorkunit },
{ key: "archiveDFUWorkUnit", text: nlsHPCC.ArchiveDFUWorkunit },
{ key: "backupECLWorkUnit", text: nlsHPCC.BackupECLWorkunit },
{ key: "backupDFUWorkUnit", text: nlsHPCC.BackupDFUWorkunit }
{ key: "listECLWorkunit", text: nlsHPCC.ListECLWorkunit },
{ key: "listDFUWorkunit", text: nlsHPCC.ListDFUWorkunit }
]}
styles={{ dropdown: { width: 400 } }}
/>
{["restoreECLWorkUnit", "restoreDFUWorkUnit", "archiveECLWorkUnit", "archiveDFUWorkUnit", "backupECLWorkUnit", "backupDFUWorkUnit"].includes(selectedOption) && (
<div>

{["listECLWorkunit", "listDFUWorkunit"].includes(selectedOption) ? (
<Stack tokens={{ childrenGap: 10 }}>
<TextField
label={nlsHPCC.WUID}
value={wuid}
onChange={(event, newValue?: string) => setWuid(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="Cluster"
value={cluster}
onChange={(event, newValue?: string) => setCluster(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="Owner"
value={owner}
onChange={(event, newValue?: string) => setOwner(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="Job Name"
value={jobName}
onChange={(event, newValue?: string) => setJobName(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="State"
value={stateFilter}
onChange={(event, newValue?: string) => setStateFilter(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="From Date"
value={fromDate}
onChange={(event, newValue?: string) => setFromDate(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="To Date"
value={toDate}
onChange={(event, newValue?: string) => setToDate(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="Before WU"
value={beforeWU}
onChange={(event, newValue?: string) => setBeforeWU(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="After WU"
value={afterWU}
onChange={(event, newValue?: string) => setAfterWU(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<TextField
label="Output Fields"
value={outputFields}
onChange={(event, newValue?: string) => setOutputFields(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
<Stack horizontal tokens={{ childrenGap: 20 }}>
<Checkbox
label="Archived"
checked={archived}
onChange={(e, checked) => setArchived(!!checked)}
/>
<Checkbox
label="Online"
checked={online}
onChange={(e, checked) => setOnline(!!checked)}
/>
<Checkbox
label="Include DT"
checked={includeDT}
onChange={(e, checked) => setIncludeDT(!!checked)}
/>
<Checkbox
label="Descending"
checked={descending}
onChange={(e, checked) => setDescending(!!checked)}
/>
</Stack>
</Stack>
) : (
(["restoreECLWorkUnit", "restoreDFUWorkUnit", "archiveECLWorkUnit", "archiveDFUWorkUnit"].includes(selectedOption)) && (
<TextField
label={nlsHPCC.WUID}
value={wuid}
onChange={(event: React.FormEvent<HTMLInputElement>, newValue?: string) => setWuid(newValue || "")}
onChange={(event, newValue?: string) => setWuid(newValue || "")}
styles={{ fieldGroup: { width: 400 } }}
/>
</div>
)
)}
<PrimaryButton type="submit">{nlsHPCC.Submit}</PrimaryButton>

<PrimaryButton type="submit" style={{ marginTop: 10, width: 150 }}>
{nlsHPCC.Submit}
</PrimaryButton>
{defaultValue}
{result && <div>{nlsHPCC.Results}: {result}</div>}
</form>
Expand Down
4 changes: 2 additions & 2 deletions esp/src/src/nls/hpcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export = {
AutoRefreshIncrement: "Auto Refresh Increment",
AutoRefreshEvery: "Auto refresh every x minutes",
Back: "Back",
BackupECLWorkunit: "Backup ECL Workunit",
BackupDFUWorkunit: "Backup DFU Workunit",
BannerColor: "Banner Color",
BannerColorTooltip: "Change the background color of the top navigation",
BannerMessage: "Banner Message",
Expand Down Expand Up @@ -488,6 +486,8 @@ export = {
Line: "Line",
LineTerminators: "Line Terminators",
Links: "Links",
ListECLWorkunit: "List ECL Workunit",
ListDFUWorkunit: "List DFU Workunit",
LoadPackageContentHere: "(Load package content here)",
LoadPackageFromFile: "Load Package from a file",
Loading: "Loading...",
Expand Down
Loading