cleanup some mixins UI

This commit is contained in:
wh1te909
2020-04-11 08:29:56 +00:00
parent 95e3d6287f
commit 2d5a44c894
3 changed files with 26 additions and 59 deletions

View File

@@ -363,27 +363,13 @@ export default {
})
.onOk(hostnameConfirm => {
if (hostnameConfirm !== hostname) {
this.$q.notify({
message: "ERROR: Please type the correct hostname",
color: "red"
});
this.notifyError("ERROR: Please type the correct hostname");
} else {
const data = { pk: pk };
axios
.delete("/agents/uninstallagent/", { data: data })
.then(r => {
this.$q.notify({
message: `${hostname} will now be uninstalled!`,
color: "green"
});
})
.catch(e => {
this.$q.notify({
message: e.response.data.error,
color: "info",
timeout: 4000
});
});
.then(r => this.notifySuccess(`${hostname} will now be uninstalled!`))
.catch(e => this.notifyInfo(e.response.data.error));
}
});
});
@@ -438,11 +424,7 @@ export default {
})
.catch(err => {
this.loadingSendCMD = false;
this.$q.notify({
color: "red",
icon: "fas fa-times-circle",
message: err.response.data
});
this.notifyError(err.response.data);
});
},
agentRowSelected(pk) {
@@ -469,9 +451,7 @@ export default {
message: `Overdue ${category} alerts ${action} on ${r.data}`
});
})
.catch(e => {
console.log(e.response.data.error);
});
.catch(e => this.notifyError(e.response.data.error));
},
agentClass(status) {
if (status === "offline") {

View File

@@ -163,6 +163,7 @@
<script>
import axios from "axios";
import mixins from "@/mixins/mixins";
export default {
name: "Services",
@@ -255,18 +256,10 @@ export default {
.then(r => {
this.serviceDetailsModal = false;
this.refreshServices();
this.$q.notify({
color: "green",
icon: "fas fa-check-circle",
message: `Service ${name} was edited!`
});
this.notifySuccess(`Service ${name} was edited!`);
})
.catch(err => {
this.$q.notify({
color: "red",
icon: "fas fa-times-circle",
message: err.response.data.error
});
this.notifyError(err.response.data.error);
});
},
startupTypeChanged() {
@@ -298,11 +291,7 @@ export default {
.catch(err => {
this.serviceDetailVisible = false;
this.serviceDetailsModal = false;
this.$q.notify({
color: "red",
icon: "fas fa-times-circle",
message: err.response.data.error
});
this.notifyError(err.response.data.error);
});
},
serviceAction(name, action, fullname) {
@@ -334,19 +323,11 @@ export default {
.then(r => {
this.refreshServices();
this.serviceDetailsModal = false;
this.$q.notify({
color: "green",
icon: "fas fa-check-circle",
message: `Service ${fullname} was ${status}!`
});
this.notifySuccess(`Service ${fullname} was ${status}!`);
})
.catch(err => {
this.$q.loading.hide();
this.$q.notify({
color: "red",
icon: "fas fa-times-circle",
message: err.response.data.error
});
this.notifyError(err.response.data.error);
});
},
async getServices() {
@@ -367,11 +348,7 @@ export default {
})
.catch(err => {
this.$q.loading.hide();
this.$q.notify({
color: "red",
icon: "fas fa-times-circle",
message: err.response.data.error
});
this.notifyError(err.response.data.error);
});
}
},

View File

@@ -27,15 +27,25 @@ export default {
},
notifySuccess(msg) {
Notify.create({
color: "green",
icon: "fas fa-check-circle",
type: "positive",
message: msg
});
},
notifyError(msg) {
Notify.create({
color: "red",
icon: "fas fa-times-circle",
type: "negative",
message: msg
});
},
notifyWarning(msg) {
Notify.create({
type: "warning",
message: msg
});
},
notifyInfo(msg) {
Notify.create({
type: "info",
message: msg
});
}