allow edit of name + address

This commit is contained in:
Emile Nijssen 2021-07-13 20:51:23 +02:00
parent 2966666cc6
commit 016382dd01
11 changed files with 221 additions and 205 deletions

View file

@ -94,4 +94,20 @@ class API {
});
}
async updateClientName({ clientId, name }) {
return this.call({
method: 'put',
path: `/wireguard/client/${clientId}/name/`,
body: { name },
});
}
async updateClientAddress({ clientId, address }) {
return this.call({
method: 'put',
path: `/wireguard/client/${clientId}/address/`,
body: { address },
});
}
}

View file

@ -17,6 +17,10 @@ new Vue({
clientDelete: null,
clientCreate: null,
clientCreateName: '',
clientEditName: null,
clientEditNameId: null,
clientEditAddress: null,
clientEditAddressId: null,
qrcode: null,
},
methods: {
@ -101,6 +105,16 @@ new Vue({
.catch(err => alert(err.message || err.toString()))
.finally(() => this.refresh().catch(console.error));
},
updateClientName(client, name) {
this.api.updateClientName({ clientId: client.id, name })
.catch(err => alert(err.message || err.toString()))
.finally(() => this.refresh().catch(console.error));
},
updateClientAddress(client, address) {
this.api.updateClientAddress({ clientId: client.id, address })
.catch(err => alert(err.message || err.toString()))
.finally(() => this.refresh().catch(console.error));
},
},
filters: {
timeago: value => {