Skip to content

Commit

Permalink
[linkis-web-next]: Microservice Management Module Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Linhao-Qian committed Aug 28, 2024
1 parent 7e4152f commit b8da249
Show file tree
Hide file tree
Showing 9 changed files with 461 additions and 87 deletions.
2 changes: 1 addition & 1 deletion linkis-web-next/src/components/sidebar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const menuItemsConfig = [
{
title: 'message.linkis.sideNavList.function.children.microserviceManage',
icon: '/sidebar/microserviceManage.svg',
path: '/xxx',
path: '/console/microServiceManagement',
},
{
title: 'message.linkis.sideNavList.function.children.dataSourceManage',
Expand Down
4 changes: 4 additions & 0 deletions linkis-web-next/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ export default {
ConfirmEdit: 'Done',
serviceRegistryCenter: 'Service Registry Center',
addTags: 'Add Tags',
labelEmptyError: 'Label cannot be empty',
labelNoSpecialSymbol: 'Spance and Chinese characters are not allowed',
labelLengthLimit: 'Label length should not exceed 16',
unfold: 'Unfold',
fold: 'Fold',
jumpPage: 'Please check in the jump page...',
Expand Down Expand Up @@ -547,6 +550,7 @@ export default {
executionCode: 'Execution Code',
status: 'Status',
label: 'Label',
editLabel: 'Edit Label',
engineVersion: 'Engine Version',
engineVersionCannotBeNull: 'Engine Version Cannot Be Null',
addApplicationRules:
Expand Down
4 changes: 4 additions & 0 deletions linkis-web-next/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ export default {
description: '描述',
noDescription: '暂无描述',
addTags: '添加标签',
labelEmptyError: '标签不能为空',
labelNoSpecialSymbol: '不得存在空格和中文',
labelLengthLimit: '标签内容长度不超过16',
find: '查询',
initiator: '创建者',
inputOwnerHint: '请输入创建者',
Expand Down Expand Up @@ -522,6 +525,7 @@ export default {
status: '状态',
costTime: '已耗时',
label: '标签',
editLabel: '编辑标签',
engineVersion: '引擎版本',
engineVersionCannotBeNull: '引擎版本不能为空',
addApplicationRules: '应用名称不能有特殊符号和空格',
Expand Down
44 changes: 22 additions & 22 deletions linkis-web-next/src/pages/globalHistoryManagement/filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
-->

<template>
<div class="label">{{ $t('message.linkis.globalTaskQuery') }}</div>
<div class="label">{{ t('message.linkis.globalTaskQuery') }}</div>
<div>
<FForm v-show="!isCheckingTaskToStop" layout="inline" :span="4">
<FFormItem
:label="$t('message.linkis.columns.taskID')"
:props="$t('message.linkis.columns.taskID')"
:label="t('message.linkis.columns.taskID')"
:props="t('message.linkis.columns.taskID')"
>
<FInput
v-model="formData.taskID"
Expand All @@ -30,8 +30,8 @@
/>
</FFormItem>
<FFormItem
:label="$t('message.linkis.columns.status')"
:props="$t('message.linkis.columns.status')"
:label="t('message.linkis.columns.status')"
:props="t('message.linkis.columns.status')"
>
<FSelect
v-model="formData.status"
Expand All @@ -42,22 +42,22 @@
v-for="(item, index) in statusList"
:key="index"
:value="item.value"
:label="$t(item.label)"
:label="t(item.label)"
/>
</FSelect>
</FFormItem>
<FFormItem
:label="$t('message.linkis.columns.requestApplicationName')"
:props="$t('message.linkis.columns.requestApplicationName')"
:label="t('message.linkis.columns.requestApplicationName')"
:props="t('message.linkis.columns.requestApplicationName')"
>
<FInput
v-model="formData.creator"
:placeholder="t('message.linkis.datasource.pleaseInput')"
/>
</FFormItem>
<FFormItem
:label="$t('message.linkis.columns.executeApplicationName')"
:props="$t('message.linkis.columns.executeApplicationName')"
:label="t('message.linkis.columns.executeApplicationName')"
:props="t('message.linkis.columns.executeApplicationName')"
>
<FSelect
v-model="formData.executeApplicationName"
Expand All @@ -68,13 +68,13 @@
v-for="(item, index) in engineList"
:key="index"
:value="item.value"
:label="$t(item.label)"
:label="t(item.label)"
/>
</FSelect>
</FFormItem>
<FFormItem
:label="$t('message.linkis.columns.createdTime')"
:prop="$t('message.linkis.columns.createdTime')"
:label="t('message.linkis.columns.createdTime')"
:prop="t('message.linkis.columns.createdTime')"
:span="8"
>
<!-- 日期修改完成后需要让日期选择组件失焦 -->
Expand All @@ -86,8 +86,8 @@
/>
</FFormItem>
<FFormItem
:label="$t('message.linkis.columns.umUser')"
:props="$t('message.linkis.columns.umUser')"
:label="t('message.linkis.columns.umUser')"
:props="t('message.linkis.columns.umUser')"
v-if="isAdminView"
>
<FInput
Expand All @@ -99,16 +99,16 @@
<div class="buttons">
<template v-if="!isCheckingTaskToStop">
<FButton type="primary" @click="search">
{{ $t('message.linkis.find') }}
{{ t('message.linkis.find') }}
</FButton>
<FButton @click="reset">
{{ $t('message.linkis.reset') }}
{{ t('message.linkis.reset') }}
</FButton>
<FButton @click="switchAdmin" v-show="isLogAdmin || isHistoryAdmin">
{{ isAdminView ? $t('message.linkis.generalView') : $t('message.linkis.manageView') }}
{{ isAdminView ? t('message.linkis.generalView') : t('message.linkis.manageView') }}
</FButton>
<FButton @click="isCheckingTaskToStop = true">
{{ $t('message.linkis.batchStop') }}
{{ t('message.linkis.batchStop') }}
</FButton>
</template>
</div>
Expand All @@ -119,21 +119,21 @@
class="confirm-stop-button"
@click="confirmStop"
>
{{ $t('message.linkis.confirmToStop') }}
{{ t('message.linkis.confirmToStop') }}
</FButton>
<FButton
class="confirm-stop-button"
@click="isCheckingTaskToStop = false"
>
{{ $t('message.linkis.cancel') }}
{{ t('message.linkis.cancel') }}
</FButton>
</div>
</template>
</div>
</template>

<script lang="ts" setup>
import { FForm, FMessage } from '@fesjs/fes-design';
import { FMessage } from '@fesjs/fes-design';
import { ref, onMounted, reactive } from 'vue';
import { useI18n } from 'vue-i18n';
import api from '@/service/api';
Expand Down
209 changes: 209 additions & 0 deletions linkis-web-next/src/pages/microServiceManagement/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<!--
~ 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
~
~ http://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.
-->

<template>
<FForm layout="inline" :span="8">
<FFormItem
:label="t('message.linkis.tableColumns.instanceName')"
:props="t('message.linkis.tableColumns.instanceName')"
>
<FInput
v-model="instanceName"
:placeholder="t('message.linkis.datasource.pleaseInput')"
/>
</FFormItem>
<FFormItem
:label="t('message.linkis.tableColumns.engineType')"
:props="t('message.linkis.tableColumns.engineType')"
>
<FSelect
v-model="engineType"
clearable
:placeholder="t('message.linkis.unselect')"
>
<FOption
v-for="(item, index) in engineTypes"
:key="index"
:value="item"
:label="item"
/>
</FSelect>
</FFormItem>
<FFormItem>
<div class="btns">
<FButton type="primary" @click="search">
{{ t('message.linkis.find') }}
</FButton>
<FButton type="primary" @click="handleJump">
{{ t('message.linkis.serviceRegistryCenter') }}
</FButton>
</div>
</FFormItem>
</FForm>
<f-table
:data="dataList"
class="table"
:rowKey="(row: Record<string, number | string>) => row.categoryId"
:emptyText="t('message.linkis.noDataText')"
>
<template v-for="col in tableColumns" :key="col.label">
<f-table-column
v-if="col.formatter"
:prop="col.prop"
:label="col.label"
:formatter="col.formatter"
/>
<f-table-column
v-else
:prop="col.prop"
:label="col.label"
:action="col.action"
/>
</template>
</f-table>
<FPagination
class="pagination"
show-size-changer
show-total
:total-count="tableData?.length || 0"
v-model:currentPage="currentPage"
@change="handleChangePagination"
:pageSizeOption="[10, 20, 30, 50, 100]"
v-model:pageSize="pageSize"
/>
<Modal ref="modalRef" :instance="currentIns" :handleInitialization="handleInitialization" />
</template>

<script lang="ts" setup>
import api from '@/service/api';
import { FSpace, FTag } from '@fesjs/fes-design';
import dayjs from 'dayjs';
import { onMounted, reactive, ref, h } from 'vue';
import Modal from './modal.vue';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const instanceName = ref('');
const engineType = ref('');
const engineTypes = reactive<{ label: string, value: string }[]>([]);
const dataList = ref();
const tableData = ref();
const allInstance = ref();
const currentPage = ref(1);
const pageSize = ref(10);
const modalRef = ref();
const currentIns = ref();

const handleEdit = (instance: any) => {
currentIns.value = instance;
modalRef.value?.open();
}

const tableColumns = [
{
prop: 'instance',
label: t('message.linkis.tableColumns.instanceName'),
},
{
prop: 'labels',
label: t('message.linkis.tableColumns.label'),
formatter: (data: { row: { labels: { stringValue: string }[] }}) =>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
h(FSpace, data.row.labels.map(label => h(FTag, { type: 'default', effect: 'plain', size: 'small' }, label.stringValue)))
},
{
prop: 'applicationName',
label: t('message.linkis.tableColumns.serveType'),
},
{
prop: 'createTime',
label: t('message.linkis.tableColumns.createdTime'),
formatter: ({ row }: { row: { createTime: number } }) => dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
prop: 'updateTime',
label: t('message.linkis.tableColumns.updateTime'),
formatter: ({ row }: { row: { updateTime: number } }) => dayjs(row.updateTime).format('YYYY-MM-DD HH:mm:ss'),
},
{
// 在“操作”两个字前添加空格,使其能与“编辑”上下对齐
label: `\u00A0\u00A0\u00A0\u00A0${t('message.linkis.columns.control.title')}`,
action: [{
label: t('message.linkis.tableColumns.editLabel'),
func: handleEdit,
}],
},
];

const search = () => {
if (instanceName.value || engineType.value) {
tableData.value = allInstance.value.filter((item: any) =>
item.instance.match(instanceName.value) && item.applicationName.match(engineType.value)
);
} else {
tableData.value = [...allInstance.value];
}
currentPage.value = 1;
handleChangePagination(currentPage.value, pageSize.value);
}

const handleJump = () => {
api.fetch("/microservice/serviceRegistryURL", "get").then((rst: any) => {
window.open(rst.url, "_blank");
});
}

// eslint-disable-next-line no-shadow
const handleChangePagination = (currentPage: number, pageSize: number) => {
const temp = tableData.value.slice(
(currentPage - 1) * pageSize,
currentPage * pageSize,
);
dataList.value = [...temp] as any;
};

const handleInitialization = () => {
api.fetch("/microservice/allInstance", "get").then((res: any) => {
allInstance.value = [...res.instances] || [];
tableData.value = [...res.instances] || [];
handleChangePagination(currentPage.value, pageSize.value);
res.instances.forEach((item: any) => {
if (engineTypes.indexOf(item.applicationName) === -1) {
engineTypes.push(item.applicationName);
}
})
})
}

onMounted(() => {
handleInitialization();
})
</script>

<style lang="less" scoped>
.btns {
display: flex;
gap: 12px;
}
.pagination {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
</style>
Loading

0 comments on commit b8da249

Please sign in to comment.