fix: bugs fix

This commit is contained in:
Qiuxia Fan 2022-02-17 23:05:48 +08:00
parent 7f6d63e669
commit 21318c1b71
4 changed files with 54 additions and 45 deletions

View File

@ -206,7 +206,7 @@ function handleLinkClick(event: any, d: Call) {
event.stopPropagation(); event.stopPropagation();
topologyStore.setNode(null); topologyStore.setNode(null);
topologyStore.setLink(d); topologyStore.setLink(d);
if (settings.value.linkDashboard) { if (!settings.value.linkDashboard) {
return; return;
} }
const e = const e =
@ -239,9 +239,7 @@ function update() {
topologyStore.nodeMetrics[m].values.filter( topologyStore.nodeMetrics[m].values.filter(
(val: { id: string; value: unknown }) => val.id === data.id (val: { id: string; value: unknown }) => val.id === data.id
)[0] || {}; )[0] || {};
const val = m.includes("_sla") const val = m.includes("_sla") ? metric.value / 100 : metric.value;
? metric.value / 100
: metric.value.value;
return ` <div class="mb-5"><span class="grey">${m}: </span>${val}</div>`; return ` <div class="mb-5"><span class="grey">${m}: </span>${val}</div>`;
}); });
return [ return [

View File

@ -213,7 +213,7 @@ function handleClick(event: any) {
position: absolute; position: absolute;
top: 40px; top: 40px;
right: 0; right: 0;
width: 360px; width: 380px;
height: 700px; height: 700px;
background-color: #2b3037; background-color: #2b3037;
overflow: auto; overflow: auto;

View File

@ -82,7 +82,8 @@ function linkTooltip(data: Call) {
(val: { id: string; value: unknown }) => val.id === data.id (val: { id: string; value: unknown }) => val.id === data.id
)[0]; )[0];
if (metric) { if (metric) {
return ` <div><span>${m}: </span>${metric.value}</div>`; const val = m.includes("_sla") ? metric.value / 100 : metric.value;
return ` <div><span>${m}: </span>${val}</div>`;
} }
}); });
const htmlClient = clientMetrics.map((m) => { const htmlClient = clientMetrics.map((m) => {
@ -90,7 +91,8 @@ function linkTooltip(data: Call) {
(val: { id: string; value: unknown }) => val.id === data.id (val: { id: string; value: unknown }) => val.id === data.id
)[0]; )[0];
if (metric) { if (metric) {
return ` <div><span>${m}: </span>${metric.value}</div>`; const val = m.includes("_sla") ? metric.value / 100 : metric.value;
return ` <div><span>${m}: </span>${val}</div>`;
} }
}); });
const html = [ const html = [
@ -109,7 +111,8 @@ function nodeTooltip(data: Node) {
topologyStore.nodeMetrics[m].values.filter( topologyStore.nodeMetrics[m].values.filter(
(val: { id: string; value: unknown }) => val.id === data.id (val: { id: string; value: unknown }) => val.id === data.id
)[0] || {}; )[0] || {};
return ` <div><span>${m}: </span>${metric.value}</div>`; const val = m.includes("_sla") ? metric.value / 100 : metric.value;
return ` <div><span>${m}: </span>${val}</div>`;
}); });
return [` <div><span>name: </span>${data.serviceName}</div>`, ...html].join( return [` <div><span>name: </span>${data.serviceName}</div>`, ...html].join(
" " " "

View File

@ -50,40 +50,42 @@ limitations under the License. -->
</div> </div>
<div class="node-settings"> <div class="node-settings">
<h5 class="title">{{ t("nodeSettings") }}</h5> <h5 class="title">{{ t("nodeSettings") }}</h5>
<div class="label">{{ t("nodeDashboard") }}</div> <span v-show="isServer">
<div v-for="(item, index) in items" :key="index" class="metric-item"> <div class="label">{{ t("nodeDashboard") }}</div>
<Selector <div v-for="(item, index) in items" :key="index" class="metric-item">
:value="item.scope" <Selector
:options="ScopeType" :value="item.scope"
size="small" :options="ScopeType"
placeholder="Select a scope" size="small"
@change="changeScope(index, $event)" placeholder="Select a scope"
class="item mr-5" @change="changeScope(index, $event)"
/> class="item mr-5"
<el-input
v-model="item.dashboard"
placeholder="Please input a dashboard name for nodes"
@change="updateNodeDashboards(index, $event)"
size="small"
class="item mr-5"
/>
<span>
<Icon
class="cp mr-5"
v-show="items.length > 1"
iconName="remove_circle_outline"
size="middle"
@click="deleteItem(index)"
/> />
<Icon <el-input
class="cp" v-model="item.dashboard"
v-show="index === items.length - 1 && items.length < 5" placeholder="Please input a dashboard name for nodes"
iconName="add_circle_outlinecontrol_point" @change="updateNodeDashboards(index, $event)"
size="middle" size="small"
@click="addItem" class="item mr-5"
/> />
</span> <span>
</div> <Icon
class="cp mr-5"
v-show="items.length > 1"
iconName="remove_circle_outline"
size="middle"
@click="deleteItem(index)"
/>
<Icon
class="cp"
v-show="index === items.length - 1 && items.length < 5"
iconName="add_circle_outlinecontrol_point"
size="middle"
@click="addItem"
/>
</span>
</div>
</span>
<div class="label">{{ t("nodeMetrics") }}</div> <div class="label">{{ t("nodeMetrics") }}</div>
<Selector <Selector
class="inputs" class="inputs"
@ -95,7 +97,7 @@ limitations under the License. -->
@change="changeNodeMetrics" @change="changeNodeMetrics"
/> />
</div> </div>
<div class="legend-settings"> <div class="legend-settings" v-show="isServer">
<h5 class="title">{{ t("legendSettings") }}</h5> <h5 class="title">{{ t("legendSettings") }}</h5>
<div class="label">{{ t("metrics") }}</div> <div class="label">{{ t("metrics") }}</div>
<Selector <Selector
@ -207,6 +209,9 @@ const states = reactive<{
nodeMetricList: [], nodeMetricList: [],
linkMetricList: [], linkMetricList: [],
}); });
const isServer = [EntityType[0].value, EntityType[1].value].includes(
dashboardStore.entity
);
const legend = reactive<{ const legend = reactive<{
metric: any; metric: any;
condition: string; condition: string;
@ -220,9 +225,12 @@ async function getMetricList() {
ElMessage.error(json.errors); ElMessage.error(json.errors);
return; return;
} }
const entity =
dashboardStore.entity === EntityType[1].value
? EntityType[0].value
: dashboardStore.entity;
states.nodeMetricList = (json.data.metrics || []).filter( states.nodeMetricList = (json.data.metrics || []).filter(
(d: { catalog: string }) => (d: { catalog: string }) => entity === (MetricCatalog as any)[d.catalog]
dashboardStore.entity === (MetricCatalog as any)[d.catalog]
); );
const e = const e =
dashboardStore.entity === EntityType[1].value dashboardStore.entity === EntityType[1].value
@ -358,7 +366,7 @@ async function changeNodeMetrics(options: Option[]) {
} }
.input-small { .input-small {
width: 60px; width: 45px;
} }
.title { .title {
@ -371,7 +379,7 @@ async function changeNodeMetrics(options: Option[]) {
} }
.legend-btn { .legend-btn {
margin-top: 20px; margin: 20px 0;
cursor: pointer; cursor: pointer;
} }
</style> </style>