2020-04-08 21:25:33 +02:00
|
|
|
import {config} from "../config"
|
2022-07-18 17:49:42 +02:00
|
|
|
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) {
|
|
|
|
url += '/#/';
|
|
|
|
}
|
|
|
|
if (route) {
|
|
|
|
url += route;
|
|
|
|
}
|
|
|
|
if (queryParams) {
|
|
|
|
url += '?';
|
2022-07-28 13:16:13 +02:00
|
|
|
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 {
|
2020-04-08 21:25:33 +02:00
|
|
|
return formUrl('update');
|
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export function monitoringConfirmUrl(monitoringToken: MonitoringToken): Url {
|
|
|
|
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 {
|
|
|
|
return formUrl('monitoring/disable', {token: monitoringToken});
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|