feat: add server common API
This commit is contained in:
@@ -18,7 +18,8 @@ import {
|
|||||||
RenewLicense,
|
RenewLicense,
|
||||||
RenewLicenseResponse,
|
RenewLicenseResponse,
|
||||||
AgoraTokenResponse,
|
AgoraTokenResponse,
|
||||||
AgoraVoicingListResponse
|
AgoraVoicingListResponse,
|
||||||
|
SystemCommon
|
||||||
} from "../../types/server";
|
} from "../../types/server";
|
||||||
import { Channel } from "../../types/channel";
|
import { Channel } from "../../types/channel";
|
||||||
import { ContentTypeKey } from "../../types/message";
|
import { ContentTypeKey } from "../../types/message";
|
||||||
@@ -146,6 +147,26 @@ export const serverApi = createApi({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
getSystemCommon: builder.query<SystemCommon, void>({
|
||||||
|
query: () => ({ url: `admin/system/common` })
|
||||||
|
}),
|
||||||
|
updateSystemCommon: builder.mutation<void, Partial<SystemCommon>>({
|
||||||
|
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<SMTPConfig, void>({
|
getSMTPConfig: builder.query<SMTPConfig, void>({
|
||||||
query: () => ({ url: `admin/smtp/config` })
|
query: () => ({ url: `admin/smtp/config` })
|
||||||
}),
|
}),
|
||||||
@@ -360,5 +381,7 @@ export const {
|
|||||||
useGetFrontendUrlQuery,
|
useGetFrontendUrlQuery,
|
||||||
useLazyGetAgoraTokenQuery,
|
useLazyGetAgoraTokenQuery,
|
||||||
useGetAgoraConfigQuery,
|
useGetAgoraConfigQuery,
|
||||||
useGetAgoraVoicingListQuery
|
useGetAgoraVoicingListQuery,
|
||||||
|
useUpdateSystemCommonMutation,
|
||||||
|
useGetSystemCommonQuery
|
||||||
} = serverApi;
|
} = serverApi;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export interface StoredServer extends Server {
|
|||||||
link: string;
|
link: string;
|
||||||
expire: number;
|
expire: number;
|
||||||
};
|
};
|
||||||
|
show_user_online_status: boolean,
|
||||||
|
webclient_auto_update: boolean
|
||||||
}
|
}
|
||||||
const initialState: StoredServer = {
|
const initialState: StoredServer = {
|
||||||
upgraded: false,
|
upgraded: false,
|
||||||
@@ -17,7 +19,9 @@ const initialState: StoredServer = {
|
|||||||
inviteLink: {
|
inviteLink: {
|
||||||
link: "",
|
link: "",
|
||||||
expire: 0
|
expire: 0
|
||||||
}
|
},
|
||||||
|
show_user_online_status: false,
|
||||||
|
webclient_auto_update: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const serverSlice = createSlice({
|
const serverSlice = createSlice({
|
||||||
@@ -36,9 +40,12 @@ const serverSlice = createSlice({
|
|||||||
},
|
},
|
||||||
logo = "", // todo: check missed logo property
|
logo = "", // todo: check missed logo property
|
||||||
name = "",
|
name = "",
|
||||||
description = ""
|
description = "",
|
||||||
|
show_user_online_status = false,
|
||||||
|
language = "en",
|
||||||
|
webclient_auto_update = true
|
||||||
} = action.payload || {};
|
} = 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<Partial<StoredServer>>) {
|
updateInfo(state, action: PayloadAction<Partial<StoredServer>>) {
|
||||||
const values = action.payload || {};
|
const values = action.payload || {};
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ export interface Server {
|
|||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
export interface SystemCommon {
|
||||||
|
show_user_online_status: boolean,
|
||||||
|
webclient_auto_update: boolean,
|
||||||
|
}
|
||||||
export interface GithubAuthConfig {
|
export interface GithubAuthConfig {
|
||||||
client_id?: string;
|
client_id?: string;
|
||||||
client_secret?: string;
|
client_secret?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user