Skip to content

Commit

Permalink
Merge pull request #49 from Kabimon/feature/ui_refactory
Browse files Browse the repository at this point in the history
Feature/UI refactory
  • Loading branch information
mingfengwang authored Feb 17, 2022
2 parents eddf442 + 68eabc1 commit 7e7c723
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 80 deletions.
4 changes: 2 additions & 2 deletions web/.fes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions web/src/common/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { request } from "@fesjs/fes";
import { BASE_URL } from "@/common/constants";
////////////////////////////////////////////////////////////////////
export const getProjectList = (name) => {
return request("/projects", { name }, { method: "POST" });
export const getProjectList = (name, current, size) => {
return request("/projects", { name, current, size }, { method: "POST" });
};

export const createProject = (body) => {
Expand Down Expand Up @@ -149,6 +149,17 @@ export const copyJob = (id, params) => {
);
};

//编辑任务
export const modifyJob = (id, params) => {
return request(
`/job/${id}`,
{ ...params },
{
method: "PUT",
}
);
};

//删除任务
export const deleteJob = (id) => {
return request(`/job/${id}`, null, {
Expand All @@ -174,8 +185,8 @@ export const executeTask = (id) => {
});
};

export const getJobs = (id, jobType) => {
return request(`/job?projectId=${id}&jobType=${jobType}`, null, {
export const getJobs = (id, jobType, current, size) => {
return request(`/job?projectId=${id}&jobType=${jobType}&current=${current}&size=${size}`, null, {
method: "GET",
});
};
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default {
action: {
createJob: "Create Job",
copyJob: "Copy Job",
modifyJob: "Modify Job",
import: "Import",
export: "Export",
save: "Save",
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default {
action: {
createJob: "创建任务",
copyJob: "复制任务",
modifyJob: "编辑任务",
import: "导入",
export: "导出",
save: "保存",
Expand Down
3 changes: 2 additions & 1 deletion web/src/pages/dataSourceManage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ export default {
{
title: t("dataSource.table.list.columns.title.describe"),
align: "center",
dataIndex: "desc"
dataIndex: "desc",
width: 250
},
{
title: t("dataSource.table.list.columns.title.updatetim"),
Expand Down
3 changes: 3 additions & 0 deletions web/src/pages/jobManagement/components/bottomLog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ export default {
created() {
this.init();
},
beforeUnmount() {
clearInterval(this.progressTimer)
},
watch: {
jobId(val) {
this.jobExecutionId = val;
Expand Down
94 changes: 58 additions & 36 deletions web/src/pages/jobManagement/components/createJob.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
<div class="container">
<a-modal
:visible="visible"
:title="
!formState.originName
? $t('job.action.createJob')
: $t('job.action.copyJob')
"
:title="actionMap[mode]"
@ok="handleOk"
@cancel="handleCancel"
>
Expand All @@ -31,19 +27,19 @@
:wrapper-col="wrapperCol"
>
<a-form-item
v-if="!!formState.originName"
v-if="mode === 'copy'"
ref="originName"
:label="$t('job.jobDetail.originJob')"
name="originName"
>
<a-input v-model:value="formState.originName" disabled />
<a-input v-model:value="formState.originName" disabled/>
</a-form-item>
<a-form-item
ref="jobName"
:label="$t('job.jobDetail.name')"
name="jobName"
>
<a-input v-model:value="formState.jobName" />
<a-input v-model:value="formState.jobName" :maxLength="100" />
</a-form-item>
<a-form-item :label="$t('job.jobDetail.label')" name="jobLabels">
<a-tag
Expand Down Expand Up @@ -79,7 +75,7 @@
>
<a-select v-model:value="formState.jobType">
<a-select-option value="OFFLINE">{{$t('job.type.offline')}}</a-select-option>
<a-select-option value="STREAM">{{$t('job.type.stream')}} </a-select-option>
<!--<a-select-option value="STREAM">{{$t('job.type.stream')}} </a-select-option>-->
</a-select>
</a-form-item>
<a-form-item :label="$t('job.jobDetail.engine')" name="engineType">
Expand All @@ -91,7 +87,7 @@
</a-select>
</a-form-item>
<a-form-item :label="$t('job.jobDetail.description')" name="jobDesc">
<a-textarea v-model:value="formState.jobDesc" />
<a-textarea v-model:value="formState.jobDesc" :maxLength="240" />
</a-form-item>
</a-form>
</a-modal>
Expand All @@ -110,7 +106,7 @@ import {
} from 'vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import { useI18n } from '@fesjs/fes';
import { createJob, copyJob, getEngineType } from '@/common/service';
import { createJob, copyJob, modifyJob, getEngineType } from '@/common/service';
import { message } from 'ant-design-vue';
export default defineComponent({
components: {
Expand All @@ -120,12 +116,24 @@ export default defineComponent({
visible: Boolean,
editData: Object,
projectId: String,
mode: String
},
emits: ['handleJobAction'], //需要声明emits
setup(props, context) {
const actionMap = {
create: '创建任务',
copy: '复制任务',
modify: '编辑任务'
}
const successMap = {
create: '创建任务成功',
copy: '复制任务成功',
modify: '编辑任务成功'
}
const { t } = useI18n({ useScope: 'global' });
const formRef = ref();
const formState = reactive({
id: '',
originName: '',
jobName: '',
jobType: 'OFFLINE',
Expand All @@ -139,15 +147,23 @@ export default defineComponent({
inputVisible: false,
inputValue: '',
});
const _setFormData = (editData) => {
formState.jobName = editData.jobName || ''
formState.jobType = editData.jobType || ''
formState.engineType = editData.engineType || ''
formState.jobLabels = editData.jobLabels || ''
formState.jobDesc = editData.jobDesc || ''
formState.id = editData.id || ''
}
watchEffect(() => {
const editData = toRaw(props.editData);
if (editData.id) {
const { editData, mode } = props
_setFormData(editData)
if (mode === 'copy') {
formState.originName = editData.jobName;
formState.engineType = editData.engineType;
state.tags = editData.jobLabels ? editData.jobLabels.split(',') : [];
} else {
formState.originName = '';
formState.engineType = '';
formState.jobName = ''
state.tags = editData.jobLabels ? editData.jobLabels.split(',') : []
} else if (mode === 'modify'){
state.tags = editData.jobLabels ? editData.jobLabels.split(',') : []
}
});
const engines = reactive({
Expand Down Expand Up @@ -190,23 +206,30 @@ export default defineComponent({
const tags = toRaw(state.tags);
const { originName, ...rest } = data;
const editData = toRaw(props.editData);
const isCopy = !!editData.id;
const params = isCopy
? {
jobName: rest.jobName,
jobLabels: tags.join(','),
jobDesc: rest.jobDesc,
}
: {
...rest,
projectId: props.projectId,
jobLabels: tags.join(','),
};
const res = isCopy
? await copyJob(editData.id, params)
: await createJob(params);
let params, res
if (props.mode === 'copy') {
params = {
jobName: rest.jobName,
jobLabels: tags.join(','),
jobDesc: rest.jobDesc,
}
res = await copyJob(editData.id, params)
} else if (props.mode === 'create') {
params = {
...rest,
projectId: props.projectId,
jobLabels: tags.join(','),
}
res = await createJob(params)
} else if (props.mode === 'modify') {
params = {
...rest,
jobLabels: tags.join(','),
}
res = await modifyJob(editData.id, params)
}
if (res && res.result) {
message.success(t(isCopy ? 'job.action.copyJobSuccess' : 'job.action.addJobSuccess'))
message.success(successMap[props.mode])
context.emit('handleJobAction', { ...params, ...editData });
formRef.value.resetFields();
Object.assign(state, {
Expand All @@ -232,7 +255,6 @@ export default defineComponent({
const handleClose = (removedTag) => {
const tags = state.tags.filter((tag) => tag !== removedTag);
console.log(tags);
state.tags = [...tags];
};
Expand All @@ -249,7 +271,6 @@ export default defineComponent({
if (inputValue && !tags.includes(inputValue.trim())) {
tags = [...tags, inputValue.trim()];
}
console.log(tags);
Object.assign(state, {
tags,
inputVisible: false,
Expand All @@ -272,6 +293,7 @@ export default defineComponent({
showInput,
handleInputConfirm,
inputRef,
actionMap
};
},
});
Expand Down
36 changes: 26 additions & 10 deletions web/src/pages/jobManagement/components/dataSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ export default defineComponent({
const dataSource = reactive({
dataSourceIds: {
source: props.dsData.dataSourceIds.source || {},
sink: props.dsData.dataSourceIds.sink || {},
source: { ...props.dsData.dataSourceIds.source },
sink: { ...props.dsData.dataSourceIds.sink }
},
params: {
sources: props.dsData.params.sources || [],
sinks: props.dsData.params.sinks || [],
sources: [ ...props.dsData.params.sources ],
sinks: [ ...props.dsData.params.sinks ]
},
});
Expand All @@ -202,25 +202,42 @@ export default defineComponent({
sinksHelpStatus[key] = "success";
});
const newProps = computed(() => JSON.parse(JSON.stringify(props.dsData)));
const newProps = computed(() => JSON.parse(JSON.stringify(props.dsData)))
watch(newProps, (val, oldVal) => {
const newVal = typeof val === "string" ? JSON.parse(val) : val;
sourceTitle.value = objToTitle(newVal.dataSourceIds.source);
sinkTitle.value = objToTitle(newVal.dataSourceIds.sink);
dataSource.dataSourceIds = {
source: newVal.dataSourceIds.source || {},
sink: newVal.dataSourceIds.sink || {},
sink: newVal.dataSourceIds.sink || {}
};
dataSource.params = {
sources: newVal.params.sources || [],
sinks: newVal.params.sinks || [],
sinks: newVal.params.sinks || []
};
});
const formRef = ref();
const updateSourceInfo = (dsInfo, id) => {
const info = dsInfo.split("-");
if ((dataSource.dataSourceIds.sink.type && dataSource.dataSourceIds.source.type !== 'HIVE')
// 修改来源数据源,清空目的数据源
dataSource.dataSourceIds.sink = {
type: '',
id: '',
db: '',
table: '',
ds: ''
}
sinkTitle.value = objToTitle({
type: '',
id: '',
db: '',
table: '',
ds: '',
})
dataSource.params.sinks = []
/*if ((dataSource.dataSourceIds.sink.type && dataSource.dataSourceIds.source.type !== 'HIVE')
&& (info[0] && info[0] !== 'HIVE')
&& props.engineType === 'SQOOP') {
sourceTitle.value = objToTitle({
Expand All @@ -231,13 +248,12 @@ export default defineComponent({
ds: "",
});
return message.error("SQOOP引擎输入/输出数据源必须包含HIVE,请重新选择");
}
}*/
dataSource.dataSourceIds.source.type = info[0];
dataSource.dataSourceIds.source.ds = info[1];
dataSource.dataSourceIds.source.db = info[2];
dataSource.dataSourceIds.source.table = info[3];
dataSource.dataSourceIds.source.id = id;
getSourceParams(
props.engineType,
dataSource.dataSourceIds.source.type,
Expand Down
Loading

0 comments on commit 7e7c723

Please sign in to comment.