-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dynamic icon showing report status
- Loading branch information
Showing
7 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script setup lang="ts"> | ||
import IconTick from "~icons/carbon/checkmark-filled" | ||
import IconWarning from "~icons/carbon/warning-filled" | ||
import IconDanger from "~icons/carbon/face-dizzy-filled" | ||
import IconUnknown from "~icons/carbon/help-filled" | ||
import { statusString } from "~~/utils/function" | ||
const props = defineProps({ | ||
uptime: Number, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="inline-flex text-xl"> | ||
<IconTick v-if="statusString(uptime) == 'success'" class="text-purple-500"></IconTick> | ||
<IconWarning v-else-if="statusString(uptime) == 'warning'" class="text-yellow-300"></IconWarning> | ||
<IconDanger v-else-if="statusString(uptime) == 'danger'" class="text-red-400"></IconDanger> | ||
<IconUnknown v-else-if="statusString(uptime) == 'unknown'" class="text-gray-300"></IconUnknown> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
export const formatUptime = (data: number) => { | ||
return ((data ?? 0) * 100).toFixed(2) + "%" | ||
} | ||
|
||
export const isSameDate = (a: string | Date, b: string | Date) => { | ||
let adt = new Date(a) | ||
let bdt = new Date(b) | ||
return adt.getDate() === bdt.getDate() && adt.getMonth() === bdt.getMonth() && adt.getFullYear() === bdt.getFullYear() | ||
} | ||
|
||
export const statusColor = (uptime: number, type = "bg") => { | ||
if (uptime >= 0.75) { | ||
return `${type}-purple-500` | ||
} else if (uptime >= 0.5) { | ||
return `${type}-yellow-400` | ||
} else if (uptime >= 0) { | ||
return `${type}-red-400` | ||
} else { | ||
return `${type}-gray-200` | ||
} | ||
} | ||
|
||
export const statusString = (uptime: number, type = "bg") => { | ||
if (uptime >= 0.75) { | ||
return "success" | ||
} else if (uptime >= 0.5) { | ||
return "warning" | ||
} else if (uptime >= 0) { | ||
return "danger" | ||
} else { | ||
return "unknown" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters