Skip to content

Commit

Permalink
fix: revision history, click opens new tab, card backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypyles committed Dec 22, 2024
1 parent 2b19c9b commit 241fe0c
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 28 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ host:
port: 22
username: user
password: password
storage:
- /path/to/storage/to/monitor

commands:
- name: "view app logs"
Expand Down
6 changes: 3 additions & 3 deletions api/backend/configs/schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional
from pydantic import BaseModel


Expand All @@ -8,17 +7,18 @@ class Host(BaseModel):
port: int
username: str
password: str
storage: list[str] | None = None


class Arg(BaseModel):
flag: str
value: Optional[str] = None
value: str | None = None


class Command(BaseModel):
name: str
command: str
args: Optional[list[Arg]] = None
args: list[Arg] | None = None


class Schema(BaseModel):
Expand Down
4 changes: 3 additions & 1 deletion api/backend/routers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ async def get_background():


@config_router.post("/api/config/background")
async def upload_background(file: UploadFile = File(...)):
async def upload_background(
file: UploadFile = File(...),
):
try:
LOG.info(f"Form: {file}")
config_utils.upload_background(file)
Expand Down
4 changes: 2 additions & 2 deletions api/backend/routers/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

# LOCAL
from api.backend.host_manager import HOST_MAP
from api.backend.database.database_functions import delete_job

from api.backend.command_queue import COMMAND_QUEUE

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -43,6 +41,7 @@ async def delete_single_job(id: str):
@host_router.get("/api/{host_name}/stats")
async def get_stats(host_name: str):
host = HOST_MAP[host_name]

try:
storage = "".join(host.runner.dispatch("storage")[0])
usage = "".join(host.runner.dispatch("cpu_usage")[0])
Expand All @@ -54,6 +53,7 @@ async def get_stats(host_name: str):
return JSONResponse(
{
"storage": storage,
"storage_paths": host.storage,
"usage": usage,
"cores": cores,
"threads": threads,
Expand Down
9 changes: 5 additions & 4 deletions api/backend/systems/commands/storage_total.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from api.backend.systems.command import Command
from api.backend.systems.arg import Arg
from typing import Literal


class StorageMetric(Command):
def __init__(self) -> None:
self.name = "storage"
self.command = "df"
self.args = [Arg(flag="-h", value=None)]
self.name: str = "storage"
self.command: str = "df"
self.args: list[Arg] | None = [Arg(flag="-h", value=None)]
super().__init__(self.name, self.command, self.args)
self.type = "system"
self.type: Literal["system", "docker", "user"] = "system"
1 change: 1 addition & 0 deletions api/backend/systems/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, config_file: str) -> None:
self.hostname: str = config.host.hostname
self.runner: MachineRunner = MachineRunner()
self.runner.read_config(config_file)
self.storage: list[str] | None = config.host.storage

def refresh(self):
LOG.info(f"Refreshing host {self.name}")
Expand Down
2 changes: 1 addition & 1 deletion charts/dashboard/templates/dashboard-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ .Values.app.metadata.name }}
spec:
replicas: {{ .Values.app.replicas }}
revisionHistoryLimit: 1
selector:
matchLabels:
app: {{ .Values.app.metadata.name }}
Expand All @@ -17,7 +18,6 @@ spec:
image: {{ .Values.app.frontendImage }}:{{ .Values.app.APP_VERSION }}
command: ["bash", "/start.sh"]
imagePullPolicy: Always
revisionHistoryLimit: 1
volumeMounts:
- mountPath: /project/configs
subPath: {{ .Values.app.metadata.name }}/configs
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ reportAny = false
reportUnknownVariableType = false
reportUnknownMemberType = false
reportExplicitAny = false
reportCallInDefaultInitializer = false

pythonVersion = "3.10"
pythonPlatform = "Linux"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import Integration from "../../../../shared/integration/integration";
import { SonarrData } from "../../../../../lib/services/external-integrations/sonarr/sonarr.types";
import Integration from "@/components/shared/integration/integration";
import { SonarrData } from "@/lib/services/external-integrations/sonarr/sonarr.types";

type SonarrIntegrationProps = {
data: SonarrData;
Expand Down
5 changes: 1 addition & 4 deletions src/components/shared/integration/integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import { Paper, Typography } from "@mui/material";
import classes from "./integration.module.css";
import Image from "next/image";
import { useRouter } from "next/navigation";
import { clsx } from "clsx";

type IntegrationProps = {
Expand All @@ -20,11 +19,9 @@ const Integration = ({
link,
children,
}: IntegrationProps) => {
const router = useRouter();

const handleNavigate = () => {
if (link) {
router.push(link);
window.open(link, "_blank");
}
};

Expand Down
11 changes: 1 addition & 10 deletions src/pages/api/[host_name]/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,10 @@ export default async function handler(
) {
try {
const { host_name } = req.query;
const data = { paths: ["/home", "/", "/mnt/nas"] };

if (!data?.paths || data.paths.length === 0) {
return res
.status(400)
.json({ message: "No paths provided in the request body" });
}

const paths = data.paths;

const response = await api.get<ResponseData>(`/${host_name}/stats`);
const json = await response.data;

const paths = json.storage_paths || [];
const uptimeRegex = new RegExp(`(\\d+\\s+days,\\s+(?:\\d+:\\d+|\\d+))`);

if (json.uptime) {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
--kuma-status-down: rgba(254, 2, 2, 0.497);
--kuma-status-up-circle: rgba(14, 46, 6, 0.497);
--kuma-status-up-down: rgba(46, 6, 6, 0.497);
--paper-opaque-bg: rgba(33, 29, 29, 0.75);
--paper-opaque-bg: rgba(8, 8, 8, 0.75);
--paper-opaque-dark: rgba(0, 0, 0, 0.5);
--paper-hover-color: rgba(61, 61, 61);
--failed: rgba(254, 2, 2, 0.25);
Expand Down

0 comments on commit 241fe0c

Please sign in to comment.