implement scheduled reboot

This commit is contained in:
wh1te909
2020-05-16 21:09:03 +00:00
parent 6b418c09d5
commit f7a9077eb2
3 changed files with 98 additions and 15 deletions

View File

@@ -163,7 +163,7 @@
clickable
v-ripple
v-close-popup
@click.stop.prevent="rebootLater(props.row.id, props.row.hostname)"
@click.stop.prevent="showRebootLaterModal = true"
>
<q-item-section>Later</q-item-section>
</q-item>
@@ -295,6 +295,10 @@
<q-dialog v-model="showEditAgentModal">
<EditAgent @close="showEditAgentModal = false" @edited="agentEdited" />
</q-dialog>
<!-- reboot later modal -->
<q-dialog v-model="showRebootLaterModal">
<RebootLater @close="showRebootLaterModal = false" />
</q-dialog>
</div>
</template>
@@ -302,10 +306,11 @@
import axios from "axios";
import mixins from "@/mixins/mixins";
import EditAgent from "@/components/modals/agents/EditAgent";
import RebootLater from "@/components/modals/agents/RebootLater";
export default {
name: "AgentTable",
props: ["frame", "columns", "tab", "filter", "userName"],
components: { EditAgent },
components: { EditAgent, RebootLater },
mixins: [mixins],
data() {
return {
@@ -319,7 +324,8 @@ export default {
sendCommandHostname: "",
rawCMD: "",
loadingSendCMD: false,
showEditAgentModal: false
showEditAgentModal: false,
showRebootLaterModal: false
};
},
methods: {
@@ -402,10 +408,6 @@ export default {
});
});
},
rebootLater() {
// TODO implement this
console.log("reboot later");
},
toggleSendCommand(pk, hostname) {
this.sendCommandToggle = true;
this.sendCommandID = pk;

View File

@@ -0,0 +1,77 @@
<template>
<q-card style="min-width: 400px" class="q-pa-xs">
<q-card-section>
<div class="row items-center">
<div class="text-h6">Schedule a reboot</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</div>
</q-card-section>
<q-card-section>
<q-input filled v-model="datetime">
<template v-slot:prepend>
<q-icon name="event" class="cursor-pointer">
<q-popup-proxy transition-show="scale" transition-hide="scale">
<q-date v-model="datetime" mask="YYYY-MM-DD HH:mm" />
</q-popup-proxy>
</q-icon>
</template>
<template v-slot:append>
<q-icon name="access_time" class="cursor-pointer">
<q-popup-proxy transition-show="scale" transition-hide="scale">
<q-time v-model="datetime" mask="YYYY-MM-DD HH:mm" />
</q-popup-proxy>
</q-icon>
</template>
</q-input>
</q-card-section>
<q-card-actions align="left">
<q-btn dense label="Schedule Reboot" color="primary" @click="scheduleReboot" />
</q-card-actions>
</q-card>
</template>
<script>
import axios from "axios";
import { mapGetters } from "vuex";
import mixins from "@/mixins/mixins";
import { date } from "quasar";
export default {
name: "RebootLater",
mixins: [mixins],
data() {
return {
datetime: null
};
},
methods: {
scheduleReboot() {
this.$q.loading.show();
const data = { pk: this.selectedAgentPk, datetime: this.datetime };
axios
.post("/agents/rebootlater/", data)
.then(r => {
this.$q.loading.hide();
this.$emit("close");
this.notifySuccess(r.data, 5000);
})
.catch(e => {
this.$q.loading.hide();
this.notifyError(e.response.data);
});
},
getCurrentDate() {
let timeStamp = Date.now();
this.datetime = date.formatDate(timeStamp, "YYYY-MM-DD HH:mm");
}
},
computed: {
...mapGetters(["selectedAgentPk"])
},
created() {
this.getCurrentDate();
}
};
</script>

View File

@@ -25,28 +25,32 @@ export default {
return Math.round(elapsed / msPerYear) + " years ago";
}
},
notifySuccess(msg) {
notifySuccess(msg, timeout = 2000) {
Notify.create({
type: "positive",
message: msg
message: msg,
timeout: timeout
});
},
notifyError(msg) {
notifyError(msg, timeout = 2000) {
Notify.create({
type: "negative",
message: msg
message: msg,
timeout: timeout
});
},
notifyWarning(msg) {
notifyWarning(msg, timeout = 2000) {
Notify.create({
type: "warning",
message: msg
message: msg,
timeout: timeout
});
},
notifyInfo(msg) {
notifyInfo(msg, timeout = 2000) {
Notify.create({
type: "info",
message: msg
message: msg,
timeout: timeout
});
}
}