aboutsummaryrefslogtreecommitdiff
path: root/src/site/components/statistics/time.vue
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2021-01-07 21:39:47 +0200
committerZephyrrus <[email protected]>2021-01-07 21:39:47 +0200
commita838d024a7b74e69b7fb65b9c1db4a3a900d160e (patch)
tree87a7ea1801fea5c2003134f17076a105806f7a1f /src/site/components/statistics/time.vue
parentfeat: change mutation timestamp on every database mutation (diff)
parentfix: indentation (diff)
downloadhost.fuwn.me-a838d024a7b74e69b7fb65b9c1db4a3a900d160e.tar.xz
host.fuwn.me-a838d024a7b74e69b7fb65b9c1db4a3a900d160e.zip
Merge branch 'feature/stats-dashboard' into feature/system_status_page
Diffstat (limited to 'src/site/components/statistics/time.vue')
-rw-r--r--src/site/components/statistics/time.vue46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/site/components/statistics/time.vue b/src/site/components/statistics/time.vue
new file mode 100644
index 0000000..ff1bb8d
--- /dev/null
+++ b/src/site/components/statistics/time.vue
@@ -0,0 +1,46 @@
+<template>
+ <div>
+ <div class="columns">
+ <div class="column is-2">
+ {{ title }}
+ </div>
+ <div class="column">
+ {{ parsedTime }}
+ </div>
+ </div>
+ </div>
+</template>
+<script>
+export default {
+ props: {
+ title: {
+ 'type': String,
+ 'default': null
+ },
+ value: {
+ 'type': Number,
+ 'default': null
+ }
+ },
+ computed: {
+ parsedTime() {
+ let seconds = this.value;
+ const days = Math.floor(seconds / 86400);
+ seconds %= 86400;
+ let hours = Math.floor(seconds / 3600);
+ seconds %= 3600;
+ let minutes = Math.floor(seconds / 60);
+ seconds %= 60;
+
+ if (hours < 10) hours = `0${hours}`;
+ if (minutes < 10) minutes = `0${minutes}`;
+ if (seconds < 10) seconds = `0${seconds}`;
+
+ if (days > 0) {
+ return `${days}d ${hours}:${minutes}:${seconds}`;
+ }
+ return `${hours}:${minutes}:${seconds}`;
+ }
+ }
+};
+</script>