From 5a385a8e9eb0c8e9013686687ae0ee0c8a0a53e3 Mon Sep 17 00:00:00 2001 From: BitcoinVM <18786721@qq.com> Date: Mon, 4 Mar 2024 14:41:46 +0800 Subject: [PATCH] improve uptime --- src/components/UptimeBar.vue | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/UptimeBar.vue b/src/components/UptimeBar.vue index b70c0495..fb84384b 100644 --- a/src/components/UptimeBar.vue +++ b/src/components/UptimeBar.vue @@ -11,13 +11,32 @@ const bars = computed(() => { const uptime = Array(50).fill({ height: 0, color: 'bg-secondary' }); if(!props.blocks) return uptime props.blocks.forEach((element) => { - const has = element.signatures?.findIndex( + // @deprecated + // const has = element.signatures?.findIndex( + // (sig) => sig.validator_address === props.validator + // ); + // // console.log(has, props.validato, element) + // uptime.push({ + // height: element.height, + // color: has > -1 ? 'bg-green-500' : 'bg-red-500', + // }); + + // show flag nil + const signature = element.signatures?.find( (sig) => sig.validator_address === props.validator ); - // console.log(has, props.validato, element) + // console.log("sign", signature) + let color = `bg-red-500` + if(signature) { + if(signature.block_id_flag === 'BLOCK_ID_FLAG_COMMIT') { + color = `bg-green-500` + } else { + color = `bg-yellow-500` + } + } uptime.push({ height: element.height, - color: has > -1 ? 'bg-green-500' : 'bg-red-500', + color, }); uptime.shift(); });