mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-04 08:25:57 +00:00
Calendar Graph - final
This commit is contained in:
parent
23f4fbae68
commit
e7bcb2bb07
2 changed files with 54 additions and 11 deletions
|
@ -1,30 +1,33 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="wrap" class="wrap" :style="wrapStyle">
|
<div ref="wrap" class="wrap" :style="wrapStyle">
|
||||||
<div class="hp-bar-big" :style="barStyle">
|
<div class="hp-bar-big" :style="barStyle">
|
||||||
<div
|
<!-- <div
|
||||||
v-for="(beat, index) in shortBeatList"
|
v-for="(beat, index) in shortBeatList"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="beat"
|
class="beat"
|
||||||
:class="{ 'empty': (beat === 0), 'down': (beat.status === 0), 'pending': (beat.status === 2), 'maintenance': (beat.status === 3) }"
|
:class="{ 'empty': (beat === 0), 'down': (beat.status === 0), 'pending': (beat.status === 2), 'maintenance': (beat.status === 3) }"
|
||||||
:style="beatStyle"
|
:style="beatStyle"
|
||||||
:title="getBeatTitle(beat)"
|
:title="getBeatTitle(beat)"
|
||||||
/>
|
/> -->
|
||||||
|
<CalendarHeatmap :style="{ fill: '#fff' }" class="heatmap" :values="values" :end-date="endDate" no-data-text="Down" tooltip-unit="counts" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<!-- <div
|
||||||
v-if="!$root.isMobile && size !== 'small' && beatList.length > 4 && $root.styleElapsedTime !== 'none'"
|
v-if="!$root.isMobile && size !== 'small' && beatList.length > 4 && $root.styleElapsedTime !== 'none'"
|
||||||
class="d-flex justify-content-between align-items-center word" :style="timeStyle"
|
class="d-flex justify-content-between align-items-center word" :style="timeStyle"
|
||||||
>
|
>
|
||||||
<div>{{ timeSinceFirstBeat }} ago</div>
|
<div>{{ timeSinceFirstBeat }} ago</div>
|
||||||
<div v-if="$root.styleElapsedTime === 'with-line'" class="connecting-line"></div>
|
<div v-if="$root.styleElapsedTime === 'with-line'" class="connecting-line"></div>
|
||||||
<div>{{ timeSinceLastBeat }}</div>
|
<div>{{ timeSinceLastBeat }}</div>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { CalendarHeatmap } from "vue3-calendar-heatmap";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: { CalendarHeatmap },
|
||||||
props: {
|
props: {
|
||||||
/** Size of the heartbeat bar */
|
/** Size of the heartbeat bar */
|
||||||
size: {
|
size: {
|
||||||
|
@ -111,6 +114,47 @@ export default {
|
||||||
return placeholders.concat(this.beatList.slice(start));
|
return placeholders.concat(this.beatList.slice(start));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
values() {
|
||||||
|
if (!this.shortBeatList || !this.shortBeatList.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const valueObj = {};
|
||||||
|
|
||||||
|
this.shortBeatList.forEach(({ status, time }) => {
|
||||||
|
const date = dayjs(time).format("YYYY-MM-DD");
|
||||||
|
|
||||||
|
if (valueObj[date] === undefined) {
|
||||||
|
valueObj[date] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
count = 10;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
count = 2;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
count = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
valueObj[date] += count;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Object.keys(valueObj).map(date => ({ date,
|
||||||
|
count: valueObj[date] }));
|
||||||
|
},
|
||||||
|
|
||||||
|
endDate() {
|
||||||
|
const date = dayjs().format("YYYY-MM-DD");
|
||||||
|
return date;
|
||||||
|
},
|
||||||
|
|
||||||
wrapStyle() {
|
wrapStyle() {
|
||||||
let topBottom = (((this.beatHeight * this.hoverScale) - this.beatHeight) / 2);
|
let topBottom = (((this.beatHeight * this.hoverScale) - this.beatHeight) / 2);
|
||||||
let leftRight = (((this.beatWidth * this.hoverScale) - this.beatWidth) / 2);
|
let leftRight = (((this.beatWidth * this.hoverScale) - this.beatWidth) / 2);
|
||||||
|
@ -263,13 +307,11 @@ export default {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss">
|
||||||
@import "../assets/vars.scss";
|
@import "../assets/vars.scss";
|
||||||
|
|
||||||
.wrap {
|
.heatmap {
|
||||||
overflow: hidden;
|
font-size: x-small;
|
||||||
width: 100%;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hp-bar-big {
|
.hp-bar-big {
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<template #item="monitor">
|
<template #item="monitor">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-9 col-md-8 small-padding">
|
<div class="col-3 col-md-4 small-padding">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<font-awesome-icon v-if="editMode" icon="arrows-alt-v" class="action drag me-3" />
|
<font-awesome-icon v-if="editMode" icon="arrows-alt-v" class="action drag me-3" />
|
||||||
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeMonitor(group.index, monitor.index)" />
|
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeMonitor(group.index, monitor.index)" />
|
||||||
|
@ -70,7 +70,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div :key="$root.userHeartbeatBar" class="col-3 col-md-4">
|
<div :key="$root.userHeartbeatBar" class="col-9 col-md-8">
|
||||||
|
<!-- <HeartbeatBar size="mid" :monitor-id="monitor.element.id" /> -->
|
||||||
<HeartbeatBar size="mid" :monitor-id="monitor.element.id" />
|
<HeartbeatBar size="mid" :monitor-id="monitor.element.id" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue