Improved stability

This commit is contained in:
DomySh
2022-06-13 10:59:05 +02:00
parent cff484a976
commit b53768b5d2
16 changed files with 270 additions and 159 deletions

View File

@@ -1,7 +1,7 @@
export const update_freq = 3000;
export const notification_time = 2000;
export const update_freq = 2000;
export const notification_time = 1500;
export type GeneralStats = {
services:number,
@@ -38,8 +38,8 @@ export type RegexFilter = {
}
export type RegexAddForm = {
"service_id":string,
"regex":string,
"is_blacklist":boolean,
"mode":string // C->S S->C BOTH
service_id:string,
regex:string,
is_blacklist:boolean,
mode:string // C->S S->C BOTH
}

View File

@@ -5,12 +5,14 @@ import { GeneralStats, Service, ServiceAddForm, ServerResponse, RegexFilter, not
var Buffer = require('buffer').Buffer
const custom_url = ""//"http://127.0.0.1:8080"
export async function getapi(path:string):Promise<any>{
return await fetch(`/api/${path}`).then( res => res.json() )
return await fetch(`${custom_url}/api/${path}`).then( res => res.json() )
}
export async function postapi(path:string,data:any):Promise<any>{
return await fetch(`/api/${path}`, {
return await fetch(`${custom_url}/api/${path}`, {
method: 'POST',
cache: 'no-cache',
headers: {
@@ -33,11 +35,40 @@ export async function serviceinfo(service_id:string){
return await getapi(`service/${service_id}`) as Service;
}
export async function deleteregex(regex_id:number){
const { status } = await getapi(`regex/${regex_id}/delete`) as ServerResponse;
return status === "ok"?undefined:status
}
export async function startservice(service_id:string){
const { status } = await getapi(`service/${service_id}/start`) as ServerResponse;
return status === "ok"?undefined:status
}
export async function stopservice(service_id:string){
const { status } = await getapi(`service/${service_id}/stop`) as ServerResponse;
return status === "ok"?undefined:status
}
export async function pauseservice(service_id:string){
const { status } = await getapi(`service/${service_id}/pause`) as ServerResponse;
return status === "ok"?undefined:status
}
export async function regenport(service_id:string){
const { status } = await getapi(`service/${service_id}/regen-port`) as ServerResponse;
return status === "ok"?undefined:status
}
export async function addservice(data:ServiceAddForm) {
const { status } = await postapi("services/add",data) as ServerResponse;
return status === "ok"?undefined:status
}
export async function deleteservice(service_id:string) {
const { status } = await getapi(`service/${service_id}/delete`) as ServerResponse;
return status === "ok"?undefined:status
}
export async function addregex(data:RegexAddForm) {
const { status } = await postapi("regexes/add",data) as ServerResponse;
return status === "ok"?undefined:status