Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 9c018ba

Browse files
authored
refactor(ui): Replace base64 assets by image (#47)
* refactor: Replace base64 assets by images --------- Signed-off-by: hayk96 <[email protected]>
1 parent c6b4ea3 commit 9c018ba

File tree

29 files changed

+1160
-1138
lines changed

29 files changed

+1160
-1138
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.4.2 / 2024-07-05
4+
5+
* [CHANGE] Replaced base64 encoded files in web assets (HTML, CSS) with common images and added a new route for images.
6+
37
## 0.4.1 / 2024-06-30
48

59
* [ENHANCEMENT] Added a new web page for reports. This page allows exporting Prometheus data in various formats directly from the web UI. #43

src/api/v1/endpoints/web.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@
44
from src.utils.log import logger
55
from fastapi import APIRouter
66
from fastapi import Request
7+
from os.path import exists
78

89
router = APIRouter()
910

1011
if arg_parser().get("web.enable_ui") == "true":
11-
rules_management = "ui/rules-management"
12-
metrics_management = "ui/metrics-management"
13-
reports = "ui/reports"
12+
rules_management = "ui/pages/rules-management"
13+
metrics_management = "ui/pages/metrics-management"
14+
reports = "ui/pages/reports"
1415
logger.info("Starting web management UI")
1516

1617
@router.get("/", response_class=HTMLResponse,
1718
description="Renders home page of this application",
1819
include_in_schema=False)
1920
async def homepage():
20-
return FileResponse("ui/homepage/index.html")
21+
return FileResponse("ui/pages/homepage/index.html")
22+
23+
@router.get(
24+
"/images/{path}",
25+
description="Returns common image resources for web UI",
26+
include_in_schema=False)
27+
async def images(path, request: Request):
28+
assets_images = "ui/assets/images"
29+
if exists(f"{assets_images}/{path}"):
30+
return FileResponse(f"{assets_images}/{path}")
31+
sts, msg = "404", "Not Found"
32+
logger.info(
33+
msg=msg,
34+
extra={
35+
"status": sts,
36+
"method": request.method,
37+
"request_path": request.url.path})
38+
return f"{sts} {msg}"
2139

2240
@router.get("/rules-management",
2341
description="Renders rules management HTML page of this application",

src/utils/openapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def openapi(app: FastAPI):
1616
"providing additional features and addressing its limitations. "
1717
"Running as a sidecar alongside the Prometheus server enables "
1818
"users to extend the capabilities of the API.",
19-
version="0.4.1",
19+
version="0.4.2",
2020
contact={
2121
"name": "Hayk Davtyan",
2222
"url": "https://hayk96.github.io",

ui/assets/images/icon-edit.png

4.08 KB
Loading

ui/assets/images/icon-home.png

5.17 KB
Loading
6.22 KB
Loading

ui/assets/images/icon-moon.png

7.75 KB
Loading

ui/assets/images/icon-remove.png

5.64 KB
Loading

ui/assets/images/icon-reports.png

14.6 KB
Loading
6.55 KB
Loading

0 commit comments

Comments
 (0)