Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
f90a7cd66d | |||
426ab872dd | |||
6920f9ee24 | |||
1340b3167f |
9 changed files with 53 additions and 48 deletions
|
@ -7,7 +7,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- run: apk add --no-cache nodejs git
|
- run: apk add --no-cache nodejs git
|
||||||
- name: login to container registry
|
- name: login to container registry
|
||||||
run: echo "${{ secrets.PACKAGE_PUBLISH_TOKEN }}" | docker login --username finn --password-stdin git.janky.solutions
|
run: echo "${{ secrets.PACKAGE_PUBLISH_TOKEN }}" | docker login --username ${{ secrets.PACKAGE_PUBLISH_USER }} --password-stdin git.janky.solutions
|
||||||
- name: gather metadata for container image tags
|
- name: gather metadata for container image tags
|
||||||
uses: https://github.com/docker/metadata-action@v5
|
uses: https://github.com/docker/metadata-action@v5
|
||||||
id: meta
|
id: meta
|
||||||
|
@ -20,7 +20,7 @@ jobs:
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION_STRING=${{ env.GITHUB_REF_NAME }}
|
VERSION_STRING=${{ env.GITHUB_REF_NAME }}
|
||||||
- name: update hassio-addons
|
- name: update hassio-addons
|
||||||
|
|
|
@ -26,5 +26,9 @@ func init() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Version == "" {
|
||||||
|
Version = "development"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"time"
|
"time"
|
||||||
|
@ -20,7 +19,7 @@ var (
|
||||||
Templates *template.Template
|
Templates *template.Template
|
||||||
|
|
||||||
funcs = template.FuncMap{
|
funcs = template.FuncMap{
|
||||||
"version": func() string { return fmt.Sprintf("better-zwave-locks %s", config.Version) },
|
"version": func() string { return config.Version },
|
||||||
"time_since": func(t time.Time) string { return time.Since(t).Round(time.Second).String() },
|
"time_since": func(t time.Time) string { return time.Since(t).Round(time.Second).String() },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<title>Better Z-Wave Locks for Home Assistant</title>
|
<title>Better Z-Wave Locks for Home Assistant</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||||
<link rel="stylesheet" href="{{ .BaseURL }}/static/main.css" />
|
<link rel="stylesheet" href="{{ .BaseURL }}/static-{{ version }}/main.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,28 +1,11 @@
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<h1>Better Z-Wave Locks</h1>
|
<h1>Better Z-Wave Locks</h1>
|
||||||
<!-- <header>Active Codes</header>
|
|
||||||
[ <a href="{{ .BaseURL }}/add-code">add</a> ]
|
|
||||||
<table border="1">
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Code</th>
|
|
||||||
<th>Last used</th>
|
|
||||||
<th>Expires</th>
|
|
||||||
<th>Actions</th>
|
|
||||||
</tr>
|
|
||||||
{{ range .ActiveCodes }}
|
|
||||||
<tr>
|
|
||||||
<td>{{ .Name.Value }}</td>
|
|
||||||
<td>{{ .Code }}</td>
|
|
||||||
<td>0.005ms ago on <a href="{{ $.BaseURL }}/locks/1">Back Door</a></td>
|
|
||||||
<td>{{ .End.Value }}</td>
|
|
||||||
<td><a href="#">details</a> | <a href="#">delete</a></td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
</table> -->
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<header>locks</header>
|
<span class="table">
|
||||||
<ul>
|
{{ range .Locks }}
|
||||||
{{ range .Locks }}<li><a href="{{ $.BaseURL }}/locks/{{ .ID }}">{{ .Name }} ({{ .ZwaveDeviceID }})</a></li>{{ end }}
|
<a class="table-row" href="{{ $.BaseURL }}/locks/{{ .ID }}">
|
||||||
</ul>
|
<p class="table-cell">{{ if eq .Name "" }}Lock #{{ .ZwaveDeviceID }}{{ else }}{{ .Name }}{{ end }}</p>
|
||||||
|
</a>
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
{{ template "footer.html" }}
|
{{ template "footer.html" }}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<header>{{ if eq .Data.lock.Name "" }}Lock #{{ .Data.lock.ID }}{{ else }}{{ .Data.lock.Name }}{{ end }} Slot #{{ .Data.code.Slot }}</header>
|
<header>{{ if eq .Data.lock.Name "" }}Lock #{{ .Data.lock.ID }}{{ else }}{{ .Data.lock.Name }}{{ end }} Slot #{{ .Data.code.Slot }}</header>
|
||||||
<br />
|
<br />
|
||||||
<form method="post">
|
<form method="post">
|
||||||
Code: <input type="text" name="code" value="{{ .Data.code.Code }}" /><br />
|
Code: <input type="text" name="code" value="{{ .Data.code.Code }}" id="code" /> <a href="#" onclick="generateCode()">🔄</a><br />
|
||||||
Name: <input type="text" name="name" value="{{ .Data.code.Name }}" /><br />
|
Name: <input type="text" name="name" value="{{ .Data.code.Name }}" /><br />
|
||||||
Enabled: <input type="checkbox" name="enabled" {{ if .Data.code.Enabled }}checked{{ end }} /><br />
|
Enabled: <input type="checkbox" name="enabled" {{ if .Data.code.Enabled }}checked{{ end }} /><br />
|
||||||
<br />
|
<br />
|
||||||
|
@ -15,4 +15,14 @@
|
||||||
<li>{{ $entry.State }} (<i>{{ $entry.Timestamp | time_since }} ago</i>)</li>
|
<li>{{ $entry.State }} (<i>{{ $entry.Timestamp | time_since }} ago</i>)</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function generateCode() {
|
||||||
|
let code = "";
|
||||||
|
while(code.length < 4) {
|
||||||
|
code += Math.round(Math.random()*10);
|
||||||
|
}
|
||||||
|
document.querySelector('#code').value = code;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{{ template "footer.html" }}
|
{{ template "footer.html" }}
|
||||||
|
|
|
@ -2,24 +2,18 @@
|
||||||
<header>{{ if eq .Data.lock.Name "" }}Lock #{{ .Data.lock.ID }}{{ else }}{{ .Data.lock.Name }}{{ end }}</header>
|
<header>{{ if eq .Data.lock.Name "" }}Lock #{{ .Data.lock.ID }}{{ else }}{{ .Data.lock.Name }}{{ end }}</header>
|
||||||
[ <a href="{{ $.BaseURL }}/locks/{{ .Data.lock.ID }}/edit">rename</a> ]<br />
|
[ <a href="{{ $.BaseURL }}/locks/{{ .Data.lock.ID }}/edit">rename</a> ]<br />
|
||||||
<br />
|
<br />
|
||||||
<table class="table">
|
<span class="table">
|
||||||
<tr>
|
<span class="table-row">
|
||||||
<td>Slot</td>
|
<span class="table-cell">Name</span>
|
||||||
<td>Name</td>
|
<span class="table-cell">Code</span>
|
||||||
<td>Code</td>
|
</span>
|
||||||
<td>Enabled?</td>
|
|
||||||
<td>Actions</td>
|
|
||||||
</tr>
|
|
||||||
{{ range $_, $code := .Data.codes }}
|
{{ range $_, $code := .Data.codes }}
|
||||||
<tr class="code-{{ if $code.Enabled }}enabled{{ else }}disabled{{ end }}">
|
<a href="{{ $.BaseURL }}/locks/{{ $.Data.lock.ID }}/codes/{{ $code.Slot }}" class="table-row code-{{ if $code.Enabled }}enabled{{ else }}disabled{{ end }}">
|
||||||
<td>{{ $code.Slot }}</td>
|
<span class="table-cell">{{ $code.Name }}</span>
|
||||||
<td>{{ $code.Name }}</td>
|
<span class="table-cell">{{ $code.Code }}</span>
|
||||||
<td>{{ $code.Code }}</td>
|
</a>
|
||||||
<td>{{ if $code.Enabled }}enabled{{ else }}disabled{{ end }}</td>
|
|
||||||
<td>[ <a href="{{ $.BaseURL }}/locks/{{ $.Data.lock.ID }}/codes/{{ $code.Slot }}">edit</a> ]</td>
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</span>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,24 @@ header {
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-enabled {
|
.code-enabled {
|
||||||
background-color: #0a0;
|
background-color: #050;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-row {
|
||||||
|
border-bottom: solid #999 1px;
|
||||||
|
/* background-color: #333; */
|
||||||
|
height: 3em;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-row:first {
|
||||||
|
border-top: solid #999 1px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func ListenAndServe(zwaveClient *zwavejs.Client) {
|
||||||
server.Use(accessLogMiddleware)
|
server.Use(accessLogMiddleware)
|
||||||
server.RouteNotFound("/*", tmpl("404.html"))
|
server.RouteNotFound("/*", tmpl("404.html"))
|
||||||
|
|
||||||
server.StaticFS("/static", frontend.Static)
|
server.StaticFS("/static-"+config.Version, frontend.Static)
|
||||||
server.GET("/", indexHandler)
|
server.GET("/", indexHandler)
|
||||||
server.GET("/locks/:lock", lockHandler)
|
server.GET("/locks/:lock", lockHandler)
|
||||||
server.GET("/locks/:lock/edit", lockEditHandler)
|
server.GET("/locks/:lock/edit", lockEditHandler)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue