diff --git a/web/components/overview-tab.js b/web/components/overview-tab.js index 8b307e6..2c1cf9c 100644 --- a/web/components/overview-tab.js +++ b/web/components/overview-tab.js @@ -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) { return { className: 'font-mono', @@ -15,23 +26,65 @@ function overviewYarnJob(cluster, search, queue, yarnQueue) { type: 'service', className: 'inline ml-2', api: `\${base}/overview/queue?queue=compaction-queue-${cluster}`, + interval: 10000, + silentPolling: true, body: [ { type: 'tpl', - tpl: '${PADSTART(size, 2)}', + tpl: "${PADSTART(size, 2)}", } ] }, - overviewYarnCluster(cluster, yarnQueue), + { + type: 'service', + className: 'inline', + api: { + method: 'get', + url: `\${base}/overview/yarn-cluster`, + data: { + cluster: cluster, + queue: yarnQueue, + }, + adaptor: function (payload, response) { + let rootUsed = (payload['data']['root']['usedCapacity'] * 100 / payload['data']['root']['capacity']).toFixed(0) + let targetUsed = (payload['data']['target']['absoluteUsedCapacity'] * 100 / payload['data']['target']['absoluteMaxCapacity']).toFixed(0) + return { + ...payload, + data: { + ...payload.data, + rootUsed: rootUsed, + rootUsedColor: color(rootUsed), + targetUsed: targetUsed, + targetUsedColor: color(targetUsed), + } + } + } + }, + interval: 10000, + silentPolling: true, + body: [ + '(', + { + type: 'tpl', + tpl: '${PADSTART(ROUND(rootUsed), 3)}%', + }, + ',', + { + type: 'tpl', + tpl: '${PADSTART(ROUND(targetUsed), 3)}%', + }, + ')' + ], + }, '(', { type: 'tpl', - tpl: '${PADSTART(total, 3)}', + tpl: "${PADSTART(total, 4)}", }, ',', { type: 'tpl', - tpl: '${PADSTART(scheduling, 3)}', + tpl: "${PADSTART(scheduling, 2)}", }, ',', { @@ -48,64 +101,9 @@ function overviewYarnJob(cluster, search, queue, yarnQueue) { } } -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', - className: 'inline', - api: { - method: 'get', - url: `\${base}/overview/yarn-cluster`, - data: { - cluster: cluster, - queue: queue, - }, - adaptor: function (payload, response) { - let rootUsed = (payload['data']['root']['usedCapacity'] * 100 / payload['data']['root']['capacity']).toFixed(0) - let targetUsed = (payload['data']['target']['absoluteUsedCapacity'] * 100 / payload['data']['target']['absoluteMaxCapacity']).toFixed(0) - return { - ...payload, - data: { - ...payload.data, - rootUsed: rootUsed, - rootUsedColor: color(rootUsed), - targetUsed: targetUsed, - targetUsedColor: color(targetUsed), - } - } - } - }, - interval: 10000, - silentPolling: true, - body: [ - '(', - { - type: 'tpl', - className: 'font-bold', - tpl: '${PADSTART(ROUND(rootUsed), 3)}%', - }, - ',', - { - type: 'tpl', - tpl: '${PADSTART(ROUND(targetUsed), 3)}%', - }, - ')' - ], - } -} - function overviewTab() { return { + className: 'white-space-pre', title: '概览', tab: [ { @@ -135,7 +133,7 @@ function overviewTab() { '
', { type: 'tpl', - tpl: 'Hudi表:${hudi_total}', + tpl: '湖底表:${hudi_total}', }, '
', { @@ -172,6 +170,8 @@ function overviewTab() { { type: 'service', api: '${base}/overview/version', + interval: 10000, + silentPolling: true, body: [ '版本:', { @@ -180,18 +180,18 @@ function overviewTab() { tpl: '${version}', }, '
', - '未接收,未跨天', + '未接收, 未跨天', '
', '重点表:', { type: 'tpl', - tpl: '${PADSTART(unReceive.focus, 3)},${PADSTART(unSchedule.focus, 3)}', + tpl: '${PADSTART(unReceive.focus, 3)}, ${PADSTART(unSchedule.focus, 3)}', }, '
', '普通表:', { type: 'tpl', - tpl: '${PADSTART(unReceive.normal, 3)},${PADSTART(unSchedule.normal, 3)}', + tpl: '${PADSTART(unReceive.normal, 3)}, ${PADSTART(unSchedule.normal, 3)}', }, ] }