Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

Add support for glances uptime

jx1630e8c64c64ccf
diff --git a/src/components/Widgets/GlancesUptime.vue b/src/components/Widgets/GlancesUptime.vue
new file mode 100644
index 00000000..be99edf7
--- /dev/null
+++ b/src/components/Widgets/GlancesUptime.vue
@@ -0,0 +1,62 @@
+<template>
+ <div class="glances-uptime-wrapper" v-if="uptime">
+ <div class="uptime-row">
+ <span class="lbl">Uptime</span>
+ <span class="val">{{ uptime }}</span>
+ </div>
+ </div>
+</template>
+
+<script>
+import WidgetMixin from '@/mixins/WidgetMixin';
+import GlancesMixin from '@/mixins/GlancesMixin';
+
+export default {
+ name: 'GlancesUptime',
+ mixins: [WidgetMixin, GlancesMixin],
+ data() {
+ return {
+ uptime: null,
+ };
+ },
+ computed: {
+ endpoint() {
+ return this.makeGlancesUrl('uptime');
+ },
+ },
+ methods: {
+ processData(resp) {
+ if (!resp) {
+ this.error('This uptime plugin is not available.');
+ return;
+ }
+
+ if (typeof resp === 'string') {
+ this.uptime = resp;
+ } else if (typeof resp === 'object') {
+ this.uptime = resp.uptime || resp.uptime_string || JSON.stringify(resp);
+ } else {
+ this.uptime = String(resp);
+ }
+ },
+ },
+};
+</script>
+
+<style scoped lang="scss">
+.glances-uptime-wrapper {
+ .uptime-row {
+ display: flex;
+ padding: 0.25rem 0.2rem;
+ align-items: center;
+ justify-content: space-between;
+ color: var(--widget-text-color);
+ span.lbl {
+ font-weight: bold;
+ }
+ span.val {
+ font-family: var(--font-monospace);
+ }
+ }
+}
+</style>