feat: add detail label

This commit is contained in:
Fine 2023-06-08 12:08:57 +08:00
parent eccf4a84a0
commit e7a79c4346
7 changed files with 36 additions and 5 deletions

View File

@ -388,5 +388,8 @@ const msg = {
elasticsearch: "Elasticsearch", elasticsearch: "Elasticsearch",
mq: "MQ", mq: "MQ",
rabbitMQ: "RabbitMQ", rabbitMQ: "RabbitMQ",
detailLabel: "Detail Label",
summary: "Summary",
detail: "Detail",
}; };
export default msg; export default msg;

View File

@ -387,5 +387,8 @@ const msg = {
elasticsearch: "Elasticsearch", elasticsearch: "Elasticsearch",
mq: "MQ", mq: "MQ",
rabbitMQ: "RabbitMQ", rabbitMQ: "RabbitMQ",
detailLabel: "Detail Label",
summary: "Summary",
detail: "Detail",
}; };
export default msg; export default msg;

View File

@ -385,5 +385,8 @@ const msg = {
elasticsearch: "Elasticsearch", elasticsearch: "Elasticsearch",
mq: "消息队列", mq: "消息队列",
rabbitMQ: "RabbitMQ", rabbitMQ: "RabbitMQ",
detailLabel: "详细标签",
summary: "概括",
detail: "详细",
}; };
export default msg; export default msg;

View File

@ -79,6 +79,7 @@ export type MetricConfigOpt = {
sortOrder?: string; sortOrder?: string;
topN?: number; topN?: number;
index?: number; index?: number;
detailLabel?: string;
}; };
export interface WidgetConfig { export interface WidgetConfig {

View File

@ -35,8 +35,8 @@ limitations under the License. -->
@change="changeMetricMode" @change="changeMetricMode"
/> />
<div v-if="isExpression && states.isList"> <div v-if="isExpression && states.isList">
<span class="title">Summary</span> <span class="title">{{ t("summary") }}</span>
<span>Detail</span> <span>{{ t("detail") }}</span>
</div> </div>
<div v-for="(metric, index) in states.metrics" :key="index" class="mb-10"> <div v-for="(metric, index) in states.metrics" :key="index" class="mb-10">
<span v-if="isExpression"> <span v-if="isExpression">
@ -551,6 +551,7 @@ limitations under the License. -->
} }
async function changeExpression(event: any, index: number) { async function changeExpression(event: any, index: number) {
const params = (event.target.textContent || "").replace(/\s+/g, ""); const params = (event.target.textContent || "").replace(/\s+/g, "");
console.log(params);
if (params) { if (params) {
const resp = await dashboardStore.getTypeOfMQE(params); const resp = await dashboardStore.getTypeOfMQE(params);

View File

@ -42,6 +42,20 @@ limitations under the License. -->
" "
/> />
</div> </div>
<div class="item mb-10" v-if="hasLabel && dashboardStore.selectedGrid.metricMode === MetricModes.Expression">
<span class="label">{{ t("detailLabel") }}</span>
<el-input
class="input"
v-model="currentMetric.detailLabel"
size="small"
placeholder="Please input a name"
@change="
updateConfig(index, {
detailLabel: encodeURIComponent(currentMetric.detailLabel || ''),
})
"
/>
</div>
<div <div
class="item mb-10" class="item mb-10"
v-if=" v-if="

View File

@ -48,7 +48,7 @@ limitations under the License. -->
<div class="view-line"> <div class="view-line">
<Line <Line
:data="{ :data="{
[colSubMetrics[index] || metric]: [decodeURIComponent(getLabel(colSubMetrics[index], index, true)) || metric]:
scope.row[colSubMetrics[index] || metric] && scope.row[colSubMetrics[index] || metric].values, scope.row[colSubMetrics[index] || metric] && scope.row[colSubMetrics[index] || metric].values,
}" }"
:intervalTime="intervalTime" :intervalTime="intervalTime"
@ -109,9 +109,15 @@ limitations under the License. -->
} }
return encodeURIComponent(""); return encodeURIComponent("");
} }
function getLabel(metric: string, index: number) { function getLabel(metric: string, index: number, isDetail?: boolean) {
const i = Number(index); const i = Number(index);
const label = props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].label; let label = "";
if (isDetail) {
label =
(props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].detailLabel) || "";
} else {
label = (props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].label) || "";
}
if (label) { if (label) {
if ( if (
( (