changes
This commit is contained in:
149
dashboardapi.html
Normal file
149
dashboardapi.html
Normal file
@@ -0,0 +1,149 @@
|
||||
<script type="module">
|
||||
|
||||
import * as menuUtils from "/generalFunctions/helper/menuUtils.js";
|
||||
|
||||
RED.nodes.registerType('dashboardapi', {
|
||||
category: 'wbd typical',
|
||||
color: '#4f8582',
|
||||
defaults: {
|
||||
name: { value: "" },
|
||||
// New defaults for configuration:
|
||||
logLevel: { value: "info" },
|
||||
enableLog: { value: false },
|
||||
host: { value: "" },
|
||||
port: { value: 0 },
|
||||
bearerToken: { value: "" }
|
||||
},
|
||||
inputs: 1,
|
||||
outputs: 1,
|
||||
inputLabels: "Usage see manual",
|
||||
outputLabels: ["feedback"],
|
||||
icon: "font-awesome/fa-line-chart",
|
||||
|
||||
label: function () {
|
||||
// Show the name
|
||||
return this.name || "dashboardapi";
|
||||
},
|
||||
|
||||
oneditprepare: function () {
|
||||
|
||||
const node = this;
|
||||
|
||||
console.log("Edit Prepare");
|
||||
|
||||
const elements = {
|
||||
// Basic fields
|
||||
name: document.getElementById("node-input-name"),
|
||||
number: document.getElementById("node-input-number"),
|
||||
// Logging fields
|
||||
logLevelSelect: document.getElementById("node-input-logLevel"),
|
||||
logCheckbox: document.getElementById("node-input-enableLog"),
|
||||
// Grafana connector fields
|
||||
host: document.getElementById("node-input-host"),
|
||||
port: document.getElementById("node-input-port"),
|
||||
bearerToken: document.getElementById("node-input-bearerToken"),
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
// UI elements
|
||||
menuUtils.initBasicToggles(elements);
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.log("Error fetching project settings", e);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
oneditsave: function () {
|
||||
const node = this;
|
||||
|
||||
console.log(`------------ Saving changes to node ------------`);
|
||||
|
||||
//save basic properties
|
||||
["name", "host", "port", "bearerToken"].forEach(
|
||||
(field) => {
|
||||
const element = document.getElementById(`node-input-${field}`);
|
||||
if (element) {
|
||||
node[field] = element.value || "";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const logLevelElement = document.getElementById("node-input-logLevel");
|
||||
node.logLevel = logLevelElement ? logLevelElement.value || "info" : "info";
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Main UI Template -->
|
||||
<script type="text/html" data-template-name="dashboardapi">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="node-input-name"
|
||||
placeholder="name"
|
||||
style="width:70%;"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-host"><i class="fa fa-server"></i> Grafana Host</label>
|
||||
<input type="text" id="node-input-host" placeholder="Host">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-port"><i class="fa fa-plug"></i> Grafana Port</label>
|
||||
<input type="number" id="node-input-port" placeholder="Port">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-bearerToken"><i class="fa fa-key"></i> Bearer Token</label>
|
||||
<input type="text" id="node-input-bearerToken" placeholder="Bearer Token">
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<!-- loglevel checkbox -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-enableLog"
|
||||
><i class="fa fa-cog"></i> Enable Log</label
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-enableLog"
|
||||
style="width:20px; vertical-align:baseline;"
|
||||
/>
|
||||
<span>Enable logging</span>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="row-logLevel">
|
||||
<label for="node-input-logLevel"><i class="fa fa-cog"></i> Log Level</label>
|
||||
<select id="node-input-logLevel" style="width:60%;">
|
||||
<option value="info">Info</option>
|
||||
<option value="debug">Debug</option>
|
||||
<option value="warn">Warn</option>
|
||||
<option value="error">Error</option>
|
||||
</select>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="dashboardapi">
|
||||
<p>
|
||||
This node interacts with the Grafana API with the following capabilities:
|
||||
|
||||
• Dashboard Management: Create, update, or delete dashboards.
|
||||
• Metrics Querying: Retrieve performance and operational data.
|
||||
• Alerts Management: Monitor and manage alerts.
|
||||
|
||||
It allows you to configure:
|
||||
|
||||
- Connection details (host, port, bearer token) for secure API access.
|
||||
- Logging options, including the ability to enable logging and set the log level (info, debug, warn, error).
|
||||
|
||||
These features provide flexible and controlled interactions with the Grafana API.
|
||||
</p>
|
||||
</script>
|
||||
Reference in New Issue
Block a user