mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
synced api for updating node domain
This commit is contained in:
parent
170dce9173
commit
643417eb1e
@ -1,8 +1,8 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
|
||||
export async function setNodeConfig(server, token, config) {
|
||||
export async function setNodeConfig(server, token, config, updated) {
|
||||
let body = JSON.stringify(config);
|
||||
let settings = await fetchWithTimeout(`https://${server}/admin/config?token=${token}`, { method: 'PUT', body });
|
||||
let settings = await fetchWithTimeout(`https://${server}/admin/config?token=${token}&domain=${updated}`, { method: 'PUT', body });
|
||||
checkResponse(settings);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ export function useDashboard(config, server, token) {
|
||||
accessUser: false,
|
||||
accessId: null,
|
||||
domain: null,
|
||||
updated: false,
|
||||
storage: null,
|
||||
keyType: null,
|
||||
enableImage: true,
|
||||
@ -60,7 +61,7 @@ export function useDashboard(config, server, token) {
|
||||
|
||||
useEffect(() => {
|
||||
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
|
||||
updateState({ keyType, storage: accountStorage.toString(), domain, enableImage, enableAudio, enableVideo, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
|
||||
updateState({ keyType, storage: accountStorage.toString(), domain, enableImage, enableAudio, enableVideo, pushSupported, enableIce, iceUrl, iceUsername, icePassword, updated: false });
|
||||
}, [config]);
|
||||
|
||||
useEffect(() => {
|
||||
@ -95,7 +96,7 @@ export function useDashboard(config, server, token) {
|
||||
updateState({ accessUser: false });
|
||||
},
|
||||
setDomain: (domain) => {
|
||||
updateState({ domain });
|
||||
updateState({ domain, updated: true });
|
||||
},
|
||||
setStorage: (storage) => {
|
||||
updateState({ storage: Number(storage.replace(/[^0-9]/g, '')) });
|
||||
@ -128,9 +129,9 @@ export function useDashboard(config, server, token) {
|
||||
updateState({ icePassword });
|
||||
},
|
||||
saveConfig: async () => {
|
||||
const { storage, domain, keyType, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword } = state;
|
||||
const { storage, domain, updated, keyType, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword } = state;
|
||||
const config = { accountStorage: Number(storage), domain, keyType, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword };
|
||||
await setNodeConfig(server, token, config);
|
||||
await setNodeConfig(server, token, config, updated);
|
||||
},
|
||||
enableUser: async (accountId, enabled) => {
|
||||
await setAccountStatus(server, token, accountId, !enabled);
|
||||
|
@ -123,6 +123,12 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: domain
|
||||
in: query
|
||||
description: if domain should be updated
|
||||
required: false
|
||||
schema:
|
||||
type: boolean
|
||||
responses:
|
||||
'200':
|
||||
description: success
|
||||
|
Loading…
Reference in New Issue
Block a user