feat: heatmap option for activity widget

This commit is contained in:
ThatOneCalculator 2023-04-25 18:06:21 -07:00
parent bafcc77509
commit 221bac64db
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
3 changed files with 19 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "calckey", "name": "calckey",
"version": "13.2.0-dev36", "version": "13.2.0-dev37",
"codename": "aqua", "codename": "aqua",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -25,6 +25,7 @@ import { useChartTooltip } from "@/scripts/use-chart-tooltip";
import { chartVLine } from "@/scripts/chart-vline"; import { chartVLine } from "@/scripts/chart-vline";
import { alpha } from "@/scripts/color"; import { alpha } from "@/scripts/color";
import { initChart } from "@/scripts/init-chart"; import { initChart } from "@/scripts/init-chart";
import { $i } from "@/account";
initChart(); initChart();
@ -108,6 +109,13 @@ async function renderChart() {
span: "day", span: "day",
}); });
values = raw.deliverFailed; values = raw.deliverFailed;
} else if (props.src === "user-notes") {
const raw = await os.api("charts/user/notes", {
limit: 7 * 21,
span: "day",
userId: $i.id,
});
values = raw.total;
} }
fetching = false; fetching = false;

View File

@ -9,11 +9,14 @@
>{{ i18n.ts._widgets.activity }}</template >{{ i18n.ts._widgets.activity }}</template
> >
<template #func <template #func
><button class="_button" @click="toggleView()"> ><button v-if="!widgetProps.newStyle" class="_button" @click="toggleView()">
<i class="ph-sort-ascending ph-bold ph-lg"></i></button <i class="ph-sort-ascending ph-bold ph-lg"></i></button
></template> ></template>
<div> <div v-if="widgetProps.newStyle">
<MkHeatmap src="notes-user" />
</div>
<div v-else>
<MkLoading v-if="fetching" /> <MkLoading v-if="fetching" />
<template v-else> <template v-else>
<XCalendar <XCalendar
@ -40,6 +43,7 @@ import {
} from "./widget"; } from "./widget";
import XCalendar from "./activity.calendar.vue"; import XCalendar from "./activity.calendar.vue";
import XChart from "./activity.chart.vue"; import XChart from "./activity.chart.vue";
import MkHeatmap from "@/components/MkHeatmap.vue";
import { GetFormResultType } from "@/scripts/form"; import { GetFormResultType } from "@/scripts/form";
import * as os from "@/os"; import * as os from "@/os";
import MkContainer from "@/components/MkContainer.vue"; import MkContainer from "@/components/MkContainer.vue";
@ -49,6 +53,10 @@ import { i18n } from "@/i18n";
const name = "activity"; const name = "activity";
const widgetPropsDef = { const widgetPropsDef = {
newStyle: {
type: "boolean" as const,
default: true,
},
showHeader: { showHeader: {
type: "boolean" as const, type: "boolean" as const,
default: true, default: true,