UNPKG

@seqera/node-red-seqera

Version:

Node-RED nodes for interacting with the Seqera Platform API

131 lines (119 loc) 5.55 kB
<script type="text/html" data-template-name="seqera-dataset-add"> <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-name"><i class="fa fa-tag"></i> Node Name</label> <input type="text" id="node-input-name" /> </div> <div class="form-row"> <label for="node-input-datasetName"><i class="fa fa-database"></i> Dataset name</label> <input type="text" id="node-input-datasetName" /> </div> <div class="form-row"> <label for="node-input-description"><i class="fa fa-info-circle"></i> Description</label> <input type="text" id="node-input-description" /> </div> <div class="form-row"> <label for="node-input-fileContents"><i class="fa fa-file-text-o"></i> File contents</label> <input type="text" id="node-input-fileContents" /> </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-fileType"><i class="fa fa-file"></i> Type</label> <select id="node-input-fileType"> <option value="csv">CSV</option> <option value="tsv">TSV</option> </select> </div> <div class="form-row"> <label for="node-input-hasHeader"><i class="fa fa-table"></i> Has header</label> <input type="checkbox" id="node-input-hasHeader" style="display: inline-block; width: auto; vertical-align: top;" /> </div> </script> <!-- prettier-ignore --> <script type="text/markdown" data-help-name="seqera-dataset-add"> Adds a new dataset and uploads its file contents to Seqera Platform. ### Inputs : datasetName (string) : Name of the dataset to create. : fileContents (string | buffer) : CSV/TSV string or buffer to upload. Defaults to `msg.payload`. : fileType (string) : File format / MIME type. Choose between 'csv' (default) or 'tsv'. : hasHeader (boolean) : Whether the file has a header row. When enabled, adds `header=true` query parameter to the upload API call. : description (string) : Optional description for the dataset. : workspaceId (string) : Override the workspace ID from the config node. ### Outputs 1. Standard output : payload (object) : The dataset addition response from the API. : datasetId (string) : The ID of the created dataset. ### Details This node adds a dataset in Seqera Platform and uploads its contents in one step. Dataset file contents can be provided in `msg.payload` or via a configured property. The node requires specifying the file format as either CSV or TSV as this is required by Seqera Platform to validate the file contents. ### References - [Seqera Platform API docs](https://docs.seqera.io/platform/latest/api) - information about datasets - [CSV format](https://en.wikipedia.org/wiki/Comma-separated_values) - information about CSV format </script> <script type="text/javascript"> RED.nodes.registerType("seqera-dataset-add", { category: "seqera", color: "#A9A1C6", inputs: 1, outputs: 1, icon: "icons/datasets.svg", align: "left", paletteLabel: "Add dataset", label: function () { return this.name || "Add dataset"; }, outputLabels: ["success"], defaults: { name: { value: "" }, seqera: { value: "", type: "seqera-config" }, datasetName: { value: "", required: true }, datasetNameType: { value: "str" }, fileContents: { value: "payload" }, fileContentsType: { value: "msg" }, workspaceId: { value: "" }, workspaceIdType: { value: "str" }, description: { value: "" }, descriptionType: { value: "str" }, fileType: { value: "csv" }, hasHeader: { value: false }, }, oneditprepare: function () { function ti(id, val, type, def = "str") { $(id).typedInput({ default: def, types: ["str", "msg", "flow", "global", "env", "jsonata", "json"] }); $(id).typedInput("value", val); $(id).typedInput("type", type); } ti("#node-input-datasetName", this.datasetName || "", this.datasetNameType || "str"); $("#node-input-fileContents").typedInput({ default: "msg", types: ["msg", "str", "flow", "global", "env", "jsonata", "json"], }); $("#node-input-fileContents").typedInput("value", this.fileContents || "payload"); $("#node-input-fileContents").typedInput("type", this.fileContentsType || "msg"); ti("#node-input-description", this.description || "", this.descriptionType || "str"); ti("#node-input-workspaceId", this.workspaceId || "", this.workspaceIdType || "str"); $("#node-input-fileType").val(this.fileType || "csv"); $("#node-input-hasHeader").prop("checked", this.hasHeader || false); }, oneditsave: function () { function save(id, prop, propType) { this[prop] = $(id).typedInput("value"); this[propType] = $(id).typedInput("type"); } save.call(this, "#node-input-datasetName", "datasetName", "datasetNameType"); save.call(this, "#node-input-fileContents", "fileContents", "fileContentsType"); save.call(this, "#node-input-description", "description", "descriptionType"); save.call(this, "#node-input-workspaceId", "workspaceId", "workspaceIdType"); this.fileType = $("#node-input-fileType").val(); this.hasHeader = $("#node-input-hasHeader").prop("checked"); }, }); </script>