fix view mode

This commit is contained in:
Qiuxia Fan 2022-07-13 10:17:56 +08:00
parent 7fbd6170de
commit 77507b9d78

View File

@ -34,7 +34,7 @@ limitations under the License. -->
</span> </span>
</div> </div>
</div> </div>
<div class="setting" v-if="showSetting"> <div class="setting" v-if="showSetting && dashboardStore.editMode">
<Settings @update="updateSettings" @updateNodes="freshNodes" /> <Settings @update="updateSettings" @updateNodes="freshNodes" />
</div> </div>
<div class="tool"> <div class="tool">
@ -113,6 +113,7 @@ import getDashboard from "@/hooks/useDashboardsSession";
import { MetricConfigOpt } from "@/types/dashboard"; import { MetricConfigOpt } from "@/types/dashboard";
import { aggregation } from "@/hooks/useProcessor"; import { aggregation } from "@/hooks/useProcessor";
import icons from "@/assets/img/icons"; import icons from "@/assets/img/icons";
import { useQueryTopologyMetrics } from "@/hooks/useProcessor";
/*global Nullable, defineProps */ /*global Nullable, defineProps */
const props = defineProps({ const props = defineProps({
@ -170,6 +171,7 @@ onMounted(async () => {
width.value = dom.width; width.value = dom.width;
window.addEventListener("resize", resize); window.addEventListener("resize", resize);
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 initLegendMetrics();
await init(); await init();
update(); update();
setNodeTools(settings.value.nodeDashboard); setNodeTools(settings.value.nodeDashboard);
@ -200,6 +202,18 @@ async function init() {
dashboardStore.selectWidget(props.config); dashboardStore.selectWidget(props.config);
}); });
} }
async function initLegendMetrics() {
const ids = topologyStore.nodes.map((d: Node) => d.id);
const names = props.config.legend.map((d: any) => d.name);
if (names.length && ids.length) {
const param = await useQueryTopologyMetrics(names, ids);
const res = await topologyStore.getLegendMetrics(param);
if (res.errors) {
ElMessage.error(res.errors);
}
}
}
function ticked() { function ticked() {
link.value.attr( link.value.attr(
"d", "d",