mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 06:48:47 +00:00
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:
parent
3bc750bfe7
commit
cdd7b2d44b
4 changed files with 115 additions and 33 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue