Skip to content

Commit 954e6c6

Browse files
[KYUUBI #7504][UI] Add a Batch management page to the Web UI
1 parent de20c20 commit 954e6c6

14 files changed

Lines changed: 1103 additions & 22 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import request from '@/utils/request'
19+
import {
20+
IBatch,
21+
IBatchSearch,
22+
ICloseBatchResponse,
23+
IGetBatchesResponse,
24+
IOperationLog
25+
} from './types'
26+
27+
function cleanParams(params: IBatchSearch): IBatchSearch {
28+
return Object.fromEntries(
29+
Object.entries(params).filter(([, value]) => value !== '')
30+
) as IBatchSearch
31+
}
32+
33+
export function getAllBatches(params: IBatchSearch) {
34+
return request({
35+
url: 'api/v1/batches',
36+
method: 'get',
37+
params: cleanParams(params)
38+
}) as Promise<IGetBatchesResponse>
39+
}
40+
41+
export function getBatch(batchId: string) {
42+
return request({
43+
url: `api/v1/batches/${batchId}`,
44+
method: 'get'
45+
}) as Promise<IBatch>
46+
}
47+
48+
export function deleteBatch(batchId: string) {
49+
return request({
50+
url: `api/v1/batches/${batchId}`,
51+
method: 'delete'
52+
}) as Promise<ICloseBatchResponse>
53+
}
54+
55+
export function getBatchLocalLog(batchId: string, from = 0, size = 1000) {
56+
return request({
57+
url: `api/v1/batches/${batchId}/localLog`,
58+
method: 'get',
59+
params: {
60+
from,
61+
size
62+
}
63+
}) as Promise<IOperationLog>
64+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export interface IBatchSearch {
19+
batchType?: string
20+
batchState?: string
21+
batchUser?: string
22+
batchName?: string
23+
createTime?: number
24+
endTime?: number
25+
from?: number
26+
size?: number
27+
desc?: boolean
28+
}
29+
30+
export interface IBatch {
31+
id: string
32+
user: string
33+
batchType: string
34+
name: string | null
35+
appStartTime: number
36+
appId: string | null
37+
appUrl: string | null
38+
appState: string | null
39+
appDiagnostic: string | null
40+
kyuubiInstance: string
41+
state: string
42+
createTime: number
43+
endTime: number
44+
batchInfo?: Record<string, string>
45+
}
46+
47+
export interface IGetBatchesResponse {
48+
from: number
49+
total: number
50+
batches: IBatch[]
51+
}
52+
53+
export interface IOperationLog {
54+
logRowSet: string[]
55+
rowCount: number
56+
}
57+
58+
export interface ICloseBatchResponse {
59+
success: boolean
60+
msg: string | null
61+
}

kyuubi-server/web-ui/src/layout/components/aside/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export const MENUS = [
3333
label: 'Operation',
3434
router: '/management/operation'
3535
},
36+
{
37+
label: 'Batch',
38+
router: '/management/batch'
39+
},
3640
{
3741
label: 'Engine',
3842
router: '/management/engine'

kyuubi-server/web-ui/src/locales/en_US/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ export default {
2323
kyuubi_instance: 'Kyuubi Instance',
2424
session_id: 'Session ID',
2525
operation_id: 'Operation ID',
26+
batch_id: 'Batch ID',
27+
batch_name: 'Batch Name',
28+
batch_type: 'Batch Type',
2629
create_time: 'Create Time',
30+
end_time: 'End Time',
2731
start_time: 'State Time',
2832
complete_time: 'Completed Time',
2933
state: 'State',
34+
app_id: 'Application ID',
35+
app_url: 'Application URL',
36+
app_state: 'Application State',
37+
app_diagnostic: 'Application Diagnostic',
3038
duration: 'Duration',
3139
statement: 'Statement',
3240
engine_address: 'Engine Address',
@@ -39,6 +47,11 @@ export default {
3947
session_properties: 'Session Properties',
4048
no_data: 'No data',
4149
no_log: 'No log',
50+
follow: 'Follow',
51+
refresh: 'Refresh',
52+
log_truncated: 'Only the latest {count} lines are shown',
53+
previous: 'Previous',
54+
next: 'Next',
4255
run_sql_tips: 'Run a SQL to get result',
4356
result: 'Result',
4457
log: 'Log',
@@ -60,7 +73,9 @@ export default {
6073
cancel_succeeded: 'Cancel {name} Succeeded',
6174
cancel_failed: 'Cancel {name} Failed',
6275
run_sql_failed: 'Run SQL Failed',
76+
get_batches_failed: 'Get Batches Failed',
6377
get_sql_log_failed: 'Get SQL Log Failed',
78+
get_batch_log_failed: 'Get Batch Log Failed',
6479
get_sql_result_failed: 'Get SQL Result Failed',
6580
get_sql_metadata_failed: 'Get SQL Metadata Failed'
6681
}

kyuubi-server/web-ui/src/locales/zh_CN/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ export default {
2323
kyuubi_instance: '服务端实例',
2424
session_id: 'Session ID',
2525
operation_id: 'Operation ID',
26+
batch_id: 'Batch ID',
27+
batch_name: 'Batch 名称',
28+
batch_type: 'Batch 类型',
2629
create_time: '创建时间',
30+
end_time: '结束时间',
2731
start_time: '开始时间',
2832
complete_time: '完成时间',
2933
state: '状态',
34+
app_id: 'Application ID',
35+
app_url: 'Application 地址',
36+
app_state: 'Application 状态',
37+
app_diagnostic: 'Application 诊断',
3038
duration: '运行时间',
3139
statement: 'Statement',
3240
engine_address: 'Engine 地址',
@@ -39,6 +47,11 @@ export default {
3947
session_properties: 'Session 参数',
4048
no_data: '无数据',
4149
no_log: '无日志',
50+
follow: '跟随',
51+
refresh: '刷新',
52+
log_truncated: '仅显示最新 {count} 行',
53+
previous: '上一页',
54+
next: '下一页',
4255
run_sql_tips: '请运行SQL获取结果',
4356
result: '结果',
4457
log: '日志',
@@ -60,7 +73,9 @@ export default {
6073
cancel_succeeded: '取消 {name} 成功',
6174
cancel_failed: '取消 {name} 失败',
6275
run_sql_failed: '运行SQL失败',
76+
get_batches_failed: '获取 Batch 列表失败',
6377
get_sql_log_failed: '获取SQL日志失败',
78+
get_batch_log_failed: '获取 Batch 日志失败',
6479
get_sql_result_failed: '获取SQL结果失败',
6580
get_sql_metadata_failed: '获取SQL元数据失败'
6681
}

kyuubi-server/web-ui/src/router/management/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const router = [
3535
path: '/management/operation',
3636
name: 'operation',
3737
component: () => import('@/views/management/operation/index.vue')
38+
},
39+
{
40+
path: '/management/batch',
41+
name: 'batch',
42+
component: () => import('@/views/management/batch/index.vue')
3843
}
3944
]
4045

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import {
19+
getEngineUIUrl,
20+
getProxyEngineUIUrl,
21+
normalizeEngineUIUrl
22+
} from '@/utils/engine-ui'
23+
import { expect, test } from 'vitest'
24+
25+
test('engine ui url direct mode', () => {
26+
expect(normalizeEngineUIUrl('host:4040')).toEqual('http://host:4040')
27+
expect(getEngineUIUrl('https://host:4040/sql', false)).toEqual(
28+
'https://host:4040/sql'
29+
)
30+
})
31+
32+
test('engine ui url proxy mode', () => {
33+
expect(getProxyEngineUIUrl('spark.example.com:4040')).toEqual(
34+
`${import.meta.env.VITE_APP_DEV_WEB_URL}engine-ui/spark.example.com:4040/`
35+
)
36+
expect(getEngineUIUrl('spark.example.com:4040/sql/?id=1', true)).toEqual(
37+
`${
38+
import.meta.env.VITE_APP_DEV_WEB_URL
39+
}engine-ui/spark.example.com:4040/sql/?id=1`
40+
)
41+
})

0 commit comments

Comments
 (0)