Unverified Commit 01db56fe authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Fix-2855] Fix savepoint table params bug (#2860)

* Spotless Apply * Fix-savepiont-search-bug * Spotless Apply --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent 83bdc31c
......@@ -20,21 +20,16 @@
package org.dinky.controller;
import org.dinky.data.model.Savepoints;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result;
import org.dinky.service.SavepointsService;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
......@@ -55,25 +50,6 @@ public class SavePointsController {
private final SavepointsService savepointsService;
/**
* query all savepoint list
*
* @param para {@link JsonNode} params
* @return {@link ProTableResult}<{@link Savepoints}>
*/
@PostMapping
@ApiOperation("Query SavePoint List")
@ApiImplicitParam(
name = "para",
value = "Query Params",
dataType = "JsonNode",
paramType = "body",
required = true,
dataTypeClass = JsonNode.class)
public ProTableResult<Savepoints> listSavePoints(@RequestBody JsonNode para) {
return savepointsService.selectForProTable(para);
}
/**
* query savepoint list by task id
*
......@@ -82,8 +58,8 @@ public class SavePointsController {
*/
@GetMapping("/listSavepointsByTaskId")
@ApiOperation("Query SavePoint List By TaskId")
@ApiImplicitParam(name = "taskID", value = "Task ID", dataType = "Integer", paramType = "query", required = true)
public Result<List<Savepoints>> listSavePointsByTaskId(@RequestParam Integer taskID) {
return Result.succeed(savepointsService.listSavepointsByTaskId(taskID));
@ApiImplicitParam(name = "taskId", value = "Task ID", dataType = "Integer", paramType = "query", required = true)
public Result<List<Savepoints>> listSavePointsByTaskId(@RequestParam Integer taskId) {
return Result.succeed(savepointsService.listSavepointsByTaskId(taskId));
}
}
......@@ -30,7 +30,7 @@ import java.util.List;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
* SavepointsServiceImpl
......@@ -42,7 +42,7 @@ public class SavepointsServiceImpl extends SuperServiceImpl<SavepointsMapper, Sa
@Override
public List<Savepoints> listSavepointsByTaskId(Integer taskId) {
return list(new QueryWrapper<Savepoints>().eq("task_id", taskId));
return list(new LambdaQueryWrapper<>(Savepoints.class).eq(Savepoints::getTaskId, taskId));
}
@Override
......
......@@ -21,6 +21,7 @@ import { TagAlignLeft } from '@/components/StyledComponents';
import { getAlertIcon } from '@/pages/RegCenter/Alert/AlertInstance/function';
import { RUN_MODE } from '@/services/constants';
import { Alert, ALERT_TYPE, Cluster } from '@/types/RegCenter/data.d';
import { TaskInfo } from '@/types/Studio/data.d';
import { l } from '@/utils/intl';
import { PaperClipOutlined } from '@ant-design/icons';
import { Badge, Space, Tag } from 'antd';
......@@ -103,7 +104,7 @@ export const buildClusterOptions = (
*/
export const buildClusterConfigOptions = (
selectedRunMode: string,
clusterConfiguration: Cluster.Config[]
clusterConfiguration: Cluster.Config[] = []
) => {
// if run mode is yarn-application or yarn per-job, need to filter yarn application and yarn per-job
if ([RUN_MODE.YARN_APPLICATION, RUN_MODE.YARN_PER_JOB].includes(selectedRunMode)) {
......@@ -140,7 +141,7 @@ export const buildClusterConfigOptions = (
/**
* build env options
*/
export const buildEnvOptions = (env: any[]) => {
export const buildEnvOptions = (env: TaskInfo[] = []) => {
const envList: DefaultOptionType[] = [
{
label: l('button.disable'),
......@@ -171,7 +172,7 @@ export const buildEnvOptions = (env: any[]) => {
/**
* build job alert groups
*/
export const buildAlertGroupOptions = (alertGroups: Alert.AlertGroup[]) => {
export const buildAlertGroupOptions = (alertGroups: Alert.AlertGroup[] = []) => {
const alertGroupOptions: DefaultOptionType[] = [
{
label: (
......@@ -184,7 +185,7 @@ export const buildAlertGroupOptions = (alertGroups: Alert.AlertGroup[]) => {
key: -1
}
];
alertGroups?.forEach((item) => {
alertGroups.forEach((item) => {
alertGroupOptions.push({
label: (
<TagAlignLeft>
......
......@@ -19,18 +19,28 @@
import EllipsisMiddle from '@/components/Typography/EllipsisMiddle';
import { JobProps } from '@/pages/DevOps/JobDetail/data';
import { queryList } from '@/services/api';
import { queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
import { SavePoint } from '@/types/Studio/data';
import { l } from '@/utils/intl';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { useRef } from 'react';
import { useEffect, useRef, useState } from 'react';
const SavepointTable = (props: JobProps) => {
const { jobDetail } = props;
const actionRef = useRef<ActionType>();
const [savepointData, setSavepointData] = useState<SavePoint[]>([]);
useEffect(() => {
queryDataByParams<Partial<SavePoint[]>>(API_CONSTANTS.GET_SAVEPOINT_LIST_BY_TASK_ID, {
taskId: jobDetail?.instance?.taskId
}).then((res) => {
setSavepointData((res as SavePoint[]) ?? []);
});
}, [jobDetail]);
const columns: ProColumns<SavePoint>[] = [
{
title: l('devops.jobinfo.ck.id'),
......@@ -73,13 +83,7 @@ const SavepointTable = (props: JobProps) => {
<ProTable<SavePoint>
columns={columns}
style={{ width: '100%', height: 'calc(100vh - 450px)' }}
request={(params, sorter, filter) =>
queryList(API_CONSTANTS.GET_SAVEPOINTS, {
...params,
sorter,
filter: { taskId: [jobDetail?.instance.taskId] }
})
}
dataSource={savepointData}
actionRef={actionRef}
toolBarRender={false}
rowKey='id'
......
......@@ -18,15 +18,15 @@
*/
import CodeEdit from '@/components/CustomEditor/CodeEdit';
import {JOB_TYPE} from '@/pages/DataStudio/LeftContainer/Project/constants';
import { JOB_TYPE } from '@/pages/DataStudio/LeftContainer/Project/constants';
import {
DOCUMENT_CATEGORY_ENUMS,
DOCUMENT_FUNCTION_TYPE_ENUMS,
DOCUMENT_TYPE_ENUMS,
VERSIONS
} from '@/pages/RegCenter/Document/constans';
import {Document} from '@/types/RegCenter/data';
import {l} from '@/utils/intl';
import { Document } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import {
ProFormGroup,
ProFormItem,
......@@ -36,10 +36,10 @@ import {
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import {FormInstance} from 'antd/es/form/hooks/useForm';
import {Values} from 'async-validator';
import {DefaultOptionType} from 'rc-select/lib/Select';
import React, {useState} from 'react';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
import { DefaultOptionType } from 'rc-select/lib/Select';
import React, { useState } from 'react';
type DocumentFormProps = {
values: Partial<Document>;
......@@ -52,16 +52,16 @@ const CodeEditProps = {
};
const DocumentForm: React.FC<DocumentFormProps> = (props) => {
const {values, form} = props;
const { values, form } = props;
/**
* status
*/
const [codeFillValue, setCodeFillValue] = useState<string>(values.fillValue || '');
const {FLINK_OPTIONS, SQL_TEMPLATE, FUN_UDF, OTHER} = DOCUMENT_TYPE_ENUMS;
const { FLINK_OPTIONS, SQL_TEMPLATE, FUN_UDF, OTHER } = DOCUMENT_TYPE_ENUMS;
const [CATEGORY_LIST] = useState<DefaultOptionType[]>(
Object.values(DOCUMENT_CATEGORY_ENUMS).map((item) => ({label: item.text, value: item.value}))
Object.values(DOCUMENT_CATEGORY_ENUMS).map((item) => ({ label: item.text, value: item.value }))
);
const [FUNCTION_TYPES] = useState<DefaultOptionType[]>(
......@@ -72,12 +72,11 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
);
const [VERSION_OPTIONS] = useState<DefaultOptionType[]>(
VERSIONS.map((item) => ({label: item.text, value: item.value}))
VERSIONS.map((item) => ({ label: item.text, value: item.value }))
);
const [documentType, setDocumentType] = useState<string>('');
/**
* form
* @constructor
......@@ -90,8 +89,9 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
name='type'
label={l('rc.doc.functionType')}
initialValue={SQL_TEMPLATE.value}
rules={[{required: true, message: l('rc.doc.typePlaceholder')}]}
valueEnum={DOCUMENT_TYPE_ENUMS} fieldProps={{onChange: (value) => setDocumentType(value as string)}}
rules={[{ required: true, message: l('rc.doc.typePlaceholder') }]}
valueEnum={DOCUMENT_TYPE_ENUMS}
fieldProps={{ onChange: (value) => setDocumentType(value as string) }}
/>
<ProFormText
......@@ -99,7 +99,7 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
width={'md'}
label={l('rc.doc.name')}
placeholder={l('rc.doc.namePlaceholder')}
rules={[{required: true, message: l('rc.doc.namePlaceholder')}]}
rules={[{ required: true, message: l('rc.doc.namePlaceholder') }]}
/>
<ProFormSwitch
......@@ -108,7 +108,6 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
checkedChildren={l('button.enable')}
unCheckedChildren={l('button.disable')}
/>
</ProFormGroup>
<ProFormGroup>
......@@ -116,7 +115,7 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
name='subtype'
width={'sm'}
label={l('rc.doc.subFunctionType')}
rules={[{required: true, message: l('rc.doc.subTypePlaceholder')}]}
rules={[{ required: true, message: l('rc.doc.subTypePlaceholder') }]}
options={documentType == FUN_UDF.value ? FUNCTION_TYPES : JOB_TYPE}
/>
......@@ -124,14 +123,14 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
name='category'
width={'sm'}
label={l('rc.doc.category')}
rules={[{required: true, message: l('rc.doc.categoryPlaceholder')}]}
rules={[{ required: true, message: l('rc.doc.categoryPlaceholder') }]}
options={CATEGORY_LIST}
/>
<ProFormSelect
name='version'
width={'sm'}
label={l('rc.doc.version')}
rules={[{required: true, message: l('rc.doc.versionPlaceholder')}]}
rules={[{ required: true, message: l('rc.doc.versionPlaceholder') }]}
options={VERSION_OPTIONS}
/>
</ProFormGroup>
......@@ -140,7 +139,7 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
name='fillValue'
label={l('rc.doc.fillValue')}
tooltip={l('rc.doc.fillValuePlaceholder')}
rules={[{required: true, message: l('rc.doc.fillValueHelp')}]}
rules={[{ required: true, message: l('rc.doc.fillValueHelp') }]}
>
<CodeEdit
code={codeFillValue}
......@@ -159,10 +158,6 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
);
};
return (
<>
{documentFormRender()}
</>
);
return <>{documentFormRender()}</>;
};
export default DocumentForm;
......@@ -19,12 +19,12 @@
import { FormContextValue } from '@/components/Context/FormContext';
import DocumentForm from '@/pages/RegCenter/Document/components/DocumentModal/DocumentForm';
import {MODAL_FORM_OPTIONS} from '@/services/constants';
import { MODAL_FORM_OPTIONS } from '@/services/constants';
import { Document } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import {Form} from 'antd';
import { ModalForm } from '@ant-design/pro-components';
import { Form } from 'antd';
import React, { useEffect } from 'react';
import {ModalForm} from "@ant-design/pro-components";
type DocumentModalProps = {
onCancel: (flag?: boolean) => void;
......@@ -75,7 +75,6 @@ const DocumentModalForm: React.FC<DocumentModalProps> = (props) => {
await handleCancel();
};
return (
<ModalForm<Partial<Document>>
{...MODAL_FORM_OPTIONS}
......
......@@ -247,7 +247,7 @@ export enum API_CONSTANTS {
RESTART_TASK = '/api/task/restartTask',
SAVEPOINT = '/api/task/savepoint',
RESTART_TASK_FROM_CHECKPOINT = '/api/task/selectSavePointRestartTask',
GET_SAVEPOINTS = '/api/savepoints',
GET_SAVEPOINT_LIST_BY_TASK_ID = '/api/savepoints/listSavepointsByTaskId',
ALERT_HISTORY_LIST = '/api/alertHistory/list',
ALERT_HISTORY_DELETE = '/api/alertHistory/delete',
......
......@@ -31,7 +31,7 @@ export type Catalogue = {
updateTime: Date;
children: Catalogue[];
configJson: TaskExtConfig;
task: Task;
task: TaskInfo;
};
export type TaskUdfConfig = {
......@@ -50,7 +50,7 @@ export type TaskExtConfig = {
customConfig: List<Map<string, object>>;
};
export type Task = {
export type TaskInfo = {
id: number;
name: string;
dialect: string;
......@@ -67,6 +67,7 @@ export type Task = {
clusterConfigurationId: number;
databaseId: number;
envId: number;
enabled: boolean;
alertGroupId: number;
note: string;
step: number;
......
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