From efe5a289071b85edace3c2a1b0e4433822f9dd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Palancher?= Date: Fri, 27 Sep 2024 16:30:00 +0200 Subject: [PATCH] refactor(front): component job progress comment Move job progress component into its own dedicated component. --- frontend/src/components/jobs/JobProgress.vue | 35 ++------------- .../components/jobs/JobProgressComment.vue | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 frontend/src/components/jobs/JobProgressComment.vue diff --git a/frontend/src/components/jobs/JobProgress.vue b/frontend/src/components/jobs/JobProgress.vue index c1690852..f2c06ad2 100644 --- a/frontend/src/components/jobs/JobProgress.vue +++ b/frontend/src/components/jobs/JobProgress.vue @@ -10,6 +10,7 @@ import { computed } from 'vue' import type { PropType } from 'vue' import type { ClusterIndividualJob } from '@/composables/GatewayAPI' +import JobProgressComment from '@/components/jobs/JobProgressComment.vue' import { CheckIcon } from '@heroicons/vue/20/solid' const props = defineProps({ @@ -40,34 +41,6 @@ const current = computed((): [number, boolean] => { return [0, false] }) -function stepComment(step: string) { - if (step === 'submitted') { - return new Date(props.job.time.submission * 1000).toLocaleString() - } - if (step === 'eligible') { - return new Date(props.job.time.eligible * 1000).toLocaleString() - } - if (step === 'scheduling') { - if (props.job.time.start) { - return new Date(props.job.time.start * 1000).toLocaleString() - } - } - if (step === 'running') { - if (props.job.time.elapsed) { - return `${props.job.time.elapsed} seconds elapsed` - } - } - if (step === 'completing') { - return '' - } - if (step === 'terminated') { - if (props.job.time.end) { - return new Date(props.job.time.end * 1000).toLocaleString() - } - } - return '' -} - function capitalize(step: string) { return step.charAt(0).toUpperCase() + step.slice(1) } @@ -99,7 +72,7 @@ const steps = ['submitted', 'eligible', 'scheduling', 'running', 'completing', ' {{ capitalize(step) }} - {{ stepComment(step) }} + @@ -119,7 +92,7 @@ const steps = ['submitted', 'eligible', 'scheduling', 'running', 'completing', ' {{ capitalize(step) }} - {{ stepComment(step) }} + @@ -139,7 +112,7 @@ const steps = ['submitted', 'eligible', 'scheduling', 'running', 'completing', ' {{ capitalize(step) }} - {{ stepComment(step) }} + diff --git a/frontend/src/components/jobs/JobProgressComment.vue b/frontend/src/components/jobs/JobProgressComment.vue new file mode 100644 index 00000000..08db1d92 --- /dev/null +++ b/frontend/src/components/jobs/JobProgressComment.vue @@ -0,0 +1,43 @@ + + + + +