Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 3 migration #109

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clear previous fetches on reload
  • Loading branch information
amimof committed Jun 12, 2024
commit 2a06c779fcea62822bb7ea9c22b6887c134b2533
10 changes: 5 additions & 5 deletions web2/src/components/Namespaces.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
import { useNamespacesStore } from '@/stores/namespace';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import Loader from './Loader.vue'
Expand All @@ -10,13 +10,11 @@ import RecentNamespacesList from './RecentNamespacesList.vue'

const store = useNamespacesStore()
const router = useRouter();
const route = useRoute();

const keyesc = 27;
const keyup = 38;
const keydown = 40;
const keyenter = 13;
const keysearch = 55;
const keychars = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 109]

const isLoading = ref(true)
Expand All @@ -28,7 +26,7 @@ const searchfield = ref(null);

onMounted(() => {
store.getNamespaces()
window.addEventListener("keydown", handlePress, false);
window.addEventListener("keydown", handlePress);
})

onBeforeUnmount(() => {
Expand All @@ -40,7 +38,9 @@ function handlePress(e) {
// Fuzzy find namespaces using regular a-z keys
if (keychars.indexOf(e.keyCode) > -1) {
activeNamespace.value = 0;
searchfield.value.focus();
if (searchfield.value != null) {
searchfield.value.focus();
}
return;
}

Expand Down
12 changes: 0 additions & 12 deletions web2/src/stores/counter.js

This file was deleted.

27 changes: 15 additions & 12 deletions web2/src/stores/pod.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const usePodStore = defineStore("pod", () => {
const lineStart = ref(0);
const maxLogLines = ref(1000);
const podError = ref(null);
const podLoading = ref(true);
const logsLoading = ref(true);
const isPodLoading = ref(true);
const isLogsLoading = ref(true);

const getPodCount = computed((n) => {
if (pods.value.has(n)) {
Expand All @@ -41,6 +41,8 @@ export const usePodStore = defineStore("pod", () => {
}

async function getPods(n) {
pods.value = [];
filteredPods.value = [];
try {
const response = await PodService.getPods(n);
if (!response.ok) {
Expand All @@ -62,35 +64,36 @@ export const usePodStore = defineStore("pod", () => {
}

async function getPod(n, p) {
pod.value = {};
try {
podLoading.value = true;
isPodLoading.value = true;
const response = await PodService.getPod(n, p);
if (!response.ok) {
podError.value = new Error(
`unable to get pod with status ${response.status}`
);
podLoading.value = false;
isPodLoading.value = false;
return;
}
const data = await response.json();
pod.value = data;
podLoading.value = false;
isPodLoading.value = false;
} catch (error) {
console.log("Error", error);
podLoading.value = false;
isPodLoading.value = false;
podError.value = error;
}
}

async function getLog(n, p, c) {
try {
logsLoading.value = true;
isLogsLoading.value = true;
const response = await PodService.getPodLog(n, p, c);
if (!response.ok) {
podError.value = new Error(
`unable to fetch logs with status ${response.status}`
);
logsLoading.value = false;
isLogsLoading.value = false;
return;
}
const data = await response.text();
Expand All @@ -99,10 +102,10 @@ export const usePodStore = defineStore("pod", () => {
lines.splice(lines.length - 1, 1);
}
logs.value = lines;
logsLoading.value = false;
isLogsLoading.value = false;
} catch (error) {
podError.value = error;
logsLoading.value = false;
isLogsLoading.value = false;
}
}
async function streamLogs(n, p, c) {
Expand Down Expand Up @@ -141,8 +144,8 @@ export const usePodStore = defineStore("pod", () => {
getLog,
streamLogs,
podError,
podLoading,
logsLoading,
isPodLoading,
isLogsLoading,
closeStream,
};
});