2020-01-03 17:17:09 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.el-row {
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.el-row:last-child {
|
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
.el-col {
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.bg-purple {
|
|
|
|
|
|
background: white;
|
|
|
|
|
|
}
|
|
|
|
|
|
.grid-content {
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
min-height: 36px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.common-float-left {
|
|
|
|
|
|
float: left;
|
|
|
|
|
|
display:inline-block;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-inner {
|
|
|
|
|
|
width: 200px;
|
|
|
|
|
|
border-top-width: 0px;
|
|
|
|
|
|
border-left-width: 0px;
|
|
|
|
|
|
border-right-width: 0px;
|
|
|
|
|
|
border-bottom-width: 10px;
|
|
|
|
|
|
border-color:red;
|
|
|
|
|
|
/*outline: medium;*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.element-bottom-border {
|
|
|
|
|
|
padding-bottom: 5px;
|
|
|
|
|
|
border-bottom: 1px solid #dfe7f2;
|
2020-01-20 21:25:55 +08:00
|
|
|
|
margin-top: 15px;
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
/*metric样式--begin*/
|
|
|
|
|
|
.element-item {
|
2020-01-20 21:25:55 +08:00
|
|
|
|
padding: 20px 0;
|
2020-01-03 17:17:09 +08:00
|
|
|
|
border-bottom: 1px dashed #dfe7f2;
|
2020-07-02 22:25:06 +08:00
|
|
|
|
width: 100%;
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2020-10-15 14:27:46 +08:00
|
|
|
|
.right-box-form .element-item.form-row-item{
|
|
|
|
|
|
width: calc(100% - 120px);
|
|
|
|
|
|
padding: 20px 20px 20px 0;
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
/*metric样式--end*/
|
|
|
|
|
|
.label-center{
|
2020-02-21 17:32:59 +08:00
|
|
|
|
vertical-align: middle;
|
|
|
|
|
|
line-height: 34px;
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2020-02-06 18:50:40 +08:00
|
|
|
|
|
|
|
|
|
|
.z-top {
|
2020-09-02 17:41:22 +08:00
|
|
|
|
/*z-index: 2900;*/
|
2020-01-06 17:10:57 +08:00
|
|
|
|
}
|
2020-09-14 13:49:31 +08:00
|
|
|
|
.save-chart-box{
|
|
|
|
|
|
z-index: 2900;
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<template key="chartBox">
|
2020-09-14 13:49:31 +08:00
|
|
|
|
<div v-clickoutside="clickOutside" class="right-box right-box-add-chart z-top right-box-chart" :class="boxClass">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<panel-box :panel="panel" @reload="panelReload" ref="panelBox2" v-if="!showPanel.type"></panel-box>
|
|
|
|
|
|
</transition>
|
2020-02-06 18:50:40 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<div class="right-box-top-btns right-box-form-delete">
|
|
|
|
|
|
<button id="chart-box-delete" type="button" v-if="editChart.id" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-min-width-82">
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{editChart.id ? $t("dashboard.panel.editChartTitle") : $t("dashboard.panel.createChartTitle")}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!-- begin--表单-->
|
|
|
|
|
|
<el-scrollbar class="right-box-form-box" ref="scrollbar">
|
|
|
|
|
|
<el-form class="right-box-form right-box-form-left" :model="editChart" label-width="120px" label-position="right" :rules="rules" ref="chartForm">
|
2020-08-06 19:44:33 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.title')" prop="panelName" v-if="showPanel.type != 'dashboard' && showPanel.type != 'project' && showPanel.type != 'asset' && showPanel.type != 'model'">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-autocomplete
|
|
|
|
|
|
:fetch-suggestions="panelSuggestion"
|
2020-07-31 20:57:04 +08:00
|
|
|
|
v-model.trim="editChart.panelName"
|
2020-07-30 18:37:04 +08:00
|
|
|
|
placeholder=""
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
value-key="name"
|
|
|
|
|
|
v-if="!editChart.id"
|
2020-09-22 11:54:25 +08:00
|
|
|
|
@input="inputPanel"
|
2020-07-30 18:37:04 +08:00
|
|
|
|
popper-class="chart-box-autocomplete no-style-class"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-autocomplete>
|
2020-07-31 20:57:04 +08:00
|
|
|
|
<el-input size="small" v-if="editChart.id" readonly="readonly" :value="editChart.panelName"></el-input>
|
2020-03-12 17:30:29 +08:00
|
|
|
|
|
2020-07-31 20:57:04 +08:00
|
|
|
|
</el-form-item>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-form-item :label='$t("dashboard.panel.chartForm.chartName")' prop="title">
|
|
|
|
|
|
<el-input size="small" maxlength="64" show-word-limit v-model="editChart.title"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2020-10-19 18:33:18 +08:00
|
|
|
|
<div class="right-box-sub-title">{{$t('dashboard.panel.chartForm.option')}}</div>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<div style="margin-bottom: 20px;width: 100%"></div>
|
2020-03-11 18:48:05 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!-- type unit start-->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.type')" prop="type" class="half-form-item">
|
|
|
|
|
|
<el-select class="right-box-row-with-btn" @change="chartTypeChange" value-key="chartType" popper-class="chart-box-dropdown-small" v-model="editChart.type" placeholder="" size="mini">
|
|
|
|
|
|
<el-option v-for="item in chartTypeList" :key="item.id" :label="item.name" :value="item.id">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2020-06-08 14:55:09 +08:00
|
|
|
|
|
2020-10-20 20:53:21 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.unit')" prop="unit" class="half-form-item" v-show="editChart.type !='text'">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-cascader filterable placeholder="" popper-class="dc-dropdown" size="mini" style="width: 100%"
|
|
|
|
|
|
:options="unitOptions"
|
|
|
|
|
|
:props="{ expandTrigger: 'hover',emitPath:false }"
|
|
|
|
|
|
:show-all-levels="false"
|
|
|
|
|
|
v-model="editChart.unit"
|
|
|
|
|
|
@change="unitSelected"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-cascader>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--type unit end-->
|
2020-03-11 18:48:05 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.width')" prop="span" class="half-form-item">
|
2020-08-06 16:37:35 +08:00
|
|
|
|
<el-select class="right-box-row-with-btn" value-key="chartSpan" popper-class="chart-box-dropdown-mini" v-model="editChart.span" placeholder="" size="mini">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-option v-for="item in spanList" :key="item" :label="'span-' + item" :value="item">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" > span-{{item}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2020-06-08 14:55:09 +08:00
|
|
|
|
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.high')" prop="hight" class="half-form-item">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-autocomplete
|
|
|
|
|
|
v-model="editChart.height"
|
|
|
|
|
|
:fetch-suggestions="querySearch"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
popper-class="popper-z-index no-style-class"
|
|
|
|
|
|
@select="handleSelect">
|
|
|
|
|
|
<template slot-scope="{ item }">
|
|
|
|
|
|
<div class="name">{{ item }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-autocomplete>
|
|
|
|
|
|
<span class="nz-input-append">px</span>
|
|
|
|
|
|
</el-form-item>
|
2020-06-08 14:55:09 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-form-item v-if="isUrl" :label='$t("dashboard.panel.chartForm.url")' prop="param.url" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur' }">
|
|
|
|
|
|
<el-input size="small" type="textarea" maxlength="1024" show-word-limit v-model="editChart.param.url"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2020-05-26 18:29:53 +08:00
|
|
|
|
|
2020-09-29 09:45:49 +08:00
|
|
|
|
<el-form-item v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'" :label='"Null Type"' prop="nullType" class="half-form-item">
|
|
|
|
|
|
<el-select class="right-box-row-with-btn" popper-class="chart-box-dropdown-small" v-model="editChart.param.nullType" placeholder="" size="mini" @change="$forceUpdate()">
|
|
|
|
|
|
<el-option v-for="item in nullTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<el-form-item v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'" :label='$t("dashboard.panel.chartForm.threshold")' prop="param.threshold" class="half-form-item">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<el-input size="mini" type="input" v-model="editChart.param.threshold"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2020-05-26 18:29:53 +08:00
|
|
|
|
|
2020-10-21 14:15:58 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.last')" v-if="editChart.type == 'table'">
|
|
|
|
|
|
<el-switch class="exporter-switch" v-model="editChart.param.last" active-color="#ee9d3f" :active-value="1" :inactive-value="0"></el-switch>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--<el-form-item :label="$t('dashboard.panel.chartForm.sync')" v-if="showPanel.type && showPanel.type == 'model'">-->
|
|
|
|
|
|
<!--<el-switch class="exporter-switch" v-model="editChart.sync" active-color="#ee9d3f" :active-value="1" :inactive-value="0"></el-switch>-->
|
|
|
|
|
|
<!--</el-form-item>-->
|
|
|
|
|
|
|
2020-10-20 20:53:21 +08:00
|
|
|
|
<div v-if="!isUrl&&!isAlert&& editChart.type != 'text'" class="right-box-sub-title" style="margin-bottom: 20px">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('alert.config.expr')}}</span>
|
2020-10-12 13:46:31 +08:00
|
|
|
|
<span v-if="!isSingleStat" style="height: 19px;display: inline-block;line-height: 1;" class="float-right" @click="addExpression">
|
|
|
|
|
|
<span class="create-square-box">
|
|
|
|
|
|
<i style="font-size: 17px; cursor: pointer;" class="nz-icon nz-icon-create-square"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</div>
|
2020-10-20 20:53:21 +08:00
|
|
|
|
<div v-if="editChart.type == 'text'" class="right-box-sub-title" style="margin-bottom: 20px">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.content')}}</span>
|
|
|
|
|
|
</div>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<div v-if="isAlert" class="right-box-sub-title">{{$t('dashboard.panel.chartForm.alertParam.param')}}</div>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<div v-if="!isUrl" style="width: 100%"></div>
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
2020-10-14 17:13:41 +08:00
|
|
|
|
<el-row v-if="isAlert" class="element-item" style="width: calc(100% - 108px);margin-left: 108px">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<alert-chart-param ref="alertParamBox" @on-enter-complate="getAlertParam"></alert-chart-param>
|
|
|
|
|
|
</el-row>
|
2020-05-28 17:32:23 +08:00
|
|
|
|
|
2020-10-20 20:53:21 +08:00
|
|
|
|
<el-row v-if="!isUrl &&!isAlert && editChart.type != 'text'" class="element-item form-row-item" style="" v-for="index of promqlKeys.length" :key="'ele' + index">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<promql-input
|
|
|
|
|
|
:ref="'promql-'+(index-1)"
|
|
|
|
|
|
:id="promqlKeys[index-1]"
|
|
|
|
|
|
:key="promqlKeys[index-1]"
|
|
|
|
|
|
:expression-list="expressions"
|
|
|
|
|
|
:index="index-1"
|
|
|
|
|
|
:styleType="2"
|
|
|
|
|
|
:plugins="['metric-selector', 'metric-input', 'remove']"
|
|
|
|
|
|
@change="expressionChange"
|
|
|
|
|
|
@removeExpression="removeExpression"
|
2020-10-14 17:04:10 +08:00
|
|
|
|
:showRemove="false"
|
2020-07-30 18:37:04 +08:00
|
|
|
|
></promql-input>
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<template v-if="editChart.type != 'singleStat'">
|
|
|
|
|
|
<el-col style="width: 120px; padding-right: 20px; text-align: right; color: #666">
|
|
|
|
|
|
{{$t('dashboard.panel.chartForm.legend')}}
|
|
|
|
|
|
<el-popover :content="$t('dashboard.panel.chartForm.legendTip')" placement="top" width="150" trigger="hover">
|
2020-10-12 13:46:31 +08:00
|
|
|
|
<i slot="reference" class="nz-icon nz-icon-info-normal" style="font-size: 14px; -webkit-transform:scale(0.75);display:inline-block;" @mouseover="rz"></i>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</el-popover>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col style="width: calc(100% - 120px);">
|
|
|
|
|
|
<el-input v-model="legends[index-1]" type="text" size="small"></el-input>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<el-col style="width: 120px; padding-right: 20px; text-align: right; color: #666">
|
|
|
|
|
|
{{$t('dashboard.panel.chartForm.statistics')}}
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col style="width: calc(100% - 120px);">
|
|
|
|
|
|
<el-select popper-class="chart-box-dropdown-mini" v-model="statistics" placeholder="" size="small">
|
2020-08-06 16:37:35 +08:00
|
|
|
|
<el-option v-for="item in statisticsList" :key="item.value" :label="item.label" :value="item.value">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{item.label}}</span>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</template>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</el-row>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<span class="nz-icon-minus-medium nz-icon-minus-position">
|
2020-10-16 13:08:17 +08:00
|
|
|
|
<i class="nz-icon nz-icon-minus" @click="removeExpression(index - 1)"></i>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
</span>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</el-row>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
<!--value mapping start-->
|
|
|
|
|
|
<div class="right-box-sub-title" v-if="editChart.type == 'singleStat'">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.valMapping.name')}}</span>
|
|
|
|
|
|
<span class="float-right" @click="addMapping"><i style="font-size: 16px; cursor: pointer;" class="nz-icon nz-icon-create-square"></i></span>
|
|
|
|
|
|
</div>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<div style="margin-bottom: 20px; width: 100%" v-if="editChart.type == 'singleStat'"></div>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.type')" prop="span" v-if="editChart.type == 'singleStat'">
|
2020-09-17 11:17:51 +08:00
|
|
|
|
<el-radio-group v-model="editChart.param.valueMapping.type" fill="#FA901C" text-color="#FA901C" size="small" class="val-mapping-type" @change="valueMappingChange">
|
2020-09-17 10:28:09 +08:00
|
|
|
|
<el-radio-button label="value" border class="no-fill">{{$t('dashboard.panel.chartForm.valMapping.value')}}</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="range" border class="no-fill">{{$t('dashboard.panel.chartForm.valMapping.range')}}</el-radio-button>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<template v-if="editChart.type == 'singleStat'&&editChart.param.valueMapping.type == 'value'">
|
|
|
|
|
|
<template v-for="(mapping,index) in editChart.param.valueMapping.mapping">
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.value')" prop="span" class="half-form-item-other" >
|
|
|
|
|
|
<el-input size="mini" type="input" v-model="mapping.value" style="display: inline-block;;"></el-input>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
</el-form-item>
|
2020-10-21 14:15:58 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.text')" prop="span" class="half-form-item-other half-form-item-other-two">
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<el-input size="mini" type="input" v-model="mapping.text" style="display: inline-block;width:calc(100% - 40px);"></el-input>
|
2020-10-14 17:13:41 +08:00
|
|
|
|
<span @click="delMapping(index)" class="nz-icon-minus-medium" style="margin-left: 7px;padding: 6px"><i class="nz-icon nz-icon-minus" style="color: #EC7F66"></i></span>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-if="editChart.type == 'singleStat'&&editChart.param.valueMapping.type == 'range'">
|
|
|
|
|
|
<template v-for="(mapping,index) in editChart.param.valueMapping.mapping">
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<div class="half-form-item-other" style="display: inline-block;margin-left: 70px">
|
2020-09-17 10:28:09 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.from')" prop="span" class="one-third-form-item-left" >
|
|
|
|
|
|
<el-input size="mini" type="input" v-model="mapping.from"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.to')" prop="span" class="one-third-form-item-right" >
|
|
|
|
|
|
<el-input size="mini" type="input" v-model="mapping.to"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.text')" prop="span" class="half-form-item-other">
|
|
|
|
|
|
<el-input size="mini" type="input" v-model="mapping.text" style="display: inline-block;width:calc(100% - 40px);" ></el-input>
|
2020-10-14 17:13:41 +08:00
|
|
|
|
<span @click="delMapping(index)" class="nz-icon-minus-medium" style="margin-left: 7px;padding: 6px"><i class="nz-icon nz-icon-minus" style="color: #EC7F66"></i></span>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<!--value mapping end-->
|
2020-09-21 11:34:17 +08:00
|
|
|
|
<template v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'">
|
|
|
|
|
|
<div class="right-box-sub-title" >
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.legendValue')}}</span>
|
|
|
|
|
|
</div>
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<div style="margin-bottom: 20px; width: 100%" ></div>
|
2020-09-21 11:34:17 +08:00
|
|
|
|
<div style="display: flex;">
|
2020-10-14 17:04:10 +08:00
|
|
|
|
<span style="margin-left: 150px;"></span>
|
2020-09-21 11:34:17 +08:00
|
|
|
|
<template v-for="item in sortedOptionKeys">
|
|
|
|
|
|
<div style="flex: 1">
|
2020-10-12 13:46:31 +08:00
|
|
|
|
<span style="margin-right: 10px;color:rgb(102, 102, 102)">{{item.label}}</span>
|
2020-09-21 11:34:17 +08:00
|
|
|
|
<el-switch
|
|
|
|
|
|
v-model="editChart.param.legendValue[item.key]"
|
|
|
|
|
|
active-value="on"
|
|
|
|
|
|
inactive-value="off"
|
|
|
|
|
|
active-color="#ee9d3f"
|
|
|
|
|
|
@change="">
|
|
|
|
|
|
</el-switch>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2020-10-20 20:53:21 +08:00
|
|
|
|
<template v-if="editChart.type=='text'&&textShow">
|
|
|
|
|
|
<rich-text-editor ref="richTextEditor" :edit-data="editChart.param.text"></rich-text-editor>
|
|
|
|
|
|
</template>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2020-10-13 14:30:57 +08:00
|
|
|
|
<button @click="esc(false)" id="chart-box-esc" class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2020-10-21 14:15:58 +08:00
|
|
|
|
<button @click="SyncSave" id="chart-box-Sync" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" v-if="showPanel.type && showPanel.type == 'model'">
|
|
|
|
|
|
<span>{{$t('overall.SyncSave')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button @click="preview" id="chart-box-preview" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" v-else>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('overall.preview')}}</span>
|
|
|
|
|
|
</button>
|
2020-10-13 14:30:57 +08:00
|
|
|
|
<button @click="confirmAdd" id="chart-box-save" class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</div>
|
2020-03-28 09:57:51 +08:00
|
|
|
|
<!--preview -->
|
|
|
|
|
|
<chart-preview :panelId="panelId" ref="chartsPreview" ></chart-preview>
|
2020-02-21 17:32:59 +08:00
|
|
|
|
</div>
|
2020-01-03 17:17:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import bus from '../../../libs/bus';
|
|
|
|
|
|
import ChartMetric from "./chartMetric";
|
2020-03-10 22:40:45 +08:00
|
|
|
|
import chartDataFormat from '../../charts/chartDataFormat';
|
2020-03-28 09:57:51 +08:00
|
|
|
|
import chartPreview from '../../charts/chartPreview';
|
2020-07-02 20:10:16 +08:00
|
|
|
|
import {getUUID, resetZIndex} from "../../common/js/common";
|
2020-05-28 17:32:23 +08:00
|
|
|
|
import alertChartParam from "./alertChartParam";
|
2020-07-02 20:10:16 +08:00
|
|
|
|
import promqlInput from "./explore/promqlInput";
|
2020-10-13 17:06:32 +08:00
|
|
|
|
import {nzNumber} from "../../common/js/validate";
|
2020-10-20 20:53:21 +08:00
|
|
|
|
import richTextEditor from "../../charts/richTextEditor";
|
2020-07-02 20:10:16 +08:00
|
|
|
|
var rz = {
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
rz(e) {
|
|
|
|
|
|
resetZIndex(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
};
|
2020-01-03 17:17:09 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "chartBox",
|
|
|
|
|
|
props: {
|
2020-09-14 13:49:31 +08:00
|
|
|
|
boxClass:String,
|
2020-04-21 20:59:58 +08:00
|
|
|
|
panelData: Array,
|
2020-07-30 18:37:04 +08:00
|
|
|
|
showPanel: Object,
|
|
|
|
|
|
chart: Object
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-07-02 20:10:16 +08:00
|
|
|
|
mixins: [rz],
|
2020-01-03 17:17:09 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
editChart: {},
|
|
|
|
|
|
|
2020-07-31 20:57:04 +08:00
|
|
|
|
statisticsList: this.$CONSTANTS.statisticsList,
|
2020-07-30 18:37:04 +08:00
|
|
|
|
|
2020-07-02 20:10:16 +08:00
|
|
|
|
promqlCount: 1,
|
|
|
|
|
|
promqlKeys: [],
|
|
|
|
|
|
elementIds: [],
|
|
|
|
|
|
expressions: [],
|
|
|
|
|
|
legends: [],
|
2020-07-08 21:39:43 +08:00
|
|
|
|
statistics: "",
|
2020-10-21 13:39:46 +08:00
|
|
|
|
isEdit:false,
|
2020-01-06 17:10:57 +08:00
|
|
|
|
editInfo: {},
|
2020-04-14 21:46:38 +08:00
|
|
|
|
isUrl:false,
|
2020-05-07 21:02:09 +08:00
|
|
|
|
isSingleStat:false,
|
2020-05-28 17:32:23 +08:00
|
|
|
|
isAlert:false,
|
2020-01-03 17:17:09 +08:00
|
|
|
|
rules: {
|
2020-07-31 20:57:04 +08:00
|
|
|
|
panelName: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'}
|
|
|
|
|
|
],
|
2020-01-03 17:17:09 +08:00
|
|
|
|
title: [
|
2020-01-09 17:02:33 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
],
|
|
|
|
|
|
url: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
2020-10-13 17:06:32 +08:00
|
|
|
|
],
|
|
|
|
|
|
'param.threshold':[
|
|
|
|
|
|
{validator:nzNumber,trigger: 'blur'}
|
2020-02-06 18:50:40 +08:00
|
|
|
|
]
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
chartTypeList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
id:"line",
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.line.label")
|
|
|
|
|
|
},
|
2020-09-17 11:49:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
id:'stackArea',
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.stackArea.label")
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
id:"bar",
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.bar.label")
|
|
|
|
|
|
},
|
2020-09-17 11:49:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
id:'singleStat',
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.singleStat.label")
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
id:"table",
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.table.label")
|
2020-03-10 22:40:45 +08:00
|
|
|
|
},
|
2020-03-12 17:41:04 +08:00
|
|
|
|
{
|
2020-09-17 11:49:46 +08:00
|
|
|
|
id:'alertList',
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.alertList.label")
|
2020-04-14 21:46:38 +08:00
|
|
|
|
},
|
2020-10-20 20:53:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
id:'text',
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.text.label")
|
|
|
|
|
|
},
|
2020-04-14 21:46:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
id:'url',
|
|
|
|
|
|
name:this.$t("dashboard.panel.chartForm.typeVal.url.label")
|
2020-05-07 21:02:09 +08:00
|
|
|
|
},
|
2020-10-20 20:53:21 +08:00
|
|
|
|
|
2020-01-03 17:17:09 +08:00
|
|
|
|
],
|
|
|
|
|
|
elements: [1], // 指标部分 tarNum
|
|
|
|
|
|
elementTarget: [], // 本地保存数据
|
2020-05-28 17:32:23 +08:00
|
|
|
|
alertParams:{},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
spanList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
2020-09-29 09:45:49 +08:00
|
|
|
|
nullTypeList:[{
|
|
|
|
|
|
label:'connected',
|
|
|
|
|
|
value:'connected'
|
|
|
|
|
|
},{
|
|
|
|
|
|
label:'null',
|
|
|
|
|
|
value:'null'
|
|
|
|
|
|
},{
|
|
|
|
|
|
label:'zero',
|
|
|
|
|
|
value:'zero'
|
|
|
|
|
|
}],
|
2020-01-03 17:17:09 +08:00
|
|
|
|
// 是否为编辑已有信息
|
|
|
|
|
|
isedit: false,
|
2020-01-06 17:10:57 +08:00
|
|
|
|
//productId: 0,//不需要这个参数,可以删除
|
2020-09-22 11:54:25 +08:00
|
|
|
|
isInputPanel:false,
|
2020-01-03 17:17:09 +08:00
|
|
|
|
panelId: 0,
|
2020-02-06 18:50:40 +08:00
|
|
|
|
panelName: '',
|
2020-02-07 19:57:39 +08:00
|
|
|
|
selectFirstPanel: false,
|
2020-01-03 17:17:09 +08:00
|
|
|
|
metricList: [], // metric列表
|
2020-01-19 10:07:34 +08:00
|
|
|
|
metricCascaderList:[],//metric级联列表
|
2020-04-09 21:27:48 +08:00
|
|
|
|
metricAllData:new Map(),//存放所有的project-module-metric-labelValue,避免重复加载
|
2020-01-03 17:17:09 +08:00
|
|
|
|
deleteIndex: '', // 要删除的指标模块
|
|
|
|
|
|
subCount: 0, // subSave保存data到bus计数器
|
2020-02-06 18:50:40 +08:00
|
|
|
|
panel: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
},
|
2020-03-10 22:40:45 +08:00
|
|
|
|
heightSuggestions:['300','400','500','600'],
|
|
|
|
|
|
unitOptions:chartDataFormat.unitOptions(),
|
2020-10-20 20:53:21 +08:00
|
|
|
|
sortedOptionKeys:[{key:'min',label:'Min'},{key:'max',label:'Max'},{key:'avg',label:'Avg'},{key:'last',label:'Last'},{key:'total',label:'Total'}],
|
|
|
|
|
|
textShow:false
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components:{
|
2020-02-06 18:50:40 +08:00
|
|
|
|
'chart-metric':ChartMetric,
|
2020-03-28 09:57:51 +08:00
|
|
|
|
'chart-preview':chartPreview,
|
2020-07-02 20:10:16 +08:00
|
|
|
|
'alert-chart-param':alertChartParam,
|
|
|
|
|
|
'promql-input': promqlInput,
|
2020-10-20 20:53:21 +08:00
|
|
|
|
'rich-text-editor':richTextEditor
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-05-25 17:15:14 +08:00
|
|
|
|
mounted() {
|
2020-07-02 20:10:16 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.initElements();
|
2020-10-20 20:53:21 +08:00
|
|
|
|
|
2020-07-02 20:10:16 +08:00
|
|
|
|
});
|
2020-10-20 20:53:21 +08:00
|
|
|
|
|
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
|
this.textShow=true;
|
|
|
|
|
|
},300)
|
2020-05-25 17:15:14 +08:00
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
methods: {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
clickOutside() {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.esc(false);
|
2020-02-26 18:26:55 +08:00
|
|
|
|
},
|
2020-02-06 18:50:40 +08:00
|
|
|
|
toAddPanel() {
|
|
|
|
|
|
this.$refs.panelBox2.show(true);
|
|
|
|
|
|
this.panel = {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
};
|
|
|
|
|
|
this.$refs.panelBox2.setTitle(this.$t("dashboard.panel.createPanelTitle"));
|
|
|
|
|
|
},
|
2020-02-12 16:15:21 +08:00
|
|
|
|
panelReload(panelName) { //刷新panel下拉框
|
2020-02-07 19:57:39 +08:00
|
|
|
|
if (panelName) {
|
|
|
|
|
|
this.panelName = panelName;
|
|
|
|
|
|
}
|
2020-02-06 18:50:40 +08:00
|
|
|
|
this.$emit("reloadOnlyPanel");
|
|
|
|
|
|
},
|
2020-02-07 19:57:39 +08:00
|
|
|
|
deletePanel(panel) {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete("panel?ids=" + panel.id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
|
|
|
|
|
if (this.panelId == panel.id) {
|
|
|
|
|
|
this.selectFirstPanel = true;
|
|
|
|
|
|
this.$emit('reload', true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$emit('reload');
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
editPanel(panel) {
|
|
|
|
|
|
this.$refs.panelBox2.show(true);
|
|
|
|
|
|
this.panel = Object.assign({}, panel);
|
|
|
|
|
|
this.$refs.panelBox2.setTitle(this.$t("dashboard.panel.editPanelTitle"));
|
|
|
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
|
setUnit(unit) {
|
|
|
|
|
|
this.$set(this.editChart,'unit',Number.parseInt(unit))
|
2020-04-29 11:48:47 +08:00
|
|
|
|
},
|
2020-07-02 20:10:16 +08:00
|
|
|
|
expressionChange: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
addExpression() {
|
|
|
|
|
|
this.expressions.push('');
|
|
|
|
|
|
this.legends.push('');
|
|
|
|
|
|
this.promqlKeys.push(getUUID());
|
|
|
|
|
|
this.elementIds.push("");
|
|
|
|
|
|
this.promqlCount++;
|
2020-10-15 14:27:46 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.scrollbar.update();
|
|
|
|
|
|
});
|
2020-07-02 20:10:16 +08:00
|
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
|
removeExpression(index) {
|
2020-08-06 17:48:07 +08:00
|
|
|
|
if (this.promqlCount > 1) {
|
2020-07-02 20:10:16 +08:00
|
|
|
|
this.expressions.splice(index, 1);
|
|
|
|
|
|
this.legends.splice(index, 1);
|
|
|
|
|
|
this.promqlKeys.splice(index, 1);
|
|
|
|
|
|
this.elementIds.splice(index, 1);
|
|
|
|
|
|
this.promqlCount--;
|
2020-07-09 19:06:23 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.expressions.forEach((ex, index) => {
|
|
|
|
|
|
if (ex) {
|
|
|
|
|
|
this.$refs[`promql-${index}`][0].metricChange(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2020-07-02 20:10:16 +08:00
|
|
|
|
}
|
2020-10-15 14:27:46 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.scrollbar.update();
|
|
|
|
|
|
});
|
2020-07-02 20:10:16 +08:00
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
save() {
|
|
|
|
|
|
this.$refs['chartForm'].validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if (this.editChart.id) {//修改
|
|
|
|
|
|
this.$put('panel/'+this.editChart.id+'/charts').then(response => {
|
2020-01-03 17:17:09 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.esc(true);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {//新增
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.$post('panel/charts', this.editChart).then(response => {
|
2020-01-03 17:17:09 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.esc(true);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2020-10-21 12:00:30 +08:00
|
|
|
|
console.error('error submit!!');
|
2020-01-03 17:17:09 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-10-14 15:41:07 +08:00
|
|
|
|
del() {
|
|
|
|
|
|
this.$emit('delete-chart',this.editChart)
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
//----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/*关闭弹框*/
|
2020-07-30 18:37:04 +08:00
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*metric部分相关方法--begin*/
|
|
|
|
|
|
// 增加指标,tarNum
|
|
|
|
|
|
addTarget() {
|
|
|
|
|
|
this.elements.push(1);
|
2020-02-27 21:57:54 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.scrollbar.update();
|
|
|
|
|
|
});
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 删除指标,第一步, 新方法
|
|
|
|
|
|
deleteTarget(index) {
|
2020-01-07 17:12:48 +08:00
|
|
|
|
//alert('box第一步,循环所有的metric,为什么要循环??');
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.deleteIndex = index;
|
2020-02-21 17:32:59 +08:00
|
|
|
|
// alert('box第一步,循环所有的metric,循环前metric,循环次数='+this.$refs.chartTag.length);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.$refs.chartTag.forEach((item) => {
|
|
|
|
|
|
// 子组件保存内容到bus
|
|
|
|
|
|
item.subSave();
|
|
|
|
|
|
});
|
2020-02-27 21:57:54 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.scrollbar.update();
|
|
|
|
|
|
});
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
// subSave保存成功后回调,第二步
|
|
|
|
|
|
subOk() {
|
|
|
|
|
|
// 每个模块均有返回,当全部模块返回完成时,将sub计数器重置
|
2020-01-07 17:12:48 +08:00
|
|
|
|
//alert('box第二步,subCount和元素个数一样了,就从deleteIndex开始删除一个元素,this.subCount='+this.subCount);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.subCount += 1;
|
|
|
|
|
|
if (this.subCount === this.elements.length) {
|
|
|
|
|
|
this.subCount = 0;
|
|
|
|
|
|
// 保存完成,进行删除操作
|
2020-04-14 21:46:38 +08:00
|
|
|
|
//('box第二步,deleteIndex='+this.deleteIndex+'=开始删除一个元素')
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.elements.splice(this.deleteIndex, 1);
|
2020-01-07 17:12:48 +08:00
|
|
|
|
this.elementTarget.splice(this.deleteIndex, 1);//没有作用,此处是[]
|
2020-01-03 17:17:09 +08:00
|
|
|
|
bus.chartAddInfo.metricTarget.splice(this.deleteIndex, 1);
|
2020-04-09 21:27:48 +08:00
|
|
|
|
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {
|
|
|
|
|
|
item.setSubdata(index); // 将数据从bus重新赋值
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 格式化tag为字符串表达式
|
2020-01-14 21:20:30 +08:00
|
|
|
|
/*
|
2020-01-03 17:17:09 +08:00
|
|
|
|
tagsToString(metric,arr) {
|
|
|
|
|
|
let str = metric;
|
2020-01-09 17:02:33 +08:00
|
|
|
|
let sepStr = '';
|
2020-01-03 17:17:09 +08:00
|
|
|
|
arr.forEach((item, index) => {
|
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
|
str +="{"
|
|
|
|
|
|
if(item.value.length===1){
|
|
|
|
|
|
str += `${item.name}='${item.value.join('|')}'`;
|
2020-01-09 17:02:33 +08:00
|
|
|
|
sepStr = ',';
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}else if(item.value.length>1){
|
|
|
|
|
|
str += `${item.name}=~'${item.value.join('|')}'`;
|
2020-01-09 17:02:33 +08:00
|
|
|
|
sepStr = ',';
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if(item.value.length===1){
|
2020-01-09 17:02:33 +08:00
|
|
|
|
str += sepStr+`${item.name}='${item.value.join('|')}'`;
|
|
|
|
|
|
sepStr = ',';
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}else if(item.value.length>1){
|
2020-01-09 17:02:33 +08:00
|
|
|
|
str += sepStr+`${item.name}=~'${item.value.join('|')}'`;
|
|
|
|
|
|
sepStr = ',';
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-01-09 17:02:33 +08:00
|
|
|
|
if(str.indexOf('{')>-1){
|
|
|
|
|
|
str +="}";
|
|
|
|
|
|
}
|
|
|
|
|
|
if(str.endsWith('{}')){
|
|
|
|
|
|
str = str.substring(0,str.indexOf('{'));
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
return str;
|
|
|
|
|
|
},
|
2020-01-14 21:20:30 +08:00
|
|
|
|
*/
|
2020-03-12 17:30:29 +08:00
|
|
|
|
autocompleteExist(string) {
|
|
|
|
|
|
let result = false;
|
|
|
|
|
|
for (let i = 0; i < this.panelData.length; i++) {
|
|
|
|
|
|
if (this.panelData[i].name.toLowerCase() == string.toLowerCase()) {
|
|
|
|
|
|
result = this.panelData[i].id;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
// 新建图表
|
|
|
|
|
|
addCharts(params) {
|
2020-05-19 20:26:11 +08:00
|
|
|
|
let panelId;
|
2020-10-19 18:33:18 +08:00
|
|
|
|
let panel;
|
2020-03-12 17:30:29 +08:00
|
|
|
|
//先处理panel
|
2020-10-19 18:33:18 +08:00
|
|
|
|
let panelPromise=new Promise(resolve => {
|
|
|
|
|
|
if (this.panelId) {
|
|
|
|
|
|
panelId = this.panelId;
|
|
|
|
|
|
panel=this.panelData.find(p => p.id === this.panelId);
|
|
|
|
|
|
resolve()
|
2020-10-23 11:57:29 +08:00
|
|
|
|
} else if (this.showPanel && this.showPanel.type != "dashboard" && this.showPanel.type != 'explore'&& this.showPanel.type != 'endpointQuery') {
|
2020-10-19 18:33:18 +08:00
|
|
|
|
panelId = this.panelData[0].id;
|
|
|
|
|
|
panel = this.panelData[0]
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
panelId = this.autocompleteExist(this.editChart.panelName);
|
|
|
|
|
|
if (!panelId) {
|
|
|
|
|
|
this.$post('panel', {name: this.editChart.panelName}).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$emit("reloadOnlyPanel");
|
|
|
|
|
|
panel = response.data.panel
|
|
|
|
|
|
panelId=panel.id;
|
|
|
|
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if(response.msg){
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
this.$message.error(response);
|
|
|
|
|
|
}
|
2020-05-19 20:26:11 +08:00
|
|
|
|
}
|
2020-10-19 18:33:18 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-05-19 20:26:11 +08:00
|
|
|
|
}
|
2020-10-21 14:15:58 +08:00
|
|
|
|
});
|
2020-05-19 20:26:11 +08:00
|
|
|
|
|
2020-10-19 18:33:18 +08:00
|
|
|
|
panelPromise.then(()=>{
|
2020-03-12 17:30:29 +08:00
|
|
|
|
if (panelId) {
|
|
|
|
|
|
this.panelId = panelId;
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.$post('panel/' + this.panelId + '/charts', params ? params : this.editChart).then(response => {
|
2020-03-12 17:30:29 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.esc();
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.$refs.chartForm.resetFields();//清空表单
|
2020-07-31 20:57:04 +08:00
|
|
|
|
this.$emit('on-create-success', 'create', response.data, params, panel);
|
2020-03-12 17:30:29 +08:00
|
|
|
|
} else {
|
2020-10-19 18:33:18 +08:00
|
|
|
|
if (response.msg) {
|
2020-04-14 21:46:38 +08:00
|
|
|
|
this.$message.error(response.msg);
|
2020-10-19 18:33:18 +08:00
|
|
|
|
} else {
|
2020-04-14 21:46:38 +08:00
|
|
|
|
this.$message.error(response);
|
|
|
|
|
|
}
|
2020-03-12 17:30:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2020-10-19 18:33:18 +08:00
|
|
|
|
})
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 更新图表
|
|
|
|
|
|
updateCharts(params) {
|
2020-10-20 16:52:27 +08:00
|
|
|
|
let panelId=this.panelId?this.panelId:this.chart.panelId;
|
|
|
|
|
|
this.$put('panel/' + panelId + '/charts', params ? params : this.editChart).then(response2 => {
|
2020-03-12 17:30:29 +08:00
|
|
|
|
if (response2.code === 200) {
|
2020-01-06 17:10:57 +08:00
|
|
|
|
this.esc();
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-10-21 18:46:49 +08:00
|
|
|
|
// this.$refs.chartForm.resetFields();//清空表单
|
2020-03-12 17:30:29 +08:00
|
|
|
|
this.$emit('on-create-success', 'update', response2.data, params);
|
2020-01-06 17:10:57 +08:00
|
|
|
|
} else {
|
2020-04-14 21:46:38 +08:00
|
|
|
|
if(response2.msg){
|
|
|
|
|
|
this.$message.error(response2.msg);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
this.$message.error(response2);
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取每个tag组件内部校验后数据,点击生成图表时触发
|
2020-03-28 09:57:51 +08:00
|
|
|
|
getTarget(target,pointer,optType) {
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.elementTarget.push(target);
|
|
|
|
|
|
if (this.elementTarget.length === this.elements.length) {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
2020-02-21 17:32:59 +08:00
|
|
|
|
// productId: this.productId,
|
2020-01-03 17:17:09 +08:00
|
|
|
|
//panelId: this.panelId,
|
2020-07-30 18:37:04 +08:00
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit:this.editChart.unit,
|
2020-05-07 21:02:09 +08:00
|
|
|
|
param:{
|
2020-05-26 18:29:53 +08:00
|
|
|
|
|
2020-05-20 19:30:22 +08:00
|
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
|
sync: this.editChart.sync
|
2020-01-03 17:17:09 +08:00
|
|
|
|
};
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type === 'singleStat'){
|
2020-07-08 21:39:43 +08:00
|
|
|
|
params.param.statistics=this.statistics;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.statistics;
|
2020-05-26 18:29:53 +08:00
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'){
|
|
|
|
|
|
params.param.threshold=this.editChart.param.threshold;
|
2020-09-29 09:45:49 +08:00
|
|
|
|
params.param.nullType=this.editChart.param.nullType;
|
2020-07-08 21:39:43 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.threshold;
|
2020-05-26 18:29:53 +08:00
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
//生成指标数组
|
|
|
|
|
|
const elements = [];
|
|
|
|
|
|
this.elementTarget.forEach((elem,index) => {
|
|
|
|
|
|
if(elem.type==='normal'){
|
2020-01-14 21:20:30 +08:00
|
|
|
|
const metricStr = bus.tagsToString(elem.metric,elem.selectedTagList);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
elements.push({
|
|
|
|
|
|
//id:index+1,
|
|
|
|
|
|
//metric: elem.metric,//指标名称
|
|
|
|
|
|
expression: metricStr,//指标对应Label及Value组成的表达式字符串
|
|
|
|
|
|
type:elem.type,//指标类型
|
2020-03-04 09:58:19 +08:00
|
|
|
|
legend:elem.legend,//配置的legend
|
2020-01-03 17:17:09 +08:00
|
|
|
|
});
|
|
|
|
|
|
}else if(elem.type==='expert'){
|
|
|
|
|
|
elements.push({
|
|
|
|
|
|
//id:index+1,
|
|
|
|
|
|
//metric: elem.metric,//指标名称
|
|
|
|
|
|
expression: elem.expression,//指标对应Label及Value组成的表达式字符串
|
|
|
|
|
|
type:elem.type,//指标类型
|
2020-03-04 09:58:19 +08:00
|
|
|
|
legend:elem.legend,//配置的legend
|
2020-01-03 17:17:09 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
params.elements = elements;
|
|
|
|
|
|
if (valid) {
|
2020-03-28 09:57:51 +08:00
|
|
|
|
if(optType==='preview') {
|
|
|
|
|
|
if (this.isedit) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
params.id = this.editChart.id;
|
2020-03-28 09:57:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$refs.chartsPreview.show(params);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if (this.isedit) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
params.id = this.editChart.id;
|
2020-03-28 09:57:51 +08:00
|
|
|
|
this.updateCharts(params);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params);
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-05-28 17:32:23 +08:00
|
|
|
|
getAlertParam:function(param,opType){
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit:this.editChart.unit,
|
2020-05-28 17:32:23 +08:00
|
|
|
|
param:param,
|
2020-08-06 16:37:35 +08:00
|
|
|
|
sync: this.editChart.sync,
|
2020-05-28 17:32:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
if(opType==='preview') {
|
|
|
|
|
|
if (this.isedit) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
params.id = this.editChart.id;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$refs.chartsPreview.show(params);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if (this.isedit) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
params.id = this.editChart.id;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.updateCharts(params);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2020-10-21 14:15:58 +08:00
|
|
|
|
SyncSave(){
|
|
|
|
|
|
this.editChart.sync=1;
|
|
|
|
|
|
this.confirmAdd();
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
confirmAdd() {
|
|
|
|
|
|
this.elementTarget = []; // 初始化清空参数
|
2020-10-20 20:53:21 +08:00
|
|
|
|
if(this.editChart.type!=='url'&&this.editChart.type != 'text'){
|
2020-07-30 18:37:04 +08:00
|
|
|
|
/*if(this.editChart.type == 'alertList'){
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.$refs.alertParamBox.saveParam();
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {//循环指标列表
|
|
|
|
|
|
// 触发每个tag组件内部进行校验
|
|
|
|
|
|
item.saveTarget(index);
|
|
|
|
|
|
});
|
2020-07-02 20:10:16 +08:00
|
|
|
|
}*/
|
2020-08-06 16:37:35 +08:00
|
|
|
|
if(this.editChart.type == 'alertList'){
|
|
|
|
|
|
this.$refs.alertParamBox.saveParam();
|
|
|
|
|
|
return ;
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type == 'singleStat'){
|
|
|
|
|
|
this.$set(this.editChart.param, "statistics", this.statistics);
|
2020-07-08 21:39:43 +08:00
|
|
|
|
} else {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
delete this.editChart.param.statistics;
|
2020-07-08 21:39:43 +08:00
|
|
|
|
}
|
2020-07-02 20:10:16 +08:00
|
|
|
|
if (this.expressions[0]) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.elements = [];
|
2020-07-02 20:10:16 +08:00
|
|
|
|
this.expressions.forEach((expr, i) => {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.elements.push({id: this.elementIds[i], expression: expr, type: "expert", legend: this.legends[i]});
|
2020-07-02 20:10:16 +08:00
|
|
|
|
});
|
2020-05-28 17:32:23 +08:00
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if (this.editChart.id) {
|
2020-07-03 16:27:04 +08:00
|
|
|
|
this.updateCharts();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts();
|
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}else {
|
2020-10-20 20:53:21 +08:00
|
|
|
|
if(this.editChart.type == 'url'){
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit:this.editChart.unit,
|
|
|
|
|
|
param:{
|
|
|
|
|
|
url:this.editChart.param.url,
|
|
|
|
|
|
},
|
|
|
|
|
|
sync: this.editChart.sync
|
|
|
|
|
|
};
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
2020-10-20 20:53:21 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
params.elements = [];
|
|
|
|
|
|
if (this.isedit) {
|
|
|
|
|
|
params.id = this.editChart.id;
|
|
|
|
|
|
this.updateCharts(params);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params);
|
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
|
});
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
2020-10-21 12:00:30 +08:00
|
|
|
|
let text=this.$refs.richTextEditor.getContent();
|
|
|
|
|
|
if(!text){
|
|
|
|
|
|
valid=false;
|
|
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
param:{
|
2020-10-21 12:00:30 +08:00
|
|
|
|
text:text
|
2020-10-20 20:53:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
sync: this.editChart.sync
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
params.elements = [];
|
|
|
|
|
|
if (this.isedit) {
|
|
|
|
|
|
params.id = this.editChart.id;
|
|
|
|
|
|
this.updateCharts(params);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 获取metric列表
|
|
|
|
|
|
getSuggestMetric() {
|
2020-03-31 21:56:51 +08:00
|
|
|
|
//this.$get('/prom/api/v1/label/__name__/values').then(response => {
|
|
|
|
|
|
this.$get('/module?pageSize=-1').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.metricList = response.data.list;
|
2020-01-19 10:07:34 +08:00
|
|
|
|
const cascaderMap = new Map();
|
|
|
|
|
|
this.metricList.forEach((item,index) => {
|
2020-03-31 21:56:51 +08:00
|
|
|
|
let projectName = item.project.name;
|
|
|
|
|
|
let moduleName = item.name;
|
2020-01-19 10:07:34 +08:00
|
|
|
|
const childOption = {
|
2020-03-31 21:56:51 +08:00
|
|
|
|
value: moduleName,
|
|
|
|
|
|
label: moduleName,
|
|
|
|
|
|
children:[],
|
2020-01-19 10:07:34 +08:00
|
|
|
|
};
|
2020-03-31 21:56:51 +08:00
|
|
|
|
if(cascaderMap.has(projectName)){
|
|
|
|
|
|
cascaderMap.get(projectName).push(childOption);
|
2020-01-19 10:07:34 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
let childArr = [];
|
|
|
|
|
|
childArr.push(childOption);
|
2020-03-31 21:56:51 +08:00
|
|
|
|
cascaderMap.set(projectName,childArr);
|
2020-01-19 10:07:34 +08:00
|
|
|
|
}
|
2020-04-09 21:27:48 +08:00
|
|
|
|
|
|
|
|
|
|
//缓存全局数据
|
|
|
|
|
|
const moduleItem = {
|
|
|
|
|
|
name:moduleName,
|
|
|
|
|
|
metricMap:new Map()
|
|
|
|
|
|
};
|
|
|
|
|
|
if(this.metricAllData.has(projectName)){
|
|
|
|
|
|
let moduleGroup = this.metricAllData.get(projectName);
|
|
|
|
|
|
this.metricAllData.get(projectName).push(moduleItem);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
let moduleList = [];
|
|
|
|
|
|
moduleList.push(moduleItem);
|
|
|
|
|
|
this.metricAllData.set(projectName,moduleList);
|
|
|
|
|
|
}
|
2020-01-19 10:07:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
let metricCascaderArr = [];
|
|
|
|
|
|
cascaderMap.forEach(function(value,index){
|
|
|
|
|
|
const option = {
|
2020-02-21 17:32:59 +08:00
|
|
|
|
value: index+"_par",
|
2020-01-19 10:07:34 +08:00
|
|
|
|
label: index,
|
|
|
|
|
|
children:value,
|
|
|
|
|
|
};
|
|
|
|
|
|
metricCascaderArr.push(option);
|
|
|
|
|
|
});
|
2020-04-09 21:27:48 +08:00
|
|
|
|
|
2020-01-19 10:07:34 +08:00
|
|
|
|
this.metricCascaderList = metricCascaderArr;
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
this.metricList = [];
|
2020-01-19 10:07:34 +08:00
|
|
|
|
this.metricCascaderList = [];
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 创建打开
|
2020-02-07 19:57:39 +08:00
|
|
|
|
createData(panelId, elementInfo) {
|
|
|
|
|
|
if (panelId == -1) {
|
2020-07-31 20:57:04 +08:00
|
|
|
|
let p = this.panelData[0];
|
|
|
|
|
|
this.editChart.panelName = p.name;
|
2020-02-07 19:57:39 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.panelId = panelId;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (elementInfo) {
|
2020-02-10 16:50:34 +08:00
|
|
|
|
if (elementInfo.elements.length > 1) {
|
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.elements = [];
|
|
|
|
|
|
elementInfo.elements.forEach((item, index) => {
|
|
|
|
|
|
this.elements.push(index);
|
|
|
|
|
|
});
|
|
|
|
|
|
let dSet = this.$refs.chartTag;
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
dSet.forEach((item, index) => {
|
|
|
|
|
|
item.setMdata(elementInfo.elements[index]);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.chartTag[0].setMdata(elementInfo.elements[0]);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-02-07 19:57:39 +08:00
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.isedit = false;
|
|
|
|
|
|
this.initInfo(); // 初始化图表信息
|
2020-07-30 18:37:04 +08:00
|
|
|
|
//this.editChartModal = true;//????控制弹出框显示和隐藏的,不需要了
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.initOpen(); // 获取metric, productId数据
|
|
|
|
|
|
},
|
2020-05-07 21:02:09 +08:00
|
|
|
|
setIsUrl(){
|
|
|
|
|
|
this.isUrl = true;
|
|
|
|
|
|
this.isSingleStat = false;
|
2020-08-05 20:58:24 +08:00
|
|
|
|
this.isAlert = false;
|
2020-05-07 21:02:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
setIsSingleStat(){
|
|
|
|
|
|
this.isUrl = false;
|
|
|
|
|
|
this.isSingleStat = true;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.isAlert=false;
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsAlertList(){
|
2020-08-06 11:29:11 +08:00
|
|
|
|
this.isAlert = true;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.isUrl = false;
|
|
|
|
|
|
this.isSingleStat = false;
|
2020-05-07 21:02:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
setIsOtherChart(){
|
|
|
|
|
|
this.isSingleStat = false;
|
|
|
|
|
|
this.isUrl = false;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.isAlert=false;
|
2020-05-07 21:02:09 +08:00
|
|
|
|
},
|
2020-01-06 17:10:57 +08:00
|
|
|
|
// 编辑chart时使用, set_tdata
|
|
|
|
|
|
editData(data, panelId) {
|
2020-07-08 21:39:43 +08:00
|
|
|
|
if (!panelId) {
|
|
|
|
|
|
this.panelId = 0;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.panelId = panelId;
|
|
|
|
|
|
let temp = this.panelData.filter((item) => {
|
|
|
|
|
|
return item.id == panelId;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-01-06 17:10:57 +08:00
|
|
|
|
this.isedit = true;
|
|
|
|
|
|
this.editInfo = data;
|
|
|
|
|
|
// 图表信息获取
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.id = data.id;
|
|
|
|
|
|
this.editChart.title = data.title;
|
|
|
|
|
|
this.editChart.span = data.span;
|
|
|
|
|
|
this.editChart.height = data.height+'';
|
|
|
|
|
|
this.editChart.type = data.type;
|
|
|
|
|
|
this.editChart.unit=data.unit;
|
|
|
|
|
|
this.editChart.elements = data.elements;
|
|
|
|
|
|
if(this.editChart.type==='url'){
|
|
|
|
|
|
this.editChart.param.url = data.param.url;
|
2020-05-07 21:02:09 +08:00
|
|
|
|
this.setIsUrl();
|
2020-07-02 20:10:16 +08:00
|
|
|
|
//this.elements = [1];
|
2020-08-06 18:13:40 +08:00
|
|
|
|
}else if(this.editChart.type==='alertList'){
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.param = data.param;
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.setIsAlertList();
|
2020-08-06 18:13:40 +08:00
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
this.$refs.alertParamBox.setData(data)
|
|
|
|
|
|
})
|
2020-07-02 20:10:16 +08:00
|
|
|
|
//this.elements=[1];
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}else{
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if((this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'||this.editChart.type==='singleStat')&&data.param){
|
|
|
|
|
|
this.editChart.param.threshold=data.param.threshold;
|
|
|
|
|
|
this.editChart.param.statistics = this.statistics = data.param.statistics;
|
2020-05-29 15:21:04 +08:00
|
|
|
|
}else{
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.param.threshold='';
|
2020-05-26 18:29:53 +08:00
|
|
|
|
}
|
2020-09-29 09:45:49 +08:00
|
|
|
|
if((this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea')&&data.param){
|
|
|
|
|
|
this.editChart.param.nullType=data.param.nullType;
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
this.setIsOtherChart();
|
2020-04-14 21:46:38 +08:00
|
|
|
|
//this.getSuggestMetric();//获得指标列表
|
|
|
|
|
|
// 指标
|
2020-07-02 20:10:16 +08:00
|
|
|
|
/*this.elements = [];
|
2020-04-14 21:46:38 +08:00
|
|
|
|
bus.chartAddInfo.metricTarget = [];
|
|
|
|
|
|
data.elements.forEach((item, index) => {
|
|
|
|
|
|
this.elements.push(index);
|
2020-01-06 17:10:57 +08:00
|
|
|
|
});
|
2020-04-14 21:46:38 +08:00
|
|
|
|
this.$nextTick(() => {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type==='alertList'){
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.setIsAlertList();
|
|
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
this.$refs.alertParamBox.setData(data);
|
|
|
|
|
|
})
|
|
|
|
|
|
}else{
|
|
|
|
|
|
const cSet = this.$refs.chartTag;
|
|
|
|
|
|
// 派发charttag数据
|
|
|
|
|
|
cSet.forEach((item, index) => {
|
|
|
|
|
|
item.setMdata(data.elements[index]);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-07-02 20:10:16 +08:00
|
|
|
|
});*/
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
2020-01-06 17:10:57 +08:00
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
|
|
|
|
|
// 初始化信息
|
|
|
|
|
|
initInfo() {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.title = '';
|
|
|
|
|
|
this.editChart.type = 'line';
|
|
|
|
|
|
this.editChart.span = 12;
|
|
|
|
|
|
this.editChart.height = 400+'';
|
|
|
|
|
|
this.editChart.unit=2;
|
2020-09-17 10:28:09 +08:00
|
|
|
|
let param = {};
|
2020-10-14 15:41:07 +08:00
|
|
|
|
param.last=0;
|
2020-09-17 10:28:09 +08:00
|
|
|
|
param.url='';
|
|
|
|
|
|
param.threshold='';
|
|
|
|
|
|
param.valueMapping={type:'text',mapping:[{value:'',text:''}]};
|
2020-09-29 09:45:49 +08:00
|
|
|
|
param.legendValue={min:'off',max:'off',avg:'off',last:'off',total:'off'};
|
|
|
|
|
|
param.nullType='connected';
|
2020-09-17 10:28:09 +08:00
|
|
|
|
this.$set(this.editChart, "param", param);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
this.elements = [1];
|
|
|
|
|
|
this.elementTarget = [];
|
|
|
|
|
|
bus.chartAddInfo.metricTarget = [];
|
2020-06-03 14:48:58 +08:00
|
|
|
|
this.setIsOtherChart();
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 创建时打开,用于清空chart-tag数据
|
|
|
|
|
|
initOpen() {
|
2020-02-07 19:57:39 +08:00
|
|
|
|
//bus.$emit('clear_history');
|
2020-01-03 17:17:09 +08:00
|
|
|
|
/* 项目不需要produce
|
|
|
|
|
|
if (this.$route.params.productId) {
|
|
|
|
|
|
this.productId = parseInt(this.$route.params.productId, 10);
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
2020-04-09 21:27:48 +08:00
|
|
|
|
//this.getSuggestMetric();
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*metric部分相关方法--end*/
|
2020-02-17 18:41:38 +08:00
|
|
|
|
querySearch(queryString, cb) {
|
2020-04-13 15:28:02 +08:00
|
|
|
|
let suggestions = this.heightSuggestions;
|
|
|
|
|
|
let results=queryString&&(suggestions.includes(queryString)||suggestions.filter(this.createFilter(queryString)).length>0)?suggestions:[];
|
2020-02-17 18:41:38 +08:00
|
|
|
|
cb(results);
|
|
|
|
|
|
},
|
|
|
|
|
|
createFilter(queryString) {
|
|
|
|
|
|
return (suggestion) => {
|
|
|
|
|
|
return (suggestion.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
handleSelect:function(item){
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.height=item;
|
2020-03-10 22:40:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
unitSelected:function(value){
|
2020-07-30 18:37:04 +08:00
|
|
|
|
//this.editChart.unit=value[value.length-1];
|
2020-03-12 17:30:29 +08:00
|
|
|
|
},
|
2020-04-14 21:46:38 +08:00
|
|
|
|
chartTypeChange(){
|
2020-07-30 18:37:04 +08:00
|
|
|
|
let chartType = this.editChart.type;
|
|
|
|
|
|
this.editChart.param.url='';
|
2020-04-14 21:46:38 +08:00
|
|
|
|
if(chartType==='url'){
|
2020-05-07 21:02:09 +08:00
|
|
|
|
this.setIsUrl();
|
|
|
|
|
|
/*if(this.$refs.chartTag){
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {
|
|
|
|
|
|
item.setNotSingleStat();
|
|
|
|
|
|
});
|
|
|
|
|
|
}*/
|
2020-05-28 17:32:23 +08:00
|
|
|
|
}else if(chartType === 'alertList'){
|
|
|
|
|
|
this.setIsAlertList();
|
2020-07-08 21:39:43 +08:00
|
|
|
|
}else if(chartType === 'singleStat'){
|
|
|
|
|
|
this.setIsSingleStat();
|
|
|
|
|
|
this.resetElements();
|
2020-09-17 11:17:51 +08:00
|
|
|
|
this.statistics='',
|
|
|
|
|
|
this.editChart.param={
|
|
|
|
|
|
statistics:'',
|
|
|
|
|
|
valueMapping:{
|
|
|
|
|
|
type:'value',
|
|
|
|
|
|
mapping:[{text:'',value:''}]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}else {
|
2020-05-07 21:02:09 +08:00
|
|
|
|
this.setIsOtherChart();
|
2020-05-26 18:29:53 +08:00
|
|
|
|
if(chartType === 'bar'||chartType === 'line'||chartType === 'stackArea'){
|
2020-09-29 09:45:49 +08:00
|
|
|
|
this.editChart.param={nullType:this.editChart.param.nullType,threshold:'',legendValue:{min:'off',max:'off',avg:'off',last:'off',total:'off'}}
|
2020-10-14 15:41:07 +08:00
|
|
|
|
}else if(chartType == 'table'){
|
2020-10-21 16:51:17 +08:00
|
|
|
|
this.$set(this.editChart.param,'last',0)
|
2020-05-26 18:29:53 +08:00
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
/*if(this.$refs.chartTag){
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {
|
|
|
|
|
|
item.setNotSingleStat();
|
|
|
|
|
|
});
|
|
|
|
|
|
}*/
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-08 21:39:43 +08:00
|
|
|
|
resetElements() {
|
|
|
|
|
|
this.promqlKeys = [""];
|
|
|
|
|
|
this.expressions = [""];
|
|
|
|
|
|
this.legends = [];
|
|
|
|
|
|
this.elementIds = [];
|
|
|
|
|
|
},
|
2020-09-22 11:54:25 +08:00
|
|
|
|
inputPanel:function(){
|
|
|
|
|
|
this.isInputPanel=true;
|
|
|
|
|
|
},
|
2020-03-12 17:30:29 +08:00
|
|
|
|
/*panel搜索建议*/
|
|
|
|
|
|
panelSuggestion(queryString, callback) {
|
2020-09-22 11:54:25 +08:00
|
|
|
|
if(!this.isInputPanel){
|
|
|
|
|
|
callback(JSON.parse(JSON.stringify(this.panelData)));
|
|
|
|
|
|
}else{
|
|
|
|
|
|
let data = [];
|
|
|
|
|
|
if (!queryString) {
|
|
|
|
|
|
data = this.panelData;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for (let i = 0; i < this.panelData.length; i++) {
|
|
|
|
|
|
if (this.panelData[i].name.toLowerCase().indexOf(queryString.toLowerCase()) != -1) {
|
|
|
|
|
|
data.push(this.panelData[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
callback(data);
|
|
|
|
|
|
}
|
2020-03-12 17:30:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2020-03-28 09:57:51 +08:00
|
|
|
|
//preview -start
|
|
|
|
|
|
//预览图表
|
|
|
|
|
|
preview(){
|
|
|
|
|
|
//验证图表数据是否合法??,合法了再显示预览窗口
|
|
|
|
|
|
this.elementTarget = []; // 初始化清空参数
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.alertParams={};
|
2020-10-20 20:53:21 +08:00
|
|
|
|
if(this.editChart.type!=='url'&&this.editChart.type!=='text'){
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type == 'alertList'){
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.$refs.alertParamBox.saveParam('preview');
|
|
|
|
|
|
}else{
|
2020-07-09 19:06:23 +08:00
|
|
|
|
/*this.$refs.chartTag.forEach((item, index) => {//循环指标列表
|
2020-05-28 17:32:23 +08:00
|
|
|
|
// 触发每个tag组件内部进行校验
|
|
|
|
|
|
item.saveTarget(index,'preview');
|
2020-07-09 19:06:23 +08:00
|
|
|
|
});*/
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
// productId: this.productId,
|
|
|
|
|
|
//panelId: this.panelId,
|
2020-07-30 18:37:04 +08:00
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit:this.editChart.unit,
|
2020-07-09 19:06:23 +08:00
|
|
|
|
param:{
|
|
|
|
|
|
|
|
|
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
|
sync: this.editChart.sync
|
2020-07-09 19:06:23 +08:00
|
|
|
|
};
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type === 'singleStat'){
|
2020-07-09 19:06:23 +08:00
|
|
|
|
params.param.statistics=this.statistics;
|
2020-09-18 10:53:09 +08:00
|
|
|
|
params.param.valueMapping=this.editChart.param.valueMapping;
|
2020-07-09 19:06:23 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.statistics;
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if(this.editChart.type==='line'||this.editChart.type==='bar'||this.editChart.type==='stackArea'){
|
|
|
|
|
|
params.param.threshold=this.editChart.param.threshold;
|
2020-09-29 09:45:49 +08:00
|
|
|
|
params.param.nullType=this.editChart.param.nullType;
|
2020-09-18 10:53:09 +08:00
|
|
|
|
params.param.legendValue=this.editChart.param.legendValue;
|
2020-07-09 19:06:23 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.threshold;
|
2020-09-29 09:45:49 +08:00
|
|
|
|
delete params.param.nullType;
|
2020-07-09 19:06:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
//生成指标数组
|
|
|
|
|
|
const elements = [];
|
|
|
|
|
|
this.expressions.forEach((expr, index) => {
|
|
|
|
|
|
elements.push({
|
|
|
|
|
|
expression: expr,
|
|
|
|
|
|
type: 'expert',
|
|
|
|
|
|
legend: this.legends[index],
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
params.elements = elements;
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
this.$refs.chartsPreview.show(params);
|
|
|
|
|
|
}
|
2020-05-28 17:32:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
|
}else if(this.editChart.type=='url'){
|
2020-04-14 21:46:38 +08:00
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit:this.editChart.unit,
|
2020-04-14 21:46:38 +08:00
|
|
|
|
param:{
|
2020-07-30 18:37:04 +08:00
|
|
|
|
url:this.editChart.param.url,
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-10-20 20:53:21 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (this.isedit) {
|
|
|
|
|
|
params.id = this.editChart.id;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.chartsPreview.show(params);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
2020-10-21 12:00:30 +08:00
|
|
|
|
let text=this.$refs.richTextEditor.getContent();
|
|
|
|
|
|
if(!text){
|
|
|
|
|
|
valid=false;
|
|
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
title: this.editChart.title,//this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit:this.editChart.unit,
|
|
|
|
|
|
param:{
|
2020-10-21 12:00:30 +08:00
|
|
|
|
text:text
|
2020-10-20 20:53:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-04-14 21:46:38 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (this.isedit) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
params.id = this.editChart.id;
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$refs.chartsPreview.show(params);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-03-28 09:57:51 +08:00
|
|
|
|
},
|
|
|
|
|
|
//preview--end
|
2020-07-02 20:10:16 +08:00
|
|
|
|
initElements() {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if (!this.editChart.elements || this.editChart.elements.length == 0) {
|
|
|
|
|
|
this.editChart.elements = [{expression: "", legend: "", type: "expert", id: ""}];
|
2020-07-02 20:10:16 +08:00
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart.elements.forEach(element => {
|
2020-08-06 17:48:07 +08:00
|
|
|
|
if(element&&element!=''){
|
|
|
|
|
|
this.promqlKeys.push(getUUID());
|
|
|
|
|
|
this.expressions.push(element.expression);
|
|
|
|
|
|
this.legends.push(element.legend);
|
|
|
|
|
|
this.elementIds.push(element.id);
|
|
|
|
|
|
}
|
2020-07-02 20:10:16 +08:00
|
|
|
|
});
|
2020-08-06 17:48:07 +08:00
|
|
|
|
this.promqlCount=this.editChart.elements.length;
|
2020-07-02 20:10:16 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.expressions.forEach((ex, index) => {
|
|
|
|
|
|
if (ex) {
|
|
|
|
|
|
this.$refs[`promql-${index}`][0].metricChange(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-09-17 10:28:09 +08:00
|
|
|
|
valueMappingChange:function(value){
|
|
|
|
|
|
if(this.editChart.param.valueMapping.type == 'value'){
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping =[{text:'',value:''}];
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping =[{from:'',to:'',text:''}];
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
addMapping:function(){
|
|
|
|
|
|
if(this.editChart.param.valueMapping.type == 'value'){
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping .push({text:'',value:''});
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping .push({from:'',to:'',text:''});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
delMapping:function(index){
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping.splice(index,1)
|
2020-10-20 20:53:21 +08:00
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
created() {
|
2020-04-09 21:27:48 +08:00
|
|
|
|
this.getSuggestMetric();
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
chart: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(n) {
|
2020-10-21 13:39:46 +08:00
|
|
|
|
console.log(n);
|
|
|
|
|
|
if(n.title){
|
|
|
|
|
|
this.isEdit=true;
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.editChart = JSON.parse(JSON.stringify(n));
|
2020-09-29 09:45:49 +08:00
|
|
|
|
if(!n.param.nullType){
|
|
|
|
|
|
this.editChart.param.nullType='connected';
|
|
|
|
|
|
}
|
2020-08-05 20:58:24 +08:00
|
|
|
|
if (n.type === 'url') {
|
|
|
|
|
|
this.setIsUrl();
|
|
|
|
|
|
} else if(n.type === 'alertList'){
|
|
|
|
|
|
this.setIsAlertList();
|
|
|
|
|
|
} else if(n.type === 'singleStat'){
|
2020-09-17 11:49:46 +08:00
|
|
|
|
n.param&&!n.param.valueMapping&&this.$set(this.editChart.param,'valueMapping',{type:'value',mapping:[{text:'',value:''}]})
|
2020-08-05 20:58:24 +08:00
|
|
|
|
this.setIsSingleStat();
|
2020-10-14 15:41:07 +08:00
|
|
|
|
} else if(n.type === 'table'){
|
|
|
|
|
|
n.param.last?this.$set(this.editChart.param,'last',n.param.last):this.$set(this.editChart.param,'last',0)
|
|
|
|
|
|
}else {
|
2020-08-05 20:58:24 +08:00
|
|
|
|
this.setIsOtherChart();
|
2020-09-21 14:08:48 +08:00
|
|
|
|
n.param&&!n.param.legendValue&&this.$set(this.editChart.param,'legendValue',{min:'off',max:'off',avg:'off',last:'off',total:'off'})
|
2020-08-05 20:58:24 +08:00
|
|
|
|
}
|
2020-07-31 20:57:04 +08:00
|
|
|
|
this.$set(this.editChart, "panelName", this.showPanel.name);
|
2020-08-05 20:58:24 +08:00
|
|
|
|
if (this.showPanel.id) {
|
|
|
|
|
|
this.panelId = this.showPanel.id;
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
if (n.id) {
|
|
|
|
|
|
this.editData(this.editChart, this.showPanel.id);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.createData(this.showPanel.id);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-31 20:57:04 +08:00
|
|
|
|
editChart: {
|
|
|
|
|
|
deep: true,
|
2020-08-05 20:58:24 +08:00
|
|
|
|
immediate: true,
|
2020-07-31 20:57:04 +08:00
|
|
|
|
handler(n) {
|
|
|
|
|
|
let panel = this.panelData.find(p => {
|
|
|
|
|
|
return p.name == n.panelName;
|
|
|
|
|
|
});
|
2020-10-19 18:33:18 +08:00
|
|
|
|
|
|
|
|
|
|
if(panel){
|
|
|
|
|
|
this.panelId = panel.id;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.panelId = null;
|
|
|
|
|
|
}
|
2020-07-31 20:57:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
/*panelData: {
|
2020-02-06 18:50:40 +08:00
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(n, o) {
|
2020-05-25 17:15:14 +08:00
|
|
|
|
if(this.showPanel){
|
|
|
|
|
|
if (!this.showPanel.type) {
|
|
|
|
|
|
if (this.selectFirstPanel) {
|
|
|
|
|
|
this.selectFirstPanel = false;
|
|
|
|
|
|
this.panelId = n[0].id;
|
|
|
|
|
|
} else if (this.panelName) {
|
|
|
|
|
|
for (let i = 0; i < n.length; i++) {
|
|
|
|
|
|
if (n[i].name == this.panelName) {
|
|
|
|
|
|
this.panelId = n[i].id;
|
|
|
|
|
|
}
|
2020-05-19 20:26:11 +08:00
|
|
|
|
}
|
2020-02-06 18:50:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-07-30 18:37:04 +08:00
|
|
|
|
}*/
|
2020-04-09 21:27:48 +08:00
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
|
if(this.$refs.chartTag){
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {//循环指标列表
|
|
|
|
|
|
item.clearSelectedTagList();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
this.isUrl = false;
|
2020-04-09 21:27:48 +08:00
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2020-02-17 18:41:38 +08:00
|
|
|
|
<style>
|
|
|
|
|
|
.popper-z-index{
|
|
|
|
|
|
z-index: 99999999 !important;
|
|
|
|
|
|
}
|
2020-03-12 17:30:29 +08:00
|
|
|
|
.right-box-add-chart .el-autocomplete {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
.chart-box-autocomplete {
|
|
|
|
|
|
z-index: 3000 !important;
|
|
|
|
|
|
}
|
2020-09-17 10:28:09 +08:00
|
|
|
|
.val-mapping-type .no-fill span{
|
|
|
|
|
|
background-color: unset !important;
|
|
|
|
|
|
}
|
2020-02-17 18:41:38 +08:00
|
|
|
|
</style>
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|