$(function () { let limNS = null $.getJSON("/status").fail(function (xhr) { // maybe /options call in the future reportError("Failed to get tool version", xhr) }).done(function (data) { $("body").data("status", data) fillToolVersion(data) limNS = data.LimitedToNamespace if (limNS) { $("#limitNamespace").show().find("span").text(limNS) } fillClusters(limNS) if (data.ClusterMode) { $(".bi-power").hide() $("#clusterFilterBlock").hide() } }) $.getJSON("/api/scanners").fail(function (xhr) { reportError("Failed to get list of scanners", xhr) }).done(function (data) { $("body").data("scanners", data) for (let k in data) { if (data[k].ManifestScannable) { $("#upgradeModal .btn-scan").show() // TODO: move this to install flow } } }) }) function fillClusters(limNS) { const clusterSelect = $("#cluster"); clusterSelect.change(function () { window.location.href = "/#context=" + clusterSelect.find("input:radio:checked").val() window.location.reload() }) const namespaceSelect = $("#namespace"); namespaceSelect.change(function () { let filteredNamespaces = [] namespaceSelect.find("input:checkbox:checked").each(function () { filteredNamespaces.push($(this).val()); }) setFilteredNamespaces(filteredNamespaces) filterInstalledList($("#installedList .body .row")) }) $.getJSON("/api/kube/contexts").fail(function (xhr) { sendStats('contexts', {'status': 'fail'}); reportError("Failed to get list of clusters", xhr) }).done(function (data) { $("body").data("contexts", data) const context = getHashParam("context") data.sort((a, b) => (getCleanClusterName(a.Name) > getCleanClusterName(b.Name)) - (getCleanClusterName(a.Name) < getCleanClusterName(b.Name))) fillClusterList(data, context); sendStats('contexts', {'status': 'success', length: data.length}); $.getJSON("/api/kube/namespaces").fail(function (xhr) { reportError("Failed to get namespaces", xhr) }).done(function (res) { const ns = res.items.map(i => i.metadata.name) $.each(ns, function (i, item) { $("#upgradeModal #ns-datalist").append($("