2022-08-23 20:08:53 +02:00
|
|
|
import { config } from "../config";
|
|
|
|
import { MonitoringToken, Url } from "../types";
|
2020-04-08 21:25:33 +02:00
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
function formUrl(route: string, queryParams?: { [key: string]: string }): Url {
|
|
|
|
let url = config.server.baseUrl as string;
|
2020-04-08 21:25:33 +02:00
|
|
|
if (route || queryParams) {
|
2022-08-23 20:08:53 +02:00
|
|
|
url += "/#/";
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
|
|
|
if (route) {
|
|
|
|
url += route;
|
|
|
|
}
|
|
|
|
if (queryParams) {
|
2022-08-23 20:08:53 +02:00
|
|
|
url += "?";
|
|
|
|
url += Object.entries(queryParams)
|
|
|
|
.map(
|
|
|
|
([key, value]) =>
|
|
|
|
encodeURIComponent(key) + "=" + encodeURIComponent(value)
|
|
|
|
)
|
|
|
|
.join("&");
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
2022-07-18 17:49:42 +02:00
|
|
|
return url as Url;
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export function editNodeUrl(): Url {
|
2022-08-23 20:08:53 +02:00
|
|
|
return formUrl("update");
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export function monitoringConfirmUrl(monitoringToken: MonitoringToken): Url {
|
2022-08-23 20:08:53 +02:00
|
|
|
return formUrl("monitoring/confirm", { token: monitoringToken });
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export function monitoringDisableUrl(monitoringToken: MonitoringToken): Url {
|
2022-08-23 20:08:53 +02:00
|
|
|
return formUrl("monitoring/disable", { token: monitoringToken });
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|