From 656413d3f778ad4cc466c5175f73fb45b14afd28 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Thu, 26 Dec 2024 13:37:14 +0800 Subject: [PATCH] 1 --- .../List/components/ApplicationModal.tsx | 55 ++++-- .../pages/Deploy/Application/List/index.tsx | 169 ++++++++++++++---- .../pages/Deploy/Application/List/types.ts | 50 ++++-- .../List/components/ProjectGroupModal.tsx | 121 +++++-------- .../pages/Deploy/ProjectGroup/List/index.tsx | 66 +++---- .../pages/Deploy/ProjectGroup/List/types.ts | 8 +- .../pages/Deploy/ProjectGroup/List/utils.tsx | 37 ++++ 7 files changed, 324 insertions(+), 182 deletions(-) create mode 100644 frontend/src/pages/Deploy/ProjectGroup/List/utils.tsx diff --git a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx index b90cfee9..434ebe59 100644 --- a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx +++ b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx @@ -1,7 +1,8 @@ import React, { useEffect } from 'react'; -import { Modal, Form, Input, InputNumber, Radio, message } from 'antd'; +import { Modal, Form, Input, InputNumber, Radio, message, Select } from 'antd'; import type { Application } from '../types'; import { createApplication, updateApplication } from '../service'; +import { DevelopmentLanguageTypeEnum } from '../types'; interface ApplicationModalProps { visible: boolean; @@ -24,12 +25,15 @@ const ApplicationModal: React.FC = ({ useEffect(() => { if (visible) { if (initialValues) { - form.setFieldsValue(initialValues); + form.setFieldsValue({ + ...initialValues, + }); } else { - form.setFieldsValue({ - appStatus: 'ENABLE', + form.setFieldsValue({ + projectGroupId, + enabled: true, sort: 0, - projectGroupId: projectGroupId // 设置项目组ID的初始值 + language: DevelopmentLanguageTypeEnum.JAVA, }); } } @@ -40,7 +44,7 @@ const ApplicationModal: React.FC = ({ const values = await form.validateFields(); const submitData = { ...values, - projectGroupId: projectGroupId // 确保提交时包含项目组ID + projectGroupId, }; if (isEdit) { @@ -70,13 +74,18 @@ const ApplicationModal: React.FC = ({ onOk={handleSubmit} onCancel={handleCancel} destroyOnClose + width={600} >
- {/* 添加一个隐藏的表单项来存储项目组ID */} + {/* 隐藏的项目组ID字段 */} @@ -108,13 +117,37 @@ const ApplicationModal: React.FC = ({ + + + + + + + + - 启用 - 禁用 + 启用 + 禁用 diff --git a/frontend/src/pages/Deploy/Application/List/index.tsx b/frontend/src/pages/Deploy/Application/List/index.tsx index 791cb8e4..e3f626c4 100644 --- a/frontend/src/pages/Deploy/Application/List/index.tsx +++ b/frontend/src/pages/Deploy/Application/List/index.tsx @@ -1,11 +1,25 @@ import React, {useState, useEffect} from 'react'; import {PageContainer} from '@ant-design/pro-layout'; import {Button, message, Popconfirm, Tag, Space, Tooltip, Select} from 'antd'; -import {PlusOutlined, EditOutlined, DeleteOutlined, CodeOutlined, CloudUploadOutlined, ApiOutlined} from '@ant-design/icons'; +import { + PlusOutlined, + EditOutlined, + DeleteOutlined, + CodeOutlined, + CloudUploadOutlined, + ApiOutlined, + GithubOutlined, + JavaOutlined, + NodeIndexOutlined, + PythonOutlined, +} from '@ant-design/icons'; import {getApplicationPage, deleteApplication} from './service'; import {getProjectGroupList} from '../../ProjectGroup/List/service'; import type {Application, ApplicationQuery} from './types'; +import {DevelopmentLanguageTypeEnum} from './types'; import type {ProjectGroup} from '../../ProjectGroup/List/types'; +import {ProjectGroupTypeEnum} from '../../ProjectGroup/List/types'; +import {getProjectTypeInfo} from '../../ProjectGroup/List/utils'; import ApplicationModal from './components/ApplicationModal'; import {ProTable} from '@ant-design/pro-components'; import type {ProColumns, ActionType} from '@ant-design/pro-components'; @@ -65,11 +79,40 @@ const ApplicationList: React.FC = () => { actionRef.current?.reload(); }; - // 根据应用编码推测应用类型 - const getAppType = (appCode: string) => { - if (appCode.toLowerCase().includes('web')) return {icon: , name: '前端应用', color: '#1890ff'}; - if (appCode.toLowerCase().includes('api')) return {icon: , name: 'API服务', color: '#52c41a'}; - return {icon: , name: '后端服务', color: '#722ed1'}; + // 获取开发语言信息 + const getLanguageInfo = (language: DevelopmentLanguageTypeEnum) => { + switch (language) { + case DevelopmentLanguageTypeEnum.JAVA: + return { + label: 'Java', + icon: , + color: '#E76F00' + }; + case DevelopmentLanguageTypeEnum.NODE_JS: + return { + label: 'NodeJS', + icon: , + color: '#339933' + }; + case DevelopmentLanguageTypeEnum.PYTHON: + return { + label: 'Python', + icon: , + color: '#3776AB' + }; + case DevelopmentLanguageTypeEnum.GO: + return { + label: 'Go', + icon: , + color: '#00ADD8' + }; + default: + return { + label: language || '未知', + icon: , + color: '#666666' + }; + } }; const columns: ProColumns[] = [ @@ -80,17 +123,6 @@ const ApplicationList: React.FC = () => { copyable: true, ellipsis: true, fixed: 'left', - render: (text, record) => { - const appType = getAppType(record.appCode); - return ( - - - {appType.icon} - - {text} - - ); - }, }, { title: '应用名称', @@ -98,6 +130,22 @@ const ApplicationList: React.FC = () => { width: 150, ellipsis: true, }, + { + title: '项目组', + dataIndex: ['projectGroup', 'projectGroupName'], + width: 150, + ellipsis: true, + render: (_, record) => ( + + {record.projectGroup?.projectGroupName} + {record.projectGroup?.type && ( + + {getProjectTypeInfo(record.projectGroup.type).label} + + )} + + ), + }, { title: '应用描述', dataIndex: 'appDesc', @@ -105,12 +153,50 @@ const ApplicationList: React.FC = () => { width: 200, }, { - title: '应用状态', - dataIndex: 'appStatus', + title: '仓库地址', + dataIndex: 'repoUrl', + width: 200, + ellipsis: true, + render: (_, record) => record.repoUrl ? ( + + + + {record.repoUrl} + + + ) : '-', + }, + { + title: '开发语言', + dataIndex: 'language', + width: 120, + render: (language) => { + const langInfo = getLanguageInfo(language as DevelopmentLanguageTypeEnum); + return ( + + + {langInfo.icon} + {langInfo.label} + + + ); + }, + filters: [ + {text: 'Java', value: DevelopmentLanguageTypeEnum.JAVA}, + {text: 'NodeJS', value: DevelopmentLanguageTypeEnum.NODE_JS}, + {text: 'Python', value: DevelopmentLanguageTypeEnum.PYTHON}, + {text: 'Go', value: DevelopmentLanguageTypeEnum.GO}, + ], + filterMode: 'menu', + filtered: false, + }, + { + title: '状态', + dataIndex: 'enabled', width: 100, valueEnum: { - 'ENABLE': {text: '启用', status: 'Success'}, - 'DISABLE': {text: '禁用', status: 'Default'}, + true: {text: '启用', status: 'Success'}, + false: {text: '禁用', status: 'Default'}, }, }, { @@ -121,7 +207,7 @@ const ApplicationList: React.FC = () => { }, { title: '操作', - width: 200, + width: 150, key: 'action', valueType: 'option', fixed: 'right', @@ -149,19 +235,37 @@ const ApplicationList: React.FC = () => { 删除 , - ], }, ]; return ( - <> + + 当前项目组: + - = ({ > + -