2021-03-19 18:52:19 +08:00
|
|
|
|
<template>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div v-clickoutside="{obj:editChart, func:clickOutside}" :class="boxClass" class="right-box right-box-chart">
|
2021-05-17 20:31:32 +08:00
|
|
|
|
<transition v-if="from !== 'chartTemp'" name="right-box">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<panel-box v-if="!showPanel.type" ref="panelBox2" :panel="panel" @reload="panelReload"></panel-box>
|
|
|
|
|
|
</transition>
|
2020-02-06 18:50:40 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div class="right-box__header">
|
2021-05-17 20:31:32 +08:00
|
|
|
|
<div class="header__title" v-if="from !== 'chartTemp'">{{editChart.id ? $t("dashboard.panel.editChartTitle") : $t("dashboard.panel.createChartTitle")}}</div>
|
|
|
|
|
|
<div class="header__title" v-if="from === 'chartTemp'">{{editChart.id ? $t("dashboard.panel.editChartTempTitle") : $t("dashboard.panel.createChartTempTitle")}}</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div class="header__operation">
|
|
|
|
|
|
<span v-cancel="{obj: editChart, func: clickOutside}"><i class="nz-icon nz-icon-close"></i></span>
|
2021-04-23 18:10:25 +08:00
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</div>
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div class="right-box__container">
|
|
|
|
|
|
<div class="container__form">
|
|
|
|
|
|
<el-form ref="chartForm" :model="editChart" :rules="rules" label-position= "top" label-width="120px">
|
2021-10-29 18:31:52 +08:00
|
|
|
|
<el-form-item :label='$t("dashboard.panel.chartForm.name")' prop="title">
|
2021-04-08 17:49:07 +08:00
|
|
|
|
<el-input maxlength="64" show-word-limit size="small" v-model="editChart.name" id="chart-box-title"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2021-05-21 15:06:58 +08:00
|
|
|
|
<el-form-item v-if="showPanel.type !== fromRoute.project && showPanel.type !== fromRoute.asset && showPanel.type !== fromRoute.endpoint && showPanel.type !== fromRoute.model && from!=='chartTemp'" :label="$t('dashboard.panel.title')" prop="panelName">
|
2021-10-20 09:40:52 +08:00
|
|
|
|
<select-panel ref="selectPanel" :disabled="showPanel.type === 'dashboard'" :filter-panel="filterPanel" :chart-box="true" :panel-lock="true" :panelData="panelData" :placement="'bottom-start'" @selectPanel="selectPanel">
|
2021-01-12 20:39:59 +08:00
|
|
|
|
<template v-slot:header>
|
|
|
|
|
|
<div class="panel-select-header">
|
2021-10-20 09:40:52 +08:00
|
|
|
|
<el-input id="chart-box-panelname" v-model="filterPanel" :placeholder="$t('overall.search')" clearable size="small" style="width: 596px"></el-input>
|
2021-01-12 20:39:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:trigger>
|
2021-04-08 17:49:07 +08:00
|
|
|
|
<el-input placeholder="" readonly="readonly" size="small" v-model="panelName" :disabled="showPanel.type==='dashboard'"></el-input>
|
2021-01-12 20:39:59 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</select-panel>
|
2020-12-04 15:24:59 +08:00
|
|
|
|
</el-form-item>
|
2020-06-08 14:55:09 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div class="form-items--half-width-group">
|
|
|
|
|
|
<!-- type -->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.type')" class="form-item--half-width" prop="type">
|
2021-09-27 10:25:19 +08:00
|
|
|
|
<el-select id="chart-box-type" v-model="editChart.type" :disabled="editChart.type==='group'&&editChart.children&&editChart.children.length" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="chartType" @change="chartTypeChange">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-option v-for="item in chartTypeList" :key="item.id" :disabled=" item.id==='group' && editChart.isGroup" :label="item.name" :value="item.id">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--group-->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.group')" class="form-item--half-width" prop="group">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select id="chart-box-group" v-model="editChart.groupId" :disabled="editChart.type==='group'" clearable placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="chartType">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-option v-for="item in groupArr" :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>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2021-04-23 18:10:25 +08:00
|
|
|
|
<!-- varType -->
|
2021-05-17 20:31:32 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.varType')" v-if="from === 'chartTemp'">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select id="chart-box-group" v-model="editChart.varType" :disabled="!!editChart.id" class="right-box__select" popper-class="right-box-select-top prevent-clickoutside" clearable placeholder="" size="small" value-key="chartType">
|
2021-04-23 18:10:25 +08:00
|
|
|
|
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in varTypeArr">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{item.name}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-04-08 18:45:58 +08:00
|
|
|
|
<!-- remark -->
|
2021-06-08 09:44:32 +08:00
|
|
|
|
<el-form-item :label="$t('overall.remark')">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="256" show-word-limit v-model="editChart.remark" :autosize="{ minRows: 1, maxRows: 6}" type="textarea"/>
|
2021-04-08 18:45:58 +08:00
|
|
|
|
</el-form-item>
|
2020-03-11 18:48:05 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div class="form__sub-title">{{$t('dashboard.panel.chartForm.option')}}</div>
|
|
|
|
|
|
<div class="form-items--half-width-group">
|
|
|
|
|
|
<!--width-->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.width')" class="form-item--half-width" prop="span">
|
2021-09-27 10:25:19 +08:00
|
|
|
|
<el-select id="chart-box-span" v-model="editChart.span" :disabled="editChart.type === 'group'" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="chartSpan">
|
2021-04-26 21:42:15 +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
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<!--height-->
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.high')" class="form-item--half-width" prop="height">
|
2021-05-17 22:31:14 +08:00
|
|
|
|
<!-- <el-autocomplete
|
2021-04-26 21:42:15 +08:00
|
|
|
|
id="chart-box-height"
|
|
|
|
|
|
v-model="editChart.height"
|
|
|
|
|
|
:disabled="editChart.type === 'group'"
|
|
|
|
|
|
:fetch-suggestions="querySearch"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="popper-z-index prevent-clickoutside"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@select="handleSelect">
|
|
|
|
|
|
<template slot-scope="{ item }">
|
|
|
|
|
|
<div class="name">{{ item }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template slot="append">px</template>
|
2021-05-17 22:31:14 +08:00
|
|
|
|
</el-autocomplete>-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 由px改为span -->
|
2021-09-27 10:25:19 +08:00
|
|
|
|
<el-select id="chart-box-height" v-model="editChart.height" :disabled="editChart.type === 'group'" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="chartSpan">
|
2021-05-17 22:31:14 +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>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</el-form-item>
|
2020-06-08 14:55:09 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<!-- unit -->
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<el-form-item v-show="editChart.type !='text' && editChart.type !=='url'&& editChart.type !=='group'&& editChart.type !=='diagram'" :label="$t('dashboard.panel.chartForm.unit')" class="form-item--half-width" prop="unit">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-cascader id="chart-box-unit" v-model="editChart.unit" :options="unitOptions" :props="{ expandTrigger: 'hover',emitPath:false }" :show-all-levels="false" filterable
|
|
|
|
|
|
placeholder=""
|
2021-10-29 12:02:34 +08:00
|
|
|
|
popper-class="dc-dropdown right-box-select-top right-public-box-dropdown-top prevent-clickoutside chart-box-unit"
|
2021-04-26 21:42:15 +08:00
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
@change="unitSelected"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-cascader>
|
|
|
|
|
|
</el-form-item>
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<!--Align-->
|
2021-07-05 16:40:19 +08:00
|
|
|
|
<!--<el-form-item v-if="editChart.type ==='diagram'" :label="$t('dashboard.panel.chartForm.align')" class="form-item--half-width" prop="unit">
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<el-select id="chart-box-statistics" v-model="editChart.param.align" placeholder="" popper-class="chart-box-dropdown-mini prevent-clickoutside" size="small" @change="$forceUpdate">
|
|
|
|
|
|
<el-option v-for="item in alignList" :key="item.value" :label="item.label" :value="item.value">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{item.label}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
2021-07-05 16:40:19 +08:00
|
|
|
|
</el-form-item>-->
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<!--lock-->
|
2021-09-03 11:10:24 +08:00
|
|
|
|
<el-form-item v-if="editChart.type ==='diagram'" :label="$t('dashboard.panel.chartForm.lock')" class="form-item--half-width" prop="lock">
|
2021-11-12 09:42:23 +08:00
|
|
|
|
<el-select id="chart-box-statistics" v-model="editChart.param.lock" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" @change="$forceUpdate()">
|
2021-11-05 10:31:16 +08:00
|
|
|
|
<el-option v-for="item in lockList" :key="item.value" :label="$t(item.label)" :value="item.value">
|
|
|
|
|
|
<span class="panel-dropdown-label-txt" >{{$t(item.label)}}</span>
|
2021-06-29 14:10:41 +08:00
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-04-08 18:45:58 +08:00
|
|
|
|
|
2021-09-13 16:21:13 +08:00
|
|
|
|
<el-form-item class="form-item--half-width" v-if="editChart.type =='url' && isUrl" :label='$t("dashboard.panel.chartForm.url")' :rules="{ required: true, message: $t('validate.required'), trigger: 'blur' }" prop="param.url">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-input id="chart-box-url" v-model="editChart.param.url" maxlength="1024" show-word-limit size="small" type="textarea"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2021-09-29 15:06:52 +08:00
|
|
|
|
<!--Default collapse-->
|
|
|
|
|
|
<el-form-item class="form-item--half-width" v-if="editChart.type == 'group'" :label='$t("dashboard.panel.chartForm.collapse")' prop="param.collapse">
|
|
|
|
|
|
<el-switch id="chart-box-collapse"
|
|
|
|
|
|
v-model="editChart.param.collapse"
|
|
|
|
|
|
:active-value="true"
|
|
|
|
|
|
:inactive-value="false"
|
|
|
|
|
|
active-color="#ee9d3f"
|
|
|
|
|
|
@change="defaultCollapse"
|
|
|
|
|
|
size="small"/>
|
|
|
|
|
|
</el-form-item>
|
2020-05-26 18:29:53 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-form-item v-if="editChart.type === 'line' || editChart.type == 'bar' || editChart.type == 'stackArea' || editChart.type == 'table'" :label='"Null value"' class="form-item--half-width" prop="nullType">
|
2021-09-29 15:06:52 +08:00
|
|
|
|
<el-select id="chart-box-nullType" v-model="editChart.param.nullType" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" @change="$forceUpdate()">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-option v-for="item in nullTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2020-09-29 09:45:49 +08:00
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-form-item v-if="editChart.type == 'singleStat' || editChart.type == 'pie'|| editChart.type=='table' || editChart.type == 'bar'" :label="$t('dashboard.panel.chartForm.statistics')" class="form-item--half-width" prop="param.statistics">
|
2021-11-12 09:42:23 +08:00
|
|
|
|
<el-select id="chart-box-statistics" v-model="editChart.param.statistics" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" @change="$forceUpdate()">
|
2021-11-04 18:21:20 +08:00
|
|
|
|
<el-option v-for="item in statisticsList" :key="item.value" :label="$t(item.label)" :value="item.value">
|
2021-11-05 11:14:11 +08:00
|
|
|
|
<span class="panel-dropdown-label-txt" >{{$t(item.label)}}</span>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-09-23 10:51:53 +08:00
|
|
|
|
<el-form-item class="form-item--half-width" v-if="editChart.type == 'logs'" :label='$t("dashboard.panel.chartForm.limit")' prop="param.limit">
|
2021-09-27 10:25:19 +08:00
|
|
|
|
<el-select v-model="editChart.param.limit" popper-class="right-box-select-top" size="small">
|
2021-09-29 15:06:52 +08:00
|
|
|
|
<el-option v-for="option in limitOptions" :key="option" :value="option"></el-option>
|
2021-09-23 10:51:53 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-09-03 11:39:16 +08:00
|
|
|
|
<el-form-item class="form-item--half-width" v-if="editChart.type == 'logs'" :label='$t("dashboard.panel.chartForm.time")' prop="param.time">
|
2021-09-03 11:10:24 +08:00
|
|
|
|
<el-switch id="chart-box-time"
|
|
|
|
|
|
v-model="editChart.param.time"
|
|
|
|
|
|
:active-value="true"
|
|
|
|
|
|
:inactive-value="false"
|
|
|
|
|
|
size="small"></el-switch>
|
|
|
|
|
|
</el-form-item>
|
2021-09-03 11:39:16 +08:00
|
|
|
|
<el-form-item class="form-item--half-width" v-if="editChart.type == 'logs'" :label='$t("dashboard.panel.chartForm.descending")' prop="param.descending">
|
2021-09-03 11:10:24 +08:00
|
|
|
|
<el-switch id="chart-box-descending"
|
|
|
|
|
|
v-model="editChart.param.descending"
|
|
|
|
|
|
:active-value="true"
|
|
|
|
|
|
:inactive-value="false"
|
|
|
|
|
|
size="small"></el-switch>
|
|
|
|
|
|
</el-form-item>
|
2021-09-03 11:39:16 +08:00
|
|
|
|
<el-form-item class="form-item--half-width" v-if="editChart.type == 'logs'" :label='$t("dashboard.panel.chartForm.wrapLines")' prop="param.wrapLines">
|
2021-09-03 11:10:24 +08:00
|
|
|
|
<el-switch id="chart-box-wrapLines"
|
|
|
|
|
|
v-model="editChart.param.wrapLines"
|
|
|
|
|
|
:active-value="true"
|
|
|
|
|
|
:inactive-value="false"
|
|
|
|
|
|
size="small"></el-switch>
|
|
|
|
|
|
</el-form-item>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</div>
|
2021-04-08 18:45:58 +08:00
|
|
|
|
|
2021-07-19 18:06:55 +08:00
|
|
|
|
<div v-if="editChart.type ==='diagram'" class="form__sub-title">
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.content')}}</span>
|
|
|
|
|
|
<span style="cursor: pointer"><i class="nz-icon nz-icon-edit" @click="topologyDialogChange(true)"></i></span>
|
|
|
|
|
|
</div>
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<!--topoData-->
|
|
|
|
|
|
<el-form-item v-if="editChart.type ==='diagram'" >
|
|
|
|
|
|
<div class="topology-box">
|
|
|
|
|
|
<div class="topology-mc"></div>
|
|
|
|
|
|
<diagram :topoData="editChart.param.topo" :fromChartBox="true" :topologyIndexF="-1"/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-form-item v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'" :label='$t("dashboard.panel.chartForm.threshold")' class="form-item--half-width" prop="param.threshold">
|
|
|
|
|
|
<el-input id="chart-box-threshold" v-model="editChart.param.threshold" size="small" type="input"></el-input>
|
2020-12-04 15:24:59 +08:00
|
|
|
|
</el-form-item>
|
2020-05-26 18:29:53 +08:00
|
|
|
|
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<div v-if="!isUrl&&!isAlert&& editChart.type != 'text'&& editChart.type != 'group' && editChart.type != 'diagram'" class="form__sub-title">
|
2021-09-15 11:40:33 +08:00
|
|
|
|
<span>{{$t('alert.config.exprBox')}}</span>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<span v-if="!isSingleStat" @click="addExpression">
|
|
|
|
|
|
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
|
2020-10-12 13:46:31 +08:00
|
|
|
|
</span>
|
2020-12-04 15:24:59 +08:00
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div v-if="editChart.type == 'text'" class="form__sub-title">
|
2020-12-04 15:24:59 +08:00
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.content')}}</span>
|
|
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div v-if="isAlert" class="form__sub-title">{{$t('dashboard.panel.chartForm.alertParam.param')}}</div>
|
2020-05-28 17:32:23 +08:00
|
|
|
|
|
2021-09-10 14:13:10 +08:00
|
|
|
|
<el-row class="element-item element-item__padding" v-if="isAlert">
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<alert-chart-param @on-enter-complate="getAlertParam" ref="alertParamBox"></alert-chart-param>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</el-row>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div style="margin-bottom: 20px">
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<el-row :key="'ele' + index" class="element-item form-row-item" style="" v-for="index of promqlKeys.length" v-if="!isUrl &&!isAlert && editChart.type != 'text'&& editChart.type != 'group' && editChart.type != 'diagram'">
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<promql-input
|
2021-09-28 16:54:07 +08:00
|
|
|
|
:from-father-data="true"
|
|
|
|
|
|
:metricOptionsParent="metricOptions"
|
2021-02-04 11:21:00 +08:00
|
|
|
|
:expression-list="expressions"
|
|
|
|
|
|
:id="promqlKeys[index-1]"
|
|
|
|
|
|
:index="index-1"
|
2021-11-29 15:37:08 +08:00
|
|
|
|
:required = 'true'
|
2021-09-03 11:10:24 +08:00
|
|
|
|
:type="promqlType"
|
2021-02-04 11:21:00 +08:00
|
|
|
|
:key="promqlKeys[index-1]"
|
|
|
|
|
|
:plugins="['metric-selector', 'metric-input', 'remove']"
|
|
|
|
|
|
:ref="'promql-'+(index-1)"
|
|
|
|
|
|
:showRemove="false"
|
|
|
|
|
|
:styleType="2"
|
|
|
|
|
|
@change="expressionChange"
|
|
|
|
|
|
@removeExpression="removeExpression"
|
|
|
|
|
|
></promql-input>
|
2021-04-30 18:54:11 +08:00
|
|
|
|
<el-row style="margin-top: 18px">
|
2021-03-18 17:03:29 +08:00
|
|
|
|
<el-col class="legend-title">
|
2021-11-17 16:41:18 +08:00
|
|
|
|
<span class="legend-title__span">{{$t('dashboard.panel.chartForm.legend')}} </span>
|
2021-11-05 15:41:25 +08:00
|
|
|
|
<el-popover placement="top" trigger="hover" width="211" popper-class="prevent-clickoutside">
|
2021-10-28 16:58:09 +08:00
|
|
|
|
<div :style="{'word-break':language!=='cn'?'keep-all':'break-all'}">{{$t('dashboard.panel.chartForm.legendTip')}}</div>
|
2021-03-11 19:59:47 +08:00
|
|
|
|
<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-04-26 21:42:15 +08:00
|
|
|
|
<el-col style="width: calc(100% - 160px);">
|
2021-05-28 10:43:41 +08:00
|
|
|
|
<el-input maxlength="512" show-word-limit size="small" type="text" v-model="legends[index-1]" ></el-input>
|
2021-03-11 19:59:47 +08:00
|
|
|
|
</el-col>
|
2021-02-04 11:21:00 +08:00
|
|
|
|
</el-row>
|
2021-03-11 19:59:47 +08:00
|
|
|
|
<div class="nz-icon-minus-position">
|
|
|
|
|
|
<span class="nz-icon-minus-medium">
|
|
|
|
|
|
<i @click="removeExpression(index - 1)" class="nz-icon nz-icon-minus"></i>
|
|
|
|
|
|
</span>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<span v-if="!isSingleStat" class="nz-icon-copy">
|
2021-03-11 19:59:47 +08:00
|
|
|
|
<i @click="copyExpression(index - 1)" class="nz-icon nz-icon-override"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
2021-02-04 11:21:00 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<!--value mapping start-->
|
|
|
|
|
|
<div v-if="editChart.type == 'singleStat'||editChart.type == 'table'" class="form__sub-title">
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<span>
|
|
|
|
|
|
{{$t('dashboard.panel.chartForm.valMapping.name')}}
|
2021-11-05 15:41:25 +08:00
|
|
|
|
<el-popover placement="top" trigger="hover" width="275" popper-class="prevent-clickoutside">
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<div style="white-space: pre-wrap;">{{$t('dashboard.panel.chartForm.valueMappingTip')}}</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>
|
|
|
|
|
|
</span>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<span class="float-right" @click="addMapping"><i class="nz-icon nz-icon-create-square" style="font-size: 16px; cursor: pointer;"></i></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="editChart.type == 'singleStat'||editChart.type == 'table'" style="margin-bottom: 20px; width: 100%"></div>
|
|
|
|
|
|
<el-form-item v-if="editChart.type == 'singleStat'||editChart.type == 'table'" :label="$t('dashboard.panel.chartForm.type')" prop="span">
|
|
|
|
|
|
<el-radio-group id="chart-box-change-valuemapping" v-model="editChart.param.valueMapping.type" class="val-mapping-type" fill="#FA901C" size="small" text-color="#FA901C" @change="valueMappingChange">
|
|
|
|
|
|
<el-radio-button border class="no-fill" label="value">{{$t('dashboard.panel.chartForm.valMapping.value')}}</el-radio-button>
|
|
|
|
|
|
<el-radio-button border class="no-fill" label="range">{{$t('dashboard.panel.chartForm.valMapping.range')}}</el-radio-button>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<template v-if="(editChart.type == 'singleStat'||editChart.type == 'table')&&editChart.param.valueMapping.type == 'value'" id="chart-box-valueMapping-type1">
|
2021-11-11 17:25:54 +08:00
|
|
|
|
<div v-for="(mapping, index) in editChart.param.valueMapping.mapping" :key="index">
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.value')" class="form-item--half-width-other" prop="span" >
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-input v-model="mapping.value" size="small" style="display: inline-block;;" type="input"></el-input>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
</el-form-item>
|
2021-11-11 17:25:54 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.text')" class="form-item--half-width-other form-item--half-width-other-two" prop="span">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-input v-model="mapping.text" size="small" style="display: inline-block;width:calc(100% - 80px);" type="input"></el-input>
|
|
|
|
|
|
<!--颜色选择器 start-->
|
|
|
|
|
|
<div class="color-show">
|
|
|
|
|
|
<nezhaColor :color-val="mapping.color" :single="false" :value-arr="[{name:'bac', value:showPicker[index].bac, key:'bac'},{name:'text', value:showPicker[index].text, key:'text'}]" @colorChange="(val,key)=>{colorChange(mapping,key,val)}"/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--颜色选择器 end-->
|
|
|
|
|
|
<span class="nz-icon-minus-medium" style="margin-left: 7px;padding: 6px" @click="delMapping(index)"><i class="nz-icon nz-icon-minus" style="color: #EC7F66"></i></span>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
</el-form-item>
|
2021-11-11 17:25:54 +08:00
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-if="(editChart.type == 'singleStat'||editChart.type == 'table')&&editChart.param.valueMapping.type == 'range'" id="chart-box-valueMapping-type2">
|
2021-11-11 17:25:54 +08:00
|
|
|
|
<div v-for="(mapping, index) in editChart.param.valueMapping.mapping" :key="index">
|
|
|
|
|
|
<div class="form-item--half-width-other" style="display: inline-block;margin-left: 15px">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.from')" class="one-third-form-item-left" prop="span" >
|
|
|
|
|
|
<el-input v-model="mapping.from" size="small" type="input"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.to')" class="one-third-form-item-right" prop="span" >
|
|
|
|
|
|
<el-input v-model="mapping.to" size="small" type="input"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2020-12-08 22:14:52 +08:00
|
|
|
|
</div>
|
2021-11-11 17:25:54 +08:00
|
|
|
|
<el-form-item :label="$t('dashboard.panel.chartForm.valMapping.text')" class="form-item--half-width-other-two range" prop="span">
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<el-input v-model="mapping.text" size="small" style="display: inline-block;width:calc(100% - 80px);" type="input" ></el-input>
|
|
|
|
|
|
<!--颜色选择器 start-->
|
|
|
|
|
|
<div class="color-show">
|
|
|
|
|
|
<nezhaColor :color-val="mapping.color" :single="false" :value-arr="[{name:'bac',value:showPicker[index].bac,key:'bac'},{name:'text',value:showPicker[index].text,key:'text'}]" @colorChange="(val,key)=>{colorChange(mapping,key,val)}"/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--颜色选择器 end-->
|
|
|
|
|
|
<span class="nz-icon-minus-medium" style="margin-left: 7px;padding: 6px" @click="delMapping(index)"><i class="nz-icon nz-icon-minus" style="color: #EC7F66"></i></span>
|
|
|
|
|
|
</el-form-item>
|
2021-11-11 17:25:54 +08:00
|
|
|
|
</div>
|
2020-09-17 10:28:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<!--value mapping end-->
|
|
|
|
|
|
<template v-if="editChart.type == 'line' || editChart.type == 'bar' || editChart.type == 'stackArea'">
|
|
|
|
|
|
<div class="form__sub-title" >
|
|
|
|
|
|
<span>{{$t('dashboard.panel.chartForm.legendValue')}}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="display: flex; margin-bottom: 20px">
|
|
|
|
|
|
<span style="margin-left: 15px;"></span>
|
|
|
|
|
|
<template v-for="(item, index) in sortedOptionKeys">
|
|
|
|
|
|
<div :key="index" style="flex: 1">
|
|
|
|
|
|
<span style="margin-right: 10px;color:rgb(102, 102, 102)">{{item.label}}</span>
|
|
|
|
|
|
<el-switch
|
|
|
|
|
|
:id="'chart-box-legendValue-'+item.label"
|
|
|
|
|
|
v-model="editChart.param.legendValue[item.key]"
|
|
|
|
|
|
active-value="on"
|
|
|
|
|
|
inactive-value="off"
|
|
|
|
|
|
>
|
|
|
|
|
|
</el-switch>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<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-12-04 15:24:59 +08:00
|
|
|
|
</el-form>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</div>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<!--底部按钮-->
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<div class="right-box__footer">
|
|
|
|
|
|
<button id="chart-box-esc" v-cancel="{obj:editChart,func:esc}" class="footer__btn footer__btn--light">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2022-01-11 11:00:03 +08:00
|
|
|
|
<button v-if="showPanel.type && showPanel.type == 'model'" id="chart-box-Sync" v-has="'main_edit'" class="footer__btn" @click="SyncSave">
|
2020-10-21 14:15:58 +08:00
|
|
|
|
<span>{{$t('overall.SyncSave')}}</span>
|
|
|
|
|
|
</button>
|
2021-05-17 20:31:32 +08:00
|
|
|
|
<button v-else-if="from!=='chartTemp'" id="chart-box-preview" class="footer__btn" @click="preview" >
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<span>{{$t('overall.preview')}}</span>
|
|
|
|
|
|
</button>
|
2022-01-11 11:00:03 +08:00
|
|
|
|
<button id="chart-box-save" v-has="'main_add'" :class="{'nz-btn-disabled':prevent_opt.save}" :disabled="prevent_opt.save" class="footer__btn" @click="confirmAdd" >
|
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 -->
|
2021-02-24 18:21:55 +08:00
|
|
|
|
<chart-preview :panelId="panelId" ref="chartsPreview" :fromEndpoint="fromEndpoint"></chart-preview>
|
2021-06-29 14:10:41 +08:00
|
|
|
|
<!--topplogy-->
|
|
|
|
|
|
<diagram :topoData="editChart.param.topo" class="topology-dialog" v-if="topologyDialog" @change="topologyDialogChange" :topologyIndexF="-2" ref="topologyDialog" :fromTopologyDialog="true"/>
|
2020-02-21 17:32:59 +08:00
|
|
|
|
</div>
|
2020-01-03 17:17:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
import bus from '../../../libs/bus'
|
|
|
|
|
|
import chartDataFormat from '../../charts/chartDataFormat'
|
|
|
|
|
|
import chartPreview from '../../charts/chartPreview'
|
|
|
|
|
|
import { getUUID, resetZIndex } from '../../common/js/common'
|
|
|
|
|
|
import alertChartParam from './alertChartParam'
|
|
|
|
|
|
import promqlInput from './explore/promqlInput'
|
|
|
|
|
|
import { nzNumber } from '../../common/js/validate'
|
|
|
|
|
|
import richTextEditor from '../../charts/richTextEditor'
|
|
|
|
|
|
import selectPanel from '../../common/popBox/selectPanel'
|
|
|
|
|
|
import nezhaColor from '../../common/nezhaColor'
|
|
|
|
|
|
import i18n from '../../common/i18n'
|
2021-05-21 15:06:58 +08:00
|
|
|
|
import { fromRoute } from '@/components/common/js/constants'
|
2021-06-29 14:10:41 +08:00
|
|
|
|
import diagram from '@/components/common/ChartDiagram/diagram'
|
2021-07-05 14:43:47 +08:00
|
|
|
|
import editRigthBox from '../../common/mixin/editRigthBox'
|
2021-09-28 16:54:07 +08:00
|
|
|
|
import promqlInputMixin from '@/components/common/mixin/promqlInput'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const rz = {
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
rz (e) {
|
|
|
|
|
|
resetZIndex(e)
|
2020-07-02 20:10:16 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'chartBox',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
boxClass: String,
|
|
|
|
|
|
panelData: Array,
|
|
|
|
|
|
showPanel: Object,
|
|
|
|
|
|
chart: Object,
|
|
|
|
|
|
from: { type: String },
|
|
|
|
|
|
fromEndpoint: {
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
default: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-09-28 16:54:07 +08:00
|
|
|
|
mixins: [rz, editRigthBox, promqlInputMixin],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2021-05-21 15:06:58 +08:00
|
|
|
|
fromRoute,
|
2021-11-08 15:55:51 +08:00
|
|
|
|
language: 3,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
optionBtn: {
|
|
|
|
|
|
save: false
|
|
|
|
|
|
},
|
2021-04-07 16:41:11 +08:00
|
|
|
|
editChart: {
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
remark: ''
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
filterPanel: '',
|
|
|
|
|
|
statisticsList: this.$CONSTANTS.statisticsList,
|
2021-06-29 14:10:41 +08:00
|
|
|
|
alignList: this.$CONSTANTS.alignList,
|
|
|
|
|
|
lockList: this.$CONSTANTS.lockList,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
promqlCount: 1,
|
|
|
|
|
|
promqlKeys: [],
|
|
|
|
|
|
elementIds: [],
|
|
|
|
|
|
expressions: [],
|
|
|
|
|
|
legends: [],
|
|
|
|
|
|
statistics: '',
|
|
|
|
|
|
isEdit: false,
|
|
|
|
|
|
editInfo: {},
|
|
|
|
|
|
isUrl: false,
|
|
|
|
|
|
isSingleStat: false,
|
|
|
|
|
|
isAlert: false,
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
panelName: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
2021-04-07 11:21:12 +08:00
|
|
|
|
name: [
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
url: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
2020-01-03 17:17:09 +08:00
|
|
|
|
],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
'param.threshold': [
|
|
|
|
|
|
{ validator: nzNumber, trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
'param.statistics': [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
2021-04-07 11:21:12 +08:00
|
|
|
|
groupArr: [],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
chartTypeList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'line',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.line.label')
|
2020-02-06 18:50:40 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'stackArea',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.stackArea.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'bar',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.bar.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'singleStat',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.singleStat.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'pie',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.pie.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'table',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.table.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'alertList',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.alertList.label')
|
|
|
|
|
|
},
|
2021-09-03 11:10:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'logs',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.logs.label')
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'text',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.text.label')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 'url',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.url.label')
|
2021-04-07 11:21:12 +08:00
|
|
|
|
},
|
2021-06-29 14:10:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'diagram',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.diagram.label')
|
|
|
|
|
|
},
|
2021-04-07 11:21:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
id: 'group',
|
|
|
|
|
|
name: this.$t('dashboard.panel.chartForm.typeVal.group.label')
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
elements: [1], // 指标部分 tarNum
|
|
|
|
|
|
elementTarget: [], // 本地保存数据
|
|
|
|
|
|
alertParams: {},
|
|
|
|
|
|
spanList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
2021-09-23 10:51:53 +08:00
|
|
|
|
limitOptions: [100, 200, 500, 1000, 2000],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
nullTypeList: [{
|
2021-11-17 13:51:28 +08:00
|
|
|
|
label: 'connected',
|
|
|
|
|
|
value: 'connected'
|
|
|
|
|
|
}, {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
label: 'null',
|
|
|
|
|
|
value: 'null'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: 'zero',
|
|
|
|
|
|
value: 'zero'
|
|
|
|
|
|
}],
|
|
|
|
|
|
// 是否为编辑已有信息
|
2021-09-13 10:40:29 +08:00
|
|
|
|
iseditChart: false,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// productId: 0,//不需要这个参数,可以删除
|
|
|
|
|
|
isInputPanel: false,
|
|
|
|
|
|
panelId: 0,
|
|
|
|
|
|
panelName: '',
|
|
|
|
|
|
selectFirstPanel: false,
|
|
|
|
|
|
metricList: [], // metric列表
|
|
|
|
|
|
metricCascaderList: [], // metric级联列表
|
|
|
|
|
|
metricAllData: new Map(), // 存放所有的project-module-metric-labelValue,避免重复加载
|
|
|
|
|
|
deleteIndex: '', // 要删除的指标模块
|
|
|
|
|
|
subCount: 0, // subSave保存data到bus计数器
|
|
|
|
|
|
panel: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
heightSuggestions: ['300', '400', '500', '600'],
|
|
|
|
|
|
unitOptions: chartDataFormat.unitOptions(),
|
|
|
|
|
|
sortedOptionKeys: [{ key: 'min', label: 'Min' }, { key: 'max', label: 'Max' }, { key: 'avg', label: 'Avg' }, { key: 'last', label: 'Last' }, { key: 'total', label: 'Total' }],
|
|
|
|
|
|
textShow: false,
|
2021-04-23 18:10:25 +08:00
|
|
|
|
showPicker: [],
|
|
|
|
|
|
varTypeArr: [
|
|
|
|
|
|
{ name: 'Asset', id: 1 },
|
|
|
|
|
|
{ name: 'Endpoint', id: 2 }
|
2021-06-29 14:10:41 +08:00
|
|
|
|
],
|
2021-09-03 11:10:24 +08:00
|
|
|
|
topologyDialog: false,
|
2021-09-29 15:06:52 +08:00
|
|
|
|
promqlType: 'metric',
|
|
|
|
|
|
chartSwitch: false
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// metricStore: []
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
'chart-preview': chartPreview,
|
|
|
|
|
|
'alert-chart-param': alertChartParam,
|
|
|
|
|
|
'promql-input': promqlInput,
|
|
|
|
|
|
'rich-text-editor': richTextEditor,
|
|
|
|
|
|
selectPanel,
|
2021-06-29 14:10:41 +08:00
|
|
|
|
nezhaColor,
|
|
|
|
|
|
diagram
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.initElements()
|
|
|
|
|
|
})
|
2020-10-20 20:53:21 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.textShow = true
|
|
|
|
|
|
}, 300)
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
clickOutside () {
|
|
|
|
|
|
this.esc(false)
|
2020-05-25 17:15:14 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
selectPanel (panel) {
|
|
|
|
|
|
this.panelName = panel.name
|
|
|
|
|
|
this.panelId = panel.id
|
2021-04-09 17:04:30 +08:00
|
|
|
|
this.editChart.groupId = ''
|
2021-04-25 14:58:03 +08:00
|
|
|
|
this.$get('visual/panel/chart?panelId=' + this.panelId + '&pageSize=-1').then(response => {
|
2021-04-09 17:04:30 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.groupArr = []
|
|
|
|
|
|
response.data.list.forEach((item, index) => {
|
|
|
|
|
|
if (item.type === 'group') {
|
|
|
|
|
|
this.groupArr.push({ id: item.id, name: item.name })
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
toAddPanel () {
|
|
|
|
|
|
this.$refs.panelBox2.show(true)
|
|
|
|
|
|
this.panel = {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.panelBox2.setTitle(this.$t('dashboard.panel.createPanelTitle'))
|
|
|
|
|
|
},
|
|
|
|
|
|
panelReload (panelName) { // 刷新panel下拉框
|
|
|
|
|
|
if (panelName) {
|
|
|
|
|
|
this.panelName = panelName
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$emit('reloadOnlyPanel')
|
|
|
|
|
|
},
|
|
|
|
|
|
deletePanel (panel) {
|
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$delete('visual/panel?ids=' + panel.id).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
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)
|
2020-02-07 19:57:39 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$emit('reload')
|
2020-02-07 19:57:39 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} 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'))
|
|
|
|
|
|
},
|
|
|
|
|
|
setUnit (unit) {
|
|
|
|
|
|
this.$set(this.editChart, 'unit', Number.parseInt(unit))
|
|
|
|
|
|
},
|
|
|
|
|
|
expressionChange: function () {
|
2021-11-29 15:37:08 +08:00
|
|
|
|
if (this.expressions[0]) {
|
|
|
|
|
|
this.editChart.elements = []
|
|
|
|
|
|
this.expressions.forEach((expr, i) => {
|
|
|
|
|
|
this.editChart.elements.push({ id: this.elementIds[i], expression: expr, type: 'expert', legend: this.legends[i] })
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.editChart.elements = []
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
addExpression () {
|
|
|
|
|
|
this.expressions.push('')
|
|
|
|
|
|
this.legends.push('')
|
|
|
|
|
|
this.promqlKeys.push(getUUID())
|
|
|
|
|
|
this.elementIds.push('')
|
|
|
|
|
|
this.promqlCount++
|
|
|
|
|
|
},
|
|
|
|
|
|
removeExpression (index) {
|
|
|
|
|
|
if (this.promqlCount > 1) {
|
|
|
|
|
|
this.expressions.splice(index, 1)
|
|
|
|
|
|
this.legends.splice(index, 1)
|
|
|
|
|
|
this.promqlKeys.splice(index, 1)
|
|
|
|
|
|
this.elementIds.splice(index, 1)
|
|
|
|
|
|
this.promqlCount--
|
2021-03-11 19:59:47 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.expressions.forEach((ex, index) => {
|
|
|
|
|
|
if (ex) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs[`promql-${index}`][0].metricChange(ex)
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
copyExpression (index) {
|
|
|
|
|
|
this.expressions.push(this.expressions[index])
|
|
|
|
|
|
this.legends.push(this.legends[index])
|
|
|
|
|
|
this.promqlKeys.push(getUUID())
|
|
|
|
|
|
this.elementIds.push('')
|
|
|
|
|
|
this.promqlCount++
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.expressions.forEach((ex, index) => {
|
|
|
|
|
|
if (ex) {
|
|
|
|
|
|
this.$refs[`promql-${index}`][0].metricChange(ex)
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-09-29 15:06:52 +08:00
|
|
|
|
defaultCollapse (val) {
|
|
|
|
|
|
this.chartSwitch = val
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
save () {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (this.editChart.id) { // 修改
|
2021-09-29 15:06:52 +08:00
|
|
|
|
this.editChart.param.collapse = this.chartSwitch
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$put('visual/panel/chart', this.editChart).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else { // 新增
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$post('visual/panel/chart', this.editChart).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error('error submit!!')
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
del () {
|
|
|
|
|
|
this.$emit('delete-chart', this.editChart)
|
|
|
|
|
|
},
|
|
|
|
|
|
// ----------------------------------
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* 关闭弹框 */
|
|
|
|
|
|
esc (refresh) {
|
|
|
|
|
|
this.$emit('close', refresh)
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* metric部分相关方法--begin */
|
|
|
|
|
|
// 增加指标,tarNum
|
|
|
|
|
|
addTarget () {
|
|
|
|
|
|
this.elements.push(1)
|
|
|
|
|
|
},
|
|
|
|
|
|
// 删除指标,第一步, 新方法
|
|
|
|
|
|
deleteTarget (index) {
|
|
|
|
|
|
// alert('box第一步,循环所有的metric,为什么要循环??');
|
|
|
|
|
|
this.deleteIndex = index
|
|
|
|
|
|
// alert('box第一步,循环所有的metric,循环前metric,循环次数='+this.$refs.chartTag.length);
|
|
|
|
|
|
this.$refs.chartTag.forEach((item) => {
|
|
|
|
|
|
// 子组件保存内容到bus
|
|
|
|
|
|
item.subSave()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// subSave保存成功后回调,第二步
|
|
|
|
|
|
subOk () {
|
|
|
|
|
|
// 每个模块均有返回,当全部模块返回完成时,将sub计数器重置
|
|
|
|
|
|
// alert('box第二步,subCount和元素个数一样了,就从deleteIndex开始删除一个元素,this.subCount='+this.subCount);
|
|
|
|
|
|
this.subCount += 1
|
|
|
|
|
|
if (this.subCount === this.elements.length) {
|
|
|
|
|
|
this.subCount = 0
|
|
|
|
|
|
// 保存完成,进行删除操作
|
|
|
|
|
|
// ('box第二步,deleteIndex='+this.deleteIndex+'=开始删除一个元素')
|
|
|
|
|
|
this.elements.splice(this.deleteIndex, 1)
|
|
|
|
|
|
this.elementTarget.splice(this.deleteIndex, 1)// 没有作用,此处是[]
|
|
|
|
|
|
bus.chartAddInfo.metricTarget.splice(this.deleteIndex, 1)
|
2020-04-09 21:27:48 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {
|
|
|
|
|
|
item.setSubdata(index) // 将数据从bus重新赋值
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 格式化tag为字符串表达式
|
|
|
|
|
|
/*
|
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
|
|
|
|
*/
|
2021-03-19 18:52:19 +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
|
2020-03-12 17:30:29 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
return result
|
|
|
|
|
|
},
|
|
|
|
|
|
// 新建图表
|
|
|
|
|
|
addCharts (params) {
|
|
|
|
|
|
// 先处理panel
|
|
|
|
|
|
/* let panelPromise=new Promise(resolve => {
|
2020-10-19 18:33:18 +08:00
|
|
|
|
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
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}); */
|
2020-05-19 20:26:11 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// panelPromise.then(()=>{
|
2021-05-17 20:31:32 +08:00
|
|
|
|
if (this.panelId || this.from === 'chartTemp') {
|
|
|
|
|
|
if (this.from === 'chartTemp') {
|
2021-04-23 18:10:25 +08:00
|
|
|
|
this.panelId = 0
|
|
|
|
|
|
}
|
2021-04-07 11:21:12 +08:00
|
|
|
|
const chartParams = params || this.editChart
|
|
|
|
|
|
chartParams.panelId = this.panelId
|
|
|
|
|
|
if (!chartParams.groupId) {
|
2021-04-08 17:49:07 +08:00
|
|
|
|
chartParams.groupId = 0
|
2021-04-07 11:21:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
delete chartParams.panel
|
2021-04-08 17:49:07 +08:00
|
|
|
|
delete chartParams.children
|
2021-04-09 18:18:34 +08:00
|
|
|
|
if (chartParams.elements) {
|
|
|
|
|
|
chartParams.elements.forEach(item => {
|
|
|
|
|
|
delete item.id
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$post('visual/panel/chart', chartParams).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
2021-04-07 16:41:11 +08:00
|
|
|
|
// this.$refs.chartForm.resetFields()// 清空表单
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$emit('on-create-success', 'create', response.data, chartParams, { id: this.panelId, name: this.panelName })
|
2021-05-27 17:57:30 +08:00
|
|
|
|
this.esc(true)
|
2020-01-06 17:10:57 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.msg) {
|
|
|
|
|
|
this.$message.error(response.msg)
|
2020-07-08 21:39:43 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$message.error(response)
|
2020-05-26 18:29:53 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// })
|
|
|
|
|
|
},
|
|
|
|
|
|
// 更新图表
|
|
|
|
|
|
updateCharts (params) {
|
2021-04-23 18:10:25 +08:00
|
|
|
|
let panelId = this.panelId ? this.panelId : this.chart.panelId
|
2021-05-17 20:31:32 +08:00
|
|
|
|
if (this.from === 'chartTemp') {
|
2021-04-23 18:10:25 +08:00
|
|
|
|
panelId = 0
|
|
|
|
|
|
}
|
2021-04-07 11:21:12 +08:00
|
|
|
|
const chartParams = params || this.editChart
|
|
|
|
|
|
chartParams.panelId = panelId
|
|
|
|
|
|
if (!chartParams.groupId) {
|
2021-04-09 15:12:07 +08:00
|
|
|
|
chartParams.groupId = 0
|
2021-04-07 11:21:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
delete chartParams.panel
|
2021-04-08 17:49:07 +08:00
|
|
|
|
delete chartParams.children
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$put('visual/panel/chart', chartParams).then(response2 => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response2.code === 200) {
|
2021-05-17 20:31:32 +08:00
|
|
|
|
this.esc(true)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
|
// this.$refs.chartForm.resetFields();//清空表单
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$emit('on-create-success', 'update', response2.data, chartParams)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (response2.msg) {
|
|
|
|
|
|
this.$message.error(response2.msg)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response2)
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取每个tag组件内部校验后数据,点击生成图表时触发
|
|
|
|
|
|
getTarget (target, pointer, optType) {
|
|
|
|
|
|
this.elementTarget.push(target)
|
|
|
|
|
|
if (this.elementTarget.length === this.elements.length) {
|
2020-05-28 17:32:23 +08:00
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// productId: this.productId,
|
|
|
|
|
|
// panelId: this.panelId,
|
2021-04-07 11:21:12 +08:00
|
|
|
|
name: this.editChart.name, // this.editChart
|
2020-07-30 18:37:04 +08:00
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
unit: this.editChart.unit,
|
|
|
|
|
|
param: {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
2021-04-12 10:53:21 +08:00
|
|
|
|
sync: this.editChart.sync,
|
2021-04-23 18:10:25 +08:00
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-04-08 17:49:07 +08:00
|
|
|
|
if (this.editChart.type === 'singleStat' || this.editChart.type === 'pie' || this.editChart.type === 'bar') {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// params.param.statistics=this.statistics;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.statistics
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.editChart.type === 'line' || this.editChart.type === 'bar' || this.editChart.type === 'stackArea') {
|
|
|
|
|
|
params.param.threshold = this.editChart.param.threshold
|
|
|
|
|
|
params.param.nullType = this.editChart.param.nullType
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.threshold
|
|
|
|
|
|
}
|
|
|
|
|
|
// 生成指标数组
|
|
|
|
|
|
const elements = []
|
|
|
|
|
|
this.elementTarget.forEach((elem, index) => {
|
|
|
|
|
|
if (elem.type === 'normal') {
|
|
|
|
|
|
const metricStr = bus.tagsToString(elem.metric, elem.selectedTagList)
|
|
|
|
|
|
elements.push({
|
|
|
|
|
|
// id:index+1,
|
|
|
|
|
|
// metric: elem.metric,//指标名称
|
|
|
|
|
|
expression: metricStr, // 指标对应Label及Value组成的表达式字符串
|
|
|
|
|
|
type: elem.type, // 指标类型
|
|
|
|
|
|
legend: elem.legend// 配置的legend
|
|
|
|
|
|
})
|
|
|
|
|
|
} else if (elem.type === 'expert') {
|
|
|
|
|
|
elements.push({
|
|
|
|
|
|
// id:index+1,
|
|
|
|
|
|
// metric: elem.metric,//指标名称
|
|
|
|
|
|
expression: elem.expression, // 指标对应Label及Value组成的表达式字符串
|
|
|
|
|
|
type: elem.type, // 指标类型
|
|
|
|
|
|
legend: elem.legend// 配置的legend
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
params.elements = elements
|
2020-05-28 17:32:23 +08:00
|
|
|
|
if (valid) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (optType === 'preview') {
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.id = this.editChart.id
|
2020-05-28 17:32:23 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.chartsPreview.show(params)
|
|
|
|
|
|
} else {
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.id = this.editChart.id
|
|
|
|
|
|
this.updateCharts(params)
|
2020-05-28 17:32:23 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.addCharts(params)
|
2020-05-28 17:32:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
getAlertParam: function (param, opType) {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
2021-04-07 11:21:12 +08:00
|
|
|
|
name: this.editChart.name, // this.editChart
|
2021-03-19 18:52:19 +08:00
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit: this.editChart.unit,
|
|
|
|
|
|
param: param,
|
2021-04-07 11:21:12 +08:00
|
|
|
|
sync: this.editChart.sync,
|
2021-04-12 10:53:21 +08:00
|
|
|
|
remark: this.editChart.remark,
|
2021-04-23 18:10:25 +08:00
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (opType === 'preview') {
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.id = this.editChart.id
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.chartsPreview.show(params)
|
|
|
|
|
|
} else {
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.id = this.editChart.id
|
|
|
|
|
|
this.updateCharts(params)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
SyncSave () {
|
|
|
|
|
|
this.editChart.sync = 1
|
|
|
|
|
|
this.confirmAdd()
|
|
|
|
|
|
},
|
|
|
|
|
|
confirmAdd () {
|
2021-06-08 14:01:16 +08:00
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
this.prevent_opt.save = true
|
|
|
|
|
|
this.elementTarget = [] // 初始化清空参数
|
|
|
|
|
|
if (this.editChart.type !== 'url' && this.editChart.type != 'text') {
|
|
|
|
|
|
/* if(this.editChart.type == 'alertList'){
|
|
|
|
|
|
this.$refs.alertParamBox.saveParam();
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {//循环指标列表
|
|
|
|
|
|
// 触发每个tag组件内部进行校验
|
|
|
|
|
|
item.saveTarget(index);
|
|
|
|
|
|
});
|
|
|
|
|
|
} */
|
|
|
|
|
|
if (this.editChart.type == 'alertList') {
|
|
|
|
|
|
this.$refs.alertParamBox.saveParam()
|
|
|
|
|
|
return
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-06-08 14:01:16 +08:00
|
|
|
|
if (this.editChart.type == 'singleStat' || this.editChart.type == 'pie' || this.editChart.type == 'table' || this.editChart.type == 'bar') {
|
|
|
|
|
|
// this.$set(this.editChart.param, "statistics", this.statistics);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete this.editChart.param.statistics
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-06-08 14:01:16 +08:00
|
|
|
|
if (this.expressions[0]) {
|
|
|
|
|
|
this.editChart.elements = []
|
|
|
|
|
|
this.expressions.forEach((expr, i) => {
|
|
|
|
|
|
this.editChart.elements.push({ id: this.elementIds[i], expression: expr, type: 'expert', legend: this.legends[i] })
|
|
|
|
|
|
})
|
2021-07-09 17:43:03 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.editChart.elements = []
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-06-08 14:01:16 +08:00
|
|
|
|
if (this.editChart.id) {
|
|
|
|
|
|
this.updateCharts()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-06-08 14:01:16 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (this.editChart.type == 'url') {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
name: this.editChart.name, // 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,
|
|
|
|
|
|
remark: this.editChart.remark,
|
|
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
|
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
|
|
2021-06-08 14:01:16 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
params.elements = []
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-06-08 14:01:16 +08:00
|
|
|
|
params.id = this.editChart.id
|
|
|
|
|
|
this.updateCharts(params)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const text = this.$refs.richTextEditor.getContent()
|
|
|
|
|
|
if (!text) {
|
|
|
|
|
|
valid = false
|
|
|
|
|
|
}
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
name: this.editChart.name, // this.editChart
|
|
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
param: {
|
|
|
|
|
|
text: text
|
|
|
|
|
|
},
|
|
|
|
|
|
sync: this.editChart.sync,
|
|
|
|
|
|
remark: this.editChart.remark,
|
|
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
params.elements = []
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-06-08 14:01:16 +08:00
|
|
|
|
params.id = this.editChart.id
|
|
|
|
|
|
this.updateCharts(params)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.addCharts(params)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-06-08 14:01:16 +08:00
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
2021-06-08 14:01:16 +08:00
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 获取metric列表
|
|
|
|
|
|
getSuggestMetric () {
|
|
|
|
|
|
// this.$get('/prom/api/v1/label/__name__/values').then(response => {
|
2021-05-17 22:31:14 +08:00
|
|
|
|
this.$get('monitor/module?pageSize=-1').then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.metricList = response.data.list
|
|
|
|
|
|
const cascaderMap = new Map()
|
|
|
|
|
|
this.metricList.forEach((item, index) => {
|
|
|
|
|
|
const projectName = item.project.name
|
|
|
|
|
|
const moduleName = item.name
|
|
|
|
|
|
const childOption = {
|
|
|
|
|
|
value: moduleName,
|
|
|
|
|
|
label: moduleName,
|
|
|
|
|
|
children: []
|
|
|
|
|
|
}
|
|
|
|
|
|
if (cascaderMap.has(projectName)) {
|
|
|
|
|
|
cascaderMap.get(projectName).push(childOption)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const childArr = []
|
|
|
|
|
|
childArr.push(childOption)
|
|
|
|
|
|
cascaderMap.set(projectName, childArr)
|
|
|
|
|
|
}
|
2020-04-09 21:27:48 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 缓存全局数据
|
|
|
|
|
|
const moduleItem = {
|
|
|
|
|
|
name: moduleName,
|
|
|
|
|
|
metricMap: new Map()
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.metricAllData.has(projectName)) {
|
|
|
|
|
|
this.metricAllData.get(projectName).push(moduleItem)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const moduleList = []
|
|
|
|
|
|
moduleList.push(moduleItem)
|
|
|
|
|
|
this.metricAllData.set(projectName, moduleList)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const metricCascaderArr = []
|
|
|
|
|
|
cascaderMap.forEach(function (value, index) {
|
|
|
|
|
|
const option = {
|
|
|
|
|
|
value: index + '_par',
|
|
|
|
|
|
label: index,
|
|
|
|
|
|
children: value
|
|
|
|
|
|
}
|
|
|
|
|
|
metricCascaderArr.push(option)
|
|
|
|
|
|
})
|
2020-04-09 21:27:48 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.metricCascaderList = metricCascaderArr
|
2020-02-07 19:57:39 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.metricList = []
|
|
|
|
|
|
this.metricCascaderList = []
|
2020-02-07 19:57:39 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 创建打开
|
2021-03-31 14:20:31 +08:00
|
|
|
|
createData (panelId, elementInfo, unit) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (panelId == -1) {
|
|
|
|
|
|
const p = this.panelData[0]
|
|
|
|
|
|
this.editChart.panelName = p.name
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.panelId = panelId
|
|
|
|
|
|
}
|
|
|
|
|
|
if (elementInfo) {
|
|
|
|
|
|
if (elementInfo.elements.length > 1) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.elements = []
|
|
|
|
|
|
elementInfo.elements.forEach((item, index) => {
|
|
|
|
|
|
this.elements.push(index)
|
|
|
|
|
|
})
|
|
|
|
|
|
const dSet = this.$refs.chartTag
|
2020-02-10 16:50:34 +08:00
|
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
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
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-09-13 10:40:29 +08:00
|
|
|
|
this.iseditChart = false
|
2021-03-31 14:20:31 +08:00
|
|
|
|
this.initInfo(unit) // 初始化图表信息
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// this.editChartModal = true;//????控制弹出框显示和隐藏的,不需要了
|
|
|
|
|
|
this.initOpen() // 获取metric, productId数据
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsUrl () {
|
|
|
|
|
|
this.isUrl = true
|
|
|
|
|
|
this.isSingleStat = false
|
|
|
|
|
|
this.isAlert = false
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsSingleStat () {
|
|
|
|
|
|
this.isUrl = false
|
|
|
|
|
|
this.isSingleStat = true
|
|
|
|
|
|
this.isAlert = false
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsAlertList () {
|
|
|
|
|
|
this.isAlert = true
|
|
|
|
|
|
this.isUrl = false
|
|
|
|
|
|
this.isSingleStat = false
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsOtherChart () {
|
|
|
|
|
|
this.isSingleStat = false
|
|
|
|
|
|
this.isUrl = false
|
|
|
|
|
|
this.isAlert = false
|
2021-04-07 16:41:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
setIsGroup () {
|
|
|
|
|
|
this.isSingleStat = false
|
|
|
|
|
|
this.isUrl = false
|
|
|
|
|
|
this.isAlert = false
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 编辑chart时使用, set_tdata
|
|
|
|
|
|
editData (data, panelId) {
|
|
|
|
|
|
if (!panelId) {
|
|
|
|
|
|
this.panelId = 0
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.panelId = panelId
|
|
|
|
|
|
}
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (data.id) {
|
|
|
|
|
|
this.iseditChart = true
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editInfo = data
|
|
|
|
|
|
// 图表信息获取
|
|
|
|
|
|
this.editChart.id = data.id
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.editChart.name = data.name
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editChart.span = data.span
|
2021-05-17 22:31:14 +08:00
|
|
|
|
this.editChart.height = data.height
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editChart.type = data.type
|
|
|
|
|
|
this.editChart.unit = data.unit
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.editChart.remark = data.remark
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editChart.elements = data.elements
|
|
|
|
|
|
if (this.editChart.type === 'url') {
|
|
|
|
|
|
this.editChart.param.url = data.param.url
|
|
|
|
|
|
this.setIsUrl()
|
|
|
|
|
|
// this.elements = [1];
|
|
|
|
|
|
} else if (this.editChart.type === 'table') {
|
|
|
|
|
|
this.statisticsList = JSON.parse(JSON.stringify(this.$CONSTANTS.statisticsList))
|
|
|
|
|
|
this.statisticsList.push({ value: 'null', label: i18n.t('dashboard.panel.chartForm.statisticsVal.null') })
|
|
|
|
|
|
} else if (this.editChart.type === 'alertList') {
|
|
|
|
|
|
this.editChart.param = data.param
|
|
|
|
|
|
this.setIsAlertList()
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.alertParamBox.setData(data)
|
|
|
|
|
|
})
|
|
|
|
|
|
// this.elements=[1];
|
|
|
|
|
|
} else if (this.editChart.type === 'singleStat') {
|
|
|
|
|
|
this.setIsSingleStat()
|
2021-04-07 19:18:22 +08:00
|
|
|
|
} else if (this.editChart.type === 'group') {
|
|
|
|
|
|
this.setIsGroup()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
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
|
2021-04-08 17:49:07 +08:00
|
|
|
|
if (this.editChart.type === 'bar') {
|
2021-04-09 17:04:30 +08:00
|
|
|
|
this.statisticsList = JSON.parse(JSON.stringify(this.$CONSTANTS.statisticsList))
|
2021-04-08 17:49:07 +08:00
|
|
|
|
this.statisticsList.push({ value: 'null', label: i18n.t('dashboard.panel.chartForm.statisticsVal.null') })
|
|
|
|
|
|
}
|
2020-07-08 21:39:43 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editChart.param.threshold = ''
|
2020-07-08 21:39:43 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if ((this.editChart.type === 'line' || this.editChart.type === 'bar' || this.editChart.type === 'stackArea') && data.param) {
|
|
|
|
|
|
this.editChart.param.nullType = data.param.nullType
|
|
|
|
|
|
}
|
|
|
|
|
|
this.setIsOtherChart()
|
|
|
|
|
|
// this.getSuggestMetric();//获得指标列表
|
|
|
|
|
|
// 指标
|
|
|
|
|
|
/* 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]);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}); */
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 初始化信息
|
2021-03-31 14:20:31 +08:00
|
|
|
|
initInfo (unit) {
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.editChart.name = ''
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editChart.type = 'line'
|
|
|
|
|
|
this.editChart.span = 12
|
2021-05-17 22:31:14 +08:00
|
|
|
|
this.editChart.height = 4
|
2021-03-31 14:20:31 +08:00
|
|
|
|
this.editChart.unit = unit || 2
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.editChart.remark = ''
|
2021-04-08 17:49:07 +08:00
|
|
|
|
this.editChart.groupId = this.editChart.groupId || ''
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const param = {}
|
|
|
|
|
|
param.last = 0
|
|
|
|
|
|
param.url = ''
|
|
|
|
|
|
param.threshold = ''
|
|
|
|
|
|
param.valueMapping = { type: 'text', mapping: [{ value: '', text: '', color: { bac: '#fff', text: '#000' } }] }
|
|
|
|
|
|
param.legendValue = { min: 'off', max: 'off', avg: 'off', last: 'off', total: 'off' }
|
2021-04-08 18:45:58 +08:00
|
|
|
|
param.nullType = 'null'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$set(this.editChart, 'param', param)
|
|
|
|
|
|
this.elements = [1]
|
|
|
|
|
|
this.elementTarget = []
|
|
|
|
|
|
bus.chartAddInfo.metricTarget = []
|
|
|
|
|
|
this.setIsOtherChart()
|
|
|
|
|
|
},
|
|
|
|
|
|
// 创建时打开,用于清空chart-tag数据
|
|
|
|
|
|
initOpen () {
|
|
|
|
|
|
// bus.$emit('clear_history');
|
|
|
|
|
|
/* 项目不需要produce
|
2020-01-03 17:17:09 +08:00
|
|
|
|
if (this.$route.params.productId) {
|
|
|
|
|
|
this.productId = parseInt(this.$route.params.productId, 10);
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// this.getSuggestMetric();
|
|
|
|
|
|
},
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* metric部分相关方法--end */
|
|
|
|
|
|
querySearch (queryString, cb) {
|
|
|
|
|
|
const suggestions = this.heightSuggestions
|
|
|
|
|
|
const results = queryString && (suggestions.includes(queryString) || suggestions.filter(this.createFilter(queryString)).length > 0) ? suggestions : []
|
|
|
|
|
|
cb(results)
|
|
|
|
|
|
},
|
|
|
|
|
|
createFilter (queryString) {
|
|
|
|
|
|
return (suggestion) => {
|
|
|
|
|
|
return (suggestion.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
handleSelect: function (item) {
|
|
|
|
|
|
this.editChart.height = item
|
|
|
|
|
|
},
|
|
|
|
|
|
unitSelected: function (value) {
|
|
|
|
|
|
// this.editChart.unit=value[value.length-1];
|
|
|
|
|
|
},
|
|
|
|
|
|
chartTypeChange () {
|
|
|
|
|
|
const chartType = this.editChart.type
|
2021-09-13 14:23:32 +08:00
|
|
|
|
// this.editChart.param.url = ''
|
2021-05-17 22:31:14 +08:00
|
|
|
|
this.editChart.height = 4
|
2021-09-03 11:10:24 +08:00
|
|
|
|
this.promqlType = 'metric'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (chartType === 'url') {
|
|
|
|
|
|
this.setIsUrl()
|
|
|
|
|
|
/* if(this.$refs.chartTag){
|
2020-05-07 21:02:09 +08:00
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {
|
|
|
|
|
|
item.setNotSingleStat();
|
|
|
|
|
|
});
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} */
|
|
|
|
|
|
} else if (chartType === 'alertList') {
|
|
|
|
|
|
this.setIsAlertList()
|
|
|
|
|
|
} else if (chartType === 'singleStat' || chartType === 'pie') {
|
|
|
|
|
|
if (chartType == 'singleStat') {
|
|
|
|
|
|
this.setIsSingleStat()
|
|
|
|
|
|
this.resetElements()
|
|
|
|
|
|
}
|
|
|
|
|
|
this.editChart.param = {
|
|
|
|
|
|
statistics: 'last',
|
|
|
|
|
|
valueMapping: {
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
mapping: [{ text: '', value: '', color: { bac: '#fff', text: '#000' } }]
|
2020-09-17 11:17:51 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.showPicker = [{ bac: false, text: false }]
|
2021-04-07 16:41:11 +08:00
|
|
|
|
} else if (chartType === 'group') {
|
|
|
|
|
|
this.editChart.span = 12
|
2021-05-17 22:31:14 +08:00
|
|
|
|
this.editChart.height = 6
|
2021-04-07 16:41:11 +08:00
|
|
|
|
this.setIsGroup()
|
2021-06-29 14:10:41 +08:00
|
|
|
|
} else if (chartType === 'diagram') {
|
|
|
|
|
|
this.editChart.param = {
|
|
|
|
|
|
lock: 0,
|
|
|
|
|
|
align: 'center',
|
|
|
|
|
|
topo: {}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.setIsOtherChart()
|
|
|
|
|
|
if (chartType === 'bar' || chartType === 'line' || chartType === 'stackArea') {
|
2021-04-08 18:45:58 +08:00
|
|
|
|
this.editChart.param = { nullType: 'null', threshold: '', legendValue: { min: 'off', max: 'off', avg: 'off', last: 'off', total: 'off' } }
|
2021-04-08 17:49:07 +08:00
|
|
|
|
if (chartType === 'bar') {
|
2021-04-08 18:45:58 +08:00
|
|
|
|
this.editChart.param = { statistics: 'last', nullType: 'null', threshold: '', legendValue: { min: 'off', max: 'off', avg: 'off', last: 'off', total: 'off' } }
|
2021-04-08 17:49:07 +08:00
|
|
|
|
this.statisticsList = JSON.parse(JSON.stringify(this.$CONSTANTS.statisticsList))
|
|
|
|
|
|
this.statisticsList.push({ value: 'null', label: i18n.t('dashboard.panel.chartForm.statisticsVal.null') })
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else if (chartType == 'table') {
|
|
|
|
|
|
this.$set(this.editChart.param, 'last', 0)
|
|
|
|
|
|
this.editChart.param = {
|
|
|
|
|
|
statistics: 'last',
|
2021-04-08 18:45:58 +08:00
|
|
|
|
nullType: 'null',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
valueMapping: {
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
mapping: [{ text: '', value: '', color: { bac: '#fff', text: '#000' } }]
|
2020-11-17 10:00:39 +08:00
|
|
|
|
}
|
2020-05-26 18:29:53 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.showPicker = [{ bac: false, text: false }]
|
|
|
|
|
|
this.statisticsList = JSON.parse(JSON.stringify(this.$CONSTANTS.statisticsList))
|
|
|
|
|
|
this.statisticsList.push({ value: 'null', label: i18n.t('dashboard.panel.chartForm.statisticsVal.null') })
|
2021-09-03 11:10:24 +08:00
|
|
|
|
} else if (chartType == 'logs') {
|
|
|
|
|
|
this.promqlType = 'log'
|
2021-09-03 11:39:16 +08:00
|
|
|
|
this.editChart.param = {
|
|
|
|
|
|
time: true,
|
|
|
|
|
|
descending: true,
|
|
|
|
|
|
wrapLines: true,
|
2021-09-23 10:51:53 +08:00
|
|
|
|
limit: 100
|
2021-09-03 11:39:16 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
/* if(this.$refs.chartTag){
|
2020-05-07 21:02:09 +08:00
|
|
|
|
this.$refs.chartTag.forEach((item, index) => {
|
|
|
|
|
|
item.setNotSingleStat();
|
|
|
|
|
|
});
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} */
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
resetElements () {
|
|
|
|
|
|
this.promqlKeys = ['']
|
|
|
|
|
|
this.expressions = ['']
|
|
|
|
|
|
this.legends = []
|
|
|
|
|
|
this.elementIds = []
|
|
|
|
|
|
},
|
2020-03-12 17:30:29 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// preview -start
|
|
|
|
|
|
// 预览图表
|
|
|
|
|
|
preview () {
|
|
|
|
|
|
// 验证图表数据是否合法??,合法了再显示预览窗口
|
|
|
|
|
|
this.elementTarget = [] // 初始化清空参数
|
|
|
|
|
|
this.alertParams = {}
|
|
|
|
|
|
if (this.editChart.type !== 'url' && this.editChart.type !== 'text') {
|
|
|
|
|
|
if (this.editChart.type == 'alertList') {
|
|
|
|
|
|
this.$refs.alertParamBox.saveParam('preview')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
/* this.$refs.chartTag.forEach((item, index) => {//循环指标列表
|
2020-05-28 17:32:23 +08:00
|
|
|
|
// 触发每个tag组件内部进行校验
|
|
|
|
|
|
item.saveTarget(index,'preview');
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}); */
|
2020-04-14 21:46:38 +08:00
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
2021-04-12 11:27:44 +08:00
|
|
|
|
let params = {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// productId: this.productId,
|
|
|
|
|
|
// panelId: this.panelId,
|
2021-04-07 11:21:12 +08:00
|
|
|
|
name: this.editChart.name, // this.editChart
|
2020-07-30 18:37:04 +08:00
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
unit: this.editChart.unit,
|
|
|
|
|
|
param: this.editChart.param,
|
2021-04-07 11:21:12 +08:00
|
|
|
|
sync: this.editChart.sync,
|
|
|
|
|
|
remark: this.editChart.remark,
|
2021-04-23 18:10:25 +08:00
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
2020-10-20 20:53:21 +08:00
|
|
|
|
}
|
2021-04-12 11:27:44 +08:00
|
|
|
|
params = JSON.parse(JSON.stringify(params))
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.editChart.type === 'singleStat' || this.editChart.type === 'table') {
|
|
|
|
|
|
// params.param.statistics=this.statistics;
|
|
|
|
|
|
params.param.valueMapping = this.editChart.param.valueMapping
|
2020-10-21 12:00:30 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.editChart.type != 'singleStat' && this.editChart.type != 'pie' && this.editChart.type != 'table') {
|
|
|
|
|
|
delete params.param.statistics
|
|
|
|
|
|
}
|
2021-04-15 11:47:44 +08:00
|
|
|
|
if (this.editChart.type === 'bar' && this.editChart.param.statistics && this.editChart.param.statistics !== 'null') {
|
2021-04-12 10:53:21 +08:00
|
|
|
|
params.param.statistics = this.editChart.param.statistics
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.editChart.type === 'line' || this.editChart.type === 'bar' || this.editChart.type === 'stackArea' || this.editChart.type === 'table') {
|
|
|
|
|
|
params.param.threshold = this.editChart.param.threshold
|
|
|
|
|
|
if (this.editChart.type === 'table') {
|
|
|
|
|
|
delete params.param.threshold
|
|
|
|
|
|
params.param.valueMapping = this.editChart.param.valueMapping
|
2020-10-20 20:53:21 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.param.nullType = this.editChart.param.nullType
|
|
|
|
|
|
params.param.legendValue = this.editChart.param.legendValue
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete params.param.threshold
|
|
|
|
|
|
delete params.param.nullType
|
|
|
|
|
|
}
|
|
|
|
|
|
// 生成指标数组
|
|
|
|
|
|
const elements = []
|
|
|
|
|
|
this.expressions.forEach((expr, index) => {
|
|
|
|
|
|
elements.push({
|
|
|
|
|
|
expression: expr,
|
|
|
|
|
|
type: 'expert',
|
|
|
|
|
|
legend: this.legends[index]
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
params.elements = elements
|
2020-04-14 21:46:38 +08:00
|
|
|
|
if (valid) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.chartsPreview.show(params)
|
2020-04-14 21:46:38 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
2020-07-02 20:10:16 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else if (this.editChart.type == 'url') {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const params = {
|
2021-04-07 11:21:12 +08:00
|
|
|
|
name: this.editChart.name, // this.editChart
|
2021-03-19 18:52:19 +08:00
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit: this.editChart.unit,
|
|
|
|
|
|
param: {
|
|
|
|
|
|
url: this.editChart.param.url
|
2021-04-07 11:21:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
remark: this.editChart.remark,
|
2021-04-23 18:10:25 +08:00
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
2020-08-06 17:48:07 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (valid) {
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.id = this.editChart.id
|
2020-07-02 20:10:16 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.chartsPreview.show(params)
|
2020-12-04 15:24:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$refs.chartForm.validate((valid) => {
|
|
|
|
|
|
const text = this.$refs.richTextEditor.getContent()
|
|
|
|
|
|
if (!text) {
|
|
|
|
|
|
valid = false
|
|
|
|
|
|
}
|
|
|
|
|
|
const params = {
|
2021-04-07 11:21:12 +08:00
|
|
|
|
name: this.editChart.name, // this.editChart
|
2021-03-19 18:52:19 +08:00
|
|
|
|
span: this.editChart.span,
|
|
|
|
|
|
height: this.editChart.height,
|
|
|
|
|
|
type: this.editChart.type,
|
|
|
|
|
|
unit: this.editChart.unit,
|
|
|
|
|
|
param: {
|
|
|
|
|
|
text: text
|
2021-04-07 11:21:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
remark: this.editChart.remark,
|
2021-04-23 18:10:25 +08:00
|
|
|
|
groupId: this.editChart.groupId,
|
|
|
|
|
|
varType: this.editChart.varType
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (valid) {
|
2021-09-13 10:40:29 +08:00
|
|
|
|
if (this.iseditChart) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
params.id = this.editChart.id
|
2020-11-22 16:51:30 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.chartsPreview.show(params)
|
2020-11-22 16:51:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-11-24 17:31:40 +08:00
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// preview--end
|
|
|
|
|
|
initElements () {
|
|
|
|
|
|
if (!this.editChart.elements || this.editChart.elements.length == 0) {
|
|
|
|
|
|
this.editChart.elements = [{ expression: '', legend: '', type: 'expert', id: '' }]
|
|
|
|
|
|
}
|
|
|
|
|
|
this.editChart.elements.forEach(element => {
|
|
|
|
|
|
if (element && element != '') {
|
|
|
|
|
|
this.promqlKeys.push(getUUID())
|
|
|
|
|
|
this.expressions.push(element.expression)
|
|
|
|
|
|
this.legends.push(element.legend)
|
|
|
|
|
|
this.elementIds.push(element.id)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.promqlCount = this.editChart.elements.length
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.expressions.forEach((ex, index) => {
|
|
|
|
|
|
if (ex) {
|
2021-05-13 19:09:25 +08:00
|
|
|
|
// this.$refs[`promql-${index}`][0].metricChange(ex)
|
2020-09-29 09:45:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
valueMappingChange: function (value) {
|
|
|
|
|
|
if (this.editChart.param.valueMapping.type == 'value') {
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping = [{ text: '', value: '', color: { bac: '#fff', text: '#000' } }]
|
|
|
|
|
|
this.showPicker = [{ bac: false, text: false }]
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping = [{ from: '', to: '', text: '', color: { bac: '#fff', text: '#000' } }]
|
|
|
|
|
|
this.showPicker = [{ bac: false, text: false }]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
addMapping: function () {
|
|
|
|
|
|
if (this.editChart.param.valueMapping.type == 'value') {
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping.push({ text: '', value: '', color: { bac: '#fff', text: '#000' } })
|
|
|
|
|
|
this.showPicker.push({ bac: false, text: false })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping.push({ from: '', to: '', text: '', color: { bac: '#fff', text: '#000' } })
|
|
|
|
|
|
this.showPicker.push({ bac: false, text: false })
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
colorPickerClick (index) {
|
|
|
|
|
|
if (this.showPicker[index].bac || this.showPicker[index].text) { // 再次点击关闭
|
|
|
|
|
|
this.showPicker[index].bac = false
|
|
|
|
|
|
this.showPicker[index].text = false
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.showPicker[index].bac = true
|
|
|
|
|
|
this.$refs['colorPickerBac' + index][0].showPicker = true
|
|
|
|
|
|
},
|
|
|
|
|
|
changeShowPicker (index, atr) {
|
|
|
|
|
|
this.$refs['colorPickerBac' + index][0].showPicker = true
|
|
|
|
|
|
this.showPicker[index].bac = false
|
|
|
|
|
|
this.showPicker[index].text = false
|
|
|
|
|
|
this.showPicker[index][atr] = true
|
|
|
|
|
|
// atr=atr.toLowerCase().replace(/( |^)[a-z]/g,(L)=>L.toUpperCase());
|
|
|
|
|
|
},
|
|
|
|
|
|
colorChange (mapping, key, val) {
|
|
|
|
|
|
mapping.color[key] = val
|
|
|
|
|
|
},
|
|
|
|
|
|
colorRGBtoHex (color) {
|
|
|
|
|
|
const rgb = color.split(',')
|
|
|
|
|
|
const r = parseInt(rgb[0].split('(')[1])
|
|
|
|
|
|
const g = parseInt(rgb[1])
|
|
|
|
|
|
const b = parseInt(rgb[2].split(')')[0])
|
|
|
|
|
|
const hex = '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)
|
|
|
|
|
|
return hex
|
|
|
|
|
|
},
|
|
|
|
|
|
colorOut (index, e) {
|
|
|
|
|
|
let flag = false
|
|
|
|
|
|
e.path.forEach((item) => {
|
|
|
|
|
|
if (item.className === 'el-color-dropdown el-color-picker__panel' || item.className === 'color-tab') {
|
|
|
|
|
|
flag = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.showPicker[index]) {
|
|
|
|
|
|
this.showPicker[index].bac = false
|
|
|
|
|
|
this.showPicker[index].text = false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
delMapping: function (index) {
|
|
|
|
|
|
this.editChart.param.valueMapping.mapping.splice(index, 1)
|
|
|
|
|
|
},
|
2021-06-29 14:10:41 +08:00
|
|
|
|
topologyDialogChange (flag, data) {
|
|
|
|
|
|
this.topologyDialog = flag
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
this.editChart.param.topo = data
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created () {
|
|
|
|
|
|
this.getSuggestMetric()
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
chart: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
2021-07-15 11:56:25 +08:00
|
|
|
|
this.isEdit = true
|
2021-07-05 11:47:29 +08:00
|
|
|
|
if (n.id) {
|
2021-07-07 14:30:27 +08:00
|
|
|
|
if (!n.param.state && n.param.state != Number) {
|
2021-07-15 11:56:25 +08:00
|
|
|
|
n.param.state = '1'
|
2021-07-07 14:30:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (n.param.severity && n.param.severity != Number) {
|
|
|
|
|
|
n.param.severity = 1
|
|
|
|
|
|
}
|
2021-07-05 11:47:29 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if ((n.param && n.param.valueMapping) && (n.type === 'singleStat' || n.type === 'table')) {
|
|
|
|
|
|
n.param.valueMapping.mapping.forEach(item => {
|
|
|
|
|
|
this.showPicker.push({ bac: false, text: false })
|
|
|
|
|
|
if (!item.color) {
|
|
|
|
|
|
item.color = { bac: '#fff', text: '#000' }
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-04-07 11:21:12 +08:00
|
|
|
|
if (n.name) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.isEdit = true
|
|
|
|
|
|
}
|
2021-04-07 11:21:12 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editChart = JSON.parse(JSON.stringify(n))
|
2021-04-23 18:10:25 +08:00
|
|
|
|
if (this.editChart.panelId === 0 && !this.editChart.varType) {
|
|
|
|
|
|
this.editChart.varType = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-08 17:49:07 +08:00
|
|
|
|
this.panelName = this.editChart.panelName
|
|
|
|
|
|
this.panelId = this.editChart.panelId
|
2021-04-07 16:41:11 +08:00
|
|
|
|
this.editChart.name = this.editChart.name || ''
|
2021-04-07 11:21:12 +08:00
|
|
|
|
if (!n.groupId || n.groupId == -1) {
|
|
|
|
|
|
this.editChart.groupId = ''
|
|
|
|
|
|
}
|
2021-04-07 16:41:11 +08:00
|
|
|
|
if (typeof (this.editChart.param) === 'string') {
|
|
|
|
|
|
this.editChart.param = JSON.parse(this.editChart.param)
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (!n.param.nullType) {
|
2021-04-08 18:45:58 +08:00
|
|
|
|
this.editChart.param.nullType = 'null'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (n.type === 'url') {
|
|
|
|
|
|
this.setIsUrl()
|
|
|
|
|
|
} else if (n.type === 'alertList') {
|
|
|
|
|
|
this.setIsAlertList()
|
|
|
|
|
|
} else if (n.type === 'singleStat') {
|
|
|
|
|
|
if (n.param && !n.param.valueMapping) {
|
|
|
|
|
|
this.$set(this.editChart.param, 'valueMapping', { type: 'value', mapping: [{ text: '', value: '', color: { bac: '#fff', text: '#000' } }] })
|
|
|
|
|
|
this.showPicker.push({ bac: false, text: false })
|
2020-08-05 20:58:24 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.setIsSingleStat()
|
|
|
|
|
|
} else if (n.type === 'table') {
|
|
|
|
|
|
n.param.last ? this.$set(this.editChart.param, 'last', n.param.last) : this.$set(this.editChart.param, 'last', 0)
|
|
|
|
|
|
if (n.param && !n.param.valueMapping) {
|
|
|
|
|
|
this.$set(this.editChart.param, 'valueMapping', { type: 'value', mapping: [{ text: '', value: '', color: { bac: '#fff', text: '#000' } }] })
|
|
|
|
|
|
this.showPicker.push({ bac: false, text: false })
|
2020-07-30 18:37:04 +08:00
|
|
|
|
}
|
2021-04-07 19:18:22 +08:00
|
|
|
|
} else if (n.type === 'group') {
|
|
|
|
|
|
this.setIsGroup()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.setIsOtherChart()
|
|
|
|
|
|
n.param && !n.param.legendValue && this.$set(this.editChart.param, 'legendValue', { min: 'off', max: 'off', avg: 'off', last: 'off', total: 'off' })
|
|
|
|
|
|
}
|
2021-09-03 11:39:16 +08:00
|
|
|
|
if (n.type === 'logs') {
|
|
|
|
|
|
this.promqlType = 'log'
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$set(this.editChart, 'panelName', this.showPanel.name)
|
2021-05-17 20:31:32 +08:00
|
|
|
|
if (this.showPanel.id || this.from === 'chartTemp') {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.panelId = this.showPanel.id
|
|
|
|
|
|
}
|
2021-04-25 14:58:03 +08:00
|
|
|
|
this.$get('visual/panel/chart?panelId=' + this.panelId + '&pageSize=-1').then(response => {
|
2021-04-07 16:41:11 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.groupArr = []
|
|
|
|
|
|
response.data.list.forEach((item, index) => {
|
|
|
|
|
|
if (item.type === 'group') {
|
|
|
|
|
|
this.groupArr.push({ id: item.id, name: item.name })
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-04-07 19:18:22 +08:00
|
|
|
|
if (n.id || n.name) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editData(this.editChart, this.showPanel.id)
|
|
|
|
|
|
} else {
|
2021-03-31 14:20:31 +08:00
|
|
|
|
this.createData(this.showPanel.id, '', n.unit)
|
2020-07-30 18:37:04 +08:00
|
|
|
|
}
|
2021-06-29 14:10:41 +08:00
|
|
|
|
if (this.editChart.param && !this.editChart.param.statistics) {
|
2021-06-08 14:01:16 +08:00
|
|
|
|
this.editChart.param.statistics = 'null'
|
|
|
|
|
|
}
|
2020-04-09 21:27:48 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
|
if (this.$refs.chartTag) {
|
|
|
|
|
|
this.$refs.chartTag.forEach((item, index) => { // 循环指标列表
|
|
|
|
|
|
item.clearSelectedTagList()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
this.isUrl = false
|
2020-01-03 17:17:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +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-12-04 15:24:59 +08:00
|
|
|
|
.el-color-picker__panel{
|
|
|
|
|
|
border-radius: 0 0 5px 5px;
|
|
|
|
|
|
}
|
2020-12-17 09:46:47 +08:00
|
|
|
|
.el-color-dropdown{
|
|
|
|
|
|
z-index: 2200!important;
|
|
|
|
|
|
}
|
2020-02-17 18:41:38 +08:00
|
|
|
|
</style>
|