add height to logo parameters

This commit is contained in:
checktheroads 2020-01-03 01:25:41 -07:00
parent 4eac733d69
commit 523afcfa70
3 changed files with 34 additions and 54 deletions

View file

@ -1,7 +1,9 @@
"""Validate branding configuration variables."""
from typing import Optional
# Third Party Imports
from pydantic import StrictStr
from pydantic import StrictStr, StrictInt, StrictBool
from pydantic import constr
from pydantic import validator
from pydantic.color import Color
@ -13,7 +15,7 @@ from hyperglass.configuration.models._utils import HyperglassModel
class Branding(HyperglassModel):
"""Validation model for params.branding."""
site_title: str = "hyperglass"
site_title: StrictStr = "hyperglass"
class Colors(HyperglassModel):
"""Validation model for params.colors."""
@ -36,7 +38,7 @@ class Branding(HyperglassModel):
class Credit(HyperglassModel):
"""Validation model for params.branding.credit."""
enable: bool = True
enable: StrictBool = True
class Font(HyperglassModel):
"""Validation model for params.branding.font."""
@ -59,14 +61,15 @@ class Branding(HyperglassModel):
class HelpMenu(HyperglassModel):
"""Validation model for params.branding.help_menu."""
enable: bool = True
enable: StrictBool = True
class Logo(HyperglassModel):
"""Validation model for params.branding.logo."""
logo_path: str = "ui/images/hyperglass-dark.png"
width: int = 384
favicons: str = "ui/images/favicons/"
logo_path: StrictStr = "ui/images/hyperglass-dark.png"
width: StrictInt = 384
height: Optional[StrictInt]
favicons: StrictStr = "ui/images/favicons/"
@validator("favicons")
def favicons_trailing_slash(cls, value):
@ -84,45 +87,45 @@ class Branding(HyperglassModel):
class PeeringDb(HyperglassModel):
"""Validation model for params.branding.peering_db."""
enable: bool = True
enable: StrictBool = True
class Terms(HyperglassModel):
"""Validation model for params.branding.terms."""
enable: bool = True
enable: StrictBool = True
class Text(HyperglassModel):
"""Validation model for params.branding.text."""
title_mode: constr(regex=("logo_only|text_only|logo_title|all")) = "logo_only"
title: str = "hyperglass"
subtitle: str = "AS{primary_asn}"
query_location: str = "Location"
query_type: str = "Query Type"
query_target: str = "Target"
query_vrf: str = "Routing Table"
terms: str = "Terms"
info: str = "Help"
title: StrictStr = "hyperglass"
subtitle: StrictStr = "AS{primary_asn}"
query_location: StrictStr = "Location"
query_type: StrictStr = "Query Type"
query_target: StrictStr = "Target"
query_vrf: StrictStr = "Routing Table"
terms: StrictStr = "Terms"
info: StrictStr = "Help"
peeringdb = "PeeringDB"
bgp_route: str = "BGP Route"
bgp_community: str = "BGP Community"
bgp_aspath: str = "BGP AS Path"
ping: str = "Ping"
traceroute: str = "Traceroute"
bgp_route: StrictStr = "BGP Route"
bgp_community: StrictStr = "BGP Community"
bgp_aspath: StrictStr = "BGP AS Path"
ping: StrictStr = "Ping"
traceroute: StrictStr = "Traceroute"
class Error404(HyperglassModel):
"""Validation model for 404 Error Page."""
title: str = "Error"
subtitle: str = "{uri} isn't a thing"
button: str = "Home"
title: StrictStr = "Error"
subtitle: StrictStr = "{uri} isn't a thing"
button: StrictStr = "Home"
class Error500(HyperglassModel):
"""Validation model for 500 Error Page."""
title: str = "Error"
subtitle: str = "Something Went Wrong"
button: str = "Home"
title: StrictStr = "Error"
subtitle: StrictStr = "Something Went Wrong"
button: StrictStr = "Home"
error404: Error404 = Error404()
error500: Error500 = Error500()

View file

@ -7,19 +7,19 @@
</div>
{% elif branding.text.title_mode == 'all' %}
<img src="{{ branding.logo.logo_path }}" style="width: {{ branding.logo.width }}px;">
<img src="{{ branding.logo.logo_path }}" style="width: {{ branding.logo.width }}px; {% if branding.logo.height %} height: {{ branding.logo.height }}px;{% endif %}">
<p class="{{ size_title }}">{{ branding.text.title }}<p>
<p class="{{ size_subtitle }}">{{ branding.text.subtitle.format(primary_asn=primary_asn) }}</p>
{% elif branding.text.title_mode == 'logo_title' %}
<div class="float-{{ direction }} mw-sm-100 mw-md-75 mw-lg-50 mw-xl-50">
<img class="img-fluid hg-logo" src="{{ branding.logo.logo_path }}">
<img class="img-fluid hg-logo" src="{{ branding.logo.logo_path }}" style="width: {{ branding.logo.width }}px; {% if branding.logo.height %} height: {{ branding.logo.height }}px;{% endif %}">
</div>
<p clas="{{ size_title }}">{{ branding.text.title }}</p>
{% elif branding.text.title_mode == 'logo_only' %}
<div class="float-{{ direction }} mw-sm-100 mw-md-75 mw-lg-50 mw-xl-50">
<img class="img-fluid hg-logo" src="{{ branding.logo.logo_path }}">
<img class="img-fluid hg-logo" src="{{ branding.logo.logo_path }}" style="width: {{ branding.logo.width }}px; {% if branding.logo.height %} height: {{ branding.logo.height }}px;{% endif %}">
</div>
{% endif %}

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="20">
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<mask id="anybadge_1">
<rect width="120" height="20" rx="3" fill="#fff"/>
</mask>
<g mask="url(#anybadge_1)">
<path fill="#555" d="M0 0h90v20H0z"/>
<path fill="#007ec6" d="M90 0h30v20H90z"/>
<path fill="url(#b)" d="M0 0h120v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="46.0" y="15" fill="#010101" fill-opacity=".3">Lines of Code</text>
<text x="45.0" y="14">Lines of Code</text>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="106.0" y="15" fill="#010101" fill-opacity=".3">3191</text>
<text x="105.0" y="14">3191</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1 KiB