Skip to content

Commit

Permalink
Merge pull request #18053 from jeclrsg/hpcc-30568-logviewer-pod-column
Browse files Browse the repository at this point in the history
HPCC-30568 ECL Watch v9 add pod name column to Logs view
  • Loading branch information
GordonSmith authored Nov 23, 2023
2 parents fa49bc6 + 1e7ed27 commit 3c870a7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
2 changes: 2 additions & 0 deletions esp/src/src-react/components/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const defaultStartDate = new Date(new Date().getTime() - startTimeOffset);

const FilterFields: Fields = {
components: { type: "cloud-containername", label: nlsHPCC.ContainerName },
instance: { type: "cloud-podname", label: nlsHPCC.PodName },
audience: {
type: "dropdown", label: nlsHPCC.Audience, options: [
{ key: TargetAudience.Operator, text: "Operator" },
Expand Down Expand Up @@ -130,6 +131,7 @@ export const Logs: React.FunctionComponent<LogsProps> = ({
timestamp: { label: nlsHPCC.TimeStamp, width: 140, sortable: false, },
message: { label: nlsHPCC.Message, sortable: false, },
components: { label: nlsHPCC.ContainerName, width: 150, sortable: false },
instance: { label: nlsHPCC.PodName, width: 150, sortable: false },
audience: { label: nlsHPCC.Audience, width: 60, sortable: false, },
class: {
label: nlsHPCC.Class, width: 40, sortable: false,
Expand Down
49 changes: 45 additions & 4 deletions esp/src/src-react/components/forms/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FileList, States as DFUStates } from "src/FileSpray";
import { joinPath } from "src/Utility";
import nlsHPCC from "src/nlsHPCC";
import { useBuildInfo, useLogicalClusters } from "../../hooks/platform";
import { useContainerNames } from "../../hooks/cloud";
import { useContainerNames, usePodNames } from "../../hooks/cloud";

const logger = scopedLogger("src-react/components/forms/Fields.tsx");

Expand Down Expand Up @@ -200,7 +200,7 @@ export type FieldType = "string" | "password" | "number" | "checkbox" | "choiceg
"target-dfuqueue" | "user-groups" | "group-members" | "permission-type" |
"logicalfile-type" | "dfuworkunit-state" |
"esdl-esp-processes" | "esdl-definitions" |
"cloud-containername";
"cloud-containername" | "cloud-podname";

export type Values = { [name: string]: string | number | boolean | (string | number | boolean)[] };

Expand Down Expand Up @@ -369,6 +369,11 @@ interface CloudContainerNameField extends BaseField {
value?: string;
}

interface CloudPodNameField extends BaseField {
type: "cloud-podname";
value?: string;
}

export type Field = StringField | NumericField | CheckboxField | ChoiceGroupField | DateTimeField | DropdownField | DropdownMultiField |
LinkField | LinksField | ProgressField |
WorkunitStateField |
Expand All @@ -378,7 +383,7 @@ export type Field = StringField | NumericField | CheckboxField | ChoiceGroupFiel
TargetDfuSprayQueueField | UserGroupsField | GroupMembersField | PermissionTypeField |
LogicalFileType | DFUWorkunitStateField |
EsdlEspProcessesField | EsdlDefinitionsField |
CloudContainerNameField;
CloudContainerNameField | CloudPodNameField;

export type Fields = { [id: string]: Field };

Expand Down Expand Up @@ -766,6 +771,28 @@ export const CloudContainerNameField: React.FunctionComponent<CloudContainerName
return <ComboBox {...props} allowFreeform={true} autoComplete={"on"} options={options} />;
};

export interface CloudPodNameFieldProps extends Omit<IComboBoxProps, "options"> {
name?: string;
}

export const CloudPodNameField: React.FunctionComponent<CloudPodNameFieldProps> = (props) => {

const [cloudPodNames] = usePodNames();
const [options, setOptions] = React.useState<IComboBoxOption[]>();

React.useEffect(() => {
const options = cloudPodNames?.map(row => {
return {
key: row,
text: row
};
}) || [];
setOptions(options);
}, [cloudPodNames]);

return <ComboBox {...props} allowFreeform={true} autoComplete={"on"} options={options} />;
};

const states = Object.keys(States).map(s => States[s]);
const dfustates = Object.keys(DFUStates).map(s => DFUStates[s]);

Expand Down Expand Up @@ -1260,7 +1287,21 @@ export function createInputs(fields: Fields, onChange?: (id: string, newValue: a
/>
});
break;

case "cloud-podname":
field.value = field.value !== undefined ? field.value : "";
retVal.push({
id: fieldID,
label: field.label,
field: <CloudPodNameField
key={fieldID}
onChange={(ev, row) => {
onChange(fieldID, row.key);
setDropzone(row.key as string);
}}
placeholder={field.placeholder}
/>
});
break;
}
}
return retVal;
Expand Down
10 changes: 10 additions & 0 deletions esp/src/src-react/hooks/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ export function useContainerNames(): [string[], () => void] {
}, [pods]);

return [containers, refreshData];
}

export function usePodNames(): [string[], () => void] {

const [pods, refreshData] = usePods();
const podNames = React.useMemo(() => {
return pods.map(pod => pod.name);
}, [pods]);

return [podNames, refreshData];
}
1 change: 1 addition & 0 deletions esp/src/src/nls/hpcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ export = {
Plugins: "Plugins",
PleaseEnterANumber: "Please enter a number 1 - ",
PleaseLogin: "Please log in using your username and password",
PodName: "Pod Name",
Pods: "Pods",
PodsAccessError: "Cannot retrieve list of pods",
Port: "Port",
Expand Down

0 comments on commit 3c870a7

Please sign in to comment.