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

Preselect all capture agent inputs when scheduling new event #979

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ const EventDetailsSchedulingTab = ({
tabIndex={8 + key}
value={inputMethod.id}
/>
{t(inputMethod.value)}
{t(inputMethod.value, inputMethod.id)}
</label>
)
)
Expand Down
19 changes: 16 additions & 3 deletions src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ const Schedule = <T extends {
value={input.id}
tabIndex={12}
/>
{t(input.value)}
{t(input.value, input.id)}
</label>
));
}
Expand Down Expand Up @@ -738,9 +738,22 @@ const Schedule = <T extends {
options={inputDevices}
type={"captureAgent"}
required={true}
handleChange={(element) => {
handleChange={async (element) => {
if (element) {
formik.setFieldValue("location", element.value)
// Set inputs depending on location
let inputDevice = inputDevices.find(
({ name }) => name === element.value
);
if (inputDevice) {
if (inputDevice.inputs.length > 0) {
await formik.setFieldValue("locationHasInputs", true)
} else {
await formik.setFieldValue("locationHasInputs", false)
}
await formik.setFieldValue("deviceInputs", inputDevice.inputs.map(input => input.id))
}
// Set location
await formik.setFieldValue("location", element.value)
}
}}
placeholder={t(
Expand Down
2 changes: 2 additions & 0 deletions src/components/events/partials/wizards/NewEventWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ const getInitialValues = (
},
];

initialValues["locationHasInputs"] = false

return initialValues;
};

Expand Down
3 changes: 2 additions & 1 deletion src/configs/modalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const initialFormValuesNewEvents: {
scheduleEndMinute: string,
repeatOn: string[],
location: string,
deviceInputs: string[],
processingWorkflow: string,
configuration: { [key: string]: string },
aclTemplate: string,
Expand All @@ -42,7 +43,7 @@ export const initialFormValuesNewEvents: {
scheduleEndMinute: "",
repeatOn: [],
location: "",
//deviceInputs: [],
deviceInputs: [],
processingWorkflow: "",
configuration: {},
aclTemplate: "",
Expand Down
5 changes: 5 additions & 0 deletions src/utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export const NewEventSchema = [
value === "SCHEDULE_SINGLE" || value === "SCHEDULE_MULTIPLE",
then: () => Yup.string().required("Required"),
}),
deviceInputs: Yup.mixed().when(["sourceMode", "locationHasInputs"], {
is: (sourceMode: string, locationHasInputs: boolean) =>
(sourceMode === "SCHEDULE_SINGLE" || sourceMode === "SCHEDULE_MULTIPLE") && locationHasInputs,
then: () => Yup.array().min(1).required("Required"),
}),
}),
Yup.object().shape({
processingWorkflow: Yup.string().required("Required"),
Expand Down
Loading