diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx
index 81feaaab..327bfa55 100755
--- a/frontend/src/views/Admin.jsx
+++ b/frontend/src/views/Admin.jsx
@@ -756,7 +756,7 @@ If you're interested, please let me know a time that works for you, or set up a
.then((responseJson) => {
setWebHooks(responseJson.webhooks || []); // Handling the case where the result is null or undefined
setAllSchedules(responseJson.schedules || []);
- setPipelines(responseJson.pipelines || []);
+ // setPipelines(responseJson.pipelines || []);
})
.catch((error) => {
toast(error.toString());
@@ -935,13 +935,54 @@ If you're interested, please let me know a time that works for you, or set up a
};
const changePipelineState = (pipeline, state) => {
- if (state.trim() === ''){
- toast("state is not defined")
- return
+ if (state.trim() === "") {
+ toast("state is not defined");
+ return;
}
-
- }
-
+
+ const data = {
+ name: pipeline.name,
+ type: state,
+ environment: pipeline.environment,
+ workflow_id: pipeline.workflow_id,
+ trigger_id: pipeline.trigger_id,
+ };
+
+ if (state === "start") toast("starting the pipeline");
+ else toast("stopping the pipeline");
+
+ const url = `${globalUrl}/api/v1/triggers/pipeline`;
+ fetch(url, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ },
+ body: JSON.stringify(data),
+ credentials: "include",
+ })
+ .then((response) => {
+ if (response.status !== 200) {
+ console.log("Status not 200 for stream results :O!");
+ toast("Failed to update the pipeline state");
+ }
+
+ return response.json();
+ })
+ .then((responseJson) => {
+ if (!responseJson.success) {
+ toast("Failed to update the pipeline: " + responseJson.reason);
+ } else {
+ if (state === "start") toast("Successfully created pipeline");
+ else toast("Sucessfully stopped the pipeline");
+ }
+ })
+ .catch((error) => {
+ //toast(error.toString());
+ console.log("Get schedule error: ", error.toString());
+ });
+ };
+
if (
userdata.support === true &&
selectedOrganization.id !== "" &&
@@ -4618,74 +4659,72 @@ If you're interested, please let me know a time that works for you, or set up a
- { allSchedules.map((schedule, index) => {
- var bgColor = "#27292d";
- if (index % 2 === 0) {
- bgColor = "#1f2023";
- }
+ {allSchedules.map((schedule, index) => {
+ var bgColor = "#27292d";
+ if (index % 2 === 0) {
+ bgColor = "#1f2023";
+ }
- return (
-
- 0 ? (
- schedule.frequency
- ) : (
- {schedule.seconds} seconds
- )
- }
- />
-
-
- {schedule.workflow_id}
-
- }
- />
-
-
-
-
-
- );
- })}
+ return (
+
+ 0 ? (
+ schedule.frequency
+ ) : (
+ {schedule.seconds} seconds
+ )
+ }
+ />
+
+
+ {schedule.workflow_id}
+
+ }
+ />
+
+
+
+
+
+ );
+ })}
)}
@@ -4833,7 +4872,7 @@ If you're interested, please let me know a time that works for you, or set up a
)}
-
+ {/*
Tenzir Pipelines
Controls a pipeline to run things.{" "}
@@ -4855,7 +4894,9 @@ If you're interested, please let me know a time that works for you, or set up a
backgroundColor: theme.palette.inputColor,
}}
/>
- {pipelines === undefined || pipelines === null || pipelines.length === 0 ? (
+ {pipelines === undefined ||
+ pipelines === null ||
+ pipelines.length === 0 ? (