2020-04-08 21:25:33 +02:00
|
|
|
import _ from "lodash"
|
|
|
|
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 += '?';
|
|
|
|
url += _.join(
|
|
|
|
_.map(
|
|
|
|
queryParams,
|
|
|
|
function (value, key) {
|
|
|
|
return encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'&'
|
|
|
|
);
|
|
|
|
}
|
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
|
|
|
}
|