mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmui: import dashboards (#2642)
* fix: switch dashboards import to fetch * make vmui-update
This commit is contained in:
parent
f149d56ac2
commit
b9ef9ddbfd
11 changed files with 19 additions and 17 deletions
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
"main.css": "./static/css/main.d8362c27.css",
|
"main.css": "./static/css/main.d8362c27.css",
|
||||||
"main.js": "./static/js/main.348f50e1.js",
|
"main.js": "./static/js/main.a35e61a3.js",
|
||||||
"static/js/27.939f971b.chunk.js": "./static/js/27.939f971b.chunk.js",
|
"static/js/27.939f971b.chunk.js": "./static/js/27.939f971b.chunk.js",
|
||||||
"index.html": "./index.html"
|
"index.html": "./index.html"
|
||||||
},
|
},
|
||||||
"entrypoints": [
|
"entrypoints": [
|
||||||
"static/css/main.d8362c27.css",
|
"static/css/main.d8362c27.css",
|
||||||
"static/js/main.348f50e1.js"
|
"static/js/main.a35e61a3.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
### Setup
|
### Setup
|
||||||
1. Create `.json` config file in a folder `dashboards`
|
1. Create `.json` config file in a folder `dashboards`
|
||||||
2. Import your config file into the `dashboards/index.js`
|
2. Import your config file into the `dashboards/index.js`
|
||||||
3. Add imported variable into the array `window.__VMUI_PREDEFINED_DASHBOARDS__`
|
3. Add filename into the array `window.__VMUI_PREDEFINED_DASHBOARDS__`
|
||||||
|
|
||||||
### Configuration options
|
### Configuration options
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import perJob from "./perJobUsage.json" assert { type: "json" };
|
|
||||||
|
|
||||||
window.__VMUI_PREDEFINED_DASHBOARDS__ = [
|
window.__VMUI_PREDEFINED_DASHBOARDS__ = [
|
||||||
perJob
|
"perJobUsage.json"
|
||||||
];
|
];
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="VM-UI is a metric explorer for Victoria Metrics"/><link rel="apple-touch-icon" href="./apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png"><link rel="manifest" href="./manifest.json"/><title>VM UI</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><script src="./dashboards/index.js" type="module"></script><script defer="defer" src="./static/js/main.348f50e1.js"></script><link href="./static/css/main.d8362c27.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link href="./favicon.ico" rel="icon"/><meta content="width=device-width,initial-scale=1" name="viewport"/><meta content="#000000" name="theme-color"/><meta content="VM-UI is a metric explorer for Victoria Metrics" name="description"/><link href="./apple-touch-icon.png" rel="apple-touch-icon"/><link href="./favicon-32x32.png" rel="icon" sizes="32x32" type="image/png"><link href="./manifest.json" rel="manifest"/><title>VM UI</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet"/><script src="./dashboards/index.js" type="module"></script><script defer="defer" src="./static/js/main.a35e61a3.js"></script><link href="./static/css/main.d8362c27.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div data-params='{"serverURL": "https://play.victoriametrics.com/select/accounting/1/6a716b0f-38bc-4856-90ce-448fd713e3fe/prometheus/"}' id="root"></div></body></html>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
||||||
### Setup
|
### Setup
|
||||||
1. Create `.json` config file in a folder `dashboards`
|
1. Create `.json` config file in a folder `dashboards`
|
||||||
2. Import your config file into the `dashboards/index.js`
|
2. Import your config file into the `dashboards/index.js`
|
||||||
3. Add imported variable into the array `window.__VMUI_PREDEFINED_DASHBOARDS__`
|
3. Add filename into the array `window.__VMUI_PREDEFINED_DASHBOARDS__`
|
||||||
|
|
||||||
### Configuration options
|
### Configuration options
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import perJob from "./perJobUsage.json" assert { type: "json" };
|
|
||||||
|
|
||||||
window.__VMUI_PREDEFINED_DASHBOARDS__ = [
|
window.__VMUI_PREDEFINED_DASHBOARDS__ = [
|
||||||
perJob
|
"perJobUsage.json"
|
||||||
];
|
];
|
||||||
|
|
|
@ -20,7 +20,7 @@ const DashboardLayout: FC = () => {
|
||||||
}, [dashboards, tab]);
|
}, [dashboards, tab]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDashboards(getDashboardSettings());
|
getDashboardSettings().then(d => d.length && setDashboards(d));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import {DashboardSettings} from "../../types";
|
import {DashboardSettings} from "../../types";
|
||||||
|
|
||||||
export default (): DashboardSettings[] => {
|
const importModule = async (filename: string) => {
|
||||||
return window.__VMUI_PREDEFINED_DASHBOARDS__ || [];
|
const data = await fetch(`./dashboards/${filename}`);
|
||||||
|
const json = await data.json();
|
||||||
|
return json as DashboardSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default async () => {
|
||||||
|
const filenames = window.__VMUI_PREDEFINED_DASHBOARDS__;
|
||||||
|
return await Promise.all(filenames.map(async f => importModule(f)));
|
||||||
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {MetricBase} from "../api/types";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
__VMUI_PREDEFINED_DASHBOARDS__: DashboardSettings[];
|
__VMUI_PREDEFINED_DASHBOARDS__: string[];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue