burst cache for status, lock, notifications if command is running
This commit is contained in:
parent
201da84967
commit
ee7aa12fd0
@ -31,7 +31,6 @@ const ServerCommandsPanel = () => {
|
|||||||
if (serverCommandsResponse) {
|
if (serverCommandsResponse) {
|
||||||
const serverCommands = serverCommandsResponse;
|
const serverCommands = serverCommandsResponse;
|
||||||
Object.keys(serverCommandsResponse).forEach((command: string) => {
|
Object.keys(serverCommandsResponse).forEach((command: string) => {
|
||||||
// serverCommands[command] = serverCommandsResponse[command];
|
|
||||||
serverCommands[command].additionalArgs = "";
|
serverCommands[command].additionalArgs = "";
|
||||||
});
|
});
|
||||||
setServerCommands(serverCommands);
|
setServerCommands(serverCommands);
|
||||||
@ -41,6 +40,12 @@ const ServerCommandsPanel = () => {
|
|||||||
fetchIsAdmin();
|
fetchIsAdmin();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (serverProcess.command === "") {
|
||||||
|
setCommandIsRunning(false);
|
||||||
|
}
|
||||||
|
}, [serverProcess]);
|
||||||
|
|
||||||
const setCommandAdditionalArgs = (command: string, additionalArgs: string) => {
|
const setCommandAdditionalArgs = (command: string, additionalArgs: string) => {
|
||||||
const updatedServerCommands = {...serverCommands};
|
const updatedServerCommands = {...serverCommands};
|
||||||
updatedServerCommands[command].additionalArgs = additionalArgs;
|
updatedServerCommands[command].additionalArgs = additionalArgs;
|
||||||
@ -53,7 +58,6 @@ const ServerCommandsPanel = () => {
|
|||||||
|
|
||||||
const response = await dataProvider.runServerCommand(etkeccAdmin, command);
|
const response = await dataProvider.runServerCommand(etkeccAdmin, command);
|
||||||
|
|
||||||
setCommandIsRunning(false);
|
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -108,6 +112,7 @@ const ServerCommandsPanel = () => {
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
{args && <TextField
|
{args && <TextField
|
||||||
size="small"
|
size="small"
|
||||||
|
variant="standard"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setCommandAdditionalArgs(command, e.target.value);
|
setCommandAdditionalArgs(command, e.target.value);
|
||||||
}}
|
}}
|
||||||
|
@ -21,7 +21,7 @@ const useServerNotifications = () => {
|
|||||||
const { notifications, success } = serverNotifications;
|
const { notifications, success } = serverNotifications;
|
||||||
|
|
||||||
const fetchNotifications = async () => {
|
const fetchNotifications = async () => {
|
||||||
const notificationsResponse: ServerNotificationsResponse = await dataProvider.getServerNotifications(etkeccAdmin);
|
const notificationsResponse: ServerNotificationsResponse = await dataProvider.getServerNotifications(etkeccAdmin, command !== "");
|
||||||
setServerNotifications({
|
setServerNotifications({
|
||||||
...notificationsResponse,
|
...notificationsResponse,
|
||||||
notifications: notificationsResponse.notifications,
|
notifications: notificationsResponse.notifications,
|
||||||
|
@ -52,13 +52,15 @@ const SERVER_CURRENT_PROCCESS_INTERVAL_TIME = 5 * 1000;
|
|||||||
|
|
||||||
const useServerStatus = () => {
|
const useServerStatus = () => {
|
||||||
const [serverStatus, setServerStatus] = useStore<ServerStatusResponse>("serverStatus", { ok: false, success: false, host: "", results: [] });
|
const [serverStatus, setServerStatus] = useStore<ServerStatusResponse>("serverStatus", { ok: false, success: false, host: "", results: [] });
|
||||||
|
const [serverProcess, setServerProcess] = useStore<ServerProcessResponse>("serverProcess", { command: "", locked_at: "" });
|
||||||
|
const { command, locked_at } = serverProcess;
|
||||||
const { etkeccAdmin } = useAppContext();
|
const { etkeccAdmin } = useAppContext();
|
||||||
const dataProvider = useDataProvider();
|
const dataProvider = useDataProvider();
|
||||||
const isOkay = serverStatus.ok;
|
const isOkay = serverStatus.ok;
|
||||||
const successCheck = serverStatus.success;
|
const successCheck = serverStatus.success;
|
||||||
|
|
||||||
const checkServerStatus = async () => {
|
const checkServerStatus = async () => {
|
||||||
const serverStatus: ServerStatusResponse = await dataProvider.getServerStatus(etkeccAdmin);
|
const serverStatus: ServerStatusResponse = await dataProvider.getServerStatus(etkeccAdmin, command !== "");
|
||||||
setServerStatus({
|
setServerStatus({
|
||||||
ok: serverStatus.ok,
|
ok: serverStatus.ok,
|
||||||
success: serverStatus.success,
|
success: serverStatus.success,
|
||||||
@ -89,7 +91,7 @@ const useServerStatus = () => {
|
|||||||
clearInterval(serverStatusInterval);
|
clearInterval(serverStatusInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [etkeccAdmin]);
|
}, [etkeccAdmin, command]);
|
||||||
|
|
||||||
return { isOkay, successCheck };
|
return { isOkay, successCheck };
|
||||||
};
|
};
|
||||||
@ -101,7 +103,7 @@ const useCurrentServerProcess = () => {
|
|||||||
const { command, locked_at } = serverProcess;
|
const { command, locked_at } = serverProcess;
|
||||||
|
|
||||||
const checkServerRunningProcess = async () => {
|
const checkServerRunningProcess = async () => {
|
||||||
const serverProcess: ServerProcessResponse = await dataProvider.getServerRunningProcess(etkeccAdmin);
|
const serverProcess: ServerProcessResponse = await dataProvider.getServerRunningProcess(etkeccAdmin, command !== "");
|
||||||
setServerProcess({
|
setServerProcess({
|
||||||
...serverProcess,
|
...serverProcess,
|
||||||
command: serverProcess.command,
|
command: serverProcess.command,
|
||||||
@ -130,7 +132,7 @@ const useCurrentServerProcess = () => {
|
|||||||
clearInterval(serverCheckInterval);
|
clearInterval(serverCheckInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [etkeccAdmin]);
|
}, [etkeccAdmin, command]);
|
||||||
|
|
||||||
return { command, locked_at };
|
return { command, locked_at };
|
||||||
};
|
};
|
||||||
|
@ -1042,9 +1042,14 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
return { locked_at, command };
|
return { locked_at, command };
|
||||||
},
|
},
|
||||||
getServerStatus: async (etkeAdminUrl: string): Promise<ServerStatusResponse> => {
|
getServerStatus: async (etkeAdminUrl: string, burstCache: boolean = false): Promise<ServerStatusResponse> => {
|
||||||
|
let serverURL = `${etkeAdminUrl}/status`;
|
||||||
|
if (burstCache) {
|
||||||
|
serverURL += `?time=${new Date().getTime()}`;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${etkeAdminUrl}/status`, {
|
const response = await fetch(serverURL, {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${localStorage.getItem("access_token")}`
|
"Authorization": `Bearer ${localStorage.getItem("access_token")}`
|
||||||
}
|
}
|
||||||
@ -1066,9 +1071,14 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
return { success: false, ok: false, host: "", results: [] };
|
return { success: false, ok: false, host: "", results: [] };
|
||||||
},
|
},
|
||||||
getServerNotifications: async (serverNotificationsUrl: string): Promise<ServerNotificationsResponse> => {
|
getServerNotifications: async (serverNotificationsUrl: string, burstCache: boolean = false): Promise<ServerNotificationsResponse> => {
|
||||||
|
let serverURL = `${serverNotificationsUrl}/notifications`;
|
||||||
|
if (burstCache) {
|
||||||
|
serverURL += `?time=${new Date().getTime()}`;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${serverNotificationsUrl}/notifications`, {
|
const response = await fetch(serverURL, {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${localStorage.getItem("access_token")}`
|
"Authorization": `Bearer ${localStorage.getItem("access_token")}`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user