$(function () { const clusterSelect = $("#cluster"); clusterSelect.change(function () { window.location.href = "/#context=" + clusterSelect.find("input:radio:checked").val() window.location.reload() }) $.getJSON("/api/kube/contexts").fail(function (xhr) { 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); initView(); // can only do it after loading cluster list $.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($("