mirror of
https://github.com/jpros/tacticalrmm-web.git
synced 2026-05-01 20:16:19 +00:00
fix policy winsvc checks
This commit is contained in:
@@ -85,7 +85,7 @@
|
||||
</div>
|
||||
<q-separator />
|
||||
<q-card-section>
|
||||
<PolicySubTableTabs />
|
||||
<PolicySubTableTabs :policypk="policyPkSelected" />
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
@@ -119,6 +119,7 @@ export default {
|
||||
showAddPolicyModal: false,
|
||||
showEditPolicyModal: false,
|
||||
showPolicyOverviewModal: false,
|
||||
policyPkSelected: null,
|
||||
pagination: {
|
||||
rowsPerPage: 0,
|
||||
sortBy: "id",
|
||||
@@ -184,6 +185,7 @@ export default {
|
||||
this.$store.commit('automation/setSelectedPolicy', pk);
|
||||
this.$store.dispatch('automation/loadPolicyChecks', pk);
|
||||
this.$store.dispatch('automation/loadPolicyAutomatedTasks', pk);
|
||||
this.policyPkSelected = pk;
|
||||
},
|
||||
clearRow () {
|
||||
this.$store.commit('automation/setSelectedPolicy', null);
|
||||
|
||||
@@ -257,6 +257,7 @@ import EditScriptCheck from "@/components/modals/checks/EditScriptCheck";
|
||||
|
||||
export default {
|
||||
name: "PolicyChecksTab",
|
||||
props: ["policypk"],
|
||||
components: {
|
||||
AddDiskSpaceCheck,
|
||||
EditDiskSpaceCheck,
|
||||
@@ -383,7 +384,7 @@ export default {
|
||||
axios
|
||||
.delete("checks/deletestandardcheck/", { data: data })
|
||||
.then(r => {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.checks.pk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
this.notifySuccess("Check was deleted!");
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.error));
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<q-separator />
|
||||
<q-tab-panels v-model="subtab" :animated="false">
|
||||
<q-tab-panel name="checks">
|
||||
<PolicyChecksTab />
|
||||
<PolicyChecksTab :policypk="policypk" />
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="tasks">
|
||||
<PolicyAutomatedTasksTab />
|
||||
@@ -32,6 +32,7 @@ import PolicyAutomatedTasksTab from '@/components/automation/PolicyAutomatedTask
|
||||
|
||||
export default {
|
||||
name: "PolicySubTableTabs",
|
||||
props: ["policypk"],
|
||||
components: {
|
||||
PolicyChecksTab,
|
||||
PolicyAutomatedTasksTab,
|
||||
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,56 @@
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Add Windows Service Check</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
<q-btn
|
||||
icon="close"
|
||||
flat
|
||||
round
|
||||
dense
|
||||
v-close-popup
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
<q-form @submit.prevent="addCheck">
|
||||
<q-card-section>
|
||||
<q-radio
|
||||
v-if="policypk"
|
||||
v-model="serviceType"
|
||||
val="svcdefault"
|
||||
label="Choose from defaults"
|
||||
@input="manualServiceName = null; manualSvcDisplayName = null; displayName = null"
|
||||
/>
|
||||
<q-radio
|
||||
v-if="policypk"
|
||||
v-model="serviceType"
|
||||
val="svcmanual"
|
||||
label="Enter manually"
|
||||
@input="manualServiceName = null; manualSvcDisplayName = null; displayName = null"
|
||||
/>
|
||||
<q-select
|
||||
v-if="policypk && serviceType === 'svcdefault'"
|
||||
dense
|
||||
outlined
|
||||
v-model="displayName"
|
||||
:options="svcDisplayNames"
|
||||
label="Service"
|
||||
@input="getRawName"
|
||||
/>
|
||||
<q-input
|
||||
v-if="policypk && serviceType === 'svcmanual'"
|
||||
outlined
|
||||
dense
|
||||
v-model="manualServiceName"
|
||||
label="Service Name"
|
||||
/>
|
||||
<q-input
|
||||
v-if="policypk && serviceType === 'svcmanual'"
|
||||
outlined
|
||||
dense
|
||||
v-model="manualSvcDisplayName"
|
||||
label="Display Name"
|
||||
/>
|
||||
<q-select
|
||||
v-if="agentpk"
|
||||
:rules="[val => !!val || '*Required']"
|
||||
dense
|
||||
outlined
|
||||
@@ -23,7 +67,10 @@
|
||||
v-model="passIfStartPending"
|
||||
label="PASS if service is in 'Start Pending' mode"
|
||||
/>
|
||||
<q-checkbox v-model="restartIfStopped" label="RESTART service if it's stopped" />
|
||||
<q-checkbox
|
||||
v-model="restartIfStopped"
|
||||
label="RESTART service if it's stopped"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
@@ -35,8 +82,15 @@
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn label="Add" color="primary" type="submit" />
|
||||
<q-btn label="Cancel" v-close-popup />
|
||||
<q-btn
|
||||
label="Add"
|
||||
color="primary"
|
||||
type="submit"
|
||||
/>
|
||||
<q-btn
|
||||
label="Cancel"
|
||||
v-close-popup
|
||||
/>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
@@ -52,6 +106,9 @@ export default {
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
serviceType: "svcdefault",
|
||||
manualServiceName: "",
|
||||
manualSvcDisplayName: "",
|
||||
servicesData: [],
|
||||
displayName: "",
|
||||
rawName: [],
|
||||
@@ -67,12 +124,15 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getServices() {
|
||||
try {
|
||||
let r = await axios.get(`/services/policies/`);
|
||||
this.servicesData = Object.freeze([r.data][0].services);
|
||||
} catch (e) {
|
||||
console.log(`ERROR!: ${e}`);
|
||||
getServices() {
|
||||
if (this.policypk) {
|
||||
axios.get("/services/getdefaultservices/").then(r => {
|
||||
this.servicesData = Object.freeze(r.data);
|
||||
});
|
||||
} else {
|
||||
axios.get(`/services/${this.agentpk}/services/`).then(r => {
|
||||
this.servicesData = Object.freeze([r.data][0].services);
|
||||
});
|
||||
}
|
||||
},
|
||||
getRawName() {
|
||||
@@ -82,29 +142,46 @@ export default {
|
||||
this.rawName = [svc].map(j => j.name);
|
||||
},
|
||||
addCheck() {
|
||||
const pk = (this.policypk) ? { policy: this.policypk } : { pk: this.agentpk }
|
||||
|
||||
pk = (this.policypk) ? {policy: policypk} : {pk: agentpk}
|
||||
let rawname, displayname;
|
||||
|
||||
if (this.policypk) {
|
||||
// policy
|
||||
if (this.serviceType === 'svcdefault') {
|
||||
rawname = { rawname: this.rawName[0] }
|
||||
displayname = { displayname: this.displayName }
|
||||
if (this.rawName.length === 0) { this.notifyError("Please select a service"); return; }
|
||||
} else if (this.serviceType === 'svcmanual') {
|
||||
rawname = { rawname: this.manualServiceName }
|
||||
displayname = { displayname: this.manualSvcDisplayName }
|
||||
if (!this.manualServiceName || !this.manualSvcDisplayName) { this.notifyError("All fields required"); return; }
|
||||
}
|
||||
} else {
|
||||
// agent
|
||||
rawname = { rawname: this.rawName[0] }
|
||||
displayname = { displayname: this.displayName }
|
||||
}
|
||||
|
||||
const data = {
|
||||
...pk,
|
||||
check_type: "winsvc",
|
||||
displayname: this.displayName,
|
||||
rawname: this.rawName[0],
|
||||
...rawname,
|
||||
...displayname,
|
||||
passifstartpending: this.passIfStartPending,
|
||||
restartifstopped: this.restartIfStopped,
|
||||
failures: this.failure
|
||||
};
|
||||
|
||||
axios
|
||||
.post("/checks/addstandardcheck/", data)
|
||||
.then(r => {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
this.notifySuccess(`${data.displayname} service check added!`);
|
||||
})
|
||||
.catch(e => this.notifyError(e.response.data.error));
|
||||
|
||||
@@ -73,7 +73,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import { mapState } from "vuex";
|
||||
import mixins from "@/mixins/mixins";
|
||||
export default {
|
||||
name: "EditWinSvcCheck",
|
||||
props: ["agentpk", "editCheckPK"],
|
||||
props: ["agentpk", "editCheckPK", "policypk"],
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
this.$emit("close");
|
||||
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("loadPolicyChecks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ export const store = new Vuex.Store({
|
||||
id: sites_arr[i].split("|")[1],
|
||||
raw: sites_arr[i],
|
||||
header: "generic",
|
||||
icon: "fas fa-map-marker-alt",
|
||||
icon: "business",
|
||||
iconColor: sites_arr[i].split("|")[2]
|
||||
});
|
||||
}
|
||||
@@ -181,7 +181,7 @@ export const store = new Vuex.Store({
|
||||
id: prop.split("|")[1],
|
||||
raw: prop,
|
||||
header: "root",
|
||||
icon: "fas fa-user",
|
||||
icon: "apartment",
|
||||
iconColor: prop.split("|")[2],
|
||||
children: child_single
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user