update node dashboards

This commit is contained in:
Qiuxia Fan 2022-03-22 11:10:09 +08:00
parent c18b0507af
commit b48358e43d
2 changed files with 11 additions and 10 deletions

View File

@ -122,10 +122,7 @@ const settings = ref<any>(props.config);
const operationsPos = reactive<{ x: number; y: number }>({ x: NaN, y: NaN }); const operationsPos = reactive<{ x: number; y: number }>({ x: NaN, y: NaN });
const items = ref< const items = ref<
{ id: string; title: string; func: any; dashboard?: string }[] { id: string; title: string; func: any; dashboard?: string }[]
>([ >([]);
{ id: "inspect", title: "Inspect", func: handleInspect },
{ id: "alarm", title: "Alarm", func: handleGoAlarm },
]);
const depth = ref<number>(props.config.graph.depth || 2); const depth = ref<number>(props.config.graph.depth || 2);
onMounted(async () => { onMounted(async () => {
@ -148,6 +145,7 @@ onMounted(async () => {
svg.value = d3.select(chart.value).append("svg").attr("class", "topo-svg"); svg.value = d3.select(chart.value).append("svg").attr("class", "topo-svg");
await init(); await init();
update(); update();
setNodeTools(settings.value.nodeDashboard);
}); });
async function init() { async function init() {
tip.value = (d3tip as any)().attr("class", "d3-tip").offset([-8, 0]); tip.value = (d3tip as any)().attr("class", "d3-tip").offset([-8, 0]);
@ -472,16 +470,19 @@ function resize() {
svg.value.attr("height", height.value).attr("width", width.value); svg.value.attr("height", height.value).attr("width", width.value);
} }
function updateSettings(config: any) { function updateSettings(config: any) {
settings.value = config;
setNodeTools(config.nodeDashboard);
}
function setNodeTools(nodeDashboard: any) {
items.value = [ items.value = [
{ id: "inspect", title: "Inspect", func: handleInspect }, { id: "inspect", title: "Inspect", func: handleInspect },
{ id: "alarm", title: "Alarm", func: handleGoAlarm }, { id: "alarm", title: "Alarm", func: handleGoAlarm },
]; ];
settings.value = config; for (const item of nodeDashboard) {
for (const item of config.nodeDashboard) {
if (item.scope === EntityType[0].value) { if (item.scope === EntityType[0].value) {
items.value.push({ items.value.push({
id: "dashboard", id: "dashboard",
title: "Dashboard", title: "Service Dashboard",
func: handleGoDashboard, func: handleGoDashboard,
...item, ...item,
}); });
@ -489,7 +490,7 @@ function updateSettings(config: any) {
if (item.scope === EntityType[2].value) { if (item.scope === EntityType[2].value) {
items.value.push({ items.value.push({
id: "endpoint", id: "endpoint",
title: "Endpoint", title: "Endpoint Dashboard",
func: handleGoEndpoint, func: handleGoEndpoint,
...item, ...item,
}); });
@ -497,7 +498,7 @@ function updateSettings(config: any) {
if (item.scope === EntityType[3].value) { if (item.scope === EntityType[3].value) {
items.value.push({ items.value.push({
id: "instance", id: "instance",
title: "Service Instance", title: "Service Instance Dashboard",
func: handleGoInstance, func: handleGoInstance,
...item, ...item,
}); });
@ -577,7 +578,6 @@ watch(
span { span {
display: block; display: block;
height: 30px; height: 30px;
width: 140px;
line-height: 30px; line-height: 30px;
text-align: center; text-align: center;
} }

View File

@ -325,6 +325,7 @@ function changeScope(index: number, opt: Option[] | any) {
[] []
); );
items[index].dashboard = states.nodeDashboards[0].value; items[index].dashboard = states.nodeDashboards[0].value;
updateSettings();
} }
function updateNodeDashboards(index: number, content: Option[] | any) { function updateNodeDashboards(index: number, content: Option[] | any) {
items[index].dashboard = content[0].value; items[index].dashboard = content[0].value;