refactor(系统设置): 监控配置移动到基本页面下
This commit is contained in:
parent
666ecafd65
commit
6f481d9d3a
|
@ -110,7 +110,8 @@ public interface ParamConstants {
|
|||
|
||||
enum BASE implements ParamConstants {
|
||||
URL("base.url"),
|
||||
CONCURRENCY("base.concurrency");
|
||||
CONCURRENCY("base.concurrency"),
|
||||
PROMETHEUS_HOST("base.prometheus.host");
|
||||
|
||||
private String value;
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public class SystemParam {
|
||||
public static final String PROMETHEUS_HOST = "prometheus.host";
|
||||
}
|
|
@ -5,7 +5,6 @@ import io.metersphere.base.domain.SystemParameter;
|
|||
import io.metersphere.base.domain.UserHeader;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.constants.SystemParam;
|
||||
import io.metersphere.controller.request.HeaderRequest;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.ldap.domain.LdapInfo;
|
||||
|
@ -57,11 +56,6 @@ public class SystemParameterController {
|
|||
return SystemParameterService.getBaseInfo();
|
||||
}
|
||||
|
||||
@GetMapping("/prometheus/host")
|
||||
public String getPrometheusInfo() {
|
||||
return SystemParameterService.getValue(SystemParam.PROMETHEUS_HOST);
|
||||
}
|
||||
|
||||
@PostMapping("/system/header")
|
||||
public SystemHeader getHeader(@RequestBody SystemHeader systemHeader) {
|
||||
return SystemParameterService.getHeader(systemHeader.getType());
|
||||
|
|
|
@ -8,4 +8,5 @@ import lombok.Setter;
|
|||
public class BaseSystemConfigDTO {
|
||||
private String url;
|
||||
private String concurrency;
|
||||
private String prometheusHost;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import io.metersphere.base.domain.TestResource;
|
|||
import io.metersphere.base.mapper.LoadTestMapper;
|
||||
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
|
||||
import io.metersphere.commons.constants.SystemParam;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.DateUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -58,7 +58,7 @@ public class MetricQueryService {
|
|||
|
||||
|
||||
public List<MetricData> queryMetricData(MetricRequest metricRequest) {
|
||||
String host = systemParameterService.getValue(SystemParam.PROMETHEUS_HOST);
|
||||
String host = systemParameterService.getValue(ParamConstants.BASE.PROMETHEUS_HOST.getValue());
|
||||
prometheusHost = StringUtils.isNotBlank(host) ? host : "http://ms-prometheus:9090";
|
||||
List<MetricData> metricDataList = new ArrayList<>();
|
||||
long endTime = metricRequest.getEndTime();
|
||||
|
@ -282,7 +282,7 @@ public class MetricQueryService {
|
|||
granularity = data.getGranularity();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage() ,e);
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
return granularity;
|
||||
}
|
||||
|
|
|
@ -233,6 +233,9 @@ public class SystemParameterService {
|
|||
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASE.CONCURRENCY.getValue())) {
|
||||
baseSystemConfigDTO.setConcurrency(param.getParamValue());
|
||||
}
|
||||
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASE.PROMETHEUS_HOST.getValue())) {
|
||||
baseSystemConfigDTO.setPrometheusHost(param.getParamValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseSystemConfigDTO;
|
||||
|
|
|
@ -40,11 +40,22 @@ CREATE TABLE `operating_log` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- add all table create_user
|
||||
ALTER TABLE api_definition ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_module ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_scenario ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_scenario_module ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_scenario_report ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE test_case_node ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE test_case ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_definition
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_module
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_scenario
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_scenario_module
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE api_scenario_report
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE test_case_node
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
ALTER TABLE test_case
|
||||
ADD create_user VARCHAR(100) NULL;
|
||||
|
||||
-- system_parameter
|
||||
UPDATE system_parameter
|
||||
SET param_key = 'base.prometheus.host'
|
||||
WHERE param_key = 'prometheus.host';
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
<el-col>
|
||||
<el-form-item :label="$t('system_config.base.url')" prop="url">
|
||||
<el-input v-model="formInline.url" :placeholder="$t('system_config.base.url_tip')"/>
|
||||
<i>({{$t('commons.examples')}}:https://rdmetersphere.fit2cloud.com)</i>
|
||||
<i>({{ $t('commons.examples') }}:https://rdmetersphere.fit2cloud.com)</i>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('report.max_users')" prop="concurrency">
|
||||
<el-input v-model="formInline.concurrency" :placeholder="$t('report.max_users')"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('system_config.prometheus.host')" prop="prometheusHost">
|
||||
<el-input v-model="formInline.prometheusHost" :placeholder="$t('system_config.prometheus.host_tip')"/>
|
||||
<i>({{ $t('commons.examples') }}:http://ms-prometheus:9090)</i>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
@ -49,6 +53,13 @@ export default {
|
|||
trigger: ['change', 'blur']
|
||||
},
|
||||
],
|
||||
prometheusHost: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t('system_config.prometheus.host_is_null'),
|
||||
trigger: ['change', 'blur']
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -79,6 +90,7 @@ export default {
|
|||
let param = [
|
||||
{paramKey: "base.url", paramValue: this.formInline.url, type: "text", sort: 1},
|
||||
{paramKey: "base.concurrency", paramValue: this.formInline.concurrency, type: "text", sort: 2},
|
||||
{paramKey: "base.prometheus.host", paramValue: this.formInline.prometheusHost, type: "text", sort: 1},
|
||||
];
|
||||
|
||||
this.$refs[formInline].validate(valid => {
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
<template>
|
||||
<div v-loading="result.loading">
|
||||
<el-form :model="formInline" :rules="rules" ref="formInline" class="demo-form-inline"
|
||||
:disabled="show" v-loading="loading" size="small">
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-form-item :label="$t('system_config.prometheus.host')" prop="host">
|
||||
<el-input v-model="formInline.host" :placeholder="$t('system_config.prometheus.host_tip')"/>
|
||||
<i>({{ $t('commons.examples') }}:http://ms-prometheus:9090)</i>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div>
|
||||
<el-button @click="edit" v-if="showEdit" size="small">{{ $t('commons.edit') }}</el-button>
|
||||
<el-button type="success" @click="save('formInline')" v-if="showSave" :disabled="disabledSave" size="small">
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
<el-button @click="cancel" type="info" v-if="showCancel" size="small">{{ $t('commons.cancel') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "PrometheusSetting",
|
||||
data() {
|
||||
return {
|
||||
formInline: {host: ''},
|
||||
input: '',
|
||||
visible: true,
|
||||
result: {},
|
||||
showEdit: true,
|
||||
showSave: false,
|
||||
showCancel: false,
|
||||
show: true,
|
||||
disabledSave: false,
|
||||
loading: false,
|
||||
rules: {
|
||||
host: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t('system_config.prometheus.host_is_null'),
|
||||
trigger: ['change', 'blur']
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.query()
|
||||
},
|
||||
methods: {
|
||||
query() {
|
||||
this.result = this.$get("/system/prometheus/host", response => {
|
||||
this.formInline.host = response.data;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.formInline.clearValidate();
|
||||
})
|
||||
})
|
||||
},
|
||||
edit() {
|
||||
this.showEdit = false;
|
||||
this.showSave = true;
|
||||
this.showCancel = true;
|
||||
this.show = false;
|
||||
},
|
||||
save(formInline) {
|
||||
this.showEdit = true;
|
||||
this.showCancel = false;
|
||||
this.showSave = false;
|
||||
this.show = true;
|
||||
let param = [
|
||||
{paramKey: "prometheus.host", paramValue: this.formInline.host, type: "text", sort: 1},
|
||||
];
|
||||
|
||||
this.$refs[formInline].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post("/system/save/base", param, response => {
|
||||
if (response.success) {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
} else {
|
||||
this.$message.error(this.$t('commons.save_failed'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
},
|
||||
cancel() {
|
||||
this.showEdit = true;
|
||||
this.showCancel = false;
|
||||
this.showSave = false;
|
||||
this.show = true;
|
||||
this.query();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.el-form {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -11,9 +11,6 @@
|
|||
<el-tab-pane :label="$t('system_parameter_setting.ldap_setting')" name="ldap">
|
||||
<ldap-setting/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('system_config.prometheus_config')" name="prometheus">
|
||||
<prometheus-setting/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="hasLicense()" :label="$t('display.title')" name="display">
|
||||
<ms-display/>
|
||||
</el-tab-pane>
|
||||
|
@ -32,7 +29,6 @@ import EmailSetting from "./EmailSetting";
|
|||
import LdapSetting from "./LdapSetting";
|
||||
import BaseSetting from "./BaseSetting";
|
||||
import {hasLicense} from '@/common/js/utils';
|
||||
import PrometheusSetting from "@/business/components/settings/system/PrometheusSetting";
|
||||
|
||||
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
|
||||
const display = requireComponent.keys().length > 0 ? requireComponent("./display/Display.vue") : {};
|
||||
|
@ -42,7 +38,6 @@ const module = requireComponent.keys().length > 0 ? requireComponent("./module/M
|
|||
export default {
|
||||
name: "SystemParameterSetting",
|
||||
components: {
|
||||
PrometheusSetting,
|
||||
BaseSetting,
|
||||
EmailSetting,
|
||||
LdapSetting,
|
||||
|
|
Loading…
Reference in New Issue