Skip to content

Commit

Permalink
[Improvement]: Supplement mock and merge code (#2841)
Browse files Browse the repository at this point in the history
Co-authored-by: ZhouJinsong <[email protected]>
  • Loading branch information
zhangmo8 and zhoujinsong authored May 17, 2024
1 parent e668d39 commit bb56cfe
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 33 deletions.
31 changes: 24 additions & 7 deletions amoro-ams/amoro-ams-dashboard/mock/modules/optimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ export default [
}
}),
},
{
url: '/mock/ams/v1/optimize/optimizerGroups/all/optimizers',
method: 'get',
response: () => ({ "message": "success", "code": 200, "result": { "list": [], "total": 0 } }),
},
{
url: '/mock/ams/v1/optimize/optimizerGroups/local/optimizers',
method: 'post',
Expand Down Expand Up @@ -160,6 +155,28 @@ export default [
"result": "The optimizer group has been successfully deleted."
}),
},


{
url: '/mock/ams/v1/optimize/optimizerGroups/all/optimizers',
method: 'get',
response: () => ({
"message": "success",
"code": 200,
"result": {
"list": [
{
"token": "183c4ce4-a006-4d18-b8b3-4f9bee3e7527",
"startTime": 1715862320085,
"touchTime": 1715862530475,
"jobId": null,
"groupName": "local",
"coreNumber": 1,
"memory": 8192,
"jobStatus": "RUNNING",
"container": "localContainer"
}
],
"total": 1
}
}),
},
]
125 changes: 123 additions & 2 deletions amoro-ams/amoro-ams-dashboard/mock/modules/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,134 @@ export default [
}),
},
{
url: '/mock/ams/v1/tables/catalogs/test_catalog/dbs/db/tables/user/optimizing-processes',
url: '/mock/ams/v1/tables/catalogs/test_catalog/dbs/db/tables/user/operations',
method: 'get',
response: () => ({ "message": "success", "code": 200, "result": { "list": [], "total": 0 } }),
},
{
url: '/mock/ams/v1/tables/catalogs/test_catalog/dbs/db/tables/user/partitions/:filter/files',
method: 'get',
response: () => ({
"message": "success",
"code": 200,
"result": {
"list": [
{
"commitId": "3015968602476930240",
"fileType": "BASE_FILE",
"commitTime": 1715861982880,
"size": "883.00B",
"partition": "ts_day=2022-07-01",
"specId": 0,
"path": "/tmp/local_iceberg/db/user/data/ts_day=2022-07-01/00042-1-179d061d-6fe9-4945-b6a6-f8c088595412-00001.parquet",
"file": "00042-1-179d061d-6fe9-4945-b6a6-f8c088595412-00001.parquet",
"fileSize": 883,
"operation": null
}
],
"total": 1
}
}),
},
{
url: '/mock/ams/v1/tables/catalogs/test_catalog/dbs/db/tables/user/snapshots/:snapshotId/detail',
method: 'get',
response: () => ({
"message": "success",
"code": 200,
"result": {
"list": [
{
"commitId": "3015968602476930240",
"fileType": "BASE_FILE",
"commitTime": 1715861982880,
"size": "883.00B",
"partition": "ts_day=2022-07-01",
"specId": 0,
"path": "/tmp/local_iceberg/db/user/data/ts_day=2022-07-01/00042-1-179d061d-6fe9-4945-b6a6-f8c088595412-00001.parquet",
"file": "00042-1-179d061d-6fe9-4945-b6a6-f8c088595412-00001.parquet",
"fileSize": 883,
"operation": "add"
},
{
"commitId": "3015968602476930240",
"fileType": "BASE_FILE",
"commitTime": 1715861982880,
"size": "891.00B",
"partition": "ts_day=2022-07-02",
"specId": 0,
"path": "/tmp/local_iceberg/db/user/data/ts_day=2022-07-02/00082-2-179d061d-6fe9-4945-b6a6-f8c088595412-00001.parquet",
"file": "00082-2-179d061d-6fe9-4945-b6a6-f8c088595412-00001.parquet",
"fileSize": 891,
"operation": "add"
}
],
"total": 2
}
}),
},
{
url: '/mock/ams/v1/tables/catalogs/test_catalog/dbs/db/tables/user/optimizing-processes',
method: 'get',
response: () => ({
"message": "success",
"code": 200,
"result": {
"list": [
{
"tableId": 1,
"catalogName": "local_iceberg",
"dbName": "db",
"tableName": "user",
"processId": 1715862413340,
"startTime": 1715862413340,
"optimizingType": "MINOR",
"status": "SUCCESS",
"failReason": null,
"duration": 1531,
"successTasks": 2,
"totalTasks": 2,
"runningTasks": 0,
"finishTime": 1715862414871,
"inputFiles": {
"fileCnt": 16,
"totalSize": 14192,
"averageSize": 887
},
"outputFiles": {
"fileCnt": 2,
"totalSize": 2064,
"averageSize": 1032
},
"summary": {
"input-data-files(rewrite)": "16",
"input-data-size(rewrite)": "13.86KB",
"input-data-records(rewrite)": "24",
"output-data-files": "2",
"output-data-size": "2.02KB",
"output-data-records": "24"
}
}
],
"total": 1
}
}),
},
{
url: '/mock/ams/v1/tables/catalogs/test_catalog/dbs/db/tables/user/operations',
method: 'get',
response: () => ({ "message": "success", "code": 200, "result": { "list": [], "total": 0 } }),
response: () => ({
"message": "success",
"code": 200,
"result": {
"list": [
{
"ts": 1715862487163,
"operation": "ALTER TABLE user ADD COLUMNS (age bigint)"
}
],
"total": 1
}
}),
},
]
3 changes: 3 additions & 0 deletions amoro-ams/amoro-ams-dashboard/src/language/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {
logout: 'Logout',
logoutModalTitle: 'Log out of the ams?',
order: 'Order',
token: 'Token',
cluster: 'Cluster',
database: 'Database | Databases',
table: 'Table | Tables',
Expand Down Expand Up @@ -83,6 +84,7 @@ export default {
fileContent: 'File Content',
startTime: 'Start Time',
finishTime: 'Finish Time',
touchTime: 'Touch Time',
duration: 'Duration',
optimizeType: 'Optimize Type',
parallelism: 'Parallelism',
Expand All @@ -94,6 +96,7 @@ export default {
operationDetails: 'Operation Details',
copy: 'Copy',
optimizer: 'Optimizer',
optimizerId: 'Optimizer Id',
optimizers: 'Optimizers',
container: 'Container',
status: 'Status',
Expand Down
2 changes: 2 additions & 0 deletions amoro-ams/amoro-ams-dashboard/src/types/common.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ export interface IIOptimizeGroupItem {
}

export interface IOptimizeResourceTableItem {
touchTime: string;
startTime: string;
index: number
jobId: number
jobStatus: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
Expand All @@ -19,31 +18,28 @@ limitations under the License.

<template>
<div class="list-wrap">
<a-table
class="ant-table-common"
:columns="columns"
:data-source="dataSource"
:pagination="pagination"
:loading="loading"
@change="changeTable"
>
<a-table class="ant-table-common" :columns="columns" :data-source="dataSource" :pagination="pagination"
:loading="loading" @change="changeTable">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'durationDisplay'">
<span :title="record.durationDesc">
{{ record.durationDisplay }}
</span>
</template>
<template v-if="column.dataIndex === 'optimizeStatus'">
<span :style="{'background-color': (STATUS_CONFIG[record.optimizeStatus] || {}).color}" class="status-icon"></span>
<span :style="{ 'background-color': (STATUS_CONFIG[record.optimizeStatus] || {}).color }"
class="status-icon"></span>
<span>{{ record.optimizeStatus }}</span>
</template>
<template v-if="column.dataIndex === 'operation'">
<span class="primary-link" :class="{'disabled': record.container === 'external'}" @click="releaseModal(record)">
<span class="primary-link" :class="{ 'disabled': record.container === 'external' }"
@click="releaseModal(record)">
{{ t('release') }}
</span>
</template>
<template v-if="column.dataIndex === 'operationGroup'">
<span class="primary-link g-mr-12" :class="{'disabled': record.container === 'external'}" @click="scaleOutGroup(record)">
<span class="primary-link g-mr-12" :class="{ 'disabled': record.container === 'external' }"
@click="scaleOutGroup(record)">
{{ t('scaleOut') }}
</span>
<span class="primary-link g-mr-12" @click="editGroup(record)">
Expand All @@ -65,7 +61,7 @@ import { IOptimizeResourceTableItem, IIOptimizeGroupItem } from '@/types/common.
import { getOptimizerResourceList, getResourceGroupsListAPI, groupDeleteCheckAPI, groupDeleteAPI, releaseResource } from '@/services/optimize.service'
import { useI18n } from 'vue-i18n'
import { usePagination } from '@/hooks/usePagination'
import { mbToSize } from '@/utils'
import { mbToSize, dateFormat } from '@/utils'
import { message, Modal, Table as ATable } from 'ant-design-vue'
Expand All @@ -77,7 +73,7 @@ const router = useRouter()
const props = defineProps<{ curGroupName: string, type: string }>()
const emit = defineEmits<{(e: 'editGroup', record: IIOptimizeGroupItem): void; (e: 'refresh'): void}>()
const emit = defineEmits<{ (e: 'editGroup', record: IIOptimizeGroupItem): void; (e: 'refresh'): void }>()
const STATUS_CONFIG = shallowReactive({
pending: { title: 'pending', color: '#ffcc00' },
Expand All @@ -98,11 +94,14 @@ const tableColumns = shallowReactive([
{ dataIndex: 'operationGroup', title: t('operation'), key: 'operationGroup', ellipsis: true, width: 230, scopedSlots: { customRender: 'operationGroup' } }
])
const optimizerColumns = shallowReactive([
{ dataIndex: 'index', title: t('order'), width: 80, ellipsis: true },
{ dataIndex: 'jobId', title: t('optimizerId'), width: '15%', ellipsis: true },
{ dataIndex: 'token', title: t('token'), width: '10%', ellipsis: true },
{ dataIndex: 'groupName', title: t('optimizerGroup'), ellipsis: true },
{ dataIndex: 'container', title: t('container'), ellipsis: true },
{ dataIndex: 'jobStatus', title: t('status'), ellipsis: true },
{ dataIndex: 'resourceAllocation', title: t('resourceAllocation'), width: '20%', ellipsis: true },
{ dataIndex: 'resourceAllocation', title: t('resourceAllocation'), width: '10%', ellipsis: true },
{ dataIndex: 'startTime', title: t('startTime'), width: 172, ellipsis: true },
{ dataIndex: 'touchTime', title: t('touchTime'), width: 172, ellipsis: true },
{ dataIndex: 'operation', title: t('operation'), key: 'operation', ellipsis: true, width: 160, scopedSlots: { customRender: 'operationGroup' } }
])
const pagination = reactive(usePagination())
Expand All @@ -128,7 +127,7 @@ function refresh(resetPage?: boolean) {
}
}
function releaseModal (record: IOptimizeResourceTableItem) {
function releaseModal(record: IOptimizeResourceTableItem) {
if (record.container === 'external') {
return
}
Expand All @@ -142,12 +141,12 @@ function releaseModal (record: IOptimizeResourceTableItem) {
}
})
}
async function releaseJob (record: IOptimizeResourceTableItem) {
async function releaseJob(record: IOptimizeResourceTableItem) {
try {
releaseLoading.value = true
await releaseResource({
optimizerGroup: record.groupName,
jobId: record.jobId
jobId: (record.jobId) as unknown as string
})
refresh(true)
emit('refreshCurGroupInfo')
Expand All @@ -156,7 +155,7 @@ async function releaseJob (record: IOptimizeResourceTableItem) {
}
}
async function getOptimizersList () {
async function getOptimizersList() {
try {
optimizersList.length = 0
loading.value = true
Expand All @@ -171,6 +170,8 @@ async function getOptimizersList () {
(list || []).forEach((p: IOptimizeResourceTableItem, index: number) => {
p.resourceAllocation = `${p.coreNumber} ${t('core')} ${mbToSize(p.memory)}`
p.index = (pagination.current - 1) * pagination.pageSize + index + 1
p.startTime = p.startTime ? dateFormat(p.startTime) : '-'
p.touchTime = p.touchTime ? dateFormat(p.touchTime) : '-'
optimizersList.push(p)
})
} catch (error) {
Expand All @@ -179,7 +180,7 @@ async function getOptimizersList () {
}
}
async function getResourceGroupsList () {
async function getResourceGroupsList() {
try {
groupList.length = 0
loading.value = true
Expand All @@ -200,12 +201,12 @@ async function getResourceGroupsList () {
const editGroup = (record: IIOptimizeGroupItem) => {
emit('editGroup', record)
}
const removeGroup = async(record: IIOptimizeGroupItem) => {
const removeGroup = async (record: IIOptimizeGroupItem) => {
const res = await groupDeleteCheckAPI({ name: record.name })
if (res) {
Modal.confirm({
title: t('deleteGroupModalTitle'),
onOk: async() => {
onOk: async () => {
await groupDeleteAPI({ name: record.name })
message.success(`${t('remove')} ${t('success')}`)
refresh()
Expand All @@ -229,7 +230,7 @@ const scaleOutGroup = (record: IIOptimizeGroupItem) => {
scaleOutViseble.value = true
}
function changeTable ({ current = pagination.current, pageSize = pagination.pageSize }) {
function changeTable({ current = pagination.current, pageSize = pagination.pageSize }) {
pagination.current = current
const resetPage = pageSize !== pagination.pageSize
pagination.pageSize = pageSize
Expand All @@ -244,16 +245,20 @@ onMounted(() => {
.list-wrap {
.primary-link {
color: @primary-color;
&:hover {
cursor: pointer;
}
&.disabled {
color: #999;
&:hover {
cursor: not-allowed;
}
}
}
.status-icon {
width: 8px;
height: 8px;
Expand Down

0 comments on commit bb56cfe

Please sign in to comment.