@seqera/node-red-seqera
Version:
Node-RED nodes for interacting with the Seqera Platform API
145 lines (122 loc) • 5.85 kB
HTML
<script type="text/html" data-template-name="seqera-workflow-monitor">
<div class="form-row">
<label for="node-input-seqera"><i class="icon-globe"></i> Seqera config</label>
<input type="text" id="node-input-seqera" data-type="seqera-config" />
</div>
<div class="form-row">
<label for="node-input-workflowId"><i class="fa fa-code"></i> Workflow ID</label>
<input type="text" id="node-input-workflowId" />
</div>
<div class="form-row">
<label for="node-input-workspaceId"><i class="icon-tasks"></i> Workspace ID</label>
<input type="text" id="node-input-workspaceId" />
</div>
<div class="form-row">
<label for="node-input-keepPolling" style="width: auto !important; padding-right:10px">
<i class="fa fa-clock-o"></i> Keep polling status
</label>
<input type="checkbox" id="node-input-keepPolling" style="margin-top: 0; display:inline-block; width:auto;" />
</div>
<div class="form-row" id="node-poll-row">
<label for="node-input-poll"><i class="fa fa-clock-o"></i> Poll every</label>
<input type="text" id="node-input-poll" style="text-align:end; width:50px !important" />
<select id="node-input-pollUnits" style="width:120px !important">
<option value="seconds">Seconds</option>
<option value="minutes">Minutes</option>
<option value="hours">Hours</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" />
</div>
</script>
<!-- prettier-ignore -->
<script type="text/markdown" data-help-name="seqera-workflow-monitor">
Monitors the status of an existing workflow in Seqera Platform.
### Inputs
: workflowId (string) : The ID of the workflow run to monitor. Defaults to `msg.workflowId`.
: workspaceId (string) : Override the workspace ID from the config node.
### Configuration
: Keep polling status (boolean) : If enabled (default), the node will poll the workflow status until it reaches a terminal state. If disabled, the node will query the status once and return immediately.
: Poll every (string) : How frequently to poll when *Keep polling status* is enabled (default `5 seconds`). Can be configured in seconds, minutes, or hours.
### Outputs
1. Status updates (active workflows)
: payload (object) : The workflow details from the API, sent on every status poll while workflow is active.
: workflowId (string) : The ID of the workflow.
2. Success
: payload (object) : The workflow details from the API, sent once when the workflow completes successfully.
: workflowId (string) : The ID of the workflow.
3. Error
: payload (object) : The workflow details from the API, sent once when the workflow fails or is cancelled.
: workflowId (string) : The ID of the workflow.
### Details
This node queries the Seqera Platform API for the current status of a workflow run. When *Keep polling status* is enabled (default) the node will keep polling at the configured interval until the workflow reaches a terminal state (success, failed, cancelled, etc.).
If *Keep polling status* is disabled the node performs a single status check and outputs the result immediately.
### References
- [Seqera Platform API docs](https://docs.seqera.io/platform/latest/api) - information about workflow status
</script>
<script type="text/javascript">
RED.nodes.registerType("seqera-workflow-monitor", {
category: "seqera",
color: "#A9A1C6",
inputs: 1,
outputs: 3,
icon: "icons/pipeline.svg",
align: "left",
paletteLabel: "Monitor wf",
label: function () {
return this.name || "Monitor workflow";
},
outputLabels: ["status", "success", "error"],
defaults: {
name: { value: "" },
seqera: { value: "", type: "seqera-config" },
workflowId: { value: "workflowId", required: true },
workflowIdType: { value: "msg" },
workspaceId: { value: "" },
workspaceIdType: { value: "str" },
keepPolling: { value: true },
poll: { value: 5 },
pollUnits: { value: "seconds" },
},
oneditprepare: function () {
function ti(id, val, type) {
$(id).typedInput({ default: "str", types: ["str", "msg", "flow", "global", "env", "jsonata"] });
$(id).typedInput("value", val);
$(id).typedInput("type", type);
}
// Workflow ID and workspace ID typed inputs
ti("#node-input-workflowId", this.workflowId || "workflowId", this.workflowIdType || "msg");
ti("#node-input-workspaceId", this.workspaceId || "", this.workspaceIdType || "str");
// Poll interval – simple number input
$("#node-input-poll").val(this.poll || 5);
$("#node-input-pollUnits").val(this.pollUnits || "seconds");
// Keep polling checkbox
const keepPolling = this.keepPolling !== undefined ? this.keepPolling : true;
$("#node-input-keepPolling").prop("checked", keepPolling);
function togglePollRow() {
if ($("#node-input-keepPolling").is(":checked")) {
$("#node-poll-row").show();
} else {
$("#node-poll-row").hide();
}
}
$("#node-input-keepPolling").on("change", togglePollRow);
togglePollRow();
},
oneditsave: function () {
function save(id, prop, propType) {
this[prop] = $(id).typedInput("value");
this[propType] = $(id).typedInput("type");
}
save.call(this, "#node-input-workflowId", "workflowId", "workflowIdType");
save.call(this, "#node-input-workspaceId", "workspaceId", "workspaceIdType");
// Save poll interval and units
this.poll = $("#node-input-poll").val();
this.pollUnits = $("#node-input-pollUnits").val();
// Save keep polling checkbox state
this.keepPolling = $("#node-input-keepPolling").is(":checked");
},
});
</script>