2020-04-08 21:25:33 +02:00
|
|
|
import _ from "lodash"
|
|
|
|
import {config} from "../config"
|
2020-04-10 00:43:15 +02:00
|
|
|
import {MonitoringToken} from "../types"
|
2020-04-08 21:25:33 +02:00
|
|
|
|
|
|
|
// TODO: Typed URLs
|
|
|
|
|
2022-07-14 20:06:05 +02:00
|
|
|
function formUrl(route: string, queryParams?: { [key: string]: string }): string {
|
2020-04-08 21:25:33 +02:00
|
|
|
let url = config.server.baseUrl;
|
|
|
|
if (route || queryParams) {
|
|
|
|
url += '/#/';
|
|
|
|
}
|
|
|
|
if (route) {
|
|
|
|
url += route;
|
|
|
|
}
|
|
|
|
if (queryParams) {
|
|
|
|
url += '?';
|
|
|
|
url += _.join(
|
|
|
|
_.map(
|
|
|
|
queryParams,
|
|
|
|
function (value, key) {
|
|
|
|
return encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'&'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2022-07-14 20:06:05 +02:00
|
|
|
export function editNodeUrl(): string {
|
2020-04-08 21:25:33 +02:00
|
|
|
return formUrl('update');
|
|
|
|
}
|
|
|
|
|
2022-07-14 20:06:05 +02:00
|
|
|
export function monitoringConfirmUrl(monitoringToken: MonitoringToken): string {
|
|
|
|
return formUrl('monitoring/confirm', {token: monitoringToken.value});
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
|
|
|
|
2022-07-14 20:06:05 +02:00
|
|
|
export function monitoringDisableUrl(monitoringToken: MonitoringToken): string {
|
|
|
|
return formUrl('monitoring/disable', {token: monitoringToken.value});
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|