π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
:lipstick: add glances speedometer widgets
kt-altd50c9731e8bd
diff --git a/docs/widgets.md b/docs/widgets.mdindex 9ed2b562..c3499463 100644--- a/docs/widgets.md+++ b/docs/widgets.md@@ -2331,6 +2331,22 @@ Live-updating current CPU usage, as a combined average across all cores---+### Current CPU Usage Speedometer++Speedometer styled version of the Current CPU Usage widget++<p align="center"><img width="400" src="https://i.ibb.co/7RHTRNq/gl-cpu-speedometer.png" /></p>++#### Example++```yaml+- type: gl-cpu-speedometer+ options:+ hostname: http://192.168.130.2:61208+```++---+### CPU Usage Per CoreLive-updating CPU usage breakdown per core@@ -2386,6 +2402,22 @@ Real-time memory usage gauge, with more info visible on click---+### Current Memory Usage Speedometer++Speedometer styled version of the Current Memory Usage widget++<p align="center"><img width="400" src="https://i.ibb.co/wsNW7Xr/gl-mem-speedometer.png" /></p>++#### Example++```yaml+- type: gl-mem-speedometer+ options:+ hostname: http://192.168.130.2:61208+```++---+### Memory Usage HistoryRecent memory usage chartdiff --git a/src/assets/locales/en.json b/src/assets/locales/en.jsonindex 60fdad8c..342c1d83 100644--- a/src/assets/locales/en.json+++ b/src/assets/locales/en.json@@ -316,6 +316,8 @@"general": {"loading": "Loading...","show-more": "Expand Details",+ "cpu-details": "CPU Details",+ "mem-details": "Memory Details","show-less": "Show Less","open-link": "Continue Reading"},diff --git a/src/components/Widgets/GlCpuSpeedometer.vue b/src/components/Widgets/GlCpuSpeedometer.vuenew file mode 100644index 00000000..adb74616--- /dev/null+++ b/src/components/Widgets/GlCpuSpeedometer.vue@@ -0,0 +1,150 @@+<template>+ <div class="glances-cpu-gauge-wrapper">+ <GaugeChart class="gl-speedometer" :value="gaugeValue"+ :baseColor="baseColor" :shadowColor="shadowColor" :gaugeColor="gaugeColor"+ :startAngle="startAngle" :endAngle="endAngle" :innerRadius="innerRadius"+ :separatorThickness="separatorThickness">+ <p class="percentage">{{ gaugeValue }}%</p>+ </GaugeChart>+ <p class="show-more-btn" @click="toggleMoreInfo">+ {{ showMoreInfo ? $t('widgets.general.show-less') : $t('widgets.general.cpu-details') }}+ </p>+ <div class="more-info" v-if="moreInfo && showMoreInfo">+ <div class="more-info-row" v-for="(info, key) in moreInfo" :key="key">+ <p class="label">{{ info.label }}</p>+ <p class="value">{{ info.value }}</p>+ </div>+ </div>+ </div>+</template>++<script>+import WidgetMixin from '@/mixins/WidgetMixin';+import GlancesMixin from '@/mixins/GlancesMixin';+import GaugeChart from '@/components/Charts/Gauge';+import { capitalize } from '@/utils/MiscHelpers';++export default {+ mixins: [WidgetMixin, GlancesMixin],+ components: {+ GaugeChart,+ },+ data() {+ return {+ gaugeValue: 0,+ baseColor: '#101010ED',+ shadowColor: '#00000000',+ gaugeColor: [+ { offset: 0, color: '#20e253' },+ { offset: 35, color: '#f6f000' },+ { offset: 65, color: '#fca016' },+ { offset: 90, color: '#f80363' },+ ],+ showMoreInfo: false,+ moreInfo: null,+ startAngle: -135,+ endAngle: 135,+ innerRadius: 80,+ separatorThickness: 0,+ };+ },+ computed: {+ endpoint() {+ return this.makeGlancesUrl('cpu');+ },+ },+ methods: {+ processData(cpuData) {+ this.gaugeValue = cpuData.total;+ const moreInfo = [];+ const ignore = ['total', 'cpucore', 'time_since_update',+ 'interrupts', 'soft_interrupts', 'ctx_switches', 'syscalls'];+ Object.keys(cpuData).forEach((key) => {+ if (!ignore.includes(key) && cpuData[key]) {+ moreInfo.push({ label: capitalize(key), value: `${cpuData[key].toFixed(1)}%` });+ }+ });+ this.moreInfo = moreInfo;+ },+ toggleMoreInfo() {+ this.showMoreInfo = !this.showMoreInfo;+ },+ },+ created() {+ this.overrideUpdateInterval = 2;+ },+};+</script>++<style scoped lang="scss">+.glances-cpu-gauge-wrapper {+ max-width: 15rem;+ margin: 0rem auto;++ p.percentage {+ color: var(--widget-text-color);+ text-align: center;+ position: absolute;+ font-size: 1.3rem;+ margin: 3.5rem 0;+ width: 100%;+ bottom: 0;+ }++ .more-info {+ background: var(--widget-accent-color);+ border-radius: var(--curve-factor);+ padding: 0.25rem 0.5rem;+ margin: 0.5rem auto;++ .more-info-row {+ display: flex;+ justify-content: space-between;+ align-items: center;++ p.label, p.value {+ color: var(--widget-text-color);+ margin: 0.25rem 0;+ }++ p.value {+ font-family: var(--font-monospace);+ }++ &:not(:last-child) {+ border-bottom: 1px dashed var(--widget-text-color);+ }+ }+ }++ p.show-more-btn {+ cursor: pointer;+ font-size: 0.9rem;+ text-align: center;+ width: fit-content;+ margin: -1.1rem auto 0 auto;+ padding: 0.1rem 0.25rem;+ border: 1px solid transparent;+ color: var(--widget-text-color);+ opacity: var(--dimming-factor);+ border-radius: var(--curve-factor);++ &:hover {+ border: 1px solid var(--widget-text-color);+ }++ &:focus,+ &:active {+ background: var(--widget-text-color);+ color: var(--widget-background-color);+ }+ }+}+</style>+<style>+/* global override for the Guage tick lines */+.gl-speedometer svg line {+ stroke: var(--widget-text-color);+ opacity: .3;+}+</style>diff --git a/src/components/Widgets/GlMemSpeedometer.vue b/src/components/Widgets/GlMemSpeedometer.vuenew file mode 100644index 00000000..9d39f6bf--- /dev/null+++ b/src/components/Widgets/GlMemSpeedometer.vue@@ -0,0 +1,150 @@+<template>+ <div class="glances-cpu-gauge-wrapper">+ <GaugeChart class="gl-speedometer" :value="gaugeValue"+ :baseColor="baseColor" :shadowColor="shadowColor" :gaugeColor="gaugeColor"+ :startAngle="startAngle" :endAngle="endAngle" :innerRadius="innerRadius"+ :separatorThickness="separatorThickness">+ <p class="percentage">{{ gaugeValue }}%</p>+ </GaugeChart>+ <p class="show-more-btn" @click="toggleMoreInfo">+ {{ showMoreInfo ? $t('widgets.general.show-less') : $t('widgets.general.mem-details') }}+ </p>+ <div class="more-info" v-if="moreInfo && showMoreInfo">+ <div class="more-info-row" v-for="(info, key) in moreInfo" :key="key">+ <p class="label">{{ info.label }}</p>+ <p class="value">{{ info.value }}</p>+ </div>+ </div>+ </div>+</template>++<script>+import WidgetMixin from '@/mixins/WidgetMixin';+import GlancesMixin from '@/mixins/GlancesMixin';+import GaugeChart from '@/components/Charts/Gauge';+import { capitalize, convertBytes } from '@/utils/MiscHelpers';++export default {+ mixins: [WidgetMixin, GlancesMixin],+ components: {+ GaugeChart,+ },+ data() {+ return {+ gaugeValue: 0,+ baseColor: '#101010ED',+ shadowColor: '#00000000',+ gaugeColor: [+ { offset: 0, color: '#20e253' },+ { offset: 35, color: '#f6f000' },+ { offset: 65, color: '#fca016' },+ { offset: 90, color: '#f80363' },+ ],+ showMoreInfo: false,+ moreInfo: null,+ startAngle: -135,+ endAngle: 135,+ innerRadius: 80,+ separatorThickness: 0,+ };+ },+ computed: {+ endpoint() {+ return this.makeGlancesUrl('mem');+ },+ },+ methods: {+ processData(memData) {+ this.gaugeValue = memData.percent;+ const moreInfo = [];+ const ignore = ['percent'];+ Object.keys(memData).forEach((key) => {+ if (!ignore.includes(key) && memData[key]) {+ moreInfo.push({ label: capitalize(key), value: convertBytes(memData[key]) });+ }+ });+ this.moreInfo = moreInfo;+ },+ toggleMoreInfo() {+ this.showMoreInfo = !this.showMoreInfo;+ },+ },+ created() {+ this.overrideUpdateInterval = 2;+ },+};+</script>++<style scoped lang="scss">+.glances-cpu-gauge-wrapper {+ max-width: 15rem;+ margin: 0rem auto;++ p.percentage {+ color: var(--widget-text-color);+ text-align: center;+ position: absolute;+ font-size: 1.3rem;+ margin: 3.5rem 0;+ width: 100%;+ bottom: 0;+ }++ .more-info {+ background: var(--widget-accent-color);+ border-radius: var(--curve-factor);+ padding: 0.25rem 0.5rem;+ margin: 0.5rem auto;++ .more-info-row {+ display: flex;+ justify-content: space-between;+ align-items: center;++ p.label,+ p.value {+ color: var(--widget-text-color);+ margin: 0.25rem 0;+ }++ p.value {+ font-family: var(--font-monospace);+ }++ &:not(:last-child) {+ border-bottom: 1px dashed var(--widget-text-color);+ }+ }+ }++ p.show-more-btn {+ cursor: pointer;+ font-size: 0.9rem;+ text-align: center;+ width: fit-content;+ margin: -1.1rem auto 0 auto;+ padding: 0.1rem 0.25rem;+ border: 1px solid transparent;+ color: var(--widget-text-color);+ opacity: var(--dimming-factor);+ border-radius: var(--curve-factor);++ &:hover {+ border: 1px solid var(--widget-text-color);+ }++ &:focus,+ &:active {+ background: var(--widget-text-color);+ color: var(--widget-background-color);+ }+ }+}+</style>+<style>+/* global override for the Guage tick lines */+.gl-speedometer svg line {+ stroke: var(--widget-text-color);+ opacity: .3;+}+</style>diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vueindex dc536303..3ab0c6c4 100644--- a/src/components/Widgets/WidgetBase.vue+++ b/src/components/Widgets/WidgetBase.vue@@ -67,12 +67,14 @@ const COMPAT = {'gl-alerts': 'GlAlerts','gl-current-cores': 'GlCpuCores','gl-current-cpu': 'GlCpuGauge',+ 'gl-cpu-speedometer': 'GlCpuSpeedometer','gl-cpu-history': 'GlCpuHistory','gl-disk-io': 'GlDiskIo','gl-disk-space': 'GlDiskSpace','gl-ip-address': 'GlIpAddress','gl-load-history': 'GlLoadHistory','gl-current-mem': 'GlMemGauge',+ 'gl-mem-speedometer': 'GlMemSpeedometer','gl-mem-history': 'GlMemHistory','gl-network-interfaces': 'GlNetworkInterfaces','gl-network-traffic': 'GlNetworkTraffic',