Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ui/console-src/modules/dashboard/widgets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PendingCommentsWidget from "./presets/comments/PendingCommentsWidget.vue"
import IframeWidget from "./presets/core/iframe/IframeWidget.vue";
import QuickActionWidget from "./presets/core/quick-action/QuickActionWidget.vue";
import StackWidget from "./presets/core/stack/StackWidget.vue";
import UpvoteStatsWidget from "./presets/core/upvote-stats/UpvoteStatsWidget.vue";
import ViewsStatsWidget from "./presets/core/view-stats/ViewsStatsWidget.vue";
import PostStatsWidget from "./presets/posts/PostStatsWidget.vue";
import RecentPublishedWidget from "./presets/posts/RecentPublishedWidget.vue";
Expand Down Expand Up @@ -157,6 +158,29 @@ export const internalWidgetDefinitions: DashboardWidgetDefinition[] = [
minW: 2,
},
},
{
id: "core:upvote:stats",
component: markRaw(UpvoteStatsWidget),
group: "core.dashboard.widgets.groups.other",
configFormKitSchema: () => [
{
$formkit: "checkbox",
label: i18n.global.t(
"core.dashboard.widgets.common_form.fields.enable_animation.label"
),
name: "enable_animation",
},
],
defaultConfig: {
enable_animation: true,
},
defaultSize: {
w: 3,
h: 3,
minH: 2,
minW: 2,
},
},
{
id: "core:quick-action",
component: markRaw(QuickActionWidget),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script lang="ts" setup>
import { useDashboardStats } from "@console/composables/use-dashboard-stats";
import WidgetCard from "@console/modules/dashboard/components/WidgetCard.vue";
import { IconThumbUpLine } from "@halo-dev/components";
import NumberFlow from "@number-flow/vue";

defineProps<{
config: {
enable_animation: boolean;
};
}>();

const { data: stats } = useDashboardStats();
</script>

<template>
<WidgetCard>
<div class="flex h-full px-4 py-3">
<div class="flex items-center gap-4">
<span class="rounded-full bg-gray-100 p-2.5 text-gray-600">
<IconThumbUpLine class="h-5 w-5" />
</span>

<div class="flex flex-col">
<span class="text-sm text-gray-500">
{{ $t("core.dashboard.widgets.presets.upvote_stats.title") }}
</span>
<NumberFlow
v-if="config.enable_animation"
class="text-2xl font-medium text-gray-900"
:value="stats?.upvotes || 0"
:format="{ notation: 'compact' }"
>
</NumberFlow>
<span v-else class="text-2xl font-medium text-gray-900">
{{ stats?.upvotes || 0 }}
</span>
</div>
</div>
</div>
</WidgetCard>
</template>




2 changes: 2 additions & 0 deletions ui/packages/components/src/icons/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import IconTeam from "~icons/ri/team-fill";
import IconTerminalBoxLine from "~icons/ri/terminal-box-line";
import IconTimerLine from "~icons/ri/timer-line";
import IconToolsFill from "~icons/ri/tools-fill";
import IconThumbUpLine from "~icons/ri/thumb-up-line";
import IconRiUpload2Fill from "~icons/ri/upload-2-fill";
import IconUpload from "~icons/ri/upload-cloud-2-line";
import IconUserFollow from "~icons/ri/user-follow-line";
Expand Down Expand Up @@ -145,6 +146,7 @@ export {
IconTerminalBoxLine,
IconTimerLine,
IconToolsFill,
IconThumbUpLine,
IconUpload,
IconUserFollow,
IconUserLine,
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ core:
title: No pending comments
views_stats:
title: Visits
upvote_stats:
title: Likes
iframe:
title: Iframe
empty:
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ core:
title: Comentarios
views_stats:
title: Visitas
upvote_stats:
title: Me gusta
post:
title: Publicaciones
actions:
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ core:
title: 评论
views_stats:
title: 浏览量
upvote_stats:
title: 点赞量
pending_comments:
title: 新评论
empty:
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/zh-TW.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ core:
title: 留言
views_stats:
title: 瀏覽量
upvote_stats:
title: 按讚數
pending_comments:
title: 新評論
empty:
Expand Down
Loading