Skip to content

Commit 3a4e031

Browse files
committed
Enhance: 登録できるユーザー数を表示できるように (#71)
1 parent f0a1668 commit 3a4e031

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

packages/backend/src/server/api/endpoints/admin/meta.ts

+11
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
*/
55

66
import { Inject, Injectable } from '@nestjs/common';
7+
import { In, IsNull, Not } from 'typeorm';
78
import { Endpoint } from '@/server/api/endpoint-base.js';
89
import { MetaService } from '@/core/MetaService.js';
910
import type { Config } from '@/config.js';
1011
import { DI } from '@/di-symbols.js';
1112
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
1213
import { envOption } from '@/env.js';
14+
import type { UsersRepository } from '@/models/_.js';
1315

1416
export const meta = {
1517
tags: ['meta'],
@@ -644,6 +646,9 @@ export const meta = {
644646
iconDark: { type: 'string', nullable: true },
645647
bannerLight: { type: 'string', nullable: true },
646648
bannerDark: { type: 'string', nullable: true },
649+
maxLocalUsers: { type: 'number', nullable: true },
650+
nowLocalUsers: { type: 'number', nullable: true },
651+
isManaged: { type: 'boolean', nullable: true },
647652
},
648653
},
649654
} as const;
@@ -659,6 +664,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
659664
constructor(
660665
@Inject(DI.config)
661666
private config: Config,
667+
@Inject(DI.usersRepository)
668+
private usersRepository: UsersRepository,
662669
private metaService: MetaService,
663670
) {
664671
super(meta, paramDef, async (_, me) => {
@@ -787,6 +794,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
787794
urlPreviewRequireContentLength: instance.urlPreviewRequireContentLength,
788795
urlPreviewUserAgent: instance.urlPreviewUserAgent,
789796
urlPreviewSummaryProxyUrl: instance.urlPreviewSummaryProxyUrl,
797+
maxLocalUsers: 0,
798+
nowLocalUsers: 0,
790799
};
791800

792801
if (!envOption.managed || this.config.rootUserName === me.username) {
@@ -807,6 +816,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
807816
objectStorageUseProxy: false,
808817
objectStorageSetPublicRead: false,
809818
objectStorageS3ForcePathStyle: false,
819+
maxLocalUsers: this.config.maxLocalUsers,
820+
nowLocalUsers: await this.usersRepository.count({ where: { host: IsNull(), username: Not(In(['instance.actor', 'relay.actor', this.config.adminUserName, this.config.rootUserName])) } }),
810821
summalyProxy: 'Masked',
811822
deeplAuthKey: 'Masked',
812823
isManaged: true,

packages/frontend/src/pages/admin/overview.stats.vue

+31-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,33 @@ SPDX-License-Identifier: AGPL-3.0-only
5555
<div class="label">Online</div>
5656
</div>
5757
</div>
58+
<div v-if="meta?.isManaged" class="item _panel users">
59+
<div class="icon"><i class="ti ti-users"></i></div>
60+
<div class="body">
61+
<div class="value">
62+
<MkNumber :value="meta?.nowLocalUsers" style="margin-right: 0.5em;"/>
63+
</div>
64+
<div class="label">Now Local Users</div>
65+
</div>
66+
</div>
67+
<div v-if="meta?.isManaged" class="item _panel users">
68+
<div class="icon"><i class="ti ti-users"></i></div>
69+
<div class="body">
70+
<div class="value">
71+
<MkNumber :value="meta?.maxLocalUsers" style="margin-right: 0.5em;"/>
72+
</div>
73+
<div class="label">Max Local Users</div>
74+
</div>
75+
</div>
76+
<div v-if="meta?.isManaged" class="item _panel users">
77+
<div class="icon"><i class="ti ti-users"></i></div>
78+
<div class="body">
79+
<div class="value">
80+
<MkNumber :value="meta?.maxLocalUsers - meta?.nowLocalUsers" style="margin-right: 0.5em;"/>
81+
</div>
82+
<div class="label">登録できるユーザー数</div>
83+
</div>
84+
</div>
5885
</div>
5986
</Transition>
6087
</div>
@@ -71,19 +98,21 @@ import { customEmojis } from '@/custom-emojis.js';
7198
import { defaultStore } from '@/store.js';
7299

73100
const stats = ref<Misskey.entities.StatsResponse | null>(null);
101+
const meta = ref<Misskey.entities.AdminMetaResponse | null>(null);
74102
const usersComparedToThePrevDay = ref<number>();
75103
const notesComparedToThePrevDay = ref<number>();
76104
const onlineUsersCount = ref(0);
77105
const fetching = ref(true);
78106

79107
onMounted(async () => {
80-
const [_stats, _onlineUsersCount] = await Promise.all([
108+
const [_stats, _meta, _onlineUsersCount] = await Promise.all([
81109
misskeyApi('stats', {}),
110+
misskeyApi('admin/meta', {}),
82111
misskeyApiGet('get-online-users-count').then(res => res.count),
83112
]);
84113
stats.value = _stats;
85114
onlineUsersCount.value = _onlineUsersCount;
86-
115+
meta.value = _meta;
87116
misskeyApiGet('charts/users', { limit: 2, span: 'day' }).then(chart => {
88117
usersComparedToThePrevDay.value = stats.value.originalUsersCount - chart.local.total[1];
89118
});

packages/misskey-js/src/autogen/types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -5442,6 +5442,9 @@ export type operations = {
54425442
iconDark: string | null;
54435443
bannerLight: string | null;
54445444
bannerDark: string | null;
5445+
maxLocalUsers: number | null;
5446+
nowLocalUsers: number | null;
5447+
isManaged: boolean | null;
54455448
};
54465449
};
54475450
};

0 commit comments

Comments
 (0)