@@ -282,8 +282,6 @@
-
diff --git a/pkg/dashboard/static/list-view.js b/pkg/dashboard/static/list-view.js
index 9e88121..41af7dc 100644
--- a/pkg/dashboard/static/list-view.js
+++ b/pkg/dashboard/static/list-view.js
@@ -33,7 +33,7 @@ function buildChartCard(elm) {
statusStyle(elm.status, card, card.find(".rel-status span"))
- card.find("a").attr("href", '#namespace=' + elm.namespace + '&name=' + elm.name)
+ card.find("a").attr("href", '#context=' + getHashParam('context') + '&namespace=' + elm.namespace + '&name=' + elm.name)
card.find(".rel-name span").data("chart", elm).click(function () {
const self = $(this)
diff --git a/pkg/dashboard/static/scripts.js b/pkg/dashboard/static/scripts.js
index b6b5d9a..9d4dc52 100644
--- a/pkg/dashboard/static/scripts.js
+++ b/pkg/dashboard/static/scripts.js
@@ -1,14 +1,14 @@
$(function () {
const clusterSelect = $("#cluster");
clusterSelect.change(function () {
- Cookies.set("context", clusterSelect.find("input:radio:checked").val())
- window.location.href = "/"
+ 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) {
- const context = Cookies.get("context")
+ const context = getHashParam("context")
fillClusterList(data, context);
const namespace = getHashParam("namespace")
@@ -31,7 +31,6 @@ function reportError(err, xhr) {
}
-
function getHashParam(name) {
const params = new URLSearchParams(window.location.hash.substring(1))
return params.get(name)
@@ -75,18 +74,24 @@ function fillClusterList(data, context) {
opt.find("span").text(label)
if (elm.IsCurrent && !context) {
opt.find("input").prop("checked", true)
+ setCurrentContext(elm.Name)
} else if (context && elm.Name === context) {
opt.find("input").prop("checked", true)
- $.ajaxSetup({
- headers: {
- 'x-kubecontext': context
- }
- });
+ setCurrentContext(elm.Name)
}
$("#cluster").append(opt)
})
}
+function setCurrentContext(ctx) {
+ setHashParam("context", ctx)
+ $.ajaxSetup({
+ headers: {
+ 'x-kubecontext': context
+ }
+ });
+}
+
function getAge(obj1, obj2) {
const date = luxon.DateTime.fromISO(obj1.updated);
let dateNext = luxon.DateTime.now()