adding pipelines to the ui
This commit is contained in:
+139
-17
@@ -203,7 +203,7 @@ const Admin = (props) => {
|
||||
const [selectedStatus, setSelectedStatus] = React.useState([]);
|
||||
const [webHooks, setWebHooks] = React.useState([]);
|
||||
const [allSchedules, setAllSchedules] = React.useState([]);
|
||||
|
||||
const [pipelines, setPipelines] = React.useState([]);
|
||||
const [, forceUpdate] = React.useState();
|
||||
|
||||
const [showDeleteAccountTextbox, setShowDeleteAccountTextbox] =
|
||||
@@ -756,6 +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 || []);
|
||||
})
|
||||
.catch((error) => {
|
||||
toast(error.toString());
|
||||
@@ -933,6 +934,14 @@ 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 (
|
||||
userdata.support === true &&
|
||||
selectedOrganization.id !== "" &&
|
||||
@@ -4573,6 +4582,21 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
backgroundColor: theme.palette.inputColor,
|
||||
}}
|
||||
/>
|
||||
{allSchedules === undefined ||
|
||||
allSchedules === null ||
|
||||
allSchedules.length === 0 ? (
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
padding: "20px",
|
||||
backgroundColor: "#f0f0f0",
|
||||
color: "#666",
|
||||
borderRadius: "5px",
|
||||
}}
|
||||
>
|
||||
No schedules found.
|
||||
</div>
|
||||
) : (
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
@@ -4594,9 +4618,7 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
<ListItemText primary="Actions" />
|
||||
<ListItemText primary="Delegation" />
|
||||
</ListItem>
|
||||
{allSchedules === undefined || allSchedules === null
|
||||
? null
|
||||
: allSchedules.map((schedule, index) => {
|
||||
{ allSchedules.map((schedule, index) => {
|
||||
var bgColor = "#27292d";
|
||||
if (index % 2 === 0) {
|
||||
bgColor = "#1f2023";
|
||||
@@ -4644,7 +4666,11 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
<ListItemText>
|
||||
<Button
|
||||
style={{}}
|
||||
variant = {schedule.status === "running" ? "contained" : "outlined"}
|
||||
variant={
|
||||
schedule.status === "running"
|
||||
? "contained"
|
||||
: "outlined"
|
||||
}
|
||||
disabled={schedule.status === "uninitialized"}
|
||||
onClick={() => {
|
||||
if (schedule.status === "running") {
|
||||
@@ -4661,6 +4687,7 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
)}
|
||||
|
||||
<div style={{ marginTop: 20, marginBottom: 20 }}>
|
||||
<h2 style={{ display: "inline" }}>WebHooks</h2>
|
||||
@@ -4673,10 +4700,25 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
backgroundColor: theme.palette.inputColor,
|
||||
}}
|
||||
/>
|
||||
|
||||
{webHooks === undefined || webHooks === null || webHooks.length === 0 ? (
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
padding: "20px",
|
||||
backgroundColor: "#f0f0f0",
|
||||
color: "#666",
|
||||
borderRadius: "5px",
|
||||
}}
|
||||
>
|
||||
No webhooks found.
|
||||
</div>
|
||||
) : (
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText primary="Name" style={{ maxWidth: 200, minWidth: 200 }} />
|
||||
<ListItemText
|
||||
primary="Name"
|
||||
style={{ maxWidth: 200, minWidth: 200 }}
|
||||
/>
|
||||
<ListItemText
|
||||
primary="Environment"
|
||||
style={{ maxWidth: 150, minWidth: 150 }}
|
||||
@@ -4689,13 +4731,9 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
primary="Url"
|
||||
style={{ minWidth: 300, maxWidth: 300, overflow: "hidden" }}
|
||||
/>
|
||||
<ListItemText
|
||||
primary="Actions"
|
||||
/>
|
||||
<ListItemText primary="Actions" />
|
||||
</ListItem>
|
||||
{webHooks === undefined || webHooks === null
|
||||
? null
|
||||
: webHooks.map((webhook, index) => {
|
||||
{webHooks.map((webhook, index) => {
|
||||
var bgColor = "#27292d";
|
||||
if (index % 2 === 0) {
|
||||
bgColor = "#1f2023";
|
||||
@@ -4773,8 +4811,10 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
|
||||
<ListItemText>
|
||||
<Button
|
||||
style={{ marginLeft: '18%' }}
|
||||
variant={webhook.status === "running" ? "contained" : "outlined"}
|
||||
style={{ marginLeft: "18%" }}
|
||||
variant={
|
||||
webhook.status === "running" ? "contained" : "outlined"
|
||||
}
|
||||
disabled={webhook.status === "uninitialized"}
|
||||
onClick={() => {
|
||||
if (webhook.status === "running") {
|
||||
@@ -4791,8 +4831,9 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
)}
|
||||
|
||||
{/* <div style={{ marginTop: 20, marginBottom: 20 }}>
|
||||
<div style={{ marginTop: 20, marginBottom: 20 }}>
|
||||
<h2 style={{ display: "inline" }}>Tenzir Pipelines</h2>
|
||||
<span style={{ marginLeft: 25 }}>
|
||||
Controls a pipeline to run things.{" "}
|
||||
@@ -4813,7 +4854,88 @@ If you're interested, please let me know a time that works for you, or set up a
|
||||
marginBottom: 20,
|
||||
backgroundColor: theme.palette.inputColor,
|
||||
}}
|
||||
/> */}
|
||||
/>
|
||||
{pipelines === undefined || pipelines === null || pipelines.length === 0 ? (
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
padding: "20px",
|
||||
backgroundColor: "#f0f0f0",
|
||||
color: "#666",
|
||||
borderRadius: "5px",
|
||||
}}
|
||||
>
|
||||
No pipelines found.
|
||||
</div>
|
||||
) : (
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemText
|
||||
primary="Name"
|
||||
style={{ maxWidth: 200, minWidth: 200 }}
|
||||
/>
|
||||
<ListItemText
|
||||
primary="Environment"
|
||||
style={{ maxWidth: 150, minWidth: 150 }}
|
||||
/>
|
||||
<ListItemText
|
||||
primary="Workflow"
|
||||
style={{ maxWidth: 315, minWidth: 315 }}
|
||||
/>
|
||||
<ListItemText primary="Actions" />
|
||||
</ListItem>
|
||||
{pipelines.map((pipeline, index) => {
|
||||
var bgColor = "#27292d";
|
||||
if (index % 2 === 0) {
|
||||
bgColor = "#1f2023";
|
||||
}
|
||||
|
||||
return (
|
||||
<ListItem key={index} style={{ backgroundColor: bgColor }}>
|
||||
<ListItemText
|
||||
style={{ maxWidth: 200, minWidth: 200 }}
|
||||
primary={pipeline.name}
|
||||
/>
|
||||
<ListItemText
|
||||
style={{ maxWidth: 150, minWidth: 150 }}
|
||||
primary={pipeline.environment}
|
||||
/>
|
||||
<ListItemText
|
||||
style={{ maxWidth: 315, minWidth: 315 }}
|
||||
primary={
|
||||
<a
|
||||
style={{ textDecoration: "none", color: "#f85a3e" }}
|
||||
href={`/workflows/${pipeline.workflow_id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{pipeline.workflow_id}
|
||||
</a>
|
||||
}
|
||||
/>
|
||||
<ListItemText>
|
||||
<Button
|
||||
style={{ marginLeft: "18%" }}
|
||||
variant={
|
||||
pipeline.status === "running" ? "contained" : "outlined"
|
||||
}
|
||||
disabled={pipeline.status === "uninitialized"}
|
||||
onClick={() => {
|
||||
if (pipeline.status === "running") {
|
||||
changePipelineState(pipeline, "stop");
|
||||
} else changePipelineState(pipeline, "start");
|
||||
}}
|
||||
>
|
||||
{pipeline.status === "running"
|
||||
? "Stop webhook"
|
||||
: "Start Webhook"}
|
||||
</Button>
|
||||
</ListItemText>
|
||||
</ListItem>
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
)}
|
||||
</div>
|
||||
) : null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user