refactor(web): 优化页面显示和信息获取

This commit is contained in:
2023-06-13 00:57:04 +08:00
parent 48c18ce7e3
commit c1a9e5b24b

View File

@@ -1,3 +1,14 @@
function color(number) {
let color = 'text-success'
if (number > 30) {
color = 'text-primary'
}
if (number > 90) {
color = 'text-danger'
}
return color
}
function overviewYarnJob(cluster, search, queue, yarnQueue) { function overviewYarnJob(cluster, search, queue, yarnQueue) {
return { return {
className: 'font-mono', className: 'font-mono',
@@ -15,52 +26,16 @@ function overviewYarnJob(cluster, search, queue, yarnQueue) {
type: 'service', type: 'service',
className: 'inline ml-2', className: 'inline ml-2',
api: `\${base}/overview/queue?queue=compaction-queue-${cluster}`, api: `\${base}/overview/queue?queue=compaction-queue-${cluster}`,
interval: 10000,
silentPolling: true,
body: [ body: [
{ {
type: 'tpl', type: 'tpl',
tpl: '${PADSTART(size, 2)}', tpl: "${PADSTART(size, 2)}",
} }
] ]
}, },
overviewYarnCluster(cluster, yarnQueue),
'(',
{ {
type: 'tpl',
tpl: '<span class="font-bold">${PADSTART(total, 3)}</span>',
},
',',
{
type: 'tpl',
tpl: '<span class="font-bold text-cyan-300">${PADSTART(scheduling, 3)}</span>',
},
',',
{
type: 'tpl',
tpl: '<span class="font-bold text-success">${PADSTART(running, 3)}</span>',
},
',',
{
type: 'tpl',
tpl: '<span class="font-bold text-danger">${PADSTART(failure, 3)}</span>',
},
')',
]
}
}
function color(number) {
let color = 'text-success'
if (number > 30) {
color = 'text-primary'
}
if (number > 80) {
color = 'text-danger'
}
return color
}
function overviewYarnCluster(cluster, queue) {
return {
type: 'service', type: 'service',
className: 'inline', className: 'inline',
api: { api: {
@@ -68,7 +43,7 @@ function overviewYarnCluster(cluster, queue) {
url: `\${base}/overview/yarn-cluster`, url: `\${base}/overview/yarn-cluster`,
data: { data: {
cluster: cluster, cluster: cluster,
queue: queue, queue: yarnQueue,
}, },
adaptor: function (payload, response) { adaptor: function (payload, response) {
let rootUsed = (payload['data']['root']['usedCapacity'] * 100 / payload['data']['root']['capacity']).toFixed(0) let rootUsed = (payload['data']['root']['usedCapacity'] * 100 / payload['data']['root']['capacity']).toFixed(0)
@@ -91,7 +66,6 @@ function overviewYarnCluster(cluster, queue) {
'(', '(',
{ {
type: 'tpl', type: 'tpl',
className: 'font-bold',
tpl: '<span class="font-bold ${rootUsedColor}">${PADSTART(ROUND(rootUsed), 3)}%</span>', tpl: '<span class="font-bold ${rootUsedColor}">${PADSTART(ROUND(rootUsed), 3)}%</span>',
}, },
',', ',',
@@ -101,11 +75,35 @@ function overviewYarnCluster(cluster, queue) {
}, },
')' ')'
], ],
},
'(',
{
type: 'tpl',
tpl: "<span class='font-bold white-space-pre'>${PADSTART(total, 4)}</span>",
},
',',
{
type: 'tpl',
tpl: "<span class='font-bold text-cyan-300'>${PADSTART(scheduling, 2)}</span>",
},
',',
{
type: 'tpl',
tpl: '<span class="font-bold text-success">${PADSTART(running, 3)}</span>',
},
',',
{
type: 'tpl',
tpl: '<span class="font-bold text-danger">${PADSTART(failure, 3)}</span>',
},
')',
]
} }
} }
function overviewTab() { function overviewTab() {
return { return {
className: 'white-space-pre',
title: '概览', title: '概览',
tab: [ tab: [
{ {
@@ -135,7 +133,7 @@ function overviewTab() {
'<br>', '<br>',
{ {
type: 'tpl', type: 'tpl',
tpl: 'Hudi表:<span class="font-bold mr-1">${hudi_total}</span>', tpl: '湖底表:<span class="font-bold mr-1">${hudi_total}</span>',
}, },
'<br>', '<br>',
{ {
@@ -172,6 +170,8 @@ function overviewTab() {
{ {
type: 'service', type: 'service',
api: '${base}/overview/version', api: '${base}/overview/version',
interval: 10000,
silentPolling: true,
body: [ body: [
'版本:', '版本:',
{ {
@@ -180,18 +180,18 @@ function overviewTab() {
tpl: '${version}', tpl: '${version}',
}, },
'<br/>', '<br/>',
'<span class="italic text-gray-500 my-2">未接收,未跨天</span>', '<span class="italic text-gray-500 my-2">未接收, 未跨天</span>',
'<br/>', '<br/>',
'重点表:', '重点表:',
{ {
type: 'tpl', type: 'tpl',
tpl: '<span class="font-bold font-mono">${PADSTART(unReceive.focus, 3)},${PADSTART(unSchedule.focus, 3)}</span>', tpl: '<span class="font-bold font-mono">${PADSTART(unReceive.focus, 3)}, ${PADSTART(unSchedule.focus, 3)}</span>',
}, },
'<br/>', '<br/>',
'普通表:', '普通表:',
{ {
type: 'tpl', type: 'tpl',
tpl: '<span class="font-bold font-mono">${PADSTART(unReceive.normal, 3)},${PADSTART(unSchedule.normal, 3)}</span>', tpl: '<span class="font-bold font-mono">${PADSTART(unReceive.normal, 3)}, ${PADSTART(unSchedule.normal, 3)}</span>',
}, },
] ]
} }