feat(ui): edit doors from the admin page (add Edit action)
The PUT /api/v1/doors/{id} endpoint already existed and preserves the
controller token when it isn't resent, but the admin UI only exposed
create / reveal-token / delete. Add a per-row Edit (pencil) button that
reuses the door dialog as create-or-update (saveDoor: POST when new, PUT
when editing), so a door's Home Assistant webhook URL / boltcards base /
timeout can be changed without deleting + recreating (which would churn
the controller token the reader uses). Bump to 0.0.3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
2fb2e1468e
commit
2bc4a01edc
3 changed files with 39 additions and 10 deletions
|
|
@ -75,14 +75,31 @@ window.app = Vue.createApp({
|
|||
)
|
||||
this.logs = data
|
||||
},
|
||||
async createDoor() {
|
||||
editDoor(door) {
|
||||
// Prefill the dialog for an update. Drop controller_token so it's left
|
||||
// untouched server-side (api_door_update keeps it when not resent).
|
||||
const { controller_token, ...data } = door
|
||||
this.doorDialog = { show: true, data }
|
||||
},
|
||||
async saveDoor() {
|
||||
// POST to create, PUT to update an existing door (data.id present).
|
||||
const d = this.doorDialog.data
|
||||
try {
|
||||
await LNbits.api.request(
|
||||
'POST',
|
||||
'/access/api/v1/doors',
|
||||
this.adminkey,
|
||||
this.doorDialog.data
|
||||
)
|
||||
if (d.id) {
|
||||
await LNbits.api.request(
|
||||
'PUT',
|
||||
`/access/api/v1/doors/${d.id}`,
|
||||
this.adminkey,
|
||||
d
|
||||
)
|
||||
} else {
|
||||
await LNbits.api.request(
|
||||
'POST',
|
||||
'/access/api/v1/doors',
|
||||
this.adminkey,
|
||||
d
|
||||
)
|
||||
}
|
||||
this.doorDialog = { show: false, data: { unlock_timeout_ms: 2500 } }
|
||||
await this.loadDoors()
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue