mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 21:33:18 +01:00
feat: changes the host when a new container is chosen (#3001)
This commit is contained in:
@@ -90,6 +90,7 @@ import Pin from "~icons/ph/map-pin-simple";
|
|||||||
import Stack from "~icons/ph/stack";
|
import Stack from "~icons/ph/stack";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import Containers from "~icons/octicon/container-24";
|
import Containers from "~icons/octicon/container-24";
|
||||||
|
import { RouteLocationNormalizedLoaded } from "vue-router";
|
||||||
|
|
||||||
const containerStore = useContainerStore();
|
const containerStore = useContainerStore();
|
||||||
const { visibleContainers } = storeToRefs(containerStore);
|
const { visibleContainers } = storeToRefs(containerStore);
|
||||||
@@ -166,6 +167,21 @@ const menuItems = computed(() => {
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const updateHostForContainerRoute = (to: RouteLocationNormalizedLoaded) => {
|
||||||
|
if (to.name === "container-id") {
|
||||||
|
const container = containerStore.findContainerById(to.params.id as string);
|
||||||
|
if (container) {
|
||||||
|
setHost(container.host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateHostForContainerRoute(route);
|
||||||
|
|
||||||
|
onBeforeRouteUpdate((to) => updateHostForContainerRoute(to));
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="postcss">
|
<style scoped lang="postcss">
|
||||||
.menu {
|
.menu {
|
||||||
|
|||||||
@@ -152,11 +152,14 @@ export const useContainerStore = defineStore("container", () => {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const findContainerById = (id: string) => allContainersById.value[id];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
containers,
|
containers,
|
||||||
allContainersById,
|
allContainersById,
|
||||||
visibleContainers,
|
visibleContainers,
|
||||||
currentContainer,
|
currentContainer,
|
||||||
|
findContainerById,
|
||||||
containerNames,
|
containerNames,
|
||||||
ready,
|
ready,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user