Skip to content

Commit 022cac5

Browse files
committed
feat(ui): add live health to home page
chore(ui): increase byte screen logo size
1 parent 21efa33 commit 022cac5

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

src/server/domain/guilds/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""Guild list URL."""
1515

1616
# -- Specific
17-
GUILD_UPDATE: Final = f"{OPENAPI_SCHEMA}/guilds/{{guild_id}}/update"
17+
GUILD_UPDATE: Final = f"{OPENAPI_SCHEMA}/guilds/{{guild_id:int}}/update"
1818
"""Update guild URL."""
19-
GUILD_DETAIL: Final = f"{OPENAPI_SCHEMA}/guilds/{{guild_id}}/info"
19+
GUILD_DETAIL: Final = f"{OPENAPI_SCHEMA}/guilds/{{guild_id:int}}/info"
2020
"""Guild detail URL."""

src/server/domain/web/controllers/web.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
"""Web Controller."""
22
from __future__ import annotations
33

4+
from typing import TYPE_CHECKING
5+
46
from litestar import Controller, get
57
from litestar.response import Template
68
from litestar.status_codes import HTTP_200_OK
79

810
from server.domain import urls
11+
from server.domain.guilds.helpers import get_byte_server_count
12+
from server.domain.system.helpers import check_byte_status, check_database_status
913

10-
__all__ = ["WebController"]
14+
if TYPE_CHECKING:
15+
from sqlalchemy.ext.asyncio import AsyncSession
1116

12-
from server.domain.guilds.helpers import get_byte_server_count
17+
__all__ = ("WebController",)
1318

1419

1520
class WebController(Controller):
@@ -25,10 +30,23 @@ class WebController(Controller):
2530
include_in_schema=False,
2631
opt={"exclude_from_auth": True},
2732
)
28-
async def index(self) -> Template:
33+
async def index(self, db_session: AsyncSession) -> Template:
2934
"""Serve site root."""
3035
server_count = await get_byte_server_count()
31-
return Template(template_name="index.html", context={"server_count": server_count})
36+
byte_status = await check_byte_status()
37+
database_status = await check_database_status(db_session)
38+
statuses = [database_status, byte_status]
39+
40+
if all(status == "offline" for status in statuses):
41+
overall_status = "offline"
42+
elif "offline" in statuses or "degraded" in statuses:
43+
overall_status = "degraded"
44+
else:
45+
overall_status = "healthy"
46+
47+
return Template(
48+
template_name="index.html", context={"server_count": server_count, "overall_status": overall_status}
49+
)
3250

3351
# add dashboard
3452
@get(

src/server/domain/web/resources/style.css

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
! tailwindcss v3.3.6 | MIT License | https://tailwindcss.com
2+
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
33
*/
44

55
/*
@@ -32,9 +32,11 @@
3232
4. Use the user's configured `sans` font-family by default.
3333
5. Use the user's configured `sans` font-feature-settings by default.
3434
6. Use the user's configured `sans` font-variation-settings by default.
35+
7. Disable tap highlights on iOS
3536
*/
3637

37-
html {
38+
html,
39+
:host {
3840
line-height: 1.5;
3941
/* 1 */
4042
-webkit-text-size-adjust: 100%;
@@ -44,26 +46,15 @@ html {
4446
-o-tab-size: 4;
4547
tab-size: 4;
4648
/* 3 */
47-
font-family:
48-
ui-sans-serif,
49-
system-ui,
50-
-apple-system,
51-
BlinkMacSystemFont,
52-
"Segoe UI",
53-
Roboto,
54-
"Helvetica Neue",
55-
Arial,
56-
"Noto Sans",
57-
sans-serif,
58-
"Apple Color Emoji",
59-
"Segoe UI Emoji",
60-
"Segoe UI Symbol",
49+
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
6150
"Noto Color Emoji";
6251
/* 4 */
6352
font-feature-settings: normal;
6453
/* 5 */
6554
font-variation-settings: normal;
6655
/* 6 */
56+
-webkit-tap-highlight-color: transparent;
57+
/* 7 */
6758
}
6859

6960
/*
@@ -3342,11 +3333,6 @@ html {
33423333
padding-bottom: 6rem;
33433334
}
33443335

3345-
.py-36 {
3346-
padding-top: 9rem;
3347-
padding-bottom: 9rem;
3348-
}
3349-
33503336
.py-4 {
33513337
padding-top: 1rem;
33523338
padding-bottom: 1rem;
@@ -3382,6 +3368,10 @@ html {
33823368
padding-left: 2.25rem;
33833369
}
33843370

3371+
.pt-12 {
3372+
padding-top: 3rem;
3373+
}
3374+
33853375
.text-center {
33863376
text-align: center;
33873377
}

src/server/domain/web/templates/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,15 @@ <h2 class="text-base font-semibold leading-7 text-base-content dark:text-base-10
9797
url(&quot;static/splash-bg.png&quot;);
9898
background-position: top center;
9999
">
100-
<div class="flex flex-col justify-between items-center h-full px-5 pb-5 py-36">
100+
<div class="flex flex-col justify-between items-center h-full px-5 pb-5 py-24 pt-12">
101101
<div class="flex flex-col justify-center items-center">
102-
<img class="h-12 w-auto align-middle" src="static/logo.svg" alt="Byte Logo" />
102+
<img class="h-24 w-auto align-middle" src="static/logo.svg" alt="Byte Logo" />
103103
<p class="text-center">
104104
Byte:
105105
<span class="{{ 'text-success' if byte_status == 'online' else 'text-warning' }}">
106-
<b>{{ byte_status | default('Unknown') }}</b>
106+
<b>{{ overall_status | default('Unknown') | upper }}</b>
107107
</span>
108-
.
109108
</p>
110-
<!-- TODO: Make this dynamic with a /health healthckeck! -->
111109
<p class="text-center py-5">
112110
Currently in
113111
<br />

0 commit comments

Comments
 (0)