Skip to content

Commit

Permalink
fix: link Открыть (#8)
Browse files Browse the repository at this point in the history
* fix: show more one camer in intercom

* fix: link Открыть

* add: support url from URL js

* fix: host in url link
  • Loading branch information
twocolors authored May 20, 2024
1 parent 80daa19 commit 118b075
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions handlers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,23 @@ func (h *Handler) HomeHandler(w http.ResponseWriter, r *http.Request) {

finances, _ := h.GetFinances()

// fix: https://github.com/ad/domru/issues/11
host := r.Host
if host == "" {
host = fmt.Sprintf("%s:%s", hostIP, strconv.Itoa(h.Config.Port))
}
var scheme string
scheme = r.URL.Scheme;
if scheme == "" {
scheme = "http"
}

data := HomePageData{
HassioIngress: ingressPath,
HostIP: hostIP,
Port: strconv.Itoa(h.Config.Port),
Host: host,
Scheme: scheme,
LoginError: loginError,
Phone: strconv.Itoa(h.Config.Login),
Token: h.Config.Token,
Expand Down
2 changes: 2 additions & 0 deletions handlers/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ type HomePageData struct {
HassioIngress string
HostIP string
Port string
Host string
Scheme string
LoginError string
Phone string
Token string
Expand Down
10 changes: 5 additions & 5 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@
<div class="table-body-cell">Адрес:</div>
<div class="table-body-cell">
{{ $ac.Name }}
<button onclick="fetch('http://{{ $.HostIP }}:{{ $.Port }}/door?placeID={{ $element.Place.ID }}&accessControlID={{ $ac.ID }}'); return false;">Открыть</button>
<button onclick="fetch('{{ $.HassioIngress }}/door?placeID={{ $element.Place.ID }}&accessControlID={{ $ac.ID }}'); return false;">Открыть</button>
</div>
</div>
<div class="resp-table-row">
<div class="table-body-cell">Видеопоток:</div>
<div class="table-body-cell">http://{{ $.HostIP }}:{{ $.Port }}/stream?cameraID={{ (index $.Cameras.Data $index).ID }}</div>
<div class="table-body-cell">{{ $.Scheme }}://{{ $.Host }}/stream?cameraID={{ (index $.Cameras.Data $index).ID }}</div>
</div>
<div class="resp-table-row">
<div class="table-body-cell"></div>
Expand All @@ -114,13 +114,13 @@
<pre>
rest_command:
domru_open_door:
url: http://{{ $.HostIP }}:{{ $.Port }}/door?placeID={{ $element.Place.ID }}&accessControlID={{ $ac.ID }}
url: {{ $.Scheme }}://{{ $.Host }}/door?placeID={{ $element.Place.ID }}&accessControlID={{ $ac.ID }}

camera:
- platform: generic
name: domofon
still_image_url: http://{{ $.HostIP }}:{{ $.Port }}/snapshot?placeID={{ $element.Place.ID }}&accessControlID={{ $ac.ID }}
stream_source: http://{{ $.HostIP }}:{{ $.Port }}/stream?cameraID={{ (index $.Cameras.Data $index).ID }}
still_image_url: {{ $.Scheme }}://{{ $.Host }}/snapshot?placeID={{ $element.Place.ID }}&accessControlID={{ $ac.ID }}
stream_source: {{ $.Scheme }}://{{ $.Host }}/stream?cameraID={{ (index $.Cameras.Data $index).ID }}
</pre>
</div>
</div>
Expand Down

0 comments on commit 118b075

Please sign in to comment.