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

Static files for Home Assistant #426

Merged
merged 7 commits into from
Jun 18, 2022
Merged

Static files for Home Assistant #426

merged 7 commits into from
Jun 18, 2022

Conversation

mrlt8
Copy link
Owner

@mrlt8 mrlt8 commented Jun 16, 2022

No description provided.

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 16, 2022

Hey @dsheehan, I was making some tweaks to the UI and I think I broke the dragability. Could you take a look when you have a chance?
Thanks!

@@ -4,45 +4,44 @@
<head>
<meta charset="UTF-8">
<title>Wyze-Bridge</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='site.css') }}" />
{% if show_video %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restore guard flag

<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='site.css') }}" />
{% if show_video %}
<link rel="stylesheet" type="text/css"
href="{{ 'static/site.css' if hass else url_for('static',filename='site.css') }}" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flask recommends using url_for. In this case it's effectively building static/site.css

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately url_for static seems to build the hrefs with a leading forward slash which breaks in HASS since the static files are located somewhere like: http://homeassistant.local:8123/api/hassio_ingress/FX8RhC_HKiSPRVURubziW8OCqGIxj-7s5kMt3L7RObU/static/site.css
and it tries to grab the static files from homeassistant.local:8123/static/

<h2>Detected {{cameras|length}} cameras:</h2>
<label for="select_number_of_columns">Number of columns: </label>
<input id="select_number_of_columns" type="number" min="1" max="10" value="{{ number_of_columns }}" />

<section class="cameras">
{% for camera in cameras.values() %}
<div id="{{ camera.name_uri }}" draggable="true" class="camera">
<details open>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer having the collapsable details element here, so I can collapse all the cameras I'm not interested in watching at the moment.

</video>
{% elif camera.img %}
<img class="refresh_img" src="{{camera.img}}" width="100%" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore class. Did you base this PR off an old commit?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, yes, changes were made from my HASS vm which may have been behind.

cameras=wb.get_cameras(),
number_of_columns=number_of_columns,
hass=wb.hass,
version=wb.version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future, if we need more things from wb, we might want to see if we can pass in the entire wb object and reference it directly. (haven't tried)

app/frontend.py Outdated
logging.basicConfig(level=logging.DEBUG)

if __name__ == "__main__":
logging.basicConfig(level=logging.CRITICAL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too my knowledge, this main isn't used by the Dockerfile, it's only for direct debugging, so might as well leave it at Debug. Flask invokes the create_app() directly IIRC.

camera.connected else 'OFFLINE'}}</span>
</div>
</summary>
<div class="title">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra div's are probably breaking the draggable logic in

if (target && target !== dragEl && target.nodeName === 'DIV') {
that looks for div

@mrlt8 mrlt8 marked this pull request as ready for review June 18, 2022 14:22
@mrlt8 mrlt8 merged commit f757d28 into main Jun 18, 2022
@mrlt8 mrlt8 deleted the web-ui branch June 18, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants