mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +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';
|
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 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);
|
checkResponse(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ export function useDashboard(config, server, token) {
|
|||||||
accessUser: false,
|
accessUser: false,
|
||||||
accessId: null,
|
accessId: null,
|
||||||
domain: null,
|
domain: null,
|
||||||
|
updated: false,
|
||||||
storage: null,
|
storage: null,
|
||||||
keyType: null,
|
keyType: null,
|
||||||
enableImage: true,
|
enableImage: true,
|
||||||
@ -60,7 +61,7 @@ export function useDashboard(config, server, token) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
|
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]);
|
}, [config]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -95,7 +96,7 @@ export function useDashboard(config, server, token) {
|
|||||||
updateState({ accessUser: false });
|
updateState({ accessUser: false });
|
||||||
},
|
},
|
||||||
setDomain: (domain) => {
|
setDomain: (domain) => {
|
||||||
updateState({ domain });
|
updateState({ domain, updated: true });
|
||||||
},
|
},
|
||||||
setStorage: (storage) => {
|
setStorage: (storage) => {
|
||||||
updateState({ storage: Number(storage.replace(/[^0-9]/g, '')) });
|
updateState({ storage: Number(storage.replace(/[^0-9]/g, '')) });
|
||||||
@ -128,9 +129,9 @@ export function useDashboard(config, server, token) {
|
|||||||
updateState({ icePassword });
|
updateState({ icePassword });
|
||||||
},
|
},
|
||||||
saveConfig: async () => {
|
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 };
|
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) => {
|
enableUser: async (accountId, enabled) => {
|
||||||
await setAccountStatus(server, token, accountId, !enabled);
|
await setAccountStatus(server, token, accountId, !enabled);
|
||||||
|
@ -123,6 +123,12 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
- name: domain
|
||||||
|
in: query
|
||||||
|
description: if domain should be updated
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: success
|
description: success
|
||||||
|
Loading…
Reference in New Issue
Block a user