2021-11-30 16:39:21 +08:00
|
|
|
|
<template>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<div class="chart-config">
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form
|
|
|
|
|
|
ref="chartForm"
|
|
|
|
|
|
:model="chartConfig"
|
|
|
|
|
|
:rules="rules"
|
|
|
|
|
|
label-position= "top"
|
|
|
|
|
|
label-width="120px"
|
2021-12-03 15:48:03 +08:00
|
|
|
|
@submit.native.prevent
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="chartConfig.elements"
|
2021-12-03 11:44:45 +08:00
|
|
|
|
class="metrics-input-box"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
2021-12-03 15:48:03 +08:00
|
|
|
|
<draggable v-model="chartConfig.elements"
|
|
|
|
|
|
:move="move"
|
|
|
|
|
|
@end="end"
|
|
|
|
|
|
@start="start"
|
|
|
|
|
|
:scroll-sensitivity="150"
|
|
|
|
|
|
:options="{
|
|
|
|
|
|
dragClass:'drag-chart-class',
|
|
|
|
|
|
fallbackClass:'fallback-class',
|
|
|
|
|
|
forceFallback:true,
|
|
|
|
|
|
ghostClass:'chart-ghost',
|
|
|
|
|
|
chosenClass:'choose-class',
|
|
|
|
|
|
scroll:true,
|
|
|
|
|
|
filter: '.drag-disabled',
|
|
|
|
|
|
animation: 150,
|
|
|
|
|
|
handle: '.chart-title-content'
|
|
|
|
|
|
}" >
|
|
|
|
|
|
<el-row
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:key="index"
|
|
|
|
|
|
class="element-item form-row-item thresholds-from-item"
|
|
|
|
|
|
style=""
|
|
|
|
|
|
v-for="index of chartConfig.elements.length"
|
2021-12-02 11:14:27 +08:00
|
|
|
|
>
|
|
|
|
|
|
<div class="chart-title chart-title-config">
|
2021-12-03 15:48:03 +08:00
|
|
|
|
<span class="chart-title-content el-form-item" :class="{
|
|
|
|
|
|
'is-error' : expressionsShow[index-1].error,
|
|
|
|
|
|
'hide-input': expressionsShow[index-1].hideInput
|
|
|
|
|
|
}">
|
|
|
|
|
|
<i class="nz-icon nz-icon-arrow-down" :class="expressionsShow[index-1].show?'':'is-active'" @click.stop="showExpression(index)"></i>
|
|
|
|
|
|
<el-input
|
2021-12-03 16:13:45 +08:00
|
|
|
|
@mousedown.stop
|
2021-12-03 15:48:03 +08:00
|
|
|
|
v-model="expressionName[index-1]"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@input="(val)=>{expressionNameInput(val,index-1)}"
|
|
|
|
|
|
@change="expressionNameChange(index-1)" style="width: 120px"
|
2021-12-03 16:13:45 +08:00
|
|
|
|
@focus.stop="showInput(index-1,false)"
|
|
|
|
|
|
@blur="showInput(index-1,true)"
|
2021-12-03 15:48:03 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<div v-if="expressionsShow[index-1].error" class="el-form-item__error" style="top: 10px;left: 164px"> {{expressionsShow[index-1].error}}</div>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
<span>
|
2021-12-10 16:18:18 +08:00
|
|
|
|
<span @click="()=>{addExpression()}" style="margin-right: 5px;padding-left: 10px">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
|
|
|
|
|
|
</span>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<span @click="copyExpression(index - 1)" style="margin-right: 5px">
|
|
|
|
|
|
<i class="nz-icon nz-icon-override"></i>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<span @click="removeExpression(index - 1)" class="nz-icon-minus-medium" style="margin-right: 5px">
|
|
|
|
|
|
<i class="nz-icon nz-icon-minus"></i>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
2021-12-03 17:59:27 +08:00
|
|
|
|
<el-row v-show="expressionsShow[index-1].show" style="margin-bottom: 10px">
|
2021-12-03 15:48:03 +08:00
|
|
|
|
<el-form-item :prop="'elements.' + (index -1) + '.expression'"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
:rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}">
|
2021-12-03 15:48:03 +08:00
|
|
|
|
<promql-input
|
|
|
|
|
|
:from-father-data="true"
|
|
|
|
|
|
:metricOptionsParent="metricOptions"
|
|
|
|
|
|
:expression-list="expressions"
|
|
|
|
|
|
:id="'promqlKeys' + [index-1]"
|
|
|
|
|
|
:index="index-1"
|
|
|
|
|
|
:required = 'true'
|
|
|
|
|
|
:type="promqlType"
|
|
|
|
|
|
:key="index-1"
|
|
|
|
|
|
:plugins="['metric-selector', 'metric-input', 'remove']"
|
|
|
|
|
|
:ref="'promql-'+(index-1)"
|
|
|
|
|
|
:showRemove="false"
|
|
|
|
|
|
:styleType="2"
|
|
|
|
|
|
@change="expressionChange"
|
|
|
|
|
|
@removeExpression="removeExpression"
|
|
|
|
|
|
></promql-input>
|
|
|
|
|
|
</el-form-item>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<el-row style="margin-top: 18px;display: flex">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<el-col class="legend-title">
|
|
|
|
|
|
<span class="legend-title__span">{{$t('dashboard.panel.chartForm.legend')}} </span>
|
|
|
|
|
|
<el-popover placement="top" trigger="hover" width="211" popper-class="prevent-clickoutside">
|
|
|
|
|
|
<div :style="{'word-break':language!=='cn'?'keep-all':'break-all'}">{{$t('dashboard.panel.chartForm.legendTip')}}</div>
|
|
|
|
|
|
<i @mouseover="rz" class="nz-icon nz-icon-info-normal" slot="reference" style="font-size: 14px; -webkit-transform:scale(0.75);display:inline-block;"></i>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</el-col>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<el-col style="flex: 1">
|
2021-12-06 15:25:09 +08:00
|
|
|
|
<el-input maxlength="512" show-word-limit size="small" type="text" v-model="expressionsShow[index-1].legend" @change="expressionChange"></el-input>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</transition>
|
2021-12-03 15:48:03 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
|
</draggable>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!--title-->
|
2021-12-03 10:08:34 +08:00
|
|
|
|
<div class="form__sub-title" >
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.displayConfig')}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="form-items--half-width-group">
|
|
|
|
|
|
<!-- type -->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.type')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="type"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-type"
|
|
|
|
|
|
v-model="chartConfig.type"
|
|
|
|
|
|
:disabled="chartConfig.type==='group'&&chartConfig.children&&chartConfig.children.length"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
value-key="chartType"
|
|
|
|
|
|
@change="chartTypeChange">
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in chartTypeList"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:disabled="
|
|
|
|
|
|
item.id==='group' && chartConfig.isGroup"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.id">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- unit -->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-show="!isTable(chartConfig.type)&&!isLog(chartConfig.type)"
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.unit')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="unit"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-cascader id="chart-box-unit"
|
|
|
|
|
|
v-model="chartConfig.unit"
|
|
|
|
|
|
:options="unitOptions"
|
|
|
|
|
|
:props="{ expandTrigger: 'hover',emitPath:false }"
|
|
|
|
|
|
:show-all-levels="false" filterable
|
2021-12-02 11:14:27 +08:00
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="dc-dropdown right-box-select-top right-public-box-dropdown-top prevent-clickoutside chart-box-unit"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
@change="unitSelected"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-cascader>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- index -->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-show="isTable(chartConfig.type)"
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.tableIndex')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.index"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<vue-tags-input
|
2021-12-15 17:55:56 +08:00
|
|
|
|
v-model="tag"
|
2021-12-02 11:14:27 +08:00
|
|
|
|
:maxlength="32"
|
|
|
|
|
|
:placeholder="$t('overall.addParameter')"
|
|
|
|
|
|
:tags="chartConfig.param.tags"
|
|
|
|
|
|
@tags-changed="(newTags)=>{tagsChange(newTags)}"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- limit -->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-show="isLog(chartConfig.type)"
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.limit')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.limit">
|
2021-12-09 10:34:11 +08:00
|
|
|
|
<el-input-number
|
2021-12-02 14:09:49 +08:00
|
|
|
|
size="small"
|
2021-12-03 11:44:45 +08:00
|
|
|
|
:placeholder="$t('placeholder.log.limit')"
|
2021-12-03 16:58:25 +08:00
|
|
|
|
v-model.number="chartConfig.param.limit"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:controls="false"
|
|
|
|
|
|
@change="change"/>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--width-->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.width')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="span">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-span"
|
|
|
|
|
|
v-model="chartConfig.span"
|
|
|
|
|
|
:disabled="chartConfig.type === 'group'"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
value-key="chartSpan"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in spanList"
|
|
|
|
|
|
:key="item"
|
|
|
|
|
|
:label="'span-' + item"
|
|
|
|
|
|
:value="item">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<span class="panel-dropdown-label-txt" > span-{{item}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--height-->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.high')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="height">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<!-- 由px改为span -->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-height"
|
|
|
|
|
|
v-model="chartConfig.height"
|
|
|
|
|
|
:disabled="chartConfig.type === 'group'"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
value-key="chartSpan"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in spanList"
|
|
|
|
|
|
:key="item"
|
|
|
|
|
|
:label="'span-' + item"
|
|
|
|
|
|
:value="item"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<span class="panel-dropdown-label-txt" > span-{{item}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--stack-->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.stack')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.stack"
|
|
|
|
|
|
v-if="isStackShow(chartConfig.type)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-height"
|
|
|
|
|
|
v-model="chartConfig.param.stack"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
value-key="chartSpan"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<el-option :value="1" label="true">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
<el-option :value="0" label="false">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--statistics-->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="isStatisticsShow(chartConfig.type)"
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.statistics')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.statistics"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-statistics"
|
|
|
|
|
|
v-model="chartConfig.param.statistics"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
2021-12-09 14:15:06 +08:00
|
|
|
|
@change="change"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<el-option v-for="item in statisticsList" :key="item.value" :label="$t(item.label)" :value="item.value">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{$t(item.label)}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- nullType -->
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
2021-12-22 14:23:39 +08:00
|
|
|
|
:label="$t('dashboard.panel.chartForm.nullType')"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.nullType"
|
2021-12-07 14:19:16 +08:00
|
|
|
|
v-if="isShowNullType(chartConfig.type)"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-nullType"
|
|
|
|
|
|
v-model="chartConfig.param.nullType"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
2021-12-09 14:15:06 +08:00
|
|
|
|
@change="change"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in nullTypeList"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="$t(item.label)"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
></el-option>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-12-07 14:19:16 +08:00
|
|
|
|
<!-- text -->
|
|
|
|
|
|
<el-form-item
|
2021-12-22 14:23:39 +08:00
|
|
|
|
:label="$t('dashboard.panel.chartForm.display')"
|
2021-12-07 14:19:16 +08:00
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.nullType"
|
|
|
|
|
|
v-if="isShowText(chartConfig.type)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-text"
|
|
|
|
|
|
v-model="chartConfig.param.text"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
2021-12-09 14:15:06 +08:00
|
|
|
|
@change="change"
|
2021-12-07 14:19:16 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in textList"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="$t(item.label)"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</div>
|
2021-12-24 15:32:16 +08:00
|
|
|
|
<div class="form-items--half-width-group" v-if="isGauge(chartConfig.type)">
|
|
|
|
|
|
<!--min-->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.min')" class="form-item--half-width">
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="margin-top: 2px"
|
|
|
|
|
|
:controls="false"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
show-word-limit v-model="chartConfig.param.min"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--max-->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.max')" class="form-item--half-width">
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="margin-top: 2px"
|
|
|
|
|
|
:controls="false"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
show-word-limit v-model="chartConfig.param.max"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
|
|
|
|
|
|
<div v-if="isShowLegend(chartConfig.type)">
|
|
|
|
|
|
<!--legendConfig-->
|
|
|
|
|
|
<div class="form__sub-title">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.legendConfig')}}</span>
|
2021-12-16 18:13:47 +08:00
|
|
|
|
<el-switch v-model="chartConfig.param.enable.legend" size="small" @change="change"></el-switch>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<div
|
2021-12-16 18:13:47 +08:00
|
|
|
|
v-if="chartConfig.param.enable.legend"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
class="form-items--half-width-group"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.legendPosition')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.legend.placement"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-legend-show"
|
|
|
|
|
|
v-model="chartConfig.param.legend.placement"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
2021-12-09 14:15:06 +08:00
|
|
|
|
@change="change"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in legendPositionList"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="$t(item.label)"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
></el-option>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="$t('dashboard.panel.chartForm.legendValues')"
|
|
|
|
|
|
class="form-item--half-width"
|
|
|
|
|
|
prop="param.legend.values"
|
2021-12-28 10:53:34 +08:00
|
|
|
|
v-if="isShowLegendVlaues(chartConfig.type)"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
id="chart-box-legend-value"
|
|
|
|
|
|
v-model="chartConfig.param.legend.values"
|
|
|
|
|
|
multiple
|
|
|
|
|
|
collapse-tags
|
2021-12-03 11:44:45 +08:00
|
|
|
|
:placeholder="$t('el.select.placeholder')"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
popper-class="right-box-select-top prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
2021-12-09 14:15:06 +08:00
|
|
|
|
@change="change"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in statisticsList"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="$t(item.label)"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
|
|
|
|
<!--thresholdConfig-->
|
|
|
|
|
|
<div class="form__sub-title">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.threshold')}}</span>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-switch
|
2021-12-23 17:02:21 +08:00
|
|
|
|
v-model="chartConfig.param.enable.thresholds"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
size="small"
|
|
|
|
|
|
@change="thresholdShowChange"
|
|
|
|
|
|
></el-switch>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
2021-12-23 17:02:21 +08:00
|
|
|
|
<el-row v-if="chartConfig.param.enable.thresholds">
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-for="(item,index) in chartConfig.param.thresholds"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="thresholds-item"
|
|
|
|
|
|
:prop="'param.thresholds.' + index + '.value'"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
:rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<nezhaColor
|
|
|
|
|
|
:value-arr="[{name:'thresholds',value:item.color}]"
|
|
|
|
|
|
:show-text="false"
|
|
|
|
|
|
:color-val="item.color"
|
|
|
|
|
|
@colorChange="(color,key)=>{colorChange(color,key,index)}"
|
|
|
|
|
|
/>
|
2021-12-09 10:34:11 +08:00
|
|
|
|
<el-input-number
|
2021-12-02 14:09:49 +08:00
|
|
|
|
size="small"
|
2021-12-03 17:59:27 +08:00
|
|
|
|
style="margin-top: 2px"
|
2021-12-03 11:44:45 +08:00
|
|
|
|
:placeholder="$t('placeholder.chart.threshold')"
|
2021-12-03 16:58:25 +08:00
|
|
|
|
v-model.number="item.value"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:controls="false"
|
|
|
|
|
|
@blur="sortThresholds"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<span
|
|
|
|
|
|
@click="delThresholds(index)"
|
|
|
|
|
|
class="del-thresholds-icon"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<i class="nz-icon nz-icon-delete" />
|
|
|
|
|
|
</span>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
</el-form-item>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<div @click="addThresholds" class="thresholds-add">
|
|
|
|
|
|
Add thresholds
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</div>
|
2021-12-16 10:10:27 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- table column-->
|
|
|
|
|
|
<div v-if="isTable(chartConfig.type)">
|
|
|
|
|
|
<div class="form__sub-title">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.columns')}}</span>
|
|
|
|
|
|
</div>
|
2022-03-15 11:14:42 +08:00
|
|
|
|
<div v-for="(item,index) in chartConfig.param.columns" :key="index" :class="item.error? 'is-item-box-error' : ''">
|
2021-12-16 10:10:27 +08:00
|
|
|
|
<div class="chart-title chart-title-config">
|
|
|
|
|
|
<span class="chart-title-content">
|
|
|
|
|
|
<i class="nz-icon nz-icon-arrow-down" :class="item.show?'':'is-active'" @click="showColumns(index)"></i>
|
|
|
|
|
|
<span v-show="!item.show" class="title-content-left">
|
|
|
|
|
|
<span>
|
|
|
|
|
|
{{item.value}}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<span @click="addColumns('')">
|
|
|
|
|
|
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span class="nz-icon-copy">
|
|
|
|
|
|
<i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span class="nz-icon-minus-medium">
|
|
|
|
|
|
<i @click="removeColumns(index)" class="nz-icon nz-icon-minus"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<transition-group appear tag="div" name="el-zoom-in-top">
|
|
|
|
|
|
<el-row class="thresholds-item" v-show="item.show" :key="1">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class='mapping-display'>Title</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-form-item :prop="'param.columns.' + index + '.title'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item" style="flex: 1">
|
2022-03-15 11:14:42 +08:00
|
|
|
|
<el-input size="small" v-model="item.title" @change="change('columns',index)"></el-input>
|
2021-12-16 10:10:27 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class='mapping-display'>Unit</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-cascader :id="'columns-unit' + index" v-model="item.unit" :options="unitOptions" :props="{ expandTrigger: 'hover',emitPath:false }" :show-all-levels="false" filterable
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="dc-dropdown right-box-select-top right-public-box-dropdown-top prevent-clickoutside chart-box-unit"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="flex: 1"
|
|
|
|
|
|
@change="unitSelected"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-cascader>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row class="thresholds-item" v-show="item.show" :key="2">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class='mapping-display'>Display</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-form-item :prop="'param.columns.' + index + '.display'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item">
|
2022-03-15 11:14:42 +08:00
|
|
|
|
<el-input v-model="item.display" style="margin-right: 10px" size="small" @change="change('columns',index)"/>
|
2021-12-16 10:10:27 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</transition-group>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div @click="addColumns" class="thresholds-add">
|
|
|
|
|
|
Add Colums
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<!-- valueMapping -->
|
2021-12-16 10:10:27 +08:00
|
|
|
|
<div v-if="isShowValueMapping(chartConfig.type) || isTable(chartConfig.type)">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<div class="form__sub-title">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.valueMapping')}}</span>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-switch
|
2021-12-16 18:13:47 +08:00
|
|
|
|
v-model="chartConfig.param.enable.valueMapping"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
size="small"
|
|
|
|
|
|
@change="change"
|
|
|
|
|
|
></el-switch>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
2021-12-23 16:06:38 +08:00
|
|
|
|
<el-row v-if="chartConfig.param.enable.valueMapping">
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<div
|
2021-12-23 16:06:38 +08:00
|
|
|
|
v-for="(item,index) in chartConfig.param.valueMapping"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:key="index"
|
2022-03-15 11:14:42 +08:00
|
|
|
|
:class="item.error? 'is-item-box-error' : ''"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<div class="chart-title chart-title-config">
|
2021-12-03 15:48:03 +08:00
|
|
|
|
<span class="chart-title-content">
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<i class="nz-icon nz-icon-arrow-down" :class="item.show?'':'is-active'" @click="showMapping(index)"></i>
|
|
|
|
|
|
<span v-show="!item.show" class="title-content-left">
|
|
|
|
|
|
<span v-if="item.type === 'value'">
|
|
|
|
|
|
{{item.value}}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span v-if="item.type === 'range'">
|
2021-12-24 18:39:31 +08:00
|
|
|
|
[{{item.from}},{{item.to}})
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
<span v-if="item.type === 'regx'">
|
|
|
|
|
|
{{item.regx}}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<div :style="{background:item.color.bac}" class="prev-mapping-box">
|
|
|
|
|
|
<span :style="{color:item.color.text}">
|
|
|
|
|
|
{{item.display || "T"}}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<span @click="addMapping('')" style="margin-right: 5px">
|
|
|
|
|
|
<i class="nz-icon nz-icon-create-square"></i>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<span @click="copyMapping(index)" style="margin-right: 5px">
|
|
|
|
|
|
<i class="nz-icon nz-icon-override"></i>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
2021-12-03 11:44:45 +08:00
|
|
|
|
<span @click="removeMapping(index)" style="margin-right: 5px">
|
|
|
|
|
|
<i class="nz-icon nz-icon-minus"></i>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<transition-group appear tag="div" name="el-zoom-in-top">
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-row
|
|
|
|
|
|
v-show="item.show"
|
|
|
|
|
|
:key="1"
|
|
|
|
|
|
class="thresholds-item"
|
|
|
|
|
|
>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<div>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="item.type"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 100px"
|
|
|
|
|
|
@change="(val)=>{mappingItemChange(index,val)}"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in mappingTypeList"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:key="item.value"/>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'value'"
|
2021-12-16 18:13:47 +08:00
|
|
|
|
:prop="'param.valueMapping.' + index + '.value'"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
:rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
class="thresholds-from-item"
|
|
|
|
|
|
>
|
2021-12-09 10:34:11 +08:00
|
|
|
|
<el-input-number
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:controls="false"
|
|
|
|
|
|
size="small"
|
2021-12-03 16:58:25 +08:00
|
|
|
|
v-model.number="item.value"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
placeholder="value"
|
2022-03-15 11:14:42 +08:00
|
|
|
|
@change="change('valueMapping', index)"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
></el-input-number>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'range'"
|
2021-12-16 18:13:47 +08:00
|
|
|
|
:prop="'param.valueMapping.' + index + '.from'"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
:rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
class="thresholds-from-item"
|
|
|
|
|
|
>
|
2021-12-09 10:34:11 +08:00
|
|
|
|
<el-input-number
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:controls="false"
|
|
|
|
|
|
size="small"
|
2021-12-03 16:58:25 +08:00
|
|
|
|
v-model.number="item.from"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
placeholder="from"
|
2022-03-15 11:14:42 +08:00
|
|
|
|
@change="change('valueMapping', index)"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
></el-input-number>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'range'"
|
2021-12-16 18:13:47 +08:00
|
|
|
|
:prop="'param.valueMapping.' + index + '.to'"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
:rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
class="thresholds-from-item"
|
|
|
|
|
|
>
|
2021-12-09 10:34:11 +08:00
|
|
|
|
<el-input-number
|
2021-12-02 14:09:49 +08:00
|
|
|
|
:controls="false"
|
|
|
|
|
|
size="small"
|
2021-12-03 16:58:25 +08:00
|
|
|
|
v-model.number="item.to"
|
2022-03-15 11:14:42 +08:00
|
|
|
|
@change="change('valueMapping', index)"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
placeholder="to"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
></el-input-number>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'regx'"
|
2021-12-16 18:13:47 +08:00
|
|
|
|
:prop="'param.valueMapping.' + index + '.regx'"
|
2021-12-09 10:34:11 +08:00
|
|
|
|
:rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
class="thresholds-from-item"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
v-model="item.regx"
|
|
|
|
|
|
placeholder="regx"
|
2022-03-15 11:14:42 +08:00
|
|
|
|
@change="change('valueMapping', index)"
|
2021-12-02 14:09:49 +08:00
|
|
|
|
></el-input>
|
|
|
|
|
|
</el-form-item>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-row v-show="item.show" :key="2" class="thresholds-item">
|
2021-12-16 10:10:27 +08:00
|
|
|
|
<div v-if="isTable(chartConfig.type)">
|
|
|
|
|
|
<div class='mapping-display'>Columns</div>
|
|
|
|
|
|
</div>
|
2021-12-16 18:13:47 +08:00
|
|
|
|
<el-form-item v-if="isTable(chartConfig.type)" :prop="'param.valueMapping.' + index + '.column'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item">
|
2022-03-15 11:14:42 +08:00
|
|
|
|
<el-input v-model="item.column" style="margin-right: 10px" :placeholder="$t('placeholder.chart.column')" size="small" @change="change('valueMapping', index)"/>
|
2021-12-16 10:10:27 +08:00
|
|
|
|
</el-form-item>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<div class='mapping-display'>Display</div>
|
|
|
|
|
|
</div>
|
2021-12-16 18:13:47 +08:00
|
|
|
|
<el-form-item :prop="'param.valueMapping.' + index + '.display'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item">
|
2022-03-15 11:14:42 +08:00
|
|
|
|
<el-input v-model="item.display" style="margin-right: 10px" :placeholder="$t('placeholder.chart.display')" size="small" @change="change('valueMapping', index)"/>
|
2021-12-02 14:09:49 +08:00
|
|
|
|
</el-form-item>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
<nezhaColor :color-val="item.color" :single="false" :value-arr="[{name:'bac',value:item.color.bac,key:'bac'},{name:'text',value:item.color.text,key:'text'}]" @colorChange="(val,key)=>{colorChange(val, key, index)}"/>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</transition-group>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div @click="addMapping" class="thresholds-add">
|
|
|
|
|
|
Add valueMapping
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form>
|
2021-11-30 16:39:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-12-02 11:14:27 +08:00
|
|
|
|
import promqlInput from '@/components/page/dashboard/explore/promqlInput'
|
|
|
|
|
|
import nezhaColor from '@/components/common/nezhaColor'
|
|
|
|
|
|
import promqlInputMixin from '@/components/common/mixin/promqlInput'
|
|
|
|
|
|
import publicConfig from '@/components/common/rightBox/chart/publicConfig'
|
|
|
|
|
|
import chartTypeShow from '@/components/common/rightBox/chart/chartTypeShow'
|
|
|
|
|
|
import VueTagsInput from '@johmun/vue-tags-input'
|
2021-12-03 15:48:03 +08:00
|
|
|
|
import draggable from 'vuedraggable'
|
2021-12-08 14:45:15 +08:00
|
|
|
|
import { randomcolor, ColorReverse } from '@/components/common/js/radomcolor/randomcolor'
|
2021-12-24 15:32:16 +08:00
|
|
|
|
import { isGauge } from '@/components/chart/chart/tools'
|
2021-12-10 11:33:45 +08:00
|
|
|
|
|
2021-11-30 16:39:21 +08:00
|
|
|
|
export default {
|
2021-12-02 14:09:49 +08:00
|
|
|
|
name: 'chartConfig',
|
2021-12-02 11:14:27 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
promqlInput,
|
|
|
|
|
|
nezhaColor,
|
2021-12-03 15:48:03 +08:00
|
|
|
|
VueTagsInput,
|
|
|
|
|
|
draggable
|
2021-12-02 11:14:27 +08:00
|
|
|
|
},
|
2021-12-02 14:09:49 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
type: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: 'metrics'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
type: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.beforeInit()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-12-02 11:14:27 +08:00
|
|
|
|
mixins: [promqlInputMixin, publicConfig, chartTypeShow],
|
|
|
|
|
|
computed: {},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2021-12-02 14:09:49 +08:00
|
|
|
|
rules: {
|
|
|
|
|
|
},
|
2021-12-07 14:19:16 +08:00
|
|
|
|
oldType: '',
|
2021-12-15 17:55:56 +08:00
|
|
|
|
tag: '',
|
2021-12-02 11:14:27 +08:00
|
|
|
|
promqlType: 'log',
|
|
|
|
|
|
chartTypeList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'line',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.line.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2021-12-07 14:19:16 +08:00
|
|
|
|
id: 'area',
|
2021-12-02 11:14:27 +08:00
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.stackArea.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'point',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.point.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2021-12-06 11:40:06 +08:00
|
|
|
|
id: 'stat',
|
2021-12-07 14:19:16 +08:00
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.singleStat.label')
|
2021-12-02 11:14:27 +08:00
|
|
|
|
},
|
2021-12-28 18:09:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'hexagon',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.hexagonFigure.label')
|
|
|
|
|
|
},
|
2021-12-02 11:14:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'bar',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.bar.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-03-07 18:06:41 +08:00
|
|
|
|
id: 'gauge',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.gauge.label')
|
2021-12-02 11:14:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'treemap',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.treemap.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'pie',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.pie.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'log',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.log.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'table',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.table.label')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-12-24 15:32:16 +08:00
|
|
|
|
isGauge,
|
2021-12-02 14:09:49 +08:00
|
|
|
|
beforeInit () {
|
|
|
|
|
|
this.promqlType = this.type
|
|
|
|
|
|
this.chartTypeList = this[this.type + 'ChartTypeList']
|
|
|
|
|
|
},
|
2021-12-02 11:14:27 +08:00
|
|
|
|
init () {
|
|
|
|
|
|
this.chartConfig = JSON.parse(JSON.stringify(this.params))
|
2021-12-07 14:19:16 +08:00
|
|
|
|
this.oldType = this.chartConfig.type
|
2021-12-02 11:14:27 +08:00
|
|
|
|
// 重置相关属性
|
|
|
|
|
|
this.expressions = []
|
|
|
|
|
|
this.expressionsShow = []
|
2021-12-03 15:48:03 +08:00
|
|
|
|
this.expressionName = []
|
2021-12-02 11:14:27 +08:00
|
|
|
|
if (!this.chartConfig.elements.length) {
|
|
|
|
|
|
this.addExpression()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.chartConfig.elements.forEach(item => {
|
|
|
|
|
|
this.addExpression(item)
|
|
|
|
|
|
})
|
2022-02-25 09:32:15 +08:00
|
|
|
|
this.expressionChange()
|
2021-12-02 11:14:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
chartTypeChange (type) {
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case 'line':
|
2021-12-07 14:19:16 +08:00
|
|
|
|
case 'area':
|
2021-12-02 11:14:27 +08:00
|
|
|
|
case 'point':
|
2021-12-07 14:19:16 +08:00
|
|
|
|
if (this.oldType === 'line' || this.oldType === 'area' || this.oldType === 'point') {
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-12-02 11:14:27 +08:00
|
|
|
|
this.chartConfig.param = {
|
|
|
|
|
|
stack: 0,
|
2021-12-24 16:06:17 +08:00
|
|
|
|
link: this.chartConfig.param.link,
|
2021-12-02 11:14:27 +08:00
|
|
|
|
nullType: this.chartConfig.param.nullType,
|
|
|
|
|
|
legend: { placement: 'bottom', values: [], show: true },
|
|
|
|
|
|
thresholdShow: true,
|
2021-12-16 18:13:47 +08:00
|
|
|
|
thresholds: [],
|
|
|
|
|
|
enable: {
|
|
|
|
|
|
legend: true,
|
2021-12-17 11:18:49 +08:00
|
|
|
|
valueMapping: false,
|
|
|
|
|
|
thresholds: false
|
2021-12-24 15:32:16 +08:00
|
|
|
|
}
|
2021-12-02 11:14:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$nextTick(() => {
|
2021-12-07 14:19:16 +08:00
|
|
|
|
this.chartConfig.param.thresholds.push({ value: undefined, color: randomcolor() })
|
2021-12-02 11:14:27 +08:00
|
|
|
|
})
|
|
|
|
|
|
break
|
2021-12-06 11:40:06 +08:00
|
|
|
|
case 'stat':
|
2021-12-28 18:09:44 +08:00
|
|
|
|
case 'hexagon':
|
2022-03-07 18:06:41 +08:00
|
|
|
|
case 'gauge':
|
|
|
|
|
|
if (this.oldType === 'stat' || this.oldType === 'gauge' || this.oldType === 'hexagon') {
|
2021-12-28 10:53:34 +08:00
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
this.chartConfig.param = {
|
|
|
|
|
|
nullType: this.chartConfig.param.nullType,
|
|
|
|
|
|
link: this.chartConfig.param.link,
|
|
|
|
|
|
statistics: 'last',
|
|
|
|
|
|
text: 'value',
|
|
|
|
|
|
valueMapping: [],
|
|
|
|
|
|
min: 0,
|
|
|
|
|
|
max: 100,
|
|
|
|
|
|
enable: {
|
|
|
|
|
|
legend: true,
|
|
|
|
|
|
valueMapping: false,
|
|
|
|
|
|
thresholds: false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break
|
2021-12-02 11:14:27 +08:00
|
|
|
|
case 'bar':
|
|
|
|
|
|
case 'treemap':
|
|
|
|
|
|
case 'pie':
|
2021-12-28 10:53:34 +08:00
|
|
|
|
if (this.oldType === 'bar' || this.oldType === 'treemap' || this.oldType === 'pie') {
|
2021-12-07 14:19:16 +08:00
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-12-02 11:14:27 +08:00
|
|
|
|
this.chartConfig.param = {
|
|
|
|
|
|
nullType: this.chartConfig.param.nullType,
|
2021-12-24 16:06:17 +08:00
|
|
|
|
link: this.chartConfig.param.link,
|
2021-12-02 11:14:27 +08:00
|
|
|
|
statistics: 'last',
|
2021-12-09 14:15:06 +08:00
|
|
|
|
text: 'value',
|
2021-12-16 18:13:47 +08:00
|
|
|
|
valueMapping: [],
|
2021-12-28 10:53:34 +08:00
|
|
|
|
legend: { placement: 'bottom', values: [], show: true },
|
2021-12-24 15:32:16 +08:00
|
|
|
|
min: 0,
|
|
|
|
|
|
max: 100,
|
2021-12-16 18:13:47 +08:00
|
|
|
|
enable: {
|
|
|
|
|
|
legend: true,
|
2021-12-17 11:18:49 +08:00
|
|
|
|
valueMapping: false,
|
|
|
|
|
|
thresholds: false
|
2021-12-02 11:14:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'table':
|
2021-12-07 14:19:16 +08:00
|
|
|
|
if (this.oldType === 'table') {
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-12-02 11:14:27 +08:00
|
|
|
|
this.chartConfig.param = {
|
|
|
|
|
|
nullType: this.chartConfig.param.nullType,
|
2021-12-24 16:06:17 +08:00
|
|
|
|
link: this.chartConfig.param.link,
|
2021-12-02 11:14:27 +08:00
|
|
|
|
statistics: 'last',
|
|
|
|
|
|
columns: [],
|
|
|
|
|
|
tags: [],
|
2021-12-16 10:10:27 +08:00
|
|
|
|
indexs: '',
|
2021-12-16 18:13:47 +08:00
|
|
|
|
valueMapping: [],
|
|
|
|
|
|
enable: {
|
|
|
|
|
|
legend: true,
|
2021-12-17 11:18:49 +08:00
|
|
|
|
valueMapping: false,
|
|
|
|
|
|
thresholds: false
|
2021-12-16 10:10:27 +08:00
|
|
|
|
}
|
2021-12-02 11:14:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
break
|
2021-12-02 14:09:49 +08:00
|
|
|
|
case 'log':
|
2021-12-07 14:19:16 +08:00
|
|
|
|
if (this.oldType === 'log') {
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-12-02 14:09:49 +08:00
|
|
|
|
this.chartConfig.param = {
|
2021-12-24 16:06:17 +08:00
|
|
|
|
link: this.chartConfig.param.link,
|
2021-12-02 14:09:49 +08:00
|
|
|
|
limit: 100
|
|
|
|
|
|
}
|
|
|
|
|
|
break
|
2021-12-02 11:14:27 +08:00
|
|
|
|
}
|
2021-12-07 14:19:16 +08:00
|
|
|
|
this.oldType = type
|
2021-12-02 11:14:27 +08:00
|
|
|
|
this.change()
|
|
|
|
|
|
},
|
|
|
|
|
|
sortThresholds () {
|
|
|
|
|
|
if (this.param && this.param.thresholds.length > 1) {
|
|
|
|
|
|
this.param.thresholds = this.chartConfig.param.thresholds.sort((a, b) => {
|
|
|
|
|
|
const value1 = a.value
|
|
|
|
|
|
const value2 = b.value
|
|
|
|
|
|
return value1 - value2
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
this.change()
|
|
|
|
|
|
},
|
|
|
|
|
|
thresholdShowChange () {
|
|
|
|
|
|
// if (this.chartConfig.param.thresholdShow) {
|
|
|
|
|
|
//
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
this.change()
|
|
|
|
|
|
},
|
|
|
|
|
|
addThresholds () {
|
|
|
|
|
|
this.chartConfig.param.thresholds.push({
|
2021-12-02 14:09:49 +08:00
|
|
|
|
value: undefined,
|
2021-12-07 14:19:16 +08:00
|
|
|
|
color: randomcolor()
|
2021-12-02 11:14:27 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.change()
|
|
|
|
|
|
},
|
|
|
|
|
|
delThresholds (index) {
|
|
|
|
|
|
if (this.chartConfig.param.thresholds.length === 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.chartConfig.param.thresholds.splice(index, 1)
|
|
|
|
|
|
this.change()
|
2021-12-03 15:48:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
move () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
end (event) {
|
|
|
|
|
|
this.expressions = []
|
|
|
|
|
|
this.expressionName = []
|
|
|
|
|
|
if (!this.chartConfig.elements.length) {
|
|
|
|
|
|
this.addExpression()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.chartConfig.elements.forEach(item => {
|
2021-12-03 16:13:45 +08:00
|
|
|
|
this.expressions.push(item.expression)
|
|
|
|
|
|
this.expressionName.push(item.name)
|
2021-12-03 15:48:03 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
this.change()
|
|
|
|
|
|
},
|
|
|
|
|
|
start () {
|
|
|
|
|
|
|
2021-12-02 11:14:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created () {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
}
|
2021-11-30 16:39:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|