mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-24 12:40:06 +00:00
58838f225c
Rewrite of the UI using Typescript, Vue3, Windicss and Vite. The design should be close to the current one with some changes: - latest pipeline in a sidebar on the right - secrets and registry as part of the repo-settings (secrets and registry entries shouldn't be used as much so they can be "hidden" under settings IMO) - start page shows list of active repositories with button to enable / add new ones (currently you see all repositories and in most cases you only add new repositories once in a while)
54 lines
1.2 KiB
Vue
54 lines
1.2 KiB
Vue
<template>
|
|
<span v-if="proc.start_time !== undefined" class="ml-auto text-sm">{{ duration }}</span>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { computed, defineComponent, PropType, toRef } from 'vue';
|
|
|
|
import { useElapsedTime } from '~/compositions/useElapsedTime';
|
|
import { BuildProc } from '~/lib/api/types';
|
|
import { durationAsNumber } from '~/utils/duration';
|
|
|
|
export default defineComponent({
|
|
name: 'BuildProcDuration',
|
|
|
|
props: {
|
|
proc: {
|
|
type: Object as PropType<BuildProc>,
|
|
required: true,
|
|
},
|
|
},
|
|
|
|
setup(props) {
|
|
const proc = toRef(props, 'proc');
|
|
|
|
const durationRaw = computed(() => {
|
|
const start = proc.value.start_time || 0;
|
|
const end = proc.value.end_time || 0;
|
|
|
|
if (end === 0 && start === 0) {
|
|
return undefined;
|
|
}
|
|
|
|
if (end === 0) {
|
|
return Date.now() - start * 1000;
|
|
}
|
|
|
|
return (end - start) * 1000;
|
|
});
|
|
|
|
const running = computed(() => proc.value.state === 'running');
|
|
const { time: durationElapsed } = useElapsedTime(running, durationRaw);
|
|
|
|
const duration = computed(() => {
|
|
if (durationElapsed.value === undefined) {
|
|
return '-';
|
|
}
|
|
|
|
return durationAsNumber(durationElapsed.value);
|
|
});
|
|
|
|
return { duration };
|
|
},
|
|
});
|
|
</script>
|