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
|
|
|
|
|
|
|
|
function formUrl(route: string, queryParams?: {[key: string]: string}): string {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function editNodeUrl (): string {
|
|
|
|
return formUrl('update');
|
|
|
|
}
|
|
|
|
|
2020-04-10 00:43:15 +02:00
|
|
|
export function monitoringConfirmUrl (monitoringToken: MonitoringToken): string {
|
|
|
|
return formUrl('monitoring/confirm', { token: monitoringToken });
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|
|
|
|
|
2020-04-10 00:43:15 +02:00
|
|
|
export function monitoringDisableUrl (monitoringToken: MonitoringToken): string {
|
|
|
|
return formUrl('monitoring/disable', { token: monitoringToken });
|
2020-04-08 21:25:33 +02:00
|
|
|
}
|