Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/flowerfine/scaleph into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kalencaya committed Dec 5, 2023
2 parents 55bc68a + 50e4ea5 commit fc79ab8
Show file tree
Hide file tree
Showing 36 changed files with 1,436 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public class ResourceJar extends BaseDO {

private static final long serialVersionUID = 1L;

@TableField("`group`")
private String group;

@TableField("file_name")
private String fileName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<result column="create_time" property="createTime" />
<result column="editor" property="editor" />
<result column="update_time" property="updateTime" />
<result column="group" property="group" />
<result column="file_name" property="fileName" />
<result column="path" property="path" />
<result column="remark" property="remark" />
Expand All @@ -35,7 +34,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, creator, create_time, editor, update_time,
`group`, file_name, `path`, remark
file_name, `path`, remark
</sql>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
sec_user t1
JOIN sec_user_role t2 ON t1.id = t2.user_id
WHERE
t2.role_id = 1
t2.role_id = #{roleId}
<if test="status != null">
AND t1.`status` = #{status}
</if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public interface JarConvert extends BaseConvert<ResourceJar, JarDTO> {

default JarListParam convert(ResourceListParam param) {
JarListParam target = BeanUtil.copy(param, new JarListParam());
target.setGroup(param.getLabel());
target.setFileName(param.getName());
target.setFileName(param.getLabel());
return target;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public Page<JarDTO> list(JarListParam param) throws IOException {
final Page<ResourceJar> page = jarMapper.selectPage(
new Page<>(param.getCurrent(), param.getPageSize()),
Wrappers.lambdaQuery(ResourceJar.class)
.eq(StringUtils.hasText(param.getGroup()), ResourceJar::getGroup, param.getGroup())
.like(StringUtils.hasText(param.getFileName()), ResourceJar::getFileName, param.getFileName()));
Page<JarDTO> result =
new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
Expand All @@ -101,7 +100,7 @@ public void upload(JarUploadParam param, MultipartFile file) throws IOException
String fileName = file.getOriginalFilename();
Path path = null;
try (InputStream inputStream = file.getInputStream()) {
path = fileSystemService.upload(inputStream, getJarPath(param.getGroup(), fileName));
path = fileSystemService.upload(inputStream, getJarPath(fileName));
}
ResourceJar record = new ResourceJar();
BeanUtils.copyProperties(param, record);
Expand Down Expand Up @@ -134,11 +133,10 @@ public void delete(Long id) throws IOException {
jarMapper.deleteById(id);
}

private String getJarPath(String group, String fileName) {
return String.format("%s/%s/%s", getJarRootPath(), group, fileName);
private String getJarPath(String fileName) {
return String.format("%s/%s", getJarRootPath(), fileName);
}


private String getJarRootPath() {
return "jar";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
@EqualsAndHashCode(callSuper = true)
public class JarListParam extends PaginationParam {

@Schema(description = "jar group")
private String group;

@Schema(description = "文件名称。支持模糊匹配")
private String fileName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class JarUploadParam {

@NotBlank
@Schema(description = "jar group")
private String group;


@Schema(description = "备注")
private String remark;
}
7 changes: 7 additions & 0 deletions scaleph-ui-react/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ export default [
pCode: PRIVILEGE_CODE.workspaceClusterConfigShow,
access: 'normalRouteFilter'
},
{
path: '/workspace/flink/kubernetes/template/steps',
exact: true,
component: './Project/Workspace/Kubernetes/Template/Steps',
pCode: PRIVILEGE_CODE.workspaceClusterConfigShow,
access: 'normalRouteFilter'
},
{
path: '/workspace/flink/kubernetes/template/detail',
exact: true,
Expand Down
10 changes: 10 additions & 0 deletions scaleph-ui-react/src/locales/zh-CN/pages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export default {
'app.common.operate.label': '操作',
'app.common.operate.success': '操作成功',
'app.common.operate.new.label': '新增',
'app.common.operate.new.roles': '分配角色',
'app.common.operate.new.rolesUser': '角色分配用户',
'app.common.operate.new.rolesWeb': '角色配置web资源',
'app.common.operate.new.user': '配置用户',
'app.common.operate.new.webs': '配置web资源',
'app.common.operate.new.accreditUser': '已授权用户',
'app.common.operate.new.accreditRoles': '已授权角色',
'app.common.operate.new.notAccreditUser': '未授权用户',
'app.common.operate.new.notAccreditRoles': '未授权角色',
'app.common.operate.new.assets': '权限配置',
'app.common.operate.new.success': '新增成功',
'app.common.operate.new.failure': '新增失败',
'app.common.operate.new.directive': '没有?去创建',
Expand Down
11 changes: 6 additions & 5 deletions scaleph-ui-react/src/locales/zh-CN/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,12 @@ export default {
// Sql
'pages.project.di.step.sql.query': 'SQL',

'pages.project.flink.kubernetes.deployment.template': 'Deployment Template',
'pages.project.flink.kubernetes.deployment.template.name': '名称',
'pages.project.flink.kubernetes.deployment.template.deploymentKind': '部署模式',
'pages.project.flink.kubernetes.deployment.template.namespace': 'Namespace',
'pages.project.flink.kubernetes.deployment.template.define': '模板定义',
'pages.project.flink.kubernetes.template': 'Template',
'pages.project.flink.kubernetes.template.name': '名称',
'pages.project.flink.kubernetes.template.deploymentKind': '部署模式',
'pages.project.flink.kubernetes.template.namespace': 'Namespace',
'pages.project.flink.kubernetes.template.detail': '模板详情',
'pages.project.flink.kubernetes.template.step.base': '基础信息',
'pages.project.flink.kubernetes.template.step.advanced.configOptions': 'ConfigOption',
'pages.project.flink.kubernetes.template.step.advanced.configOptions.key': 'Config',
'pages.project.flink.kubernetes.template.step.advanced.configOptions.value': 'Value',
Expand Down
1 change: 0 additions & 1 deletion scaleph-ui-react/src/locales/zh-CN/pages/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default {
'YARN 上传 core-site.xml 和 hdfs-site.xml, ' +
'Kubernetes 上传 kubeconfig 文件',
'pages.resource.jar': '公共 Jar',
'pages.resource.jar.group': 'Group',
'pages.resource.jar.file': 'Jar',
'pages.resource.jar.fileName': '文件名',
'pages.resource.jar.path': '存储路径',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import { Reducer, Effect } from "umi";
import {WsFlinkKubernetesTemplateService} from "@/services/project/WsFlinkKubernetesTemplateService";
import YAML from "yaml";

export interface StateType {
template: WsFlinkKubernetesTemplate,
templateYaml: string
templateYamlWithDefault: string
}

export interface ModelType {
namespace: string;

state: StateType;

effects: {
queryTemplate: Effect;
};

reducers: {
updateTemplate: Reducer<StateType>;
};
}

const model: ModelType = {
namespace: "flinkKubernetesTemplateDetail",

state: {
template: null,
templateYaml: null,
templateYamlWithDefault: null
},

effects: {
*editTemplate({ payload }, { call, put }) {
const { data } = yield call(WsFlinkKubernetesTemplateService.asYaml, payload);
const response = yield call(WsFlinkKubernetesTemplateService.asYamlWithDefault, payload);
yield put({ type: 'updateTemplate', payload: {template: payload, templateYaml: YAML.stringify(data), templateYamlWithDefault: YAML.stringify(response.data)} });
},
},

reducers: {
updateTemplate(state, { payload }) {
return {
...state,
template: payload.template,
templateYaml: payload.templateYaml,
templateYamlWithDefault: payload.templateYamlWithDefault,
};
},
},
};

export default model;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {WsFlinkKubernetesTemplate} from "@/services/project/typings";
import { Reducer, Effect } from "umi";
import {WsFlinkKubernetesTemplateService} from "@/services/project/WsFlinkKubernetesTemplateService";
import YAML from "yaml";

export interface StateType {
template: WsFlinkKubernetesTemplate,
templateYaml: string
templateYamlWithDefault: string
}

export interface ModelType {
namespace: string;

state: StateType;

effects: {
queryTemplate: Effect;
};

reducers: {
updateTemplate: Reducer<StateType>;
};
}

const model: ModelType = {
namespace: "flinkKubernetesTemplateSteps",

state: {
template: null,
templateYaml: null,
templateYamlWithDefault: null
},

effects: {
*editTemplate({ payload }, { call, put }) {
const { data } = yield call(WsFlinkKubernetesTemplateService.asYaml, payload);
const response = yield call(WsFlinkKubernetesTemplateService.asYamlWithDefault, payload);
yield put({ type: 'updateTemplate', payload: {template: payload, templateYaml: YAML.stringify(data), templateYamlWithDefault: YAML.stringify(response.data)} });
},
},

reducers: {
updateTemplate(state, { payload }) {
return {
...state,
template: payload.template,
templateYaml: payload.templateYaml,
templateYamlWithDefault: payload.templateYamlWithDefault,
};
},
},
};

export default model;
26 changes: 26 additions & 0 deletions scaleph-ui-react/src/models/useMainSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useLayoutEffect, useState } from "react";
import { throttle } from "lodash";

export default (mainCl = ".ant-pro-basicLayout-content") => {
const [container, setContainer] = useState<{ height: number; width: number }>({
width: 100,
height: 100
});
// const mainCl = '.ant-pro-basicLayout-content';
useLayoutEffect(() => {
const handler = throttle(() => {
const rt = document.querySelector(mainCl)?.getBoundingClientRect();
setContainer({
height: rt?.height,
width: rt?.width
});
}, 100);
handler();
window.addEventListener("resize", handler, false);
return () => {
window.removeEventListener("resize", handler, false);
};
}, []);

return container;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Table, Transfer } from 'antd';
import { difference } from 'lodash'; // 注意这里改为大写的Difference
import React from 'react';

// 定义组件的Props类型
interface Props {
leftColumns: any[]; // 左侧表格列配置数组
rightColumns: any[]; // 右侧表格列配置数组
containerHeight: number; // 容器高度
}

// 使用React.FC声明函数组件,并传入Props类型
const TableTransfer: React.FC<Props> = ({ leftColumns, rightColumns, ...restProps }) => (
<Transfer {...restProps}>
{({
direction,
filteredItems,
onItemSelectAll,
onItemSelect,
selectedKeys: listSelectedKeys,
disabled: listDisabled,
}) => {
const columns = direction === 'left' ? leftColumns : rightColumns;
// 表格行选择配置
const rowSelection = {
onSelectAll(selected: boolean, selectedRows: any[]) {
const treeSelectedKeys = selectedRows.map(({ key }) => key);
const diffKeys = selected
? difference(treeSelectedKeys, listSelectedKeys)
: difference(listSelectedKeys, treeSelectedKeys);
onItemSelectAll(diffKeys, selected);
},
onSelect: ({ id }: { id: string }, selected: boolean) => {
onItemSelect(id, selected);
},
selectedRowKeys: listSelectedKeys,
};

return (
<Table
scroll={{ y: restProps.containerHeight - 380 }}
rowSelection={rowSelection}
columns={columns}
dataSource={filteredItems}
size="small"
rowKey="id"
pagination={{
defaultPageSize: 20,
}}
style={{ pointerEvents: listDisabled ? 'none' : null }}
/>
);
}}
</Transfer>
);
export default React.memo(TableTransfer);
Loading

0 comments on commit fc79ab8

Please sign in to comment.