🎨
This commit is contained in:
parent
773b2aa3d1
commit
ccb9ed3489
|
@ -5,7 +5,7 @@
|
||||||
<button slot="func" @click="toggle" title="%i18n:@toggle%">%fa:sort%</button>
|
<button slot="func" @click="toggle" title="%i18n:@toggle%">%fa:sort%</button>
|
||||||
|
|
||||||
<div class="qpdmibaztplkylerhdbllwcokyrfxeyj" :class="{ dual: props.view == 0 }" :data-darkmode="$store.state.device.darkmode">
|
<div class="qpdmibaztplkylerhdbllwcokyrfxeyj" :class="{ dual: props.view == 0 }" :data-darkmode="$store.state.device.darkmode">
|
||||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" preserveAspectRatio="none" v-show="props.view != 2">
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" v-show="props.view != 2">
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient :id="localGradientId" x1="0" x2="0" y1="1" y2="0">
|
<linearGradient :id="localGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||||
<stop offset="0%" stop-color="hsl(200, 80%, 70%)"></stop>
|
<stop offset="0%" stop-color="hsl(200, 80%, 70%)"></stop>
|
||||||
|
@ -21,15 +21,20 @@
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="#fff"
|
stroke="#fff"
|
||||||
stroke-width="1"/>
|
stroke-width="1"/>
|
||||||
|
<circle
|
||||||
|
:cx="localHeadX"
|
||||||
|
:cy="localHeadY"
|
||||||
|
r="1.5"
|
||||||
|
fill="#fff"/>
|
||||||
</mask>
|
</mask>
|
||||||
</defs>
|
</defs>
|
||||||
<rect
|
<rect
|
||||||
x="-1" y="-1"
|
x="-2" y="-2"
|
||||||
:width="viewBoxX + 2" :height="viewBoxY + 2"
|
:width="viewBoxX + 4" :height="viewBoxY + 4"
|
||||||
:style="`stroke: none; fill: url(#${ localGradientId }); mask: url(#${ localMaskId })`"/>
|
:style="`stroke: none; fill: url(#${ localGradientId }); mask: url(#${ localMaskId })`"/>
|
||||||
<text x="1" y="5">Local</text>
|
<text x="1" y="5">Local</text>
|
||||||
</svg>
|
</svg>
|
||||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" preserveAspectRatio="none" v-show="props.view != 1">
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" v-show="props.view != 1">
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient :id="fediGradientId" x1="0" x2="0" y1="1" y2="0">
|
<linearGradient :id="fediGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||||
<stop offset="0%" stop-color="hsl(200, 80%, 70%)"></stop>
|
<stop offset="0%" stop-color="hsl(200, 80%, 70%)"></stop>
|
||||||
|
@ -45,11 +50,16 @@
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="#fff"
|
stroke="#fff"
|
||||||
stroke-width="1"/>
|
stroke-width="1"/>
|
||||||
|
<circle
|
||||||
|
:cx="fediHeadX"
|
||||||
|
:cy="fediHeadY"
|
||||||
|
r="1.5"
|
||||||
|
fill="#fff"/>
|
||||||
</mask>
|
</mask>
|
||||||
</defs>
|
</defs>
|
||||||
<rect
|
<rect
|
||||||
x="-1" y="-1"
|
x="-2" y="-2"
|
||||||
:width="viewBoxX + 2" :height="viewBoxY + 2"
|
:width="viewBoxX + 4" :height="viewBoxY + 4"
|
||||||
:style="`stroke: none; fill: url(#${ fediGradientId }); mask: url(#${ fediMaskId })`"/>
|
:style="`stroke: none; fill: url(#${ fediGradientId }); mask: url(#${ fediMaskId })`"/>
|
||||||
<text x="1" y="5">Fedi</text>
|
<text x="1" y="5">Fedi</text>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -82,7 +92,11 @@ export default define({
|
||||||
fediPolylinePoints: '',
|
fediPolylinePoints: '',
|
||||||
localPolylinePoints: '',
|
localPolylinePoints: '',
|
||||||
fediPolygonPoints: '',
|
fediPolygonPoints: '',
|
||||||
localPolygonPoints: ''
|
localPolygonPoints: '',
|
||||||
|
fediHeadX: null,
|
||||||
|
fediHeadY: null,
|
||||||
|
localHeadX: null,
|
||||||
|
localHeadY: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -133,11 +147,18 @@ export default define({
|
||||||
const fediPeak = Math.max.apply(null, stats.map(x => x.all)) || 1;
|
const fediPeak = Math.max.apply(null, stats.map(x => x.all)) || 1;
|
||||||
const localPeak = Math.max.apply(null, stats.map(x => x.local)) || 1;
|
const localPeak = Math.max.apply(null, stats.map(x => x.local)) || 1;
|
||||||
|
|
||||||
this.fediPolylinePoints = stats.map((s, i) => `${this.viewBoxX - ((stats.length - 1) - i)},${(1 - (s.all / fediPeak)) * this.viewBoxY}`).join(' ');
|
const fediPolylinePoints = stats.map((s, i) => [this.viewBoxX - ((stats.length - 1) - i), (1 - (s.all / fediPeak)) * this.viewBoxY]);
|
||||||
this.localPolylinePoints = stats.map((s, i) => `${this.viewBoxX - ((stats.length - 1) - i)},${(1 - (s.local / localPeak)) * this.viewBoxY}`).join(' ');
|
const localPolylinePoints = stats.map((s, i) => [this.viewBoxX - ((stats.length - 1) - i), (1 - (s.local / localPeak)) * this.viewBoxY]);
|
||||||
|
this.fediPolylinePoints = fediPolylinePoints.map(xy => `${xy[0]},${xy[1]}`).join(' ');
|
||||||
|
this.localPolylinePoints = localPolylinePoints.map(xy => `${xy[0]},${xy[1]}`).join(' ');
|
||||||
|
|
||||||
this.fediPolygonPoints = `${this.viewBoxX - (stats.length - 1)},${ this.viewBoxY } ${ this.fediPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
this.fediPolygonPoints = `${this.viewBoxX - (stats.length - 1)},${ this.viewBoxY } ${ this.fediPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||||
this.localPolygonPoints = `${this.viewBoxX - (stats.length - 1)},${ this.viewBoxY } ${ this.localPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
this.localPolygonPoints = `${this.viewBoxX - (stats.length - 1)},${ this.viewBoxY } ${ this.localPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||||
|
|
||||||
|
this.fediHeadX = fediPolylinePoints[fediPolylinePoints.length - 1][0];
|
||||||
|
this.fediHeadY = fediPolylinePoints[fediPolylinePoints.length - 1][1];
|
||||||
|
this.localHeadX = localPolylinePoints[localPolylinePoints.length - 1][0];
|
||||||
|
this.localHeadY = localPolylinePoints[localPolylinePoints.length - 1][1];
|
||||||
},
|
},
|
||||||
onStats(stats) {
|
onStats(stats) {
|
||||||
this.stats.push(stats);
|
this.stats.push(stats);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="cpu-memory">
|
<div class="cpu-memory">
|
||||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" preserveAspectRatio="none">
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient :id="cpuGradientId" x1="0" x2="0" y1="1" y2="0">
|
<linearGradient :id="cpuGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||||
<stop offset="0%" stop-color="hsl(180, 80%, 70%)"></stop>
|
<stop offset="0%" stop-color="hsl(180, 80%, 70%)"></stop>
|
||||||
|
@ -16,15 +16,20 @@
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="#fff"
|
stroke="#fff"
|
||||||
stroke-width="1"/>
|
stroke-width="1"/>
|
||||||
|
<circle
|
||||||
|
:cx="cpuHeadX"
|
||||||
|
:cy="cpuHeadY"
|
||||||
|
r="1.5"
|
||||||
|
fill="#fff"/>
|
||||||
</mask>
|
</mask>
|
||||||
</defs>
|
</defs>
|
||||||
<rect
|
<rect
|
||||||
x="-1" y="-1"
|
x="-2" y="-2"
|
||||||
:width="viewBoxX + 2" :height="viewBoxY + 2"
|
:width="viewBoxX + 4" :height="viewBoxY + 4"
|
||||||
:style="`stroke: none; fill: url(#${ cpuGradientId }); mask: url(#${ cpuMaskId })`"/>
|
:style="`stroke: none; fill: url(#${ cpuGradientId }); mask: url(#${ cpuMaskId })`"/>
|
||||||
<text x="1" y="5">CPU <tspan>{{ cpuP }}%</tspan></text>
|
<text x="1" y="5">CPU <tspan>{{ cpuP }}%</tspan></text>
|
||||||
</svg>
|
</svg>
|
||||||
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" preserveAspectRatio="none">
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient :id="memGradientId" x1="0" x2="0" y1="1" y2="0">
|
<linearGradient :id="memGradientId" x1="0" x2="0" y1="1" y2="0">
|
||||||
<stop offset="0%" stop-color="hsl(180, 80%, 70%)"></stop>
|
<stop offset="0%" stop-color="hsl(180, 80%, 70%)"></stop>
|
||||||
|
@ -40,11 +45,16 @@
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="#fff"
|
stroke="#fff"
|
||||||
stroke-width="1"/>
|
stroke-width="1"/>
|
||||||
|
<circle
|
||||||
|
:cx="memHeadX"
|
||||||
|
:cy="memHeadY"
|
||||||
|
r="1.5"
|
||||||
|
fill="#fff"/>
|
||||||
</mask>
|
</mask>
|
||||||
</defs>
|
</defs>
|
||||||
<rect
|
<rect
|
||||||
x="-1" y="-1"
|
x="-2" y="-2"
|
||||||
:width="viewBoxX + 2" :height="viewBoxY + 2"
|
:width="viewBoxX + 4" :height="viewBoxY + 4"
|
||||||
:style="`stroke: none; fill: url(#${ memGradientId }); mask: url(#${ memMaskId })`"/>
|
:style="`stroke: none; fill: url(#${ memGradientId }); mask: url(#${ memMaskId })`"/>
|
||||||
<text x="1" y="5">MEM <tspan>{{ memP }}%</tspan></text>
|
<text x="1" y="5">MEM <tspan>{{ memP }}%</tspan></text>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -70,6 +80,10 @@ export default Vue.extend({
|
||||||
memPolylinePoints: '',
|
memPolylinePoints: '',
|
||||||
cpuPolygonPoints: '',
|
cpuPolygonPoints: '',
|
||||||
memPolygonPoints: '',
|
memPolygonPoints: '',
|
||||||
|
cpuHeadX: null,
|
||||||
|
cpuHeadY: null,
|
||||||
|
memHeadX: null,
|
||||||
|
memHeadY: null,
|
||||||
cpuP: '',
|
cpuP: '',
|
||||||
memP: ''
|
memP: ''
|
||||||
};
|
};
|
||||||
|
@ -92,12 +106,19 @@ export default Vue.extend({
|
||||||
this.stats.push(stats);
|
this.stats.push(stats);
|
||||||
if (this.stats.length > 50) this.stats.shift();
|
if (this.stats.length > 50) this.stats.shift();
|
||||||
|
|
||||||
this.cpuPolylinePoints = this.stats.map((s, i) => `${this.viewBoxX - ((this.stats.length - 1) - i)},${(1 - s.cpu_usage) * this.viewBoxY}`).join(' ');
|
const cpuPolylinePoints = this.stats.map((s, i) => [this.viewBoxX - ((this.stats.length - 1) - i), (1 - s.cpu_usage) * this.viewBoxY]);
|
||||||
this.memPolylinePoints = this.stats.map((s, i) => `${this.viewBoxX - ((this.stats.length - 1) - i)},${(1 - (s.mem.used / s.mem.total)) * this.viewBoxY}`).join(' ');
|
const memPolylinePoints = this.stats.map((s, i) => [this.viewBoxX - ((this.stats.length - 1) - i), (1 - (s.mem.used / s.mem.total)) * this.viewBoxY]);
|
||||||
|
this.cpuPolylinePoints = cpuPolylinePoints.map(xy => `${xy[0]},${xy[1]}`).join(' ');
|
||||||
|
this.memPolylinePoints = memPolylinePoints.map(xy => `${xy[0]},${xy[1]}`).join(' ');
|
||||||
|
|
||||||
this.cpuPolygonPoints = `${this.viewBoxX - (this.stats.length - 1)},${ this.viewBoxY } ${ this.cpuPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
this.cpuPolygonPoints = `${this.viewBoxX - (this.stats.length - 1)},${ this.viewBoxY } ${ this.cpuPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||||
this.memPolygonPoints = `${this.viewBoxX - (this.stats.length - 1)},${ this.viewBoxY } ${ this.memPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
this.memPolygonPoints = `${this.viewBoxX - (this.stats.length - 1)},${ this.viewBoxY } ${ this.memPolylinePoints } ${ this.viewBoxX },${ this.viewBoxY }`;
|
||||||
|
|
||||||
|
this.cpuHeadX = cpuPolylinePoints[cpuPolylinePoints.length - 1][0];
|
||||||
|
this.cpuHeadY = cpuPolylinePoints[cpuPolylinePoints.length - 1][1];
|
||||||
|
this.memHeadX = memPolylinePoints[memPolylinePoints.length - 1][0];
|
||||||
|
this.memHeadY = memPolylinePoints[memPolylinePoints.length - 1][1];
|
||||||
|
|
||||||
this.cpuP = (stats.cpu_usage * 100).toFixed(0);
|
this.cpuP = (stats.cpu_usage * 100).toFixed(0);
|
||||||
this.memP = (stats.mem.used / stats.mem.total * 100).toFixed(0);
|
this.memP = (stats.mem.used / stats.mem.total * 100).toFixed(0);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue