Skip to content

Commit

Permalink
maybe a working page
Browse files Browse the repository at this point in the history
  • Loading branch information
slackspace-io committed Mar 9, 2024
1 parent 1a4f067 commit 089efad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions frontend/src/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const BE_BASE_URL = "http://slackwatch-be-svc.slackwatch.svc.cluster.local/";
//export const BE_BASE_URL = "http://localhost:8080/";
31 changes: 27 additions & 4 deletions frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
<script lang="ts">
export let podsInfo: Array<{ name: string; timeScanned: string }> = [];
export let podsInfo: Array<{ name: string; timeScanned: string }> = [];
export let data;
console.log(podsInfo);
console.log(data);
</script>

<main>
<h1>Pods Information</h1>
{#each podsInfo as { name, timeScanned }}
{#each data.podsInfo as { name, timeScanned }}
<div>
<p>Image Name: {name}</p>
<p>Time Scanned: {timeScanned}</p>
<article class="pod-info">
<h2>{name}</h2>
<time datetime="{timeScanned}">{timeScanned}</time>
</article>
<style>
.pod-info {
background-color: #f0f0f0;
border-radius: 8px;
padding: 20px;
margin-bottom: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.pod-info h2 {
color: #333;
font-size: 1.2rem;
}
.pod-info time {
font-size: 0.9rem;
color: #666;
}
</style>
</div>
{/each}
</main>
12 changes: 5 additions & 7 deletions frontend/src/routes/+page.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { BE_BASE_URL } from "../config";

console.log('before');
export async function load({
fetch
}: {
fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
}) {
console.log('inside');
const response = await fetch('http://localhost:8080/api/pods');
const text = await response.text(); // Get the raw response text
console.log('Raw response:', text);
const podsInfo = await response.json(); // Parse the response as JSON
console.log(podsInfo);
return { props: { podsInfo } }; // Return podsInfo for Svelte to use
const response = await fetch(`${BE_BASE_URL}api/pods`);
const podsInfo = await response.json(); // Parse the response as JSON
return { podsInfo };
}

0 comments on commit 089efad

Please sign in to comment.