mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-28 03:26:32 +00:00
logo as well
This commit is contained in:
parent
0073660bdf
commit
20a6c53c2d
@ -553,6 +553,11 @@ class AddonModel(CoreSysAttributes, ABC):
|
|||||||
"""Return path to add-on logo."""
|
"""Return path to add-on logo."""
|
||||||
return Path(self.path_location, "logo.png")
|
return Path(self.path_location, "logo.png")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_dark_logo(self) -> Path:
|
||||||
|
"""Return path to the dark variant of the add-on logo."""
|
||||||
|
return Path(self.path_location, "dark_logo.png")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_changelog(self) -> Path:
|
def path_changelog(self) -> Path:
|
||||||
"""Return path to add-on changelog."""
|
"""Return path to add-on changelog."""
|
||||||
|
@ -69,7 +69,7 @@ from ..const import (
|
|||||||
ATTR_NETWORK_RX,
|
ATTR_NETWORK_RX,
|
||||||
ATTR_NETWORK_TX,
|
ATTR_NETWORK_TX,
|
||||||
ATTR_OPTIONS,
|
ATTR_OPTIONS,
|
||||||
ATTR_PREFER_DARK_ICON,
|
ATTR_PREFER_DARK,
|
||||||
ATTR_PRIVILEGED,
|
ATTR_PRIVILEGED,
|
||||||
ATTR_PROTECTED,
|
ATTR_PROTECTED,
|
||||||
ATTR_PWNED,
|
ATTR_PWNED,
|
||||||
@ -114,9 +114,9 @@ _LOGGER: logging.Logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
SCHEMA_VERSION = vol.Schema({vol.Optional(ATTR_VERSION): str})
|
SCHEMA_VERSION = vol.Schema({vol.Optional(ATTR_VERSION): str})
|
||||||
|
|
||||||
SCHEMA_ICON = vol.Schema(
|
SCHEMA_DARK = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_PREFER_DARK_ICON, default=False): bool,
|
vol.Optional(ATTR_PREFER_DARK, default=False): bool,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -470,8 +470,8 @@ class APIAddons(CoreSysAttributes):
|
|||||||
if not addon.with_icon:
|
if not addon.with_icon:
|
||||||
raise APIError(f"No icon found for add-on {addon.slug}!")
|
raise APIError(f"No icon found for add-on {addon.slug}!")
|
||||||
|
|
||||||
body = await api_validate(SCHEMA_ICON, request)
|
body = await api_validate(SCHEMA_DARK, request)
|
||||||
if body[ATTR_PREFER_DARK_ICON] and addon.path_dark_icon.exists():
|
if body[ATTR_PREFER_DARK] and addon.path_dark_icon.exists():
|
||||||
with addon.path_dark_icon.open("rb") as png:
|
with addon.path_dark_icon.open("rb") as png:
|
||||||
return png.read()
|
return png.read()
|
||||||
|
|
||||||
@ -485,6 +485,11 @@ class APIAddons(CoreSysAttributes):
|
|||||||
if not addon.with_logo:
|
if not addon.with_logo:
|
||||||
raise APIError(f"No logo found for add-on {addon.slug}!")
|
raise APIError(f"No logo found for add-on {addon.slug}!")
|
||||||
|
|
||||||
|
body = await api_validate(SCHEMA_DARK, request)
|
||||||
|
if body[ATTR_PREFER_DARK] and addon.path_dark_logo.exists():
|
||||||
|
with addon.path_dark_logo.open("rb") as png:
|
||||||
|
return png.read()
|
||||||
|
|
||||||
with addon.path_logo.open("rb") as png:
|
with addon.path_logo.open("rb") as png:
|
||||||
return png.read()
|
return png.read()
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ ATTR_PASSWORD = "password"
|
|||||||
ATTR_PORT = "port"
|
ATTR_PORT = "port"
|
||||||
ATTR_PORTS = "ports"
|
ATTR_PORTS = "ports"
|
||||||
ATTR_PORTS_DESCRIPTION = "ports_description"
|
ATTR_PORTS_DESCRIPTION = "ports_description"
|
||||||
ATTR_PREFER_DARK_ICON = "prefer_dark_icon"
|
ATTR_PREFER_DARK = "prefer_dark_icon"
|
||||||
ATTR_PREFIX = "prefix"
|
ATTR_PREFIX = "prefix"
|
||||||
ATTR_PRIMARY = "primary"
|
ATTR_PRIMARY = "primary"
|
||||||
ATTR_PRIORITY = "priority"
|
ATTR_PRIORITY = "priority"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user