Add Policy
@@ -15,7 +15,73 @@
Description:
-
+
+
+
+
+ Active:
+
+
+
+
+
+ Clients:
+
+
+
+
+
+ No Results
+
+
+
+
+
+
+
+ Sites:
+
+
+
+
+
+ No Results
+
+
+
+
+
+
+
+ Agents:
+
+
+
+
+
+ No Results
+
+
+
+
@@ -34,7 +100,14 @@ export default {
data() {
return {
name: "",
- desc: ""
+ desc: "",
+ active: false,
+ selectedAgents: [],
+ selectedSites: [],
+ selectedClients: [],
+ clientOptions: [],
+ siteOptions: [],
+ agentOptions: [],
};
},
methods: {
@@ -45,22 +118,78 @@ export default {
}
this.$q.loading.show();
- let formData = new FormData();
- formData.append("name", this.name);
- formData.append("desc", this.desc);
- axios
- .post("/automation/policies/", formData)
+
+ let formData = {
+ name: this.name,
+ desc: this.desc,
+ active: this.active,
+ agents: this.selectedAgents.map(agent => agent.value),
+ sites: this.selectedSites.map(site => site.value),
+ clients: this.selectedClients.map(client => client.value)
+ };
+
+ axios.post("/automation/policies/", formData)
.then(r => {
this.$q.loading.hide();
this.$emit("close");
this.$emit("added");
- this.notifySuccess("Policy added! Edit the policy to add Checks!");
+ this.notifySuccess("Policy added! Now you can add Tasks and Checks!");
})
.catch(e => {
this.$q.loading.hide();
this.notifyError(e.response.data);
});
- }
+ },
+ getClients() {
+
+ axios.get(`/clients/listclients/`).then(r => {
+ this.clientOptions = r.data.map(client => {
+ return {
+ label: client.client,
+ value: client.id
+ }
+ });
+ })
+ .catch(e => {
+ this.$q.loading.hide();
+ this.notifyError(e.response.data);
+ });
+ },
+ getSites() {
+
+ axios.get(`/clients/listsites/`).then(r => {
+ this.siteOptions = r.data.map(site => {
+ return {
+ label: `${site.client_name}\\${site.site}`,
+ value: site.id
+ }
+ });
+ })
+ .catch(e => {
+ this.$q.loading.hide();
+ this.notifyError(e.response.data);
+ });
+ },
+ getAgents() {
+
+ axios.get(`/agents/listagents/`).then(r => {
+ this.agentOptions = r.data.map(agent => {
+ return {
+ label: `${agent.client}\\${agent.site}\\${agent.hostname}`,
+ value: agent.pk
+ }
+ });
+ })
+ .catch(e => {
+ this.$q.loading.hide();
+ this.notifyError(e.response.data);
+ });
+ },
+ },
+ created() {
+ this.getClients();
+ this.getSites();
+ this.getAgents();
}
};
\ No newline at end of file
diff --git a/src/components/modals/automation/EditPolicy.vue b/src/components/modals/automation/EditPolicy.vue
index 8810fc2..cf7e813 100644
--- a/src/components/modals/automation/EditPolicy.vue
+++ b/src/components/modals/automation/EditPolicy.vue
@@ -1,5 +1,5 @@
-
+
Edit Policy
@@ -15,7 +15,73 @@
Description:
-
+
+
+
+
+ Active:
+
+
+
+
+
+ Clients:
+
+
+
+
+
+ No Results
+
+
+
+
+
+
+
+ Sites:
+
+
+
+
+
+ No Results
+
+
+
+
+
+
+
+ Agents:
+
+
+
+
+
+ No Results
+
+
+
+
@@ -37,15 +103,41 @@ export default {
return {
name: "",
desc: "",
- associations: []
+ active: false,
+ selectedAgents: [],
+ selectedSites: [],
+ selectedClients: [],
+ clientOptions: [],
+ siteOptions: [],
+ agentOptions: [],
};
},
methods: {
getPolicy() {
axios.get(`/automation/policies/${this.pk}/`).then(r => {
+
this.name = r.data.name;
this.desc = r.data.desc;
- })
+ this.active = r.data.active;
+ this.selectedAgents = r.data.agents.map(agent => {
+ return {
+ label: agent.hostname,
+ value: agent.pk
+ }
+ });
+ this.selectedSites = r.data.sites.map(site => {
+ return {
+ label: site.site,
+ value: site.id
+ }
+ });
+ this.selectedClients = r.data.clients.map(client => {
+ return {
+ label: client.client,
+ value: client.id
+ }
+ });
+ });
},
editPolicy() {
if (!this.name) {
@@ -54,10 +146,15 @@ export default {
}
this.$q.loading.show();
- let formData = new FormData();
- formData.append("name", this.name);
- formData.append("desc", this.desc);
+ let formData = {
+ name: this.name,
+ desc: this.desc,
+ active: this.active,
+ agents: this.selectedAgents.map(agent => agent.value),
+ sites: this.selectedSites.map(site => site.value),
+ clients: this.selectedClients.map(client => client.value)
+ }
axios.put(`/automation/policies/${this.pk}/`, formData)
.then(r => {
@@ -70,10 +167,58 @@ export default {
this.$q.loading.hide();
this.notifyError(e.response.data);
});
- }
+ },
+ getClients() {
+
+ axios.get(`/clients/listclients/`).then(r => {
+ this.clientOptions = r.data.map(client => {
+ return {
+ label: client.client,
+ value: client.id
+ }
+ });
+ })
+ .catch(e => {
+ this.$q.loading.hide();
+ this.notifyError(e.response.data);
+ });
+ },
+ getSites() {
+
+ axios.get(`/clients/listsites/`).then(r => {
+ this.siteOptions = r.data.map(site => {
+ return {
+ label: `${site.client_name}\\${site.site}`,
+ value: site.id
+ }
+ });
+ })
+ .catch(e => {
+ this.$q.loading.hide();
+ this.notifyError(e.response.data);
+ });
+ },
+ getAgents() {
+
+ axios.get(`/agents/listagents/`).then(r => {
+ this.agentOptions = r.data.map(agent => {
+ return {
+ label: `${agent.client}\\${agent.site}\\${agent.hostname}`,
+ value: agent.pk
+ }
+ });
+ })
+ .catch(e => {
+ this.$q.loading.hide();
+ this.notifyError(e.response.data);
+ });
+ },
},
created() {
this.getPolicy();
+ this.getClients();
+ this.getSites();
+ this.getAgents();
}
};
\ No newline at end of file
diff --git a/src/components/modals/automation/PolicyOverview.vue b/src/components/modals/automation/PolicyOverview.vue
index 3dfec97..e07fb6a 100644
--- a/src/components/modals/automation/PolicyOverview.vue
+++ b/src/components/modals/automation/PolicyOverview.vue
@@ -1,7 +1,166 @@
- Policy Overview
+
+
+ Policy Overview
+
+
+ Close
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ List Checks
+
+
+ List Tasks
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/modals/checks/AddCpuLoadCheck.vue b/src/components/modals/checks/AddCpuLoadCheck.vue
index ef7b78b..cd264ba 100644
--- a/src/components/modals/checks/AddCpuLoadCheck.vue
+++ b/src/components/modals/checks/AddCpuLoadCheck.vue
@@ -42,7 +42,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddCpuLoadCheck",
- props: ["agentpk"],
+ props: ["agentpk", "policypk"],
mixins: [mixins],
data() {
return {
@@ -53,8 +53,10 @@ export default {
},
methods: {
addCheck() {
+ pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
+
const data = {
- pk: this.agentpk,
+ pk,
check_type: "cpuload",
threshold: this.threshold,
failure: this.failure
@@ -63,7 +65,13 @@ export default {
.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");
- this.$store.dispatch("loadChecks", this.agentpk);
+
+ if (this.policypk) {
+ this.$store.dispatch("loadPolicyChecks", this.policypk);
+ } else {
+ this.$store.dispatch("loadChecks", this.agentpk);
+ }
+
this.notifySuccess("CPU load check was added!");
})
.catch(e => this.notifyError(e.response.data.error));
diff --git a/src/components/modals/checks/AddPingCheck.vue b/src/components/modals/checks/AddPingCheck.vue
index 24250f2..4a0b6b4 100644
--- a/src/components/modals/checks/AddPingCheck.vue
+++ b/src/components/modals/checks/AddPingCheck.vue
@@ -45,7 +45,7 @@ import { mapState } from "vuex";
import mixins from "@/mixins/mixins";
export default {
name: "AddPingCheck",
- props: ["agentpk"],
+ props: ["agentpk", "policypk"],
mixins: [mixins],
data() {
return {
@@ -57,21 +57,32 @@ export default {
},
methods: {
addCheck() {
+ let pk = (this.policypk) ? {policy: this.policypk} : {pk: this.agentpk}
+
const data = {
- pk: this.agentpk,
+ ...pk,
check_type: "ping",
failures: this.failure,
name: this.pingname,
ip: this.pingip,
};
- axios
- .post("/checks/addstandardcheck/", data)
+
+ axios.post("/checks/addstandardcheck/", data)
.then(r => {
this.$emit("close");
- this.$store.dispatch("loadChecks", this.agentpk);
+
+ if (this.policypk) {
+ this.$store.dispatch("loadPolicyChecks", this.policypk);
+ } else {
+ this.$store.dispatch("loadChecks", this.agentpk);
+ }
+
this.notifySuccess("Ping check was added!");
})
- .catch(e => this.notifyError(e.response.data.error));
+ .catch(e => {
+ this.notifyError(e.response.data);
+ console.log(e.response.data)
+ });
}
}
};
diff --git a/src/store/store.js b/src/store/store.js
index c1953a0..fd5257c 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -24,6 +24,8 @@ export const store = new Vuex.Store({
winUpdates: {},
agentChecks: {},
automatedTasks: {},
+ selectedPolicy: null,
+ policyChecks: {},
agentTableLoading: false,
treeLoading: false,
installedSoftware: [],
@@ -108,6 +110,9 @@ export const store = new Vuex.Store({
SET_AUTOMATED_TASKS(state, tasks) {
state.automatedTasks = tasks;
},
+ setPolicyChecks(state, checks) {
+ state.policyChecks = checks;
+ },
destroySubTable(state) {
(state.agentSummary = {}),
(state.agentChecks = {}),
@@ -120,7 +125,10 @@ export const store = new Vuex.Store({
},
SET_POLICIES(state, policies) {
state.policies = policies;
- }
+ },
+ setSelectedPolicy(state, pk) {
+ state.selectedPolicy = pk;
+ },
},
actions: {
getPolicies(context) {
@@ -158,6 +166,11 @@ export const store = new Vuex.Store({
context.commit("setChecks", r.data);
});
},
+ loadPolicyChecks(context, pk) {
+ axios.get(`/checks/${pk}/loadpolicychecks/`).then(r => {
+ context.commit("setPolicyChecks", r.data);
+ });
+ },
getUpdatedSites(context) {
axios.get("/clients/loadclients/").then(r => {
context.commit("getUpdatedSites", r.data);