Skip to content
Snippets Groups Projects
Commit ba41855f authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#30 - show icon and localize weekday

parent af7f70dc
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
<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>
......@@ -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__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment