🔨 添加策略类型.
This commit is contained in:
@@ -7,6 +7,7 @@ import axios from 'axios';
|
||||
*/
|
||||
export interface AlarmPolicyCreateRequest {
|
||||
name?: string;
|
||||
type?: string;
|
||||
description?: string;
|
||||
notifyIdList?: Array<number>;
|
||||
}
|
||||
@@ -24,6 +25,7 @@ export interface AlarmPolicyUpdateRequest extends AlarmPolicyCreateRequest {
|
||||
*/
|
||||
export interface AlarmPolicyQueryRequest extends Pagination, OrderDirection {
|
||||
id?: number;
|
||||
type?: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
}
|
||||
@@ -33,6 +35,7 @@ export interface AlarmPolicyQueryRequest extends Pagination, OrderDirection {
|
||||
*/
|
||||
export interface AlarmPolicyQueryResponse extends TableData {
|
||||
id: number;
|
||||
type: string;
|
||||
name: string;
|
||||
description: string;
|
||||
notifyIdList: Array<number>;
|
||||
@@ -73,8 +76,8 @@ export function getAlarmPolicy(id: number) {
|
||||
/**
|
||||
* 查询全部监控告警策略
|
||||
*/
|
||||
export function getAlarmPolicyList() {
|
||||
return axios.get<Array<AlarmPolicyQueryResponse>>('/monitor/alarm-policy/list');
|
||||
export function getAlarmPolicyList(type: string) {
|
||||
return axios.get<Array<AlarmPolicyQueryResponse>>('/monitor/alarm-policy/list', { params: { type } });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
|
||||
const props = withDefaults(defineProps<Partial<{
|
||||
type?: string;
|
||||
}>>(), {
|
||||
type: 'all',
|
||||
});
|
||||
|
||||
const modelValue = defineModel({ type: Number });
|
||||
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -30,7 +36,7 @@
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const values = await cacheStore.loadMonitorAlarmPolicy();
|
||||
const values = await cacheStore.loadMonitorAlarmPolicy(props.type);
|
||||
optionData.value = values.map(s => {
|
||||
return {
|
||||
label: s.name,
|
||||
|
||||
@@ -177,8 +177,8 @@ export default defineStore('cache', {
|
||||
},
|
||||
|
||||
// 查询监控告警策略列表
|
||||
async loadMonitorAlarmPolicy(force = false) {
|
||||
return await this.load('alarmPolicy', getAlarmPolicyList, ['monitor:alarm-policy:query'], force);
|
||||
async loadMonitorAlarmPolicy(type: string = 'all', force = false) {
|
||||
return await this.load(`alarmPolicy_${type}`, () => getAlarmPolicyList(type), ['monitor:alarm-policy:query'], force);
|
||||
},
|
||||
|
||||
// 查询监控指标列表
|
||||
|
||||
@@ -7,7 +7,7 @@ export type CacheType = 'users' | 'menus' | 'roles'
|
||||
| 'authorizedHostKeys' | 'authorizedHostIdentities'
|
||||
| 'commandSnippetGroups' | 'pathBookmarkGroups'
|
||||
| 'commandSnippets' | 'pathBookmarks'
|
||||
| 'alarmPolicy' | 'monitorMetrics'
|
||||
| 'alarmPolicy_*' | 'monitorMetrics'
|
||||
| 'systemSetting' | 'notifyTemplate*'
|
||||
| '*_Tags' | 'preference_*'
|
||||
| string
|
||||
|
||||
@@ -57,8 +57,9 @@
|
||||
import formRules from '../types/form.rules';
|
||||
import { assignOmitRecord } from '@/utils';
|
||||
import { createAlarmPolicy, updateAlarmPolicy, copyAlarmPolicy, getAlarmPolicy } from '@/api/monitor/alarm-policy';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useToggle } from '@vueuse/core';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { AlarmPolicyType } from '../types/const';
|
||||
import NotifyTemplateSelector from '@/components/system/notify-template/selector/index.vue';
|
||||
|
||||
const emits = defineEmits(['added', 'updated']);
|
||||
@@ -75,6 +76,7 @@
|
||||
const defaultForm = (): AlarmPolicyUpdateRequest => {
|
||||
return {
|
||||
id: undefined,
|
||||
type: AlarmPolicyType.HOST,
|
||||
name: undefined,
|
||||
description: undefined,
|
||||
notifyIdList: [],
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { TableName } from '../types/const';
|
||||
import { AlarmPolicyType, TableName } from '../types/const';
|
||||
import { useTablePagination, useTableColumns } from '@/hooks/table';
|
||||
import { useQueryOrder, ASC } from '@/hooks/query-order';
|
||||
import TableAdjust from '@/components/app/table-adjust/index.vue';
|
||||
@@ -161,6 +161,7 @@
|
||||
const tableRenderData = ref<Array<AlarmPolicyQueryResponse>>([]);
|
||||
const formModel = reactive<AlarmPolicyQueryRequest>({
|
||||
id: undefined,
|
||||
type: AlarmPolicyType.HOST,
|
||||
name: undefined,
|
||||
description: undefined,
|
||||
});
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
export const TableName = 'monitor_alarm_policy';
|
||||
|
||||
// 告警策略类型
|
||||
export const AlarmPolicyType = {
|
||||
HOST: 'HOST',
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<!-- 告警策略 -->
|
||||
<a-form-item field="policyId" label="告警策略">
|
||||
<alarm-policy-selector v-model="formModel.policyId"
|
||||
type="HOST"
|
||||
placeholder="请选择告警策略"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
|
||||
Reference in New Issue
Block a user