forgotten error report

This commit is contained in:
Andrei Pohilko
2022-09-15 21:41:17 +01:00
parent d662849424
commit 927d507fd1

View File

@@ -4,7 +4,9 @@ const revRow = $("#sectionDetails .row");
function reportError(err, xhr) { function reportError(err, xhr) {
$("#errorAlert h4 span").text(err) $("#errorAlert h4 span").text(err)
$("#errorAlert p").text(xhr.responseText) if (xhr) {
$("#errorAlert p").text(xhr.responseText)
}
$("#errorAlert").show() $("#errorAlert").show()
} }
@@ -107,8 +109,8 @@ function loadContent(mode, namespace, name, revision, revDiff, flag) {
url += "?" + qstr url += "?" + qstr
const diffDisplay = $("#manifestText"); const diffDisplay = $("#manifestText");
diffDisplay.empty().append('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>') diffDisplay.empty().append('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>')
$.get(url).fail(function () { $.get(url).fail(function (xhr) {
reportError("Failed to get diff of " + mode) reportError("Failed to get diff of " + mode, xhr)
}).done(function (data) { }).done(function (data) {
diffDisplay.empty(); diffDisplay.empty();
if (data === "") { if (data === "") {
@@ -200,8 +202,8 @@ function loadChartHistory(namespace, name) {
$("#sectionDetails").show() $("#sectionDetails").show()
$("#sectionDetails h1 span.name").text(name) $("#sectionDetails h1 span.name").text(name)
revRow.empty().append("<div><span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span></div>") revRow.empty().append("<div><span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span></div>")
$.getJSON("/api/helm/charts/history?name=" + name + "&namespace=" + namespace).fail(function () { $.getJSON("/api/helm/charts/history?name=" + name + "&namespace=" + namespace).fail(function (xhr) {
reportError("Failed to get chart details") reportError("Failed to get chart details", xhr)
}).done(function (data) { }).done(function (data) {
fillChartHistory(data, namespace, name); fillChartHistory(data, namespace, name);
@@ -222,8 +224,8 @@ $("#btnUpgradeCheck").click(function () {
self.find(".spinner-border").show() self.find(".spinner-border").show()
const repoName = self.data("repo") const repoName = self.data("repo")
$("#btnUpgrade").text("Checking...") $("#btnUpgrade").text("Checking...")
$.post("/api/helm/repo/update?name=" + repoName).fail(function () { $.post("/api/helm/repo/update?name=" + repoName).fail(function (xhr) {
reportError("Failed to update chart repo") reportError("Failed to update chart repo", xhr)
}).done(function () { }).done(function () {
self.find(".spinner-border").hide() self.find(".spinner-border").hide()
self.find(".bi-repeat").show() self.find(".bi-repeat").show()
@@ -235,8 +237,8 @@ $("#btnUpgradeCheck").click(function () {
function checkUpgradeable(name) { function checkUpgradeable(name) {
$.getJSON("/api/helm/repo/search?name=" + name).fail(function () { $.getJSON("/api/helm/repo/search?name=" + name).fail(function (xhr) {
reportError("Failed to find chart in repo") reportError("Failed to find chart in repo", xhr)
}).done(function (data) { }).done(function (data) {
if (!data) { if (!data) {
return return
@@ -271,8 +273,8 @@ $('#upgradeModalLabel select').change(function () {
$("#upgradeModalBody").empty().append('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>') $("#upgradeModalBody").empty().append('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>')
$("#upgradeModal .btn-success").prop("disabled", true) $("#upgradeModal .btn-success").prop("disabled", true)
$.get(self.data("url") + "&version=" + self.val()).fail(function () { $.get(self.data("url") + "&version=" + self.val()).fail(function (xhr) {
reportError("Failed to get upgrade") reportError("Failed to get upgrade", xhr)
}).done(function (data) { }).done(function (data) {
$("#upgradeModalBody").empty(); $("#upgradeModalBody").empty();
$("#upgradeModal .btn-success").prop("disabled", false) $("#upgradeModal .btn-success").prop("disabled", false)
@@ -317,8 +319,8 @@ function popUpUpgrade(self, verCur, elm) {
$.ajax({ $.ajax({
url: url + "&version=" + $('#upgradeModalLabel select').val(), url: url + "&version=" + $('#upgradeModalLabel select').val(),
type: 'POST', type: 'POST',
}).fail(function () { }).fail(function (xhr) {
reportError("Failed to upgrade the chart") reportError("Failed to upgrade the chart", xhr)
}).done(function (data) { }).done(function (data) {
setHashParam("revision", data.version) setHashParam("revision", data.version)
window.location.reload() window.location.reload()
@@ -394,8 +396,8 @@ $(function () {
window.location.href = "/" window.location.href = "/"
}) })
$.getJSON("/api/kube/contexts").fail(function () { $.getJSON("/api/kube/contexts").fail(function (xhr) {
reportError("Failed to get list of clusters") reportError("Failed to get list of clusters", xhr)
}).done(function (data) { }).done(function (data) {
const context = Cookies.get("context") const context = Cookies.get("context")
@@ -453,8 +455,8 @@ function showResources(namespace, chart, revision) {
let qstr = "name=" + chart + "&namespace=" + namespace + "&revision=" + revision let qstr = "name=" + chart + "&namespace=" + namespace + "&revision=" + revision
let url = "/api/helm/charts/resources" let url = "/api/helm/charts/resources"
url += "?" + qstr url += "?" + qstr
$.getJSON(url).fail(function () { $.getJSON(url).fail(function (xhr) {
reportError("Failed to get list of resources") reportError("Failed to get list of resources", xhr)
}).done(function (data) { }).done(function (data) {
$("#nav-resources").empty(); $("#nav-resources").empty();
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
@@ -511,8 +513,8 @@ function showDescribe(ns, kind, name) {
const myModal = new bootstrap.Modal(document.getElementById('describeModal'), {}); const myModal = new bootstrap.Modal(document.getElementById('describeModal'), {});
myModal.show() myModal.show()
$.get("/api/kube/describe/" + kind.toLowerCase() + "?name=" + name + "&namespace=" + ns).fail(function () { $.get("/api/kube/describe/" + kind.toLowerCase() + "?name=" + name + "&namespace=" + ns).fail(function (xhr) {
reportError("Failed to describe resource") reportError("Failed to describe resource", xhr)
}).done(function (data) { }).done(function (data) {
data = hljs.highlight(data, {language: 'yaml'}).value data = hljs.highlight(data, {language: 'yaml'}).value
$("#describeModalBody").empty().append("<pre class='bg-white rounded p-3'></pre>").find("pre").html(data) $("#describeModalBody").empty().append("<pre class='bg-white rounded p-3'></pre>").find("pre").html(data)
@@ -531,8 +533,8 @@ $("#btnUninstall").click(function () {
$.ajax({ $.ajax({
url: url, url: url,
type: 'DELETE', type: 'DELETE',
}).fail(function () { }).fail(function (xhr) {
reportError("Failed to delete the chart") reportError("Failed to delete the chart", xhr)
}).done(function () { }).done(function () {
window.location.href = "/" window.location.href = "/"
}) })
@@ -544,8 +546,8 @@ $("#btnUninstall").click(function () {
let qstr = "name=" + chart + "&namespace=" + namespace + "&revision=" + revision let qstr = "name=" + chart + "&namespace=" + namespace + "&revision=" + revision
let url = "/api/helm/charts/resources" let url = "/api/helm/charts/resources"
url += "?" + qstr url += "?" + qstr
$.getJSON(url).fail(function () { $.getJSON(url).fail(function (xhr) {
reportError("Failed to get list of resources") reportError("Failed to get list of resources", xhr)
}).done(function (data) { }).done(function (data) {
$("#confirmModalBody").empty().append("<p>Following resources will be deleted from the cluster:</p>"); $("#confirmModalBody").empty().append("<p>Following resources will be deleted from the cluster:</p>");
$("#confirmModal .btn-primary").prop("disabled", false) $("#confirmModal .btn-primary").prop("disabled", false)
@@ -582,8 +584,8 @@ $("#btnRollback").click(function () {
let qstr = "name=" + chart + "&namespace=" + namespace + "&revision=" + revisionNew + "&revisionDiff=" + revisionCur let qstr = "name=" + chart + "&namespace=" + namespace + "&revision=" + revisionNew + "&revisionDiff=" + revisionCur
let url = "/api/helm/charts/manifests" let url = "/api/helm/charts/manifests"
url += "?" + qstr url += "?" + qstr
$.get(url).fail(function () { $.get(url).fail(function (xhr) {
reportError("Failed to get list of resources") reportError("Failed to get list of resources", xhr)
}).done(function (data) { }).done(function (data) {
$("#confirmModalBody").empty(); $("#confirmModalBody").empty();
$("#confirmModal .btn-primary").prop("disabled", false) $("#confirmModal .btn-primary").prop("disabled", false)