From 2130b3650e6e28264de8a088031691710b1e3358 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Thu, 6 Apr 2023 11:38:59 +0800 Subject: [PATCH] feat: add server common API --- src/app/services/server.ts | 27 +++++++++++++++++++++++++-- src/app/slices/server.ts | 13 ++++++++++--- src/types/server.ts | 4 ++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/app/services/server.ts b/src/app/services/server.ts index 796336c8..86c83bf4 100644 --- a/src/app/services/server.ts +++ b/src/app/services/server.ts @@ -18,7 +18,8 @@ import { RenewLicense, RenewLicenseResponse, AgoraTokenResponse, - AgoraVoicingListResponse + AgoraVoicingListResponse, + SystemCommon } from "../../types/server"; import { Channel } from "../../types/channel"; import { ContentTypeKey } from "../../types/message"; @@ -146,6 +147,26 @@ export const serverApi = createApi({ } } }), + getSystemCommon: builder.query({ + query: () => ({ url: `admin/system/common` }) + }), + updateSystemCommon: builder.mutation>({ + query: (data) => ({ + url: `admin/system/common`, + method: "PUT", + body: data + }), + async onQueryStarted(data, { dispatch, queryFulfilled }) { + try { + await queryFulfilled; + dispatch( + updateInfo(data) + ); + } catch { + console.error("update server common error"); + } + } + }), getSMTPConfig: builder.query({ query: () => ({ url: `admin/smtp/config` }) }), @@ -360,5 +381,7 @@ export const { useGetFrontendUrlQuery, useLazyGetAgoraTokenQuery, useGetAgoraConfigQuery, - useGetAgoraVoicingListQuery + useGetAgoraVoicingListQuery, + useUpdateSystemCommonMutation, + useGetSystemCommonQuery } = serverApi; diff --git a/src/app/slices/server.ts b/src/app/slices/server.ts index 879411b9..21543a93 100644 --- a/src/app/slices/server.ts +++ b/src/app/slices/server.ts @@ -8,6 +8,8 @@ export interface StoredServer extends Server { link: string; expire: number; }; + show_user_online_status: boolean, + webclient_auto_update: boolean } const initialState: StoredServer = { upgraded: false, @@ -17,7 +19,9 @@ const initialState: StoredServer = { inviteLink: { link: "", expire: 0 - } + }, + show_user_online_status: false, + webclient_auto_update: true }; const serverSlice = createSlice({ @@ -36,9 +40,12 @@ const serverSlice = createSlice({ }, logo = "", // todo: check missed logo property name = "", - description = "" + description = "", + show_user_online_status = false, + language = "en", + webclient_auto_update = true } = action.payload || {}; - return { upgraded, name, logo, description, inviteLink }; + return { upgraded, name, logo, description, inviteLink, show_user_online_status, language, webclient_auto_update }; }, updateInfo(state, action: PayloadAction>) { const values = action.payload || {}; diff --git a/src/types/server.ts b/src/types/server.ts index 37fbe6bf..210dca53 100644 --- a/src/types/server.ts +++ b/src/types/server.ts @@ -6,6 +6,10 @@ export interface Server { name: string; description: string; } +export interface SystemCommon { + show_user_online_status: boolean, + webclient_auto_update: boolean, +} export interface GithubAuthConfig { client_id?: string; client_secret?: string;