diff --git a/api/api.go b/api/api.go index 683d0ea..ea7cbba 100644 --- a/api/api.go +++ b/api/api.go @@ -470,6 +470,21 @@ func (api *ManagementAPI) DeleteEvents(w http.ResponseWriter, r *http.Request) { } } +// Trigger trap +func (api *ManagementAPI) TriggerTrap(w http.ResponseWriter, r *http.Request) { + log.Println("triggering trap") + err := eventclient.AddEvent(eventclient.Event{ + Timestamp: time.Now(), + Type: "trapped", + Details: map[string]interface{}{"test": true}, + }) + + if err != nil { + badRequest(&w, err) + return + } +} + // CheckSaltConnection will try to ping the salt server and return the response func (api *ManagementAPI) CheckSaltConnection(w http.ResponseWriter, r *http.Request) { log.Println("pinging salt server") diff --git a/cmd/managementd/main.go b/cmd/managementd/main.go index f85582d..6c2137a 100644 --- a/cmd/managementd/main.go +++ b/cmd/managementd/main.go @@ -120,6 +120,7 @@ func main() { apiRouter.HandleFunc("/event-keys", apiObj.GetEventKeys).Methods("GET") apiRouter.HandleFunc("/events", apiObj.GetEvents).Methods("GET") apiRouter.HandleFunc("/events", apiObj.DeleteEvents).Methods("DELETE") + apiRouter.HandleFunc("/trigger-trap", apiObj.TriggerTrap).Methods("PUT") apiRouter.HandleFunc("/check-salt-connection", apiObj.CheckSaltConnection).Methods("GET") apiRouter.HandleFunc("/salt-update", apiObj.StartSaltUpdate).Methods("POST") apiRouter.HandleFunc("/salt-update", apiObj.GetSaltUpdateState).Methods("GET") @@ -185,7 +186,7 @@ func WebsocketServer(ws *websocket.Conn) { } socketsLock.Unlock() if firstSocket { - log.Print("Git new client register") + log.Print("Get new client register") haveClients <- true } } diff --git a/html/camera.html b/html/camera.html index 6af300c..490e060 100644 --- a/html/camera.html +++ b/html/camera.html @@ -13,11 +13,14 @@

Camera

+