2019-07-24 05:25:30 -07:00
|
|
|
<template>
|
2022-12-14 01:04:10 -08:00
|
|
|
<span>
|
|
|
|
{{ time }}
|
|
|
|
</span>
|
2019-07-24 05:25:30 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-11-23 04:41:53 -08:00
|
|
|
import { genericHelpers } from '@/mixins/genericHelpers';
|
2019-07-24 05:25:30 -07:00
|
|
|
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
export default mixins(genericHelpers).extend({
|
|
|
|
name: 'ExecutionTime',
|
|
|
|
props: ['startTime'],
|
|
|
|
computed: {
|
|
|
|
time(): string {
|
|
|
|
if (!this.startTime) {
|
|
|
|
return '...';
|
2019-07-24 05:25:30 -07:00
|
|
|
}
|
2022-12-14 01:04:10 -08:00
|
|
|
const msPassed = this.nowTime - new Date(this.startTime).getTime();
|
|
|
|
return this.displayTimer(msPassed);
|
2019-07-24 05:25:30 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
nowTime: -1,
|
|
|
|
intervalTimer: null as null | NodeJS.Timeout,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setNow();
|
|
|
|
this.intervalTimer = setInterval(() => {
|
|
|
|
this.setNow();
|
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
// Make sure that the timer gets destroyed once no longer needed
|
|
|
|
if (this.intervalTimer !== null) {
|
|
|
|
clearInterval(this.intervalTimer);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setNow() {
|
|
|
|
this.nowTime = new Date().getTime();
|
2019-07-24 05:25:30 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
});
|
2019-07-24 05:25:30 -07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
// .data-display-wrapper {
|
|
|
|
|
|
|
|
// }
|
|
|
|
</style>
|