Skip to content

Commit dbafe16

Browse files
authored
Merge branch 'master' into update-api
2 parents a8b9253 + 50775b5 commit dbafe16

File tree

7 files changed

+46
-3
lines changed

7 files changed

+46
-3
lines changed

.goreleaser.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ builds:
1818
- "7"
1919
ldflags: -s -w -X main.version={{.Version}}
2020
hooks:
21-
pre: packr
21+
pre:
22+
- packr
23+
- tsc
2224
post: packr clean
2325
- id: "signal-strength"
2426
binary: "signal-strength"

api/api.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ func (api *ManagementAPI) TakeSnapshot(w http.ResponseWriter, r *http.Request) {
201201
}
202202
}
203203

204+
// TakeSnapshotRecording will request a new snapshot recording to be taken by thermal-recorder
205+
func (api *ManagementAPI) TakeSnapshotRecording(w http.ResponseWriter, r *http.Request) {
206+
conn, err := dbus.SystemBus()
207+
if err != nil {
208+
w.WriteHeader(http.StatusInternalServerError)
209+
return
210+
}
211+
recorder := conn.Object("org.cacophony.thermalrecorder", "/org/cacophony/thermalrecorder")
212+
err = recorder.Call("org.cacophony.thermalrecorder.TakeTestRecording", 0).Err
213+
if err != nil {
214+
w.WriteHeader(http.StatusInternalServerError)
215+
return
216+
}
217+
}
218+
204219
// Reregister can change the devices name and group
205220
func (api *ManagementAPI) Reregister(w http.ResponseWriter, r *http.Request) {
206221
group := r.FormValue("group")

cmd/managementd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func main() {
106106
apiRouter.HandleFunc("/recording/{id}", apiObj.GetRecording).Methods("GET")
107107
apiRouter.HandleFunc("/recording/{id}", apiObj.DeleteRecording).Methods("DELETE")
108108
apiRouter.HandleFunc("/camera/snapshot", apiObj.TakeSnapshot).Methods("PUT")
109+
apiRouter.HandleFunc("/camera/snapshot-recording", apiObj.TakeSnapshotRecording).Methods("PUT")
109110
apiRouter.HandleFunc("/signal-strength", apiObj.GetSignalStrength).Methods("GET")
110111
apiRouter.HandleFunc("/reregister", apiObj.Reregister).Methods("POST")
111112
apiRouter.HandleFunc("/reboot", apiObj.Reboot).Methods("POST")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/TheCacophonyProject/audiobait/v3 v3.0.1
77
github.com/TheCacophonyProject/event-reporter v1.3.2-0.20200210010421-ca3fcb76a231
88
github.com/TheCacophonyProject/go-api v1.0.2
9-
github.com/TheCacophonyProject/go-config v1.7.0
9+
github.com/TheCacophonyProject/go-config v1.8.1
1010
github.com/TheCacophonyProject/go-cptv v0.0.0-20201215230510-ae7134e91a71
1111
github.com/TheCacophonyProject/lepton3 v0.0.0-20211005194419-22311c15d6ee
1212
github.com/TheCacophonyProject/rtc-utils v1.2.0

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ github.com/TheCacophonyProject/go-api v1.0.2/go.mod h1:SH5Jo4bH5UdMetAUpoDeFwMYx
6161
github.com/TheCacophonyProject/go-config v0.0.0-20190922224052-7c2a21bc6b88/go.mod h1:gPUJLVu408NRz9/P3BrsxzOzLc+KJLrv+jVdDw3RI0Y=
6262
github.com/TheCacophonyProject/go-config v0.0.0-20190927054511-c93578ae648a/go.mod h1:QCgT+KCrz1CmLVpeeOMl5L8/X1QvWwpsLzR7afTmEJc=
6363
github.com/TheCacophonyProject/go-config v1.4.0/go.mod h1:oARW/N3eJbcewCqB+Jc7TBwuODawwYgpo56UO6yBdKU=
64-
github.com/TheCacophonyProject/go-config v1.7.0 h1:f20lrqbFjiOvMfVAUfqJkhhhBUOMWVsUAu7WpgxE184=
6564
github.com/TheCacophonyProject/go-config v1.7.0/go.mod h1:2VGuQR5dATuq8nzdBMQd7mbc6OhCimkSsGHRLWcer2c=
65+
github.com/TheCacophonyProject/go-config v1.8.1 h1:E8nYRC/Q6Jev9hOUb304T+/l5NswItfBxc7vjABsiI4=
66+
github.com/TheCacophonyProject/go-config v1.8.1/go.mod h1:65yj/WEJ4yBUjYSMmTRH4wuzcvsmJNUrvziP6lzGXcA=
6667
github.com/TheCacophonyProject/go-cptv v0.0.0-20200116020937-858bd8b71512/go.mod h1:8H6Aaft5549sIWxcsuCIL2o60/TQkoF93fVoSTpgZb8=
6768
github.com/TheCacophonyProject/go-cptv v0.0.0-20200616224711-fc633122087a/go.mod h1:Vg73Ezn4kr8qDNP9LNgjki9qgi+5T/0Uc9oDyflaYUY=
6869
github.com/TheCacophonyProject/go-cptv v0.0.0-20201215230510-ae7134e91a71 h1:g6XLYIt3hFo2JOQhbfySLxcFFv0kofg0L1Z7MyNXsLc=

html/camera.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
<div class="container">
1515
<h2>Camera</h2>
16+
<button id="take-snapshot-recording" style="position: relative" type="button">
17+
Take test recording
18+
</button>
1619
<div id="snapshot-stopped" style="display: none">
20+
1721
<p id="snapshot-stopped-message"></p>
1822
<button id="snapshot-restart" type="button">
1923
Continue viewing camera

static/js/camera.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,32 @@ function restartCameraViewing() {
6868
}
6969
}
7070

71+
async function takeTestRecording() {
72+
document.getElementById("take-snapshot-recording")!.innerText = 'Making a test recording';
73+
document.getElementById("take-snapshot-recording")!.setAttribute("disabled", "true");
74+
console.log("making a test recording");
75+
fetch('/api/camera/snapshot-recording', {
76+
method: 'PUT',
77+
headers: {
78+
'Authorization': 'Basic YWRtaW46ZmVhdGhlcnM='
79+
}})
80+
81+
.then(response => console.log(response))
82+
.then(data => console.log(data))
83+
.catch(error => console.error(error))
84+
//TODO handle errors better and check that recording was made properly instead of just waiting..
85+
await new Promise(r => setTimeout(r, 3000));
86+
document.getElementById("take-snapshot-recording")!.removeAttribute("disabled");
87+
document.getElementById("take-snapshot-recording")!.innerText = 'Take test recording';
88+
}
89+
7190
window.onload = function () {
7291
const urlParams = new URLSearchParams(window.location.search);
7392
if (urlParams.get("timeout") == "off") {
7493
snapshotLimit = Number.MAX_SAFE_INTEGER;
7594
}
7695
document.getElementById("snapshot-restart")!.onclick = restartCameraViewing;
96+
document.getElementById("take-snapshot-recording")!.onclick = takeTestRecording;
7797
cameraConnection = new CameraConnection(
7898
window.location.hostname,
7999
window.location.port,

0 commit comments

Comments
 (0)