-
Notifications
You must be signed in to change notification settings - Fork 26
Migrating composables and a few vue component #1697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d4744de
3621b95
d9ce78d
5d19b69
a62a8f2
be0a7fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,18 @@ | ||
| <script setup> | ||
| <script setup lang="ts"> | ||
| import { onMounted, onUnmounted, ref } from "vue"; | ||
| import moment from "moment"; | ||
|
|
||
| const props = defineProps({ | ||
| dateUtc: String, | ||
| default: function () { | ||
| return "0001-01-01T00:00:00"; | ||
| }, | ||
| }); | ||
| const emptyDate = "0001-01-01T00:00:00"; | ||
|
|
||
| const props = withDefaults(defineProps<{ dateUtc: string }>(), { dateUtc: emptyDate }); | ||
|
|
||
| let interval = null; | ||
| let interval: number | undefined = undefined; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left this one as |
||
|
|
||
| const title = ref(), | ||
| text = ref(); | ||
|
|
||
| function updateText() { | ||
| if (props.dateUtc !== "0001-01-01T00:00:00" && props.dateUtc !== undefined) { | ||
| if (props.dateUtc != null && props.dateUtc !== emptyDate) { | ||
| const m = moment.utc(props.dateUtc); | ||
| text.value = m.fromNow(); | ||
| title.value = m.local().format("LLLL") + " (local)\n" + m.utc().format("LLLL") + " (UTC)"; | ||
|
|
@@ -26,14 +23,14 @@ function updateText() { | |
| } | ||
|
|
||
| onMounted(() => { | ||
| interval = setInterval(function () { | ||
| interval = window.setInterval(function () { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it doesn't get confused with Node Timer, since we are also referencing the node definitions |
||
| updateText(); | ||
| }, 5000); | ||
|
|
||
| updateText(); | ||
| }); | ||
|
|
||
| onUnmounted(() => clearInterval(interval)); | ||
| onUnmounted(() => window.clearInterval(interval)); | ||
| </script> | ||
|
|
||
| <template> | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,8 +172,11 @@ async function downloadBody() { | |
| } | ||
| } | ||
|
|
||
| const textBody = await response.text(); | ||
| failedMessage.value.messageBody = textBody; | ||
| try { | ||
| failedMessage.value.messageBody = await response.text(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed this could throw when no body, so I added a catch |
||
| } catch { | ||
| failedMessage.value.bodyUnavailable = true; | ||
| } | ||
| } | ||
|
|
||
| // taken from https://github.com/krtnio/angular-pretty-xml/blob/master/src/angular-pretty-xml.js | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { useTypedFetchFromServiceControl } from "./serviceServiceControlUrls"; | ||
| import type EventLogItem from "@/resources/EventLogItem"; | ||
|
|
||
| export async function getEventLogItems() { | ||
| const [, data] = await useTypedFetchFromServiceControl<EventLogItem[]>("eventlogitems"); | ||
|
|
||
| return data; | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import moment from "moment"; | ||
|
|
||
| const secondDuration = moment.duration(10 * 1000); | ||
| const minuteDuration = moment.duration(60 * 1000); | ||
| const hourDuration = moment.duration(60 * 1000); //this ensures that we never use minute formatting | ||
| const dayDuration = moment.duration(24 * 60 * 60 * 1000); | ||
|
|
||
| export function useFormatTime(value: string) { | ||
| const duration = moment.duration(value); | ||
| const time = { value: "0", unit: "" }; | ||
| const asUtc = moment.utc(duration.asMilliseconds()); | ||
|
|
||
| if (duration >= dayDuration) { | ||
| time.value = asUtc.format("D [d] h [hr]"); | ||
| } else if (duration >= hourDuration) { | ||
| time.value = asUtc.format("HH:mm"); | ||
| time.unit = "hr"; | ||
| } else if (duration >= minuteDuration) { | ||
| time.value = asUtc.format("mm:ss"); | ||
| time.unit = "min"; | ||
| } else if (duration >= secondDuration) { | ||
| time.value = asUtc.format("ss"); | ||
| time.unit = "sec"; | ||
| } else { | ||
| time.value = asUtc.format("s,SSS"); | ||
| time.unit = "ms"; | ||
| } | ||
|
|
||
| return time; | ||
| } | ||
|
|
||
| export function useGetDayDiffFromToday(value: string) { | ||
| const today = new Date(); | ||
| today.setHours(0, 0, 0, 0); | ||
| const diff = new Date(value.replace("Z", "")).getTime() - today.getTime(); | ||
| return Math.round(diff / 1000 / 60 / 60 / 24); | ||
| } | ||
|
|
||
| export function useFormatLargeNumber(value: string, decimals: number) { | ||
| const suffixes = ["k", "M", "G", "T", "P", "E"]; | ||
|
|
||
| const num = Number(value); | ||
|
|
||
| if (isNaN(num)) { | ||
| return null; | ||
| } | ||
|
|
||
| if (num < 1000000) { | ||
| return round(num, decimals); | ||
| } | ||
|
|
||
| const exp = Math.floor(Math.log(num) / Math.log(1000)); | ||
|
|
||
| return round(num / Math.pow(1000, exp), decimals) + suffixes[exp - 1]; | ||
| } | ||
|
|
||
| function round(num: number, decimals: number) { | ||
| return Math.round(num + Number(`e+${decimals}`)) + Number(`e-${decimals}`); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope I got this right. |
||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { useTypedFetchFromServiceControl } from "./serviceServiceControlUrls"; | ||
| import type QueueAddress from "@/resources/QueueAddress"; | ||
|
|
||
| export class useEndpoints { | ||
| async getQueueNames() { | ||
| const [, data] = await useTypedFetchFromServiceControl<QueueAddress>("errors/queues/addresses"); | ||
| return data; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from reading the doco, I think this was wrong.
It should have been:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway, I fixed it