-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: global settings, color changing background, argocd integration
- Loading branch information
Showing
42 changed files
with
493 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ class Apps(Enum): | |
SONARR = "sonarr" | ||
QBITTORRENT = "qbittorrent" | ||
KUMA = "kuma" | ||
ARGOCD = "argocd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .integration import get_argocd_data | ||
|
||
__all__ = ["get_argocd_data"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import requests | ||
from typing import Any | ||
|
||
from api.backend.integrations.integration import INTEGRATIONS | ||
|
||
argocd_integration = next( | ||
(integration for integration in INTEGRATIONS if integration.name == "argocd"), | ||
None, | ||
) | ||
|
||
|
||
def get_auth_token() -> str: | ||
assert argocd_integration is not None | ||
|
||
payload = { | ||
"username": argocd_integration.config["username"], | ||
"password": argocd_integration.config["password"], | ||
} | ||
|
||
response = requests.post( | ||
f"{argocd_integration.config['url']}/api/v1/session", json=payload | ||
) | ||
|
||
return response.json()["token"] | ||
|
||
|
||
def get_applications() -> list[dict[str, Any]]: | ||
assert argocd_integration is not None | ||
|
||
response = requests.get( | ||
f"{argocd_integration.config['url']}/api/v1/applications", | ||
headers={"Authorization": f"Bearer {get_auth_token()}"}, | ||
) | ||
|
||
return response.json()["items"] | ||
|
||
|
||
def format_application_data(application: dict[str, Any]) -> dict[str, Any]: | ||
metadata = application["metadata"] | ||
status = application["status"] | ||
|
||
return { | ||
"name": metadata["name"], | ||
"status": status["sync"]["status"], | ||
} | ||
|
||
|
||
def get_argocd_data() -> list[dict[str, Any]]: | ||
applications = get_applications() | ||
|
||
return [format_application_data(application) for application in applications] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/components/dashboard/controls/settings/settings-control/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./settings-control"; |
23 changes: 23 additions & 0 deletions
23
src/components/dashboard/controls/settings/settings-control/settings-control.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IconButton } from "@mui/material"; | ||
import SettingsIcon from "@mui/icons-material/Settings"; | ||
import React, { useState } from "react"; | ||
import { SettingsMenu } from "../settings-menu"; | ||
|
||
export type SettingsControlProps = { | ||
className?: string; | ||
}; | ||
|
||
export const SettingsControl = ({ className }: SettingsControlProps) => { | ||
const [open, setOpen] = useState<boolean>(false); | ||
|
||
return ( | ||
<div className={className}> | ||
<label htmlFor="settings-menu"> | ||
<IconButton component="span" onClick={() => setOpen(true)}> | ||
<SettingsIcon /> | ||
</IconButton> | ||
</label> | ||
<SettingsMenu open={open} onClose={() => setOpen(false)} /> | ||
</div> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
src/components/dashboard/controls/settings/settings-menu/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./settings-menu"; |
Empty file.
41 changes: 41 additions & 0 deletions
41
src/components/dashboard/controls/settings/settings-menu/settings-menu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Dialog, DialogTitle, DialogContent } from "@mui/material"; | ||
import React, { useState } from "react"; | ||
import { ColorResult, SketchPicker } from "react-color"; | ||
import { useGetSettings } from "@/lib/hooks/useGetSettings"; | ||
import { setSettings } from "@/lib/slices/settings"; | ||
import { useDispatch } from "react-redux"; | ||
import { Divider } from "@mui/material"; | ||
|
||
export type SettingsMenuProps = { | ||
open: boolean; | ||
onClose: () => void; | ||
}; | ||
|
||
export const SettingsMenu = ({ open, onClose }: SettingsMenuProps) => { | ||
const settings = useGetSettings(); | ||
const dispatch = useDispatch(); | ||
const [color, setColor] = useState({ hex: settings.cardColor }); | ||
|
||
const handleChange = (color: ColorResult) => { | ||
setColor(color); | ||
dispatch(setSettings({ cardColor: `${color.hex}85` })); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} onClose={onClose}> | ||
<DialogTitle className="text-2xl font-bold">Settings</DialogTitle> | ||
<DialogContent> | ||
<div className="flex flex-col gap-2"> | ||
<span className="text-sm font-medium">Card Colors</span> | ||
<Divider /> | ||
<SketchPicker | ||
className="w-[20rem]" | ||
color={color.hex} | ||
onChange={handleChange} | ||
onChangeComplete={handleChange} | ||
/> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; |
34 changes: 34 additions & 0 deletions
34
.../dashboard/widgets/external-integrations/argocd-integration/argocd-integration.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.applications { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
} | ||
|
||
.application { | ||
background-color: var(--integration-bg-color); | ||
padding: 0.125rem; | ||
border-radius: 0.125rem; | ||
|
||
width: 100%; | ||
text-align: center; | ||
|
||
display: flex; | ||
gap: 0.25rem; | ||
|
||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.applicationStatus { | ||
font-family: monospace; | ||
padding: 0.125rem; | ||
border-radius: 0.125rem; | ||
} | ||
|
||
.synced { | ||
background-color: var(--synced); | ||
} | ||
|
||
.outOfSync { | ||
background-color: var(--outOfSync); | ||
} |
Oops, something went wrong.