diff --git a/Pipfile b/Pipfile index 4d2b47851232f73fda0307dbcfeac52002cd3490..5dc026a0d2e3dc6cd65f1b0658e316bb31f476fa 100644 --- a/Pipfile +++ b/Pipfile @@ -18,6 +18,7 @@ TheCodeLabs-BaseUtils = "*" TheCodeLabs-FlaskUtils = "*" flask-socketio= "==4.3.1" apscheduler = "==3.6.3" +Babel = "==2.8.0" # services icalendar = "==4.0.7" diff --git a/src/logic/tile/tiles/GarbageContainerScheduleTile.html b/src/logic/tile/tiles/GarbageContainerScheduleTile.html index bf77d2fabc53be34df27326b304bb8130ea43764..471abb30b0101373b427e4c1797f8b16dd629688 100644 --- a/src/logic/tile/tiles/GarbageContainerScheduleTile.html +++ b/src/logic/tile/tiles/GarbageContainerScheduleTile.html @@ -1,7 +1,7 @@ <style> .garbageContainerScheduleTile { background-color: #2F2F2F; - font-size: 3.5vmin; + font-size: 3vmin; border-radius: 1vh; font-weight: bold; flex-direction: row; @@ -15,54 +15,20 @@ display: flex; flex-direction: row; align-items: center; - justify-content: space-between; + justify-content: space-evenly; width: 85%; height: 85%; } - .garbageContainerScheduleTile .entries { - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - flex: 1; - } - - .garbageContainerScheduleTile .temperatures { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - } - - .garbageContainerScheduleTile .temperature-entry { - display: flex; - flex-direction: column; - align-items: center; - padding-left: 3vmin; - justify-content: space-between; - } - - .garbageContainerScheduleTile .label { - font-size: 2vmin; - } - - .garbageContainerScheduleTile .wind { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - font-size: 2vmin; - padding-top: 1vmin; - } - - .garbageContainerScheduleTile .windSpeed { - padding-left: 1vmin; + .garbageContainerScheduleTile .icon { + width: 12%; + height: auto; } </style> <div class="garbageContainerScheduleTile"> <div class="content"> - {{ nextEventDate }} + <img src="../../static/images/{{ data['iconFileName'] }}" class="icon"/> + {{ data['nextEventDate'] }} </div> </div> diff --git a/src/logic/tile/tiles/GarbageContainerScheduleTile.py b/src/logic/tile/tiles/GarbageContainerScheduleTile.py index 5e11a70bda60333609335224c5fa0daa1eef5c04..b525907ca34a422dc9488a979201e7e7bc2a9476 100644 --- a/src/logic/tile/tiles/GarbageContainerScheduleTile.py +++ b/src/logic/tile/tiles/GarbageContainerScheduleTile.py @@ -3,6 +3,7 @@ from datetime import datetime from typing import Dict, List from flask import Blueprint +from babel.dates import format_date from logic.service.ServiceManager import ServiceManager from logic.service.services.IcsService import CalendarEvent @@ -10,11 +11,18 @@ from logic.tile.Tile import Tile class GarbageContainerScheduleTile(Tile): - DATE_FORMAT = '%d.%m. (%a)' + DATE_FORMAT = 'dd.MM. (E)' + + ICON_BY_GARBAGE_TYPE = { + 'Papier': 'garbage_paper', + 'Gelbe Säcke': 'garbage_plastic', + 'Bioabfall': 'garbage_bio', + 'Restabfall': 'garbage_waste' + } EXAMPLE_SETTINGS = { "path": "path/to/my/calendar.ics", - "garbageType": "Papier" or "Gelbe Säcke" or "Bioabfall" or "Restabfall" + "garbageType": "Papier" or "Gelbe Säcke" or "Bioabfall" or "Restabfall", } def __init__(self, uniqueName: str, settings: Dict, intervalInSeconds: int): @@ -31,13 +39,14 @@ class GarbageContainerScheduleTile(Tile): nextEventDate = '--.--.' if nextEvent: - nextEventDate = datetime.strftime(nextEvent.start, self.DATE_FORMAT) + nextEventDate = nextEvent.start + nextEventDate = format_date(nextEventDate, self.DATE_FORMAT, 'de') - # TODO: set locale for weekday - # TODO: set icon for garbageType + iconName = self.ICON_BY_GARBAGE_TYPE[self._settings['garbageType']] return { - 'nextEventDate': nextEventDate + 'nextEventDate': nextEventDate, + 'iconFileName': f'{iconName}.png' } def __find_next_date(self, events: List[CalendarEvent]) -> CalendarEvent or None: @@ -49,7 +58,7 @@ class GarbageContainerScheduleTile(Tile): return None def render(self, data: Dict) -> str: - return Tile.render_template(os.path.dirname(__file__), __class__.__name__, nextEventDate=data['nextEventDate']) + return Tile.render_template(os.path.dirname(__file__), __class__.__name__, data=data) def construct_blueprint(self, pageName: str, *args, **kwargs): return Blueprint(f'{pageName}_{__class__.__name__}_{self.get_uniqueName()}', __name__)