You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2022/12/10 15:18:33 UTC
[incubator-streampark] branch dev updated: [Improve]: project Git repository input group (#2145)
This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 4dbc8425a [Improve]: project Git repository input group (#2145)
4dbc8425a is described below
commit 4dbc8425a515a0a76095ef8d130d592bf632a542
Author: WSZ <12...@qq.com>
AuthorDate: Sat Dec 10 23:18:28 2022 +0800
[Improve]: project Git repository input group (#2145)
* [Improve]: project Git repository input group
* [Fix] remove console
Co-authored-by: benjobs <be...@apache.org>
---
.../src/assets/images/logo-text.png | Bin 97457 -> 91439 bytes
.../src/components/Application/src/AppLogo.vue | 2 +-
.../src/design/ant/input.less | 4 ++
.../src/design/var/index.less | 4 +-
.../src/layouts/default/menu/index.vue | 4 +-
.../src/locales/lang/en/flink/project.ts | 3 +
.../src/locales/lang/zh-CN/flink/project.ts | 3 +
.../src/views/flink/app/View.vue | 4 +-
.../flink/project/components/RepositoryGroup.tsx | 77 ++++++++++++++++++++
.../project/{useProject.ts => useProject.tsx} | 78 ++++++++++++---------
.../streampark-console-webapp/stylelint.config.js | 1 +
11 files changed, 140 insertions(+), 40 deletions(-)
diff --git a/streampark-console/streampark-console-webapp/src/assets/images/logo-text.png b/streampark-console/streampark-console-webapp/src/assets/images/logo-text.png
index 5b5c01e52..20e3c761f 100644
Binary files a/streampark-console/streampark-console-webapp/src/assets/images/logo-text.png and b/streampark-console/streampark-console-webapp/src/assets/images/logo-text.png differ
diff --git a/streampark-console/streampark-console-webapp/src/components/Application/src/AppLogo.vue b/streampark-console/streampark-console-webapp/src/components/Application/src/AppLogo.vue
index bfc636995..815a89b48 100644
--- a/streampark-console/streampark-console-webapp/src/components/Application/src/AppLogo.vue
+++ b/streampark-console/streampark-console-webapp/src/components/Application/src/AppLogo.vue
@@ -17,7 +17,7 @@
<template>
<div class="anticon" :class="getAppLogoClass" @click="goHome">
<img src="/@/assets/images/logo.png" alt="logo" v-show="!showTitle" />
- <div class="ml-2 truncate md:opacity-100" :class="getTitleClass" v-show="showTitle">
+ <div class="truncate md:opacity-100" :class="getTitleClass" v-show="showTitle">
<!-- {{ title }} -->
<img src="/@/assets/images/logo-text.png" class="logo-text" alt="logo" />
</div>
diff --git a/streampark-console/streampark-console-webapp/src/design/ant/input.less b/streampark-console/streampark-console-webapp/src/design/ant/input.less
index 12ce09853..b92e67442 100644
--- a/streampark-console/streampark-console-webapp/src/design/ant/input.less
+++ b/streampark-console/streampark-console-webapp/src/design/ant/input.less
@@ -58,3 +58,7 @@
border-color: transparent !important;
}
}
+
+.custom-input-group.ant-input-group-compact > *:not(:last-child) {
+ border-right-width: 0 !important;
+}
diff --git a/streampark-console/streampark-console-webapp/src/design/var/index.less b/streampark-console/streampark-console-webapp/src/design/var/index.less
index d14f45ca2..ad2a85780 100644
--- a/streampark-console/streampark-console-webapp/src/design/var/index.less
+++ b/streampark-console/streampark-console-webapp/src/design/var/index.less
@@ -24,10 +24,10 @@
@multiple-height: 30px;
// headers
-@header-height: 48px;
+@header-height: 56px;
// logo width
-@logo-width: 32px;
+@logo-width: 48px;
//
@side-drag-z-index: 200;
diff --git a/streampark-console/streampark-console-webapp/src/layouts/default/menu/index.vue b/streampark-console/streampark-console-webapp/src/layouts/default/menu/index.vue
index 7e94c4240..73157b413 100644
--- a/streampark-console/streampark-console-webapp/src/layouts/default/menu/index.vue
+++ b/streampark-console/streampark-console-webapp/src/layouts/default/menu/index.vue
@@ -198,10 +198,10 @@
img {
width: @logo-width;
- height: @logo-width;
+ height: auto;
&.logo-text {
- width: 180px;
+ width: 220px;
height: auto !important;
}
}
diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts
index 805848b8e..44b7fdd33 100644
--- a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts
+++ b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/project.ts
@@ -39,6 +39,9 @@ export default {
cvsPlaceholder: 'CVS',
repositoryURL: 'Repository URL',
repositoryURLPlaceholder: 'The Repository URL for this project',
+ repositoryURLRequired: 'The repository URL is required',
+ httpChecked: 'The repository address must be a valid http(s) address',
+ gitChecked: 'The repository address must be a valid ssh address',
userName: 'UserName',
userNamePlaceholder: 'UserName for this project',
password: 'Password',
diff --git a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts
index 12b5db81e..fd56b43b7 100644
--- a/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts
+++ b/streampark-console/streampark-console-webapp/src/locales/lang/zh-CN/flink/project.ts
@@ -39,6 +39,9 @@ export default {
cvsPlaceholder: 'CVS类型: git/svn',
repositoryURL: '仓库地址',
repositoryURLPlaceholder: '请输入该项目的仓库地址',
+ repositoryURLRequired: '仓库地址不能为空',
+ httpChecked: '仓库地址必须合法的http(s)地址',
+ gitChecked: '仓库地址必须合法的ssh地址',
userName: '用户名',
userNamePlaceholder: '请输入(访问)该项目仓库的用户名',
password: '密码',
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue b/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue
index 82510262f..6dc6e0a41 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue
+++ b/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue
@@ -187,8 +187,8 @@
<BasicTable @register="registerTable" class="app_list !px-0 pt-20px" :formConfig="formConfig">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'jobName'">
- <span class="app_type app_jar" v-if="record['jobType'] === 1"> JAR </span>
- <span class="app_type app_sql" v-if="record['jobType'] === 2"> SQL </span>
+ <span class="app_type app_jar" v-if="record['jobType'] === JobTypeEnum.JAR"> JAR </span>
+ <span class="app_type app_sql" v-if="record['jobType'] === JobTypeEnum.SQL"> SQL </span>
<span
class="link"
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/components/RepositoryGroup.tsx b/streampark-console/streampark-console-webapp/src/views/flink/project/components/RepositoryGroup.tsx
new file mode 100644
index 000000000..e1ff08929
--- /dev/null
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/components/RepositoryGroup.tsx
@@ -0,0 +1,77 @@
+/*
+ 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
+
+ https://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.
+*/
+import { defineComponent } from 'vue';
+import type { PropType } from 'vue';
+import { Form, Input, Select } from 'ant-design-vue';
+export interface RepositoryProps {
+ gitProtocol: string | number;
+ url: string;
+}
+import { useI18n } from '/@/hooks/web/useI18n';
+import { GitProtocolEnum } from '/@/enums/projectEnum';
+export default defineComponent({
+ name: 'RepositoryUrl',
+ props: {
+ value: {
+ type: Object as PropType<RepositoryProps>,
+ required: true,
+ },
+ },
+ emits: ['updateProtocol', 'updateUrl'],
+ setup(props, { emit }) {
+ const { t } = useI18n();
+ const formItemContext = Form.useInjectFormItemContext();
+ const handleProtocolChange = (value: any) => {
+ emit('updateProtocol', value);
+ formItemContext.onFieldChange();
+ };
+ const handleUrlChange = (value: any) => {
+ emit('updateUrl', value);
+ formItemContext.onFieldChange();
+ };
+
+ const options = [
+ { label: 'http/https', value: GitProtocolEnum.HTTPS },
+ { label: 'ssh', value: GitProtocolEnum.SSH },
+ ];
+
+ return () => {
+ return (
+ <div>
+ <Input.Group compact class="!flex custom-input-group">
+ <Select
+ name="gitProtocol"
+ style="width: 120px"
+ placeholder={t('flink.project.form.gitProtocolPlaceholder')}
+ value={props.value?.gitProtocol}
+ onChange={(e: any) => handleProtocolChange(e)}
+ options={options}
+ />
+ <Input
+ name="url"
+ placeholder={t('flink.project.form.repositoryURLPlaceholder')}
+ allow-clear
+ class="flex-1"
+ value={props.value?.url}
+ onInput={(e: any) => handleUrlChange(e.target.value)}
+ />
+ </Input.Group>
+ </div>
+ );
+ };
+ },
+});
diff --git a/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts b/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.tsx
similarity index 84%
rename from streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts
rename to streampark-console/streampark-console-webapp/src/views/flink/project/useProject.tsx
index cd501b41e..a90af291b 100644
--- a/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.ts
+++ b/streampark-console/streampark-console-webapp/src/views/flink/project/useProject.tsx
@@ -25,6 +25,8 @@ import { ProjectRecord } from '/@/api/flink/project/model/projectModel';
import { filterOption } from '../app/utils';
import { useI18n } from '/@/hooks/web/useI18n';
import { GitProtocolEnum } from '/@/enums/projectEnum';
+import RepositoryGroup from './components/RepositoryGroup';
+import { Form } from 'ant-design-vue';
const { t } = useI18n();
export const useProject = () => {
@@ -37,7 +39,25 @@ export const useProject = () => {
const getLoading = computed(() => {
return submitLoading.value;
});
-
+ const handleCheckRepositoryUrl = (values: Recordable) => {
+ if (!values.url) {
+ return Promise.reject(t('flink.project.form.repositoryURLRequired'));
+ }
+ switch (values.gitProtocol) {
+ case GitProtocolEnum.SSH:
+ if (/^git@(.*)/.test(values.url)) {
+ return Promise.resolve();
+ } else {
+ return Promise.reject(t('flink.project.form.gitChecked'));
+ }
+ default:
+ if (/^http(s)?:\/\//.test(values.url)) {
+ return Promise.resolve();
+ } else {
+ return Promise.reject(t('flink.project.form.httpChecked'));
+ }
+ }
+ };
const projectFormSchema = computed((): FormSchema[] => {
return [
{
@@ -70,6 +90,7 @@ export const useProject = () => {
},
],
},
+
{
field: 'repository',
label: t('flink.project.form.cvs'),
@@ -89,41 +110,30 @@ export const useProject = () => {
},
],
},
+ { field: 'gitProtocol', label: '', component: 'Input', show: false },
+ { field: 'url', label: '', component: 'Input', show: false },
{
- field: 'gitProtocol',
- label: t('flink.project.form.gitProtocol'),
- component: 'Select',
- componentProps: {
- showSearch: true,
- optionFilterProp: 'children',
- filterOption,
- options: [
- { label: 'http/https', value: GitProtocolEnum.HTTPS },
- { label: 'ssh', value: GitProtocolEnum.SSH },
- ],
- placeholder: t('flink.project.form.gitProtocolPlaceholder'),
- },
- rules: [
- {
- required: true,
- type: 'number',
- message: t('flink.project.operationTips.gitProtocolIsRequiredMessage'),
- },
- ],
- },
- {
- field: 'url',
+ field: 'repositoryUrl',
label: t('flink.project.form.repositoryURL'),
component: 'Input',
- componentProps: {
- placeholder: t('flink.project.form.repositoryURLPlaceholder'),
+ renderColContent: ({ model }) => {
+ return (
+ <Form.Item
+ label={t('flink.project.form.repositoryURL')}
+ name="repositoryUrl"
+ rules={[{ required: true, validator: () => handleCheckRepositoryUrl(model) }]}
+ >
+ <RepositoryGroup
+ value={{
+ gitProtocol: Number(model.gitProtocol) || GitProtocolEnum.HTTPS,
+ url: model.url || '',
+ }}
+ onUpdateProtocol={(value) => (model.gitProtocol = value)}
+ onUpdateUrl={(value) => (model.url = value)}
+ />
+ </Form.Item>
+ );
},
- rules: [
- {
- required: true,
- message: t('flink.project.operationTips.repositoryURLIsRequiredMessage'),
- },
- ],
},
{
field: 'rsaPath',
@@ -141,6 +151,7 @@ export const useProject = () => {
ifShow: ({ values }) => values.gitProtocol == GitProtocolEnum.HTTPS,
componentProps: {
placeholder: t('flink.project.form.userNamePlaceholder'),
+ autocomplete: 'new-password',
},
},
{
@@ -149,6 +160,7 @@ export const useProject = () => {
component: 'InputPassword',
componentProps: {
placeholder: t('flink.project.form.passwordPlaceholder'),
+ autocomplete: 'new-password',
},
},
{
@@ -300,7 +312,7 @@ export const useProject = () => {
name: res.name,
type: res.type,
repository: res.repository,
- gitProtocol: res.gitProtocol,
+ gitProtocol: res.gitProtocol || GitProtocolEnum.HTTPS,
url: res.url,
userName: res.userName,
password: res.password,
diff --git a/streampark-console/streampark-console-webapp/stylelint.config.js b/streampark-console/streampark-console-webapp/stylelint.config.js
index 58c9602d3..a6f8c0ff2 100644
--- a/streampark-console/streampark-console-webapp/stylelint.config.js
+++ b/streampark-console/streampark-console-webapp/stylelint.config.js
@@ -51,6 +51,7 @@ module.exports = {
],
},
],
+ 'import-notation': null,
'no-empty-source': null,
'string-quotes': null,
'named-grid-areas-no-invalid': null,