-
-
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.
feat: add scalar, correct routes, fix frontend boxes
- Loading branch information
1 parent
9e44541
commit 58f0a3c
Showing
7 changed files
with
193 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
======= | ||
helpers | ||
======= | ||
|
||
Helper utilities for the application calculator. | ||
|
||
.. automodule:: app.domain.calculator.helpers | ||
:members: |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Helpers for calculator domain module.""" | ||
|
||
import ipaddress | ||
|
||
from app.domain.calculator.schema import NetworkInfo | ||
|
||
__all__ = ("get_network_info",) | ||
|
||
|
||
def get_network_info(ip: str, prefix: str) -> NetworkInfo: | ||
"""Get network information. | ||
Args: | ||
ip: The IP address in standard IPv4 format. | ||
prefix: The CIDR notation. | ||
Returns: | ||
NetworkInfo: The network information. | ||
""" | ||
net = ipaddress.IPv4Network(f"{ip}/{prefix}", strict=False) | ||
|
||
subnet_mask = str(net.netmask) | ||
wildcard_subnet_mask = str(net.hostmask) | ||
total_ips = net.num_addresses | ||
usable_ips = total_ips - 2 # minus network and broadcast addresses | ||
network_ip = str(net.network_address) | ||
broadcast_ip = str(net.broadcast_address) | ||
|
||
# First and last usable IP addresses | ||
hosts = list(net.hosts()) | ||
first_ip = str(hosts[0]) if hosts else None | ||
last_ip = str(hosts[-1]) if hosts else None | ||
|
||
return NetworkInfo( | ||
subnet_mask=subnet_mask, | ||
wildcard_subnet_mask=wildcard_subnet_mask, | ||
total_ips=total_ips, | ||
usable_ips=usable_ips, | ||
network_ip=network_ip, | ||
broadcast_ip=broadcast_ip, | ||
first_ip=first_ip, | ||
last_ip=last_ip, | ||
) |
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,57 @@ | ||
/* Custom Litestar-branded Styling for the Scalar.com OpenAPI documentation renderer */ | ||
|
||
/* basic theme */ | ||
.light-mode { | ||
--theme-color-1: #202235; | ||
--theme-color-2: #757575; | ||
--theme-color-3: #8e8e8e; | ||
--theme-color-accent: #4297e8; | ||
|
||
--theme-background-1: #fff; | ||
--theme-background-2: #f6f6f6; | ||
--theme-background-3: #e7e7e7; | ||
--theme-background-accent: rgba(31, 76, 120, 0.12); | ||
|
||
--theme-color-green: #069061; | ||
--theme-color-red: #ef0006; | ||
--theme-color-yellow: #edbe20; | ||
--theme-color-blue: #0082d0; | ||
--theme-color-orange: #fb892c; | ||
--theme-color-purple: #5203d1; | ||
} | ||
|
||
.dark-mode { | ||
--theme-color-1: rgb(221, 223, 227, 1); | ||
--theme-color-2: rgba(221, 223, 227, 0.62); | ||
--theme-color-3: rgba(221, 223, 227, 0.44); | ||
--theme-color-accent: #d0e8ff; | ||
|
||
--theme-background-1: #18181b; | ||
--theme-background-2: #27272a; | ||
--theme-background-3: #3e3e41; | ||
--theme-background-accent: #d0e8ff1f; | ||
|
||
--theme-border-color: rgba(255, 255, 255, 0.1); | ||
|
||
--theme-color-green: #00b648; | ||
--theme-color-red: #ff7b72; | ||
--theme-color-yellow: #eabf6c; | ||
--theme-color-blue: #a5d6ff; | ||
--theme-color-orange: #ff8d4d; | ||
--theme-color-purple: #f3c7ee; | ||
} | ||
|
||
.dark-mode .sidebar, | ||
.light-mode .sidebar { | ||
--sidebar-background-1: var(--theme-background-1); | ||
--sidebar-item-hover-color: currentColor; | ||
--sidebar-item-hover-background: var(--theme-background-2); | ||
--sidebar-item-active-background: var(--theme-background-accent); | ||
--sidebar-border-color: var(--theme-border-color); | ||
--sidebar-color-1: var(--theme-color-1); | ||
--sidebar-color-2: var(--theme-color-2); | ||
--sidebar-color-active: var(--theme-color-accent); | ||
--sidebar-search-background: transparent; | ||
--sidebar-search-border-color: var(--theme-border-color); | ||
--sidebar-search--color: var(--theme-color-3); | ||
} |
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
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