const clusterSelect = $("#cluster"); const chartsCards = $("#charts"); function reportError(err) { alert(err) // TODO: nice modal/baloon/etc } $(function () { // cluster list $.getJSON("/api/kube/contexts").fail(function () { reportError("Failed to get list of clusters") }).done(function (data) { data.forEach(function (elm) { // aws CLI uses complicated context names, the suffix does not work well // maybe we should have an `if` statement here let label = elm.Name //+ " (" + elm.Cluster + "/" + elm.AuthInfo + "/" + elm.Namespace + ")" let opt = $("").val(elm.Name).text(label) if (elm.IsCurrent) { opt.attr("selected", "selected") } clusterSelect.append(opt) }) }) clusterSelect.change(function () { // TODO: remember it, respect it in the function above and in all other places }) // charts list $.getJSON("/api/helm/charts").fail(function () { reportError("Failed to get list of clusters") }).done(function (data) { chartsCards.empty() data.forEach(function (elm) { const header = $("
") header.append($('