Skip to content

Commit

Permalink
feature: update schedule job form
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqi committed Nov 26, 2024
1 parent 86836c5 commit 1f98a0d
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.scaleph.common.dict;

import cn.sliew.carp.framework.common.dict.EnumDictRegistry;
import org.apache.commons.lang3.EnumUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DictRegister implements InitializingBean {

@Override
public void afterPropertiesSet() throws Exception {
List<DictType> enumList = EnumUtils.getEnumList(DictType.class);
for (DictType dictType : enumList) {
List values = EnumUtils.getEnumList(dictType.getInstanceClass());
EnumDictRegistry.register(dictType, values);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package cn.sliew.scaleph.common.dict;

import cn.sliew.carp.framework.common.dict.DictDefinition;
import cn.sliew.carp.framework.common.dict.EnumDictRegistry;
import cn.sliew.scaleph.common.dict.catalog.CatalogColumnType;
import cn.sliew.scaleph.common.dict.catalog.CatalogConstraintType;
import cn.sliew.scaleph.common.dict.catalog.CatalogFunctionLanguage;
Expand All @@ -40,10 +39,8 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.EnumUtils;

import java.util.Arrays;
import java.util.List;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum DictType implements DictDefinition {
Expand Down Expand Up @@ -138,14 +135,6 @@ public static DictType of(String code) {
.findAny().orElseThrow(() -> new EnumConstantNotPresentException(DictType.class, code));
}

static {
List<DictType> enumList = EnumUtils.getEnumList(DictType.class);
for (DictType dictType : enumList) {
List values = EnumUtils.getEnumList(dictType.getInstanceClass());
EnumDictRegistry.register(dictType, values);
}
}

@EnumValue
private String code;
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const DataIntegrationSeaTunnelForm: React.FC<ModalFormProps<WsArtifactSeaTunnel>
name: values.name,
remark: values.remark,
};
console.log('values',job, values)
return job.id
? WsArtifactSeaTunnelService.update(job).then((response) => {
if (response.success) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, {useRef} from "react";
import {ProCard, ProFormInstance, StepsForm} from "@ant-design/pro-components";
import {connect, useIntl} from "@umijs/max";
import {connect, useIntl, history} from "@umijs/max";
import {WORKSPACE_CONF} from "@/constants/constant";
import {DataserviceConfig, DataserviceConfigSaveParam} from "@/services/dataservice/typings";
import DataserviceConfigBaseStep from "@/pages/Project/Workspace/DataService/Config/Steps/BaseStepForm";
import DataserviceConfigConfigStep from "@/pages/Project/Workspace/DataService/Config/Steps/ConfigStepForm";
import {DataserviceConfigService} from "@/services/dataservice/DataserviceConfigService";
import {history} from "@@/core/history";

const DataserviceConfigSteps: React.FC = (props: any) => {
const intl = useIntl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,76 @@ import {WORKSPACE_CONF} from '@/constants/constant';
import {ScheduleGroup} from '@/services/project/typings';
import {WsScheduleGroupService} from "@/services/project/WsScheduleGroupService";

const ScheduleGroupForm: React.FC<ModalFormProps<ScheduleGroup>> = ({
data,
visible,
onVisibleChange
}) => {
const intl = useIntl();
const [form] = Form.useForm();
const projectId = localStorage.getItem(WORKSPACE_CONF.projectId);
const ScheduleGroupForm: React.FC<ModalFormProps<ScheduleGroup>> = ({data, visible, onVisibleChange}) => {
const intl = useIntl();
const [form] = Form.useForm();
const projectId = localStorage.getItem(WORKSPACE_CONF.projectId);

return (
<ModalForm
title={
intl.formatMessage({id: 'app.common.operate.new.label'}) +
intl.formatMessage({id: 'pages.project.schedule.group'})
}
form={form}
initialValues={{
id: data?.id,
name: data?.name,
remark: data?.remark,
}}
open={visible}
onOpenChange={onVisibleChange}
width={580}
layout={"horizontal"}
labelCol={{span: 6}}
wrapperCol={{span: 16}}
modalProps={{
destroyOnClose: true,
closeIcon: false
}}
onFinish={(values: Record<string, any>) => {
const param = {
id: values.id,
namespace: projectId,
name: values.name,
remark: values.remark
};
return values.id
? WsScheduleGroupService.update(param).then((response) => {
if (response.success) {
message.success(intl.formatMessage({id: 'app.common.operate.edit.success'}));
if (onVisibleChange) {
onVisibleChange(false);
}
return (
<ModalForm
title={
data?.id
? intl.formatMessage({id: 'app.common.operate.edit.label'}) +
intl.formatMessage({id: 'pages.project.schedule.group'})
: intl.formatMessage({id: 'app.common.operate.new.label'}) +
intl.formatMessage({id: 'pages.project.schedule.group'})
}
})
: WsScheduleGroupService.add(param).then((response) => {
if (response.success) {
message.success(intl.formatMessage({id: 'app.common.operate.new.success'}));
if (onVisibleChange) {
onVisibleChange(false);
}
}
})
}}
>
<ProFormDigit name="id" hidden/>
<ProFormText
name="name"
label={intl.formatMessage({id: 'pages.project.schedule.group.name'})}
rules={[{required: true}, {max: 32}]}
/>
<ProFormTextArea
name="remark"
label={intl.formatMessage({id: 'app.common.data.remark'})}
rules={[{max: 200}]}
/>
</ModalForm>
);
form={form}
initialValues={{
id: data?.id,
name: data?.name,
remark: data?.remark,
}}
open={visible}
onOpenChange={onVisibleChange}
width={580}
layout={"horizontal"}
labelCol={{span: 6}}
wrapperCol={{span: 16}}
modalProps={{
destroyOnClose: true,
closeIcon: false
}}
onFinish={(values: Record<string, any>) => {
const param = {
id: values.id,
namespace: projectId,
name: values.name,
remark: values.remark
};
console.log('values', dataValue, param)
return values.id
? WsScheduleGroupService.update(param).then((response) => {
if (response.success) {
message.success(intl.formatMessage({id: 'app.common.operate.edit.success'}));
if (onVisibleChange) {
onVisibleChange(false);
}
}
})
: WsScheduleGroupService.add(param).then((response) => {
if (response.success) {
message.success(intl.formatMessage({id: 'app.common.operate.new.success'}));
if (onVisibleChange) {
onVisibleChange(false);
}
}
})
}}
>
<ProFormDigit name="id" hidden/>
<ProFormText
name="name"
label={intl.formatMessage({id: 'pages.project.schedule.group.name'})}
rules={[{required: true}, {max: 32}]}
/>
<ProFormTextArea
name="remark"
label={intl.formatMessage({id: 'app.common.data.remark'})}
rules={[{max: 200}]}
/>
</ModalForm>
);
};

export default ScheduleGroupForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {Form, message} from 'antd';
import {ModalForm, ProFormDigit, ProFormText, ProFormTextArea} from "@ant-design/pro-components";
import {useIntl} from '@umijs/max';
import {ModalFormProps} from '@/typings';
import {WORKSPACE_CONF} from '@/constants/constant';
import {ScheduleJob} from '@/services/project/typings';
import {WsScheduleGroupService} from "@/services/project/WsScheduleGroupService";

const ScheduleJobForm: React.FC<ModalFormProps<ScheduleJob>> = ({
data,
visible,
onVisibleChange
}) => {
const intl = useIntl();
const [form] = Form.useForm();
const projectId = localStorage.getItem(WORKSPACE_CONF.projectId);

return (
<ModalForm
title={
data.id
? intl.formatMessage({id: 'app.common.operate.edit.label'}) +
intl.formatMessage({id: 'pages.project.schedule.job'})
: intl.formatMessage({id: 'app.common.operate.new.label'}) +
intl.formatMessage({id: 'pages.project.schedule.job'})
}
form={form}
initialValues={{
id: data?.id,
name: data?.name,
remark: data?.remark,
}}
open={visible}
onOpenChange={onVisibleChange}
width={580}
layout={"horizontal"}
labelCol={{span: 6}}
wrapperCol={{span: 16}}
modalProps={{
destroyOnClose: true,
closeIcon: false
}}
onFinish={(values: Record<string, any>) => {
const param = {
id: values.id,
namespace: projectId,
name: values.name,
remark: values.remark
};
return values.id
? WsScheduleGroupService.update(param).then((response) => {
if (response.success) {
message.success(intl.formatMessage({id: 'app.common.operate.edit.success'}));
if (onVisibleChange) {
onVisibleChange(false);
}
}
})
: WsScheduleGroupService.add(param).then((response) => {
if (response.success) {
message.success(intl.formatMessage({id: 'app.common.operate.new.success'}));
if (onVisibleChange) {
onVisibleChange(false);
}
}
})
}}
>
<ProFormDigit name="id" hidden/>
<ProFormText
name="name"
label={intl.formatMessage({id: 'pages.project.schedule.group.name'})}
rules={[{required: true}, {max: 32}]}
/>
<ProFormTextArea
name="remark"
label={intl.formatMessage({id: 'app.common.data.remark'})}
rules={[{max: 200}]}
/>
</ModalForm>
);
};

export default ScheduleJobForm;
Loading

0 comments on commit 1f98a0d

Please sign in to comment.