Skip to content

Commit 8cfe88b

Browse files
authored
Merge pull request #3 from codersforcauses/issue-1-Add_healthcheck_page_to_replace_defailt_Vue_page_huxley_modifications
Issue 1 add healthcheck page to replace defailt vue page huxley modifications
2 parents 4cea892 + 307dbaa commit 8cfe88b

File tree

10 files changed

+167
-113
lines changed

10 files changed

+167
-113
lines changed

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"tasks": [
44
{
55
"type": "npm",
6-
"script": "lint:fix",
6+
"script": "lint",
77
"path": "client",
88
"group": "none",
99
"problemMatcher": ["$eslint-stylish"],
10-
"label": "npm run lint:fix - client",
10+
"label": "npm run lint - client",
1111
"detail": "eslint --fix"
1212
},
1313
{

client/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
APP_ENV=DEVELOPMENT
2+
VITE_BACKEND_URL="http://localhost:8000/api"

client/package-lock.json

Lines changed: 103 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite --port 3000",
8-
"build": "run-p type-check \"build-only {@}\" --",
8+
"build": "run-p typecheck \"build-only {@}\" --",
99
"preview": "vite preview",
1010
"build-only": "vite build",
1111
"typecheck": "vue-tsc --build --force",
12-
"lint:fix": "eslint --fix",
12+
"lint": "eslint --fix",
1313
"lint:strict": "eslint",
1414
"format": "prettier --write src/",
1515
"format:check": "prettier --check src/"
1616
},
1717
"dependencies": {
18+
"axios": "^1.7.7",
1819
"pinia": "^2.2.6",
1920
"vue": "^3.5.12",
2021
"vue-router": "^4.4.5"

client/src/App.vue

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,9 @@
11
<script setup lang="ts">
2-
import { RouterLink, RouterView } from 'vue-router'
3-
import HelloWorld from './components/HelloWorld.vue'
2+
import { RouterView } from 'vue-router'
43
</script>
54

65
<template>
7-
<header>
8-
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
9-
10-
<div class="wrapper">
11-
<HelloWorld msg="You did it!" />
12-
13-
<nav>
14-
<RouterLink to="/">Home</RouterLink>
15-
<RouterLink to="/about">About</RouterLink>
16-
</nav>
17-
</div>
18-
</header>
19-
206
<RouterView />
217
</template>
228

23-
<style scoped>
24-
header {
25-
line-height: 1.5;
26-
max-height: 100vh;
27-
}
28-
29-
.logo {
30-
display: block;
31-
margin: 0 auto 2rem;
32-
}
33-
34-
nav {
35-
width: 100%;
36-
font-size: 12px;
37-
text-align: center;
38-
margin-top: 2rem;
39-
}
40-
41-
nav a.router-link-exact-active {
42-
color: var(--color-text);
43-
}
44-
45-
nav a.router-link-exact-active:hover {
46-
background-color: transparent;
47-
}
48-
49-
nav a {
50-
display: inline-block;
51-
padding: 0 1rem;
52-
border-left: 1px solid var(--color-border);
53-
}
54-
55-
nav a:first-of-type {
56-
border: 0;
57-
}
58-
59-
@media (min-width: 1024px) {
60-
header {
61-
display: flex;
62-
place-items: center;
63-
padding-right: calc(var(--section-gap) / 2);
64-
}
65-
66-
.logo {
67-
margin: 0 2rem 0 0;
68-
}
69-
70-
header .wrapper {
71-
display: flex;
72-
place-items: flex-start;
73-
flex-wrap: wrap;
74-
}
75-
76-
nav {
77-
text-align: left;
78-
margin-left: -1rem;
79-
font-size: 1rem;
80-
81-
padding: 1rem 0;
82-
margin-top: 1rem;
83-
}
84-
}
85-
</style>
9+
<style></style>

client/src/assets/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ a,
2929

3030
#app {
3131
display: grid;
32-
grid-template-columns: 1fr 1fr;
32+
/* grid-template-columns: 1fr 1fr; */
3333
padding: 0 2rem;
3434
}
3535
}

client/src/router/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ const router = createRouter({
99
name: 'home',
1010
component: HomeView,
1111
},
12-
{
13-
path: '/about',
14-
name: 'about',
15-
// route level code-splitting
16-
// this generates a separate chunk (About.[hash].js) for this route
17-
// which is lazy-loaded when the route is visited.
18-
component: () => import('../views/AboutView.vue'),
19-
},
2012
],
2113
})
2214

client/src/utils/server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import axios from 'axios'
2+
3+
const server = axios.create({ baseURL: import.meta.env.VITE_BACKEND_URL, timeout: 8000 })
4+
export default server

client/src/views/AboutView.vue

Lines changed: 0 additions & 15 deletions
This file was deleted.

client/src/views/HomeView.vue

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,55 @@
11
<script setup lang="ts">
2-
import TheWelcome from '../components/TheWelcome.vue'
2+
import { ref } from 'vue'
3+
import server from '@/utils/server'
4+
5+
const isLoading = ref(false)
6+
const healthcheckMessage = ref('')
7+
8+
const handlePing = async () => {
9+
isLoading.value = true
10+
healthcheckMessage.value = '' // Clear previous messages
11+
12+
try {
13+
const response = await server.get('/healthcheck/ping/')
14+
healthcheckMessage.value = response.data
15+
} catch {
16+
healthcheckMessage.value = 'Failed to ping server'
17+
} finally {
18+
isLoading.value = false
19+
}
20+
}
321
</script>
422

523
<template>
6-
<main>
7-
<TheWelcome />
8-
</main>
24+
<div id="healthcheck">
25+
<h1>Healthcheck</h1>
26+
<button id="ping" @click="handlePing" :disabled="isLoading">
27+
{{ isLoading ? 'Loading' : 'Ping' }}
28+
</button>
29+
<p>
30+
Response from server: <span>{{ healthcheckMessage }}</span>
31+
</p>
32+
</div>
933
</template>
34+
35+
<style scoped>
36+
#healthcheck {
37+
display: flex;
38+
flex-direction: column;
39+
place-items: center;
40+
height: 80vh;
41+
}
42+
43+
#ping {
44+
background-color: var(--color-text);
45+
color: var(--color-background);
46+
border: none;
47+
border-radius: 2px;
48+
padding: 8px 16px;
49+
margin: 8px;
50+
}
51+
52+
#ping:hover {
53+
filter: brightness(80%);
54+
}
55+
</style>

0 commit comments

Comments
 (0)