Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading icons #42

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aqimon/read/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
class MockReader:
"""Mock reader class."""

def __init__(self, fake_sleep_secs=5, raise_error_odds=50):
def __init__(self, fake_sleep_secs=5, raise_error_odds=50, warm_up_secs=5):
"""Create a mock reader."""
self.state = ReaderState(ReaderStatus.IDLE, None)
self.fake_sleep_secs = fake_sleep_secs
self.raise_error_odds = raise_error_odds
self.warm_up_secs = warm_up_secs

async def read(self) -> AqiRead:
"""Read from the 'device'.
Expand All @@ -25,6 +26,8 @@ async def read(self) -> AqiRead:
Also, randomly fails some percentage of the time.
"""
try:
self.state = ReaderState(ReaderStatus.WARM_UP, None)
await asyncio.sleep(self.warm_up_secs)
self.state = ReaderState(ReaderStatus.READING, None)
raise_error_roll = random.randint(0, 100)
if raise_error_roll < self.raise_error_odds:
Expand Down
Binary file modified aqimon/static/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added aqimon/static/images/warmingup.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion elm/src/DeviceStatus.elm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ deviceStatusImage deviceStatus =
"/static/images/loading.gif"

WarmingUp ->
"/static/images/loading.gif"
"/static/images/warmingup.gif"

Idle ->
"/static/images/idle.png"
Expand Down