Unverified Commit 5d87ce9c authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Fix] Fix compatibility issues with MySQL stored procedures (#3594)

parent d33d97f6
...@@ -15,7 +15,7 @@ SET FOREIGN_KEY_CHECKS = 0; ...@@ -15,7 +15,7 @@ SET FOREIGN_KEY_CHECKS = 0;
DELIMITER $$ DELIMITER $$
DROP PROCEDURE IF EXISTS add_column_if_not_exists$$ DROP PROCEDURE IF EXISTS add_column_if_not_exists$$
CREATE PROCEDURE if not exists add_column_if_not_exists(IN tableName VARCHAR(64), IN columnName VARCHAR(64), IN columnDefinitionType VARCHAR(64), IN columnDefinitionDefaultValue VARCHAR(128), IN columnDefinitionComment VARCHAR(255), in afterColumnName VARCHAR(64)) CREATE PROCEDURE add_column_if_not_exists(IN tableName VARCHAR(64), IN columnName VARCHAR(64), IN columnDefinitionType VARCHAR(64), IN columnDefinitionDefaultValue VARCHAR(128), IN columnDefinitionComment VARCHAR(255), in afterColumnName VARCHAR(64))
BEGIN BEGIN
IF NOT EXISTS ( IF NOT EXISTS (
SELECT * SELECT *
......
...@@ -22,7 +22,7 @@ import { ClusterType } from '@/pages/RegCenter/Cluster/constants'; ...@@ -22,7 +22,7 @@ import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { CheckboxOptionType } from 'antd/es/checkbox/Group'; import { CheckboxOptionType } from 'antd/es/checkbox/Group';
import { DefaultOptionType } from 'antd/es/select'; import { DefaultOptionType } from 'antd/es/select';
import {RUN_MODE} from "@/services/constants"; import { RUN_MODE } from '@/services/constants';
export enum RuleType { export enum RuleType {
SYSTEM = 'SYSTEM', SYSTEM = 'SYSTEM',
...@@ -41,19 +41,19 @@ export const TriggerType: CheckboxOptionType[] = [ ...@@ -41,19 +41,19 @@ export const TriggerType: CheckboxOptionType[] = [
]; ];
export const AllRuleOperator: DefaultOptionType[] = [ export const AllRuleOperator: DefaultOptionType[] = [
{ label: '>', value: 'GT' , key: 'GT'}, { label: '>', value: 'GT', key: 'GT' },
{ label: '<', value: 'LT' , key: 'LT' }, { label: '<', value: 'LT', key: 'LT' },
{ label: '=', value: 'EQ' , key: 'EQ' }, { label: '=', value: 'EQ', key: 'EQ' },
{ label: '!=', value: 'NE' , key: 'NE' }, { label: '!=', value: 'NE', key: 'NE' },
{ label: '>=', value: 'GE' , key: 'GE' }, { label: '>=', value: 'GE', key: 'GE' },
{ label: '<=', value: 'LE' , key: 'LE'} { label: '<=', value: 'LE', key: 'LE' }
]; ];
export const EqRuleOperator: DefaultOptionType[] = [{ label: '=', value: 'EQ' , key: 'EQ' }]; export const EqRuleOperator: DefaultOptionType[] = [{ label: '=', value: 'EQ', key: 'EQ' }];
export const BOOLEAN_VALUE_ENUM: DefaultOptionType[] = [ export const BOOLEAN_VALUE_ENUM: DefaultOptionType[] = [
{ label: 'True', value: 'true' , key: 'true' }, { label: 'True', value: 'true', key: 'true' },
{ label: 'False', value: 'false' , key: 'false' } { label: 'False', value: 'false', key: 'false' }
]; ];
export const AlertRules: any = { export const AlertRules: any = {
......
...@@ -34,7 +34,7 @@ export const AlertRulesOption = () => { ...@@ -34,7 +34,7 @@ export const AlertRulesOption = () => {
// @ts-ignore // @ts-ignore
label: v.label, label: v.label,
value: k, value: k,
key: k, key: k
}); });
} }
return res; return res;
...@@ -77,7 +77,7 @@ export const buildValueItem = (key: string, isSystem: boolean) => { ...@@ -77,7 +77,7 @@ export const buildValueItem = (key: string, isSystem: boolean) => {
disabled={isSystem} disabled={isSystem}
fieldProps={{ fieldProps={{
defaultActiveFirstOption: true, defaultActiveFirstOption: true,
showSearch: true, showSearch: true
}} }}
name='ruleValue' name='ruleValue'
mode={'single'} mode={'single'}
......
...@@ -17,20 +17,23 @@ ...@@ -17,20 +17,23 @@
* *
*/ */
import {Authorized} from '@/hooks/useAccess'; import { Authorized } from '@/hooks/useAccess';
import {RuleType, TriggerType} from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants'; import {
RuleType,
TriggerType
} from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants';
import { import {
AlertRulesOption, AlertRulesOption,
buildValueItem, buildValueItem,
getOperatorOptions getOperatorOptions
} from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/function'; } from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/function';
import {getData} from '@/services/api'; import { getData } from '@/services/api';
import {SWITCH_OPTIONS} from '@/services/constants'; import { SWITCH_OPTIONS } from '@/services/constants';
import {API_CONSTANTS} from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import {Alert} from '@/types/RegCenter/data'; import { Alert } from '@/types/RegCenter/data';
import {AlertRule, AlertRuleCondition} from '@/types/SettingCenter/data'; import { AlertRule, AlertRuleCondition } from '@/types/SettingCenter/data';
import {l} from '@/utils/intl'; import { l } from '@/utils/intl';
import { import {
DrawerForm, DrawerForm,
ProCard, ProCard,
...@@ -43,10 +46,10 @@ import { ...@@ -43,10 +46,10 @@ import {
ProFormText, ProFormText,
ProFormTextArea ProFormTextArea
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import {ProFormDependency} from '@ant-design/pro-form'; import { ProFormDependency } from '@ant-design/pro-form';
import {Button, Divider, Form, Space, Typography} from 'antd'; import { Button, Divider, Form, Space, Typography } from 'antd';
const {Link} = Typography; const { Link } = Typography;
type AlertRuleFormProps = { type AlertRuleFormProps = {
onCancel: (flag?: boolean) => void; onCancel: (flag?: boolean) => void;
...@@ -56,7 +59,7 @@ type AlertRuleFormProps = { ...@@ -56,7 +59,7 @@ type AlertRuleFormProps = {
}; };
const RuleEditForm = (props: AlertRuleFormProps) => { const RuleEditForm = (props: AlertRuleFormProps) => {
const {onSubmit: handleSubmit, onCancel: handleModalVisible, modalVisible, values} = props; const { onSubmit: handleSubmit, onCancel: handleModalVisible, modalVisible, values } = props;
// if is system rule disable edit // if is system rule disable edit
const isSystem = values.ruleType == RuleType.SYSTEM; const isSystem = values.ruleType == RuleType.SYSTEM;
...@@ -65,12 +68,12 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -65,12 +68,12 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
const getAlertTemplate = async () => { const getAlertTemplate = async () => {
const template: Alert.AlertTemplate[] = (await getData(API_CONSTANTS.ALERT_TEMPLATE)).data; const template: Alert.AlertTemplate[] = (await getData(API_CONSTANTS.ALERT_TEMPLATE)).data;
return template.map((t) => ({label: t.name, value: t.id})); return template.map((t) => ({ label: t.name, value: t.id }));
}; };
const submit = async () => { const submit = async () => {
const fieldsValue = await form.validateFields(); const fieldsValue = await form.validateFields();
return handleSubmit({...values,...fieldsValue}); return handleSubmit({ ...values, ...fieldsValue });
}; };
const renderTemplateDropDown = (item: any) => { const renderTemplateDropDown = (item: any) => {
...@@ -79,7 +82,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -79,7 +82,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
{item} {item}
<Authorized key='create' path='/registration/alert/template/add'> <Authorized key='create' path='/registration/alert/template/add'>
<> <>
<Divider style={{margin: '8px 0'}}/> <Divider style={{ margin: '8px 0' }} />
<Link href={'#/registration/alert/template'}>+ {l('rc.alert.template.new')}</Link> <Link href={'#/registration/alert/template'}>+ {l('rc.alert.template.new')}</Link>
</> </>
</Authorized> </Authorized>
...@@ -110,7 +113,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -110,7 +113,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
form={form} form={form}
width={'40%'} width={'40%'}
open={modalVisible} open={modalVisible}
submitter={{render: () => [...renderFooter()]}} submitter={{ render: () => [...renderFooter()] }}
drawerProps={{ drawerProps={{
onClose: () => handleModalVisible(false), onClose: () => handleModalVisible(false),
destroyOnClose: true destroyOnClose: true
...@@ -118,11 +121,11 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -118,11 +121,11 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
initialValues={values} initialValues={values}
> >
<ProFormGroup> <ProFormGroup>
<ProFormText name='id' hidden={true}/> <ProFormText name='id' hidden={true} />
<ProFormText name='ruleType' hidden={true}/> <ProFormText name='ruleType' hidden={true} />
<ProFormText <ProFormText
disabled={isSystem} disabled={isSystem}
rules={[{required: true}]} rules={[{ required: true }]}
name='name' name='name'
width='md' width='md'
label={l('sys.alert.rule.name')} label={l('sys.alert.rule.name')}
...@@ -135,14 +138,14 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -135,14 +138,14 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
name='templateId' name='templateId'
request={async () => getAlertTemplate()} request={async () => getAlertTemplate()}
placeholder={l('sys.alert.rule.template')} placeholder={l('sys.alert.rule.template')}
rules={[{required: true, message: l('sys.alert.rule.template')}]} rules={[{ required: true, message: l('sys.alert.rule.template') }]}
fieldProps={{dropdownRender: (item) => renderTemplateDropDown(item)}} fieldProps={{ dropdownRender: (item) => renderTemplateDropDown(item) }}
/> />
</ProFormGroup> </ProFormGroup>
<ProFormGroup> <ProFormGroup>
<ProFormTextArea width='md' name='description' label={l('global.table.note')}/> <ProFormTextArea width='md' name='description' label={l('global.table.note')} />
<ProFormSwitch name='enabled' {...SWITCH_OPTIONS()} label={l('global.table.isEnable')}/> <ProFormSwitch name='enabled' {...SWITCH_OPTIONS()} label={l('global.table.isEnable')} />
</ProFormGroup> </ProFormGroup>
<Divider orientation={'left'}>{l('sys.alert.rule.trigger')}</Divider> <Divider orientation={'left'}>{l('sys.alert.rule.trigger')}</Divider>
...@@ -151,7 +154,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -151,7 +154,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
disabled={isSystem} disabled={isSystem}
name='triggerConditions' name='triggerConditions'
label={l('sys.alert.rule.triggerConditions')} label={l('sys.alert.rule.triggerConditions')}
rules={[{required: true}]} rules={[{ required: true }]}
options={TriggerType} options={TriggerType}
/> />
......
...@@ -65,7 +65,7 @@ export type AlertRuleCondition = { ...@@ -65,7 +65,7 @@ export type AlertRuleCondition = {
ruleOperator: string; ruleOperator: string;
ruleValue: string; ruleValue: string;
rulePriority?: number; rulePriority?: number;
} };
// ============================ System Settings ============================ // ============================ System Settings ============================
export type Settings = { export type Settings = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment