Skip to content

Commit 95467cc

Browse files
committed
fix issue with empty field (null) values
Signed-off-by: Markus Blaschke <[email protected]>
1 parent 8701afc commit 95467cc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

templates/query.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ <h2>Prometheus scrape_config</h2>
378378
let formEl = $(el);
379379
let fieldName = formEl.attr("id");
380380
let fieldValue = formEl.val();
381-
fieldValue = fieldValue.trim();
382-
383-
formData[fieldName] = fieldValue;
381+
formData[fieldName] = fieldValue ? fieldValue.trim() : ""
384382
});
385383

386384
let hashString = btoa(JSON.stringify(formData));
@@ -408,7 +406,8 @@ <h2>Prometheus scrape_config</h2>
408406
};
409407

410408
let formSetVisibility = () => {
411-
let endpoint = $("#endpoint:input").val().trim();
409+
let endpoint = $("#endpoint:input").val()
410+
endpoint = endpoint ? endpoint.trim() : ""
412411
$("form.query div.row").removeClass("hidden");
413412
$("form.query div.row[query-endpoint]:not([query-endpoint~=\"" + endpoint + "\"])").addClass("hidden");
414413
$("form.query div.row[query-endpoint-exclude][query-endpoint-exclude~=\"" + endpoint + "\"]").addClass("hidden");
@@ -453,7 +452,7 @@ <h2>Prometheus scrape_config</h2>
453452
let formEl = $(el);
454453
let fieldName = formEl.attr("id");
455454
let fieldValue = formEl.val();
456-
fieldValue = fieldValue.trim();
455+
fieldValue = fieldValue ? fieldValue.trim(): "";
457456

458457
switch (fieldName) {
459458
case "endpoint":

0 commit comments

Comments
 (0)