Fixed shutdown button disappearing

This commit is contained in:
Joel Collins 2020-03-13 16:42:32 +00:00
parent 928126ee9a
commit 6b0359e432

View file

@ -48,7 +48,7 @@
<div class="uk-grid-small uk-child-width-1-2" uk-grid> <div class="uk-grid-small uk-child-width-1-2" uk-grid>
<div> <div>
<button <button
v-if="'shutdown' in systemActionLinks" v-show="'shutdown' in systemActionLinks"
class="uk-button uk-button-danger uk-form-small uk-float-right uk-margin uk-margin-remove-top uk-width-1-1" class="uk-button uk-button-danger uk-form-small uk-float-right uk-margin uk-margin-remove-top uk-width-1-1"
@click="shutdownRequest" @click="shutdownRequest"
> >
@ -58,7 +58,7 @@
<div> <div>
<button <button
v-if="'reboot' in systemActionLinks" v-show="'reboot' in systemActionLinks"
class="uk-button uk-button-danger uk-form-small uk-float-right uk-margin uk-margin-remove-top uk-width-1-1" class="uk-button uk-button-danger uk-form-small uk-float-right uk-margin uk-margin-remove-top uk-width-1-1"
@click="rebootRequest" @click="rebootRequest"
> >
@ -155,14 +155,20 @@ export default {
.get(this.actionsUri) .get(this.actionsUri)
.then(response => { .then(response => {
if ("reboot" in response.data) { if ("reboot" in response.data) {
this.systemActionLinks.reboot = this.$set(
response.data.reboot.links.self.href; this.systemActionLinks,
"reboot",
response.data.reboot.links.self.href
);
} else { } else {
delete this.systemActionLinks.reboot; delete this.systemActionLinks.reboot;
} }
if ("shutdown" in response.data) { if ("shutdown" in response.data) {
this.systemActionLinks.shutdown = this.$set(
response.data.shutdown.links.self.href; this.systemActionLinks,
"shutdown",
response.data.shutdown.links.self.href
);
} else { } else {
delete this.systemActionLinks.shutdown; delete this.systemActionLinks.shutdown;
} }
@ -177,11 +183,11 @@ export default {
if ("shutdown" in this.systemActionLinks) { if ("shutdown" in this.systemActionLinks) {
axios axios
.post(this.systemActionLinks.shutdown) .post(this.systemActionLinks.shutdown)
.then(() => {
this.$store.commit("resetState");
})
.catch(error => { .catch(error => {
this.modalError(error); // Let mixin handle error this.modalError(error); // Let mixin handle error
})
.finally(() => {
this.$store.commit("resetState");
}); });
} }
}, },
@ -194,11 +200,11 @@ export default {
if ("reboot" in this.systemActionLinks) { if ("reboot" in this.systemActionLinks) {
axios axios
.post(this.systemActionLinks.reboot) .post(this.systemActionLinks.reboot)
.then(() => {
this.$store.commit("resetState");
})
.catch(error => { .catch(error => {
this.modalError(error); // Let mixin handle error this.modalError(error); // Let mixin handle error
})
.finally(() => {
this.$store.commit("resetState");
}); });
} }
}, },