Enhanced glances widget (#1534)

* Enhanced glances widget (resource match)

* Make widget clickable + cleanup helperrs

* Prevent unused glances API calls

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Georges-Antoine Assi 2023-05-22 13:50:58 -04:00 committed by GitHub
parent 3bc750bfe7
commit cdd7b2d44b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 115 additions and 33 deletions

View file

@ -5,8 +5,6 @@ import yaml from "js-yaml";
import checkAndCopyConfig, { substituteEnvironmentVars } from "utils/config/config";
const exemptWidgets = ["search"];
export async function widgetsFromConfig() {
checkAndCopyConfig("widgets.yaml");
@ -32,15 +30,17 @@ export async function cleanWidgetGroups(widgets) {
return widgets.map((widget, index) => {
const sanitizedOptions = widget.options;
const optionKeys = Object.keys(sanitizedOptions);
if (!exemptWidgets.includes(widget.type)) {
["url", "username", "password", "key"].forEach((pO) => {
if (optionKeys.includes(pO)) {
// allow URL in search
if (widget.type !== "search" && pO !== "key") {
delete sanitizedOptions[pO];
}
}
});
// delete private options from the sanitized options
["username", "password", "key"].forEach((pO) => {
if (optionKeys.includes(pO)) {
delete sanitizedOptions[pO];
}
});
// delete url from the sanitized options if the widget is not a search or glances widgeth
if (widget.type !== "search" && widget.type !== "glances" && optionKeys.includes("url")) {
delete sanitizedOptions.url;
}
return {
@ -78,4 +78,4 @@ export async function getPrivateWidgetOptions(type, widgetIndex) {
});
return (type !== undefined && widgetIndex !== undefined) ? privateOptions.find(o => o.type === type && o.options.index === parseInt(widgetIndex, 10))?.options : privateOptions;
}
}