Skip to content

Commit

Permalink
Merge pull request #42 from TimOrme/fix_loading_icons
Browse files Browse the repository at this point in the history
Fix loading icons
  • Loading branch information
TimOrme authored Apr 26, 2023
2 parents 5cd0d76 + ff51918 commit a3958e9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
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

0 comments on commit a3958e9

Please sign in to comment.