mirror of
https://github.com/jpros/tacticalrmm-web.git
synced 2026-02-21 11:51:08 +00:00
migrations fix and finishing up automation manager rework
This commit is contained in:
@@ -217,7 +217,7 @@
|
||||
</q-menu>
|
||||
</q-item>
|
||||
|
||||
<q-item clickable v-close-popup @click.stop.prevent="showPolicyAdd(props.row.id)">
|
||||
<q-item clickable v-close-popup @click.stop.prevent="showPolicyAdd(props.row)">
|
||||
<q-item-section side>
|
||||
<q-icon size="xs" name="policy" />
|
||||
</q-item-section>
|
||||
@@ -339,10 +339,6 @@
|
||||
<PendingActions :agentpk="pendingActionAgentPk" @close="closePendingActionsModal" @edited="agentEdited" />
|
||||
</q-dialog>
|
||||
</div>
|
||||
<!-- add policy modal -->
|
||||
<q-dialog v-model="showPolicyAddModal">
|
||||
<PolicyAdd @close="showPolicyAddModal = false" type="agent" :pk="policyAddPk" />
|
||||
</q-dialog>
|
||||
<!-- send command modal -->
|
||||
<q-dialog v-model="showSendCommand">
|
||||
<SendCommand @close="showSendCommand = false" :pk="selectedAgentPk" />
|
||||
@@ -379,7 +375,6 @@ export default {
|
||||
EditAgent,
|
||||
RebootLater,
|
||||
PendingActions,
|
||||
PolicyAdd,
|
||||
SendCommand,
|
||||
AgentRecovery,
|
||||
RunScript,
|
||||
@@ -395,10 +390,8 @@ export default {
|
||||
showSendCommand: false,
|
||||
showEditAgentModal: false,
|
||||
showRebootLaterModal: false,
|
||||
showPolicyAddModal: false,
|
||||
showAgentRecovery: false,
|
||||
showRunScript: false,
|
||||
policyAddPk: null,
|
||||
showPendingActions: false,
|
||||
pendingActionAgentPk: null,
|
||||
favoriteScripts: [],
|
||||
@@ -671,9 +664,13 @@ export default {
|
||||
return "agent-normal";
|
||||
}
|
||||
},
|
||||
showPolicyAdd(pk) {
|
||||
this.policyAddPk = pk;
|
||||
this.showPolicyAddModal = true;
|
||||
showPolicyAdd(agent) {
|
||||
this.$q.dialog({
|
||||
component: PolicyAdd,
|
||||
parent: this,
|
||||
type: "agent",
|
||||
object: agent,
|
||||
});
|
||||
},
|
||||
toggleMaintenance(agent) {
|
||||
let data = {
|
||||
|
||||
@@ -15,26 +15,26 @@
|
||||
<q-btn
|
||||
ref="edit"
|
||||
label="Edit"
|
||||
:disable="selected.length === 0"
|
||||
:disable="!selectedTemplate"
|
||||
dense
|
||||
flat
|
||||
push
|
||||
unelevated
|
||||
no-caps
|
||||
icon="edit"
|
||||
@click="showEditTemplateModal(selected[0])"
|
||||
@click="showEditTemplateModal(selectedTemplate)"
|
||||
/>
|
||||
<q-btn
|
||||
ref="delete"
|
||||
label="Delete"
|
||||
:disable="selected.length === 0"
|
||||
:disable="!selectedTemplate"
|
||||
dense
|
||||
flat
|
||||
push
|
||||
unelevated
|
||||
no-caps
|
||||
icon="delete"
|
||||
@click="deleteTemplate(selected[0])"
|
||||
@click="deleteTemplate(selectedTemplate)"
|
||||
/>
|
||||
</div>
|
||||
<q-table
|
||||
@@ -60,13 +60,13 @@
|
||||
|
||||
<template v-slot:header-cell-email_severity="props">
|
||||
<q-th :props="props" auto-width>
|
||||
{{ props.name }}
|
||||
{{ props.col.label }}
|
||||
</q-th>
|
||||
</template>
|
||||
|
||||
<template v-slot:header-cell-text_severity="props">
|
||||
<q-th :props="props" auto-width>
|
||||
{{ props.name }}
|
||||
{{ props.col.label }}
|
||||
</q-th>
|
||||
</template>
|
||||
<!-- body slots -->
|
||||
@@ -74,9 +74,9 @@
|
||||
<q-tr
|
||||
:props="props"
|
||||
class="cursor-pointer"
|
||||
:class="rowSelectedClass(props.row.id, selected)"
|
||||
@click="selected = props.row"
|
||||
@contextmenu="selected = props.row"
|
||||
:class="rowSelectedClass(props.row.id, selectedTemplate)"
|
||||
@click="selectedTemplate = props.row"
|
||||
@contextmenu="selectedTemplate = props.row"
|
||||
>
|
||||
<!-- context menu -->
|
||||
<q-menu context-menu>
|
||||
@@ -173,7 +173,7 @@ export default {
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
selected: [],
|
||||
selectedTemplate: null,
|
||||
templates: [],
|
||||
columns: [
|
||||
{ name: "is_active", label: "Active", field: "is_active", align: "left" },
|
||||
@@ -225,7 +225,7 @@ export default {
|
||||
});
|
||||
},
|
||||
clearRow() {
|
||||
this.selected = [];
|
||||
this.selectedTemplate = null;
|
||||
},
|
||||
refresh() {
|
||||
this.getTemplates();
|
||||
@@ -292,8 +292,8 @@ export default {
|
||||
this.notifyError("An Error occured while editing the template");
|
||||
});
|
||||
},
|
||||
rowSelectedClass(id, selected) {
|
||||
if (selected.length !== 0 && selected[0].id === id) return this.$q.dark.isActive ? "highlight-dark" : "highlight";
|
||||
rowSelectedClass(id, selectedTemplate) {
|
||||
if (selectedTemplate && selectedTemplate.id === id) return this.$q.dark.isActive ? "highlight-dark" : "highlight";
|
||||
},
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<q-dialog ref="dialog" @hide="onHide">
|
||||
<div class="q-dialog-plugin" style="min-width: 90vw; max-width: 90vw">
|
||||
<div class="q-dialog-plugin" style="width: 90vw; max-width: 90vw">
|
||||
<q-card>
|
||||
<q-bar>
|
||||
<q-btn ref="refresh" @click="refresh" class="q-mr-sm" dense flat push icon="refresh" />Automation Manager
|
||||
@@ -11,9 +11,8 @@
|
||||
</q-bar>
|
||||
<div class="q-pa-md">
|
||||
<div class="q-gutter-sm">
|
||||
<q-btn ref="new" label="New" dense flat push unelevated no-caps icon="add" @click="showAddPolicyForm" />
|
||||
<q-btn label="New" dense flat push unelevated no-caps icon="add" @click="showAddPolicyForm" />
|
||||
<q-btn
|
||||
ref="edit"
|
||||
label="Edit"
|
||||
:disable="!selectedPolicy"
|
||||
dense
|
||||
@@ -25,7 +24,6 @@
|
||||
@click="showEditPolicyForm(selectedPolicy)"
|
||||
/>
|
||||
<q-btn
|
||||
ref="delete"
|
||||
label="Delete"
|
||||
:disable="!selectedPolicy"
|
||||
dense
|
||||
@@ -37,7 +35,6 @@
|
||||
@click="deletePolicy(selectedPolicy)"
|
||||
/>
|
||||
<q-btn
|
||||
ref="overview"
|
||||
label="Policy Overview"
|
||||
dense
|
||||
flat
|
||||
@@ -49,17 +46,18 @@
|
||||
/>
|
||||
</div>
|
||||
<q-table
|
||||
style="max-height: 35vh"
|
||||
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
||||
class="tabs-tbl-sticky"
|
||||
:data="policies"
|
||||
:columns="columns"
|
||||
:pagination.sync="pagination"
|
||||
:rows-per-page-options="[0]"
|
||||
dense
|
||||
row-key="id"
|
||||
binary-state-sort
|
||||
hide-pagination
|
||||
virtual-scroll
|
||||
dense
|
||||
flat
|
||||
:rows-per-page-options="[0]"
|
||||
no-data-label="No Policies"
|
||||
>
|
||||
<!-- header slots -->
|
||||
@@ -84,6 +82,7 @@
|
||||
<q-tr
|
||||
:props="props"
|
||||
class="cursor-pointer"
|
||||
:class="rowSelectedClass(props.row.id, selectedPolicy)"
|
||||
@click="selectedPolicy = props.row"
|
||||
@contextmenu="selectedPolicy = props.row"
|
||||
>
|
||||
@@ -97,7 +96,7 @@
|
||||
<q-item-section>Edit</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-item clickable v-close-popup @click="showAddPolicyForm(props.row)">
|
||||
<q-item clickable v-close-popup @click="showCopyPolicyForm(props.row)">
|
||||
<q-item-section side>
|
||||
<q-icon name="content_copy" />
|
||||
</q-item-section>
|
||||
@@ -184,7 +183,7 @@
|
||||
>
|
||||
</q-td>
|
||||
<q-td>
|
||||
<q-icon name="content_copy" size="1.5em" @click="showAddPolicyForm(props.row)">
|
||||
<q-icon name="content_copy" size="1.5em" @click="showCopyPolicyForm(props.row)">
|
||||
<q-tooltip>Create a copy of this policy</q-tooltip>
|
||||
</q-icon>
|
||||
</q-td>
|
||||
@@ -211,10 +210,10 @@
|
||||
<q-separator />
|
||||
<q-tab-panels v-model="subtab" :animated="false">
|
||||
<q-tab-panel name="checks">
|
||||
<PolicyChecksTab :selectedPolicy="selectedPolicy" />
|
||||
<PolicyChecksTab v-if="!!selectedPolicy" :selectedPolicy="selectedPolicy.id" />
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="tasks">
|
||||
<PolicyAutomatedTasksTab :selectedPolicy="selectedPolicy" />
|
||||
<PolicyAutomatedTasksTab v-if="!!selectedPolicy" :selectedPolicy="selectedPolicy.id" />
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card-section>
|
||||
@@ -293,10 +292,17 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getPolicies() {
|
||||
this.$axios.get("/automation/policies/").then(r => {
|
||||
console.log(r.data);
|
||||
this.policies = r.data;
|
||||
});
|
||||
this.$q.loading.show();
|
||||
this.$axios
|
||||
.get("/automation/policies/")
|
||||
.then(r => {
|
||||
this.policies = r.data;
|
||||
this.$q.loading.hide();
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("Unable to get policies");
|
||||
});
|
||||
},
|
||||
clearRow() {
|
||||
this.selectedPolicy = null;
|
||||
@@ -336,7 +342,17 @@ export default {
|
||||
parent: this,
|
||||
});
|
||||
},
|
||||
showAddPolicyForm(policy) {
|
||||
showAddPolicyForm(policy = undefined) {
|
||||
this.$q
|
||||
.dialog({
|
||||
component: PolicyForm,
|
||||
parent: this,
|
||||
})
|
||||
.onOk(() => {
|
||||
this.refresh();
|
||||
});
|
||||
},
|
||||
showCopyPolicyForm(policy = undefined) {
|
||||
this.$q
|
||||
.dialog({
|
||||
component: PolicyForm,
|
||||
@@ -386,6 +402,7 @@ export default {
|
||||
});
|
||||
},
|
||||
toggleCheckbox(policy, type) {
|
||||
this.$q.loading.show();
|
||||
let text = "";
|
||||
|
||||
if (type === "Active") {
|
||||
@@ -405,18 +422,23 @@ export default {
|
||||
this.$axios
|
||||
.put(`/automation/policies/${data.id}/`, data)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.notifySuccess(text);
|
||||
})
|
||||
.catch(error => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("An Error occured while editing policy");
|
||||
});
|
||||
},
|
||||
patchPolicyText(policy) {
|
||||
return policy.winupdatepolicy.length > 0 ? "Show Patch Policy" : "Create Patch Policy";
|
||||
return policy.winupdatepolicy.length > 0 ? "Modify Patch Policy" : "Create Patch Policy";
|
||||
},
|
||||
alertTemplateText(policy) {
|
||||
return policy.alert_template ? "Modify Alert Template" : "Assign Alert Template";
|
||||
},
|
||||
rowSelectedClass(id, selectedPolicy) {
|
||||
if (selectedPolicy && selectedPolicy.id === id) return this.$q.dark.isActive ? "highlight-dark" : "highlight";
|
||||
},
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
},
|
||||
|
||||
@@ -2,87 +2,63 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<q-btn
|
||||
v-if="selectedPolicy !== null"
|
||||
v-if="!!selectedPolicy"
|
||||
size="sm"
|
||||
color="grey-5"
|
||||
icon="fas fa-plus"
|
||||
label="Add Task"
|
||||
text-color="black"
|
||||
ref="add"
|
||||
@click="showAddAutomatedTask = true"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="selectedPolicy !== null"
|
||||
dense
|
||||
flat
|
||||
push
|
||||
@click="refreshTasks(selectedPolicy)"
|
||||
icon="refresh"
|
||||
ref="refresh"
|
||||
@click="showAddTask = true"
|
||||
/>
|
||||
<q-btn v-if="!!selectedPolicy" dense flat push @click="getTasks" icon="refresh" />
|
||||
<template>
|
||||
<q-table
|
||||
dense
|
||||
style="max-height: 35vh"
|
||||
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
||||
class="tabs-tbl-sticky"
|
||||
style="max-height: 35vh"
|
||||
:data="tasks"
|
||||
:columns="columns"
|
||||
:rows-per-page-options="[0]"
|
||||
:pagination.sync="pagination"
|
||||
dense
|
||||
row-key="id"
|
||||
binary-state-sort
|
||||
:pagination.sync="pagination"
|
||||
hide-pagination
|
||||
virtual-scroll
|
||||
>
|
||||
<!-- No data Slot -->
|
||||
<template v-slot:no-data>
|
||||
<div class="full-width row flex-center q-gutter-sm">
|
||||
<span v-if="!selectedPolicy">Click on a policy to see the tasks</span>
|
||||
<span v-else>There are no tasks added to this policy</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- header slots -->
|
||||
<template v-slot:header-cell-enabled="props">
|
||||
<q-th auto-width :props="props">
|
||||
<small>Enabled</small>
|
||||
</q-th>
|
||||
</template>
|
||||
<!-- No data Slot -->
|
||||
<template v-slot:no-data>
|
||||
<div class="full-width row flex-center q-gutter-sm">
|
||||
<span v-if="selectedPolicy === null">Click on a policy to see the tasks</span>
|
||||
<span v-else>There are no tasks added to this policy</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- body slots -->
|
||||
<template v-slot:body="props" :props="props">
|
||||
<q-tr @contextmenu="editTaskPk = props.row.id">
|
||||
<!-- context menu -->
|
||||
<q-menu context-menu>
|
||||
<q-list dense style="min-width: 200px">
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="runTask(props.row.id, props.row.enabled)"
|
||||
id="context-runtask"
|
||||
>
|
||||
<q-item clickable v-close-popup @click="runTask(props.row.id, props.row.enabled)">
|
||||
<q-item-section side>
|
||||
<q-icon name="play_arrow" />
|
||||
</q-item-section>
|
||||
<q-item-section>Run task now</q-item-section>
|
||||
</q-item>
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="showEditAutomatedTask = true"
|
||||
id="context-edit"
|
||||
v-show="false"
|
||||
>
|
||||
<q-item-section side>
|
||||
<q-icon name="edit" />
|
||||
</q-item-section>
|
||||
<q-item-section>Edit</q-item-section>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="deleteTask(props.row.name, props.row.id)" id="context-delete">
|
||||
<q-item clickable v-close-popup @click="deleteTask(props.row.name, props.row.id)">
|
||||
<q-item-section side>
|
||||
<q-icon name="delete" />
|
||||
</q-item-section>
|
||||
<q-item-section>Delete</q-item-section>
|
||||
</q-item>
|
||||
<q-separator />
|
||||
<q-item clickable v-close-popup @click="showStatus(props.row)" id="context-status">
|
||||
<q-item clickable v-close-popup @click="showStatus(props.row)">
|
||||
<q-item-section side>
|
||||
<q-icon name="sync" />
|
||||
</q-item-section>
|
||||
@@ -120,40 +96,35 @@
|
||||
</template>
|
||||
</div>
|
||||
<!-- modals -->
|
||||
<q-dialog v-model="showAddAutomatedTask" position="top">
|
||||
<AddAutomatedTask :policypk="selectedPolicy" @close="showAddAutomatedTask = false" />
|
||||
</q-dialog>
|
||||
|
||||
<!-- policy task status -->
|
||||
<q-dialog v-model="showPolicyTaskStatus">
|
||||
<PolicyStatus type="task" :item="statusTask" :description="`${statusTask.name} Agent Status`" />
|
||||
<q-dialog v-model="showAddTask" position="top">
|
||||
<AddAutomatedTask
|
||||
:policypk="selectedPolicy"
|
||||
@close="
|
||||
getTasks();
|
||||
showAddTask = false;
|
||||
"
|
||||
/>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import mixins, { notifySuccessConfig, notifyErrorConfig } from "@/mixins/mixins";
|
||||
import mixins from "@/mixins/mixins";
|
||||
import DialogWrapper from "@/components/ui/DialogWrapper";
|
||||
import AddAutomatedTask from "@/components/modals/tasks/AddAutomatedTask";
|
||||
import PolicyStatus from "@/components/automation/modals/PolicyStatus";
|
||||
|
||||
export default {
|
||||
name: "PolicyAutomatedTasksTab",
|
||||
components: {
|
||||
AddAutomatedTask,
|
||||
PolicyStatus,
|
||||
},
|
||||
mixins: [mixins],
|
||||
components: { AddAutomatedTask },
|
||||
props: {
|
||||
selectedPolicy: !Number
|
||||
selectedPolicy: !Number,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showAddAutomatedTask: false,
|
||||
showEditAutomatedTask: false,
|
||||
showPolicyTaskStatus: false,
|
||||
statusTask: {},
|
||||
editTaskPk: null,
|
||||
tasks: [],
|
||||
showAddTask: false,
|
||||
columns: [
|
||||
{ name: "enabled", align: "left", field: "enabled" },
|
||||
{ name: "name", label: "Name", field: "name", align: "left" },
|
||||
@@ -177,37 +148,71 @@ export default {
|
||||
},
|
||||
],
|
||||
pagination: {
|
||||
rowsPerPage: 9999,
|
||||
rowsPerPage: 0,
|
||||
sortBy: "name",
|
||||
descending: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
selectedPolicy: function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) this.getTasks();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
taskEnableorDisable(pk, action) {
|
||||
const data = { id: pk, enableordisable: action };
|
||||
this.$store
|
||||
.dispatch("editAutoTask", data)
|
||||
getTasks() {
|
||||
this.$q.loading.show();
|
||||
this.$axios
|
||||
.get(`/automation/${this.selectedPolicy}/policyautomatedtasks/`)
|
||||
.then(r => {
|
||||
this.$store.dispatch("automation/loadPolicyAutomatedTasks", this.selectedPolicy);
|
||||
this.$q.notify(notifySuccessConfig(r.data));
|
||||
this.tasks = r.data;
|
||||
this.$q.loading.hide();
|
||||
})
|
||||
.catch(e => this.$q.notify(notifySuccessConfig("Something went wrong")));
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("There was an issue getting tasks");
|
||||
});
|
||||
},
|
||||
taskEnableorDisable(pk, action) {
|
||||
this.$q.loading.show();
|
||||
const data = { id: pk, enableordisable: action };
|
||||
this.$axios
|
||||
.patch(`/tasks/${pk}/automatedtasks/`, data)
|
||||
.then(r => {
|
||||
this.getTasks();
|
||||
this.$q.loading.hide();
|
||||
this.notifySuccess("Task has edited successfully");
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("There was an issue editing the task");
|
||||
});
|
||||
},
|
||||
showStatus(task) {
|
||||
this.statusTask = task;
|
||||
this.showPolicyTaskStatus = true;
|
||||
},
|
||||
refreshTasks(id) {
|
||||
this.$store.dispatch("automation/loadPolicyAutomatedTasks", id);
|
||||
this.$q.dialog({
|
||||
component: PolicyStatus,
|
||||
parent: this,
|
||||
type: "task",
|
||||
item: task,
|
||||
});
|
||||
},
|
||||
runTask(pk, enabled) {
|
||||
if (!enabled) {
|
||||
this.$q.notify(notifyErrorConfig("Task cannot be run when it's disabled. Enable it first."));
|
||||
this.notifyError("Task cannot be run when it's disabled. Enable it first.");
|
||||
return;
|
||||
}
|
||||
this.$store
|
||||
.dispatch("automation/runPolicyTask", pk)
|
||||
.then(r => this.$q.notify(notifySuccessConfig(r.data)))
|
||||
.catch(() => this.$q.notify(notifyErrorConfig("Something went wrong")));
|
||||
|
||||
this.$q.loading.show();
|
||||
this.$axios
|
||||
.put(`/automation/runwintask/${pk}/`)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.notifySuccess("The task was initated on all affected agents");
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("There was an issue running the task");
|
||||
});
|
||||
},
|
||||
deleteTask(name, pk) {
|
||||
this.$q
|
||||
@@ -218,21 +223,23 @@ export default {
|
||||
persistent: true,
|
||||
})
|
||||
.onOk(() => {
|
||||
this.$store
|
||||
.dispatch("deleteAutoTask", pk)
|
||||
this.$q.loading.show();
|
||||
this.$axios
|
||||
.delete(`/tasks/${pk}/automatedtasks/`)
|
||||
.then(r => {
|
||||
this.$store.dispatch("automation/loadPolicyAutomatedTasks", this.selectedPolicy);
|
||||
this.$q.notify(notifySuccessConfig(r.data));
|
||||
this.getTasks();
|
||||
this.$q.loading.hide();
|
||||
this.notifySuccess("Task was deleted successfully");
|
||||
})
|
||||
.catch(e => this.$q.notify(notifyErrorConfig("Something went wrong")));
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("There was an issue deleting the task");
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
tasks: "automation/tasks",
|
||||
selectedPolicy: "automation/selectedPolicyPk",
|
||||
}),
|
||||
mounted() {
|
||||
this.getTasks();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<q-btn
|
||||
v-if="selectedPolicy !== null"
|
||||
size="sm"
|
||||
color="grey-5"
|
||||
icon="fas fa-plus"
|
||||
label="Add Check"
|
||||
text-color="black"
|
||||
ref="add"
|
||||
>
|
||||
<q-btn v-if="!!selectedPolicy" size="sm" color="grey-5" icon="fas fa-plus" label="Add Check" text-color="black">
|
||||
<q-menu>
|
||||
<q-list dense style="min-width: 200px">
|
||||
<q-item clickable v-close-popup @click="showAddDialog('DiskSpaceCheck')">
|
||||
@@ -57,28 +49,29 @@
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-if="selectedPolicy !== null"
|
||||
dense
|
||||
flat
|
||||
push
|
||||
@click="onRefresh(selectedPolicy)"
|
||||
icon="refresh"
|
||||
ref="refresh"
|
||||
/>
|
||||
<q-btn v-if="!!selectedPolicy" dense flat push @click="getChecks" icon="refresh" />
|
||||
<template>
|
||||
<q-table
|
||||
dense
|
||||
style="max-height: 35vh"
|
||||
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
||||
class="tabs-tbl-sticky"
|
||||
style="max-height: 35vh"
|
||||
:data="checks"
|
||||
:columns="columns"
|
||||
:pagination.sync="pagination"
|
||||
:rows-per-page-options="[0]"
|
||||
row-key="id"
|
||||
binary-state-sort
|
||||
:pagination.sync="pagination"
|
||||
dense
|
||||
hide-pagination
|
||||
virtual-scroll
|
||||
>
|
||||
<!-- No data Slot -->
|
||||
<template v-slot:no-data>
|
||||
<div class="full-width row flex-center q-gutter-sm">
|
||||
<span v-if="!selectedPolicy">Click on a policy to see the checks</span>
|
||||
<span v-else>There are no checks added to this policy</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- header slots -->
|
||||
<template v-slot:header-cell-smsalert="props">
|
||||
<q-th auto-width :props="props">
|
||||
@@ -97,13 +90,6 @@
|
||||
<template v-slot:header-cell-statusicon="props">
|
||||
<q-th auto-width :props="props"></q-th>
|
||||
</template>
|
||||
<!-- No data Slot -->
|
||||
<template v-slot:no-data>
|
||||
<div class="full-width row flex-center q-gutter-sm">
|
||||
<span v-if="selectedPolicy === null">Click on a policy to see the checks</span>
|
||||
<span v-else>There are no checks added to this policy</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- body slots -->
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props">
|
||||
@@ -125,7 +111,7 @@
|
||||
|
||||
<q-separator></q-separator>
|
||||
|
||||
<q-item clickable v-close-popup @click="showPolicyCheckStatusModal(props.row)" id="context-status">
|
||||
<q-item clickable v-close-popup @click="showPolicyStatus(props.row)" id="context-status">
|
||||
<q-item-section side>
|
||||
<q-icon name="sync" />
|
||||
</q-item-section>
|
||||
@@ -158,7 +144,7 @@
|
||||
<q-td>
|
||||
<span
|
||||
style="cursor: pointer; text-decoration: underline"
|
||||
@click="showPolicyCheckStatusModal(props.row)"
|
||||
@click="showPolicyStatus(props.row)"
|
||||
class="status-cell text-primary"
|
||||
>See Status</span
|
||||
>
|
||||
@@ -174,11 +160,6 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- policy status -->
|
||||
<q-dialog v-model="showPolicyCheckStatus">
|
||||
<PolicyStatus type="check" :item="statusCheck" />
|
||||
</q-dialog>
|
||||
|
||||
<!-- add/edit modals -->
|
||||
<q-dialog v-model="showDialog" @hide="hideDialog">
|
||||
<component
|
||||
@@ -207,7 +188,6 @@ import EventLogCheck from "@/components/modals/checks/EventLogCheck";
|
||||
export default {
|
||||
name: "PolicyChecksTab",
|
||||
components: {
|
||||
PolicyStatus,
|
||||
DiskSpaceCheck,
|
||||
PingCheck,
|
||||
CpuLoadCheck,
|
||||
@@ -225,9 +205,7 @@ export default {
|
||||
checks: [],
|
||||
dialogComponent: null,
|
||||
showDialog: false,
|
||||
showPolicyCheckStatus: false,
|
||||
editCheckPK: null,
|
||||
statusCheck: {},
|
||||
columns: [
|
||||
{ name: "smsalert", field: "text_alert", align: "left" },
|
||||
{ name: "emailalert", field: "email_alert", align: "left" },
|
||||
@@ -242,8 +220,27 @@ export default {
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
selectedPolicy: function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) this.getChecks();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getChecks() {
|
||||
this.$q.loading.show();
|
||||
this.$axios
|
||||
.get(`/automation/${this.selectedPolicy}/policychecks/`)
|
||||
.then(r => {
|
||||
this.checks = r.data;
|
||||
this.$q.loading.hide();
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("Unable to get checks");
|
||||
});
|
||||
},
|
||||
checkAlert(id, alert_type, action) {
|
||||
this.$q.loading.show();
|
||||
const data = {};
|
||||
|
||||
if (alert_type === "Email") {
|
||||
@@ -254,16 +251,20 @@ export default {
|
||||
data.check_alert = true;
|
||||
const act = action ? "enabled" : "disabled";
|
||||
const color = action ? "positive" : "warning";
|
||||
this.$store.dispatch("editCheckAlert", { pk: id, data }).then(r => {
|
||||
this.$q.notify({
|
||||
color: color,
|
||||
icon: "fas fa-check-circle",
|
||||
message: `${alert_type} alerts ${act}`,
|
||||
this.$axios
|
||||
.patch(`/checks/${id}/check/`, data)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.$q.notify({
|
||||
color: color,
|
||||
icon: "fas fa-check-circle",
|
||||
message: `${alert_type} alerts ${act}`,
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("Unable to edit check alert");
|
||||
});
|
||||
});
|
||||
},
|
||||
onRefresh(id) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", id);
|
||||
},
|
||||
showAddDialog(component) {
|
||||
this.dialogComponent = component;
|
||||
@@ -311,23 +312,32 @@ export default {
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(() => {
|
||||
this.$store
|
||||
.dispatch("deleteCheck", check.id)
|
||||
this.$q.loading.show();
|
||||
this.axios
|
||||
.delete(`/checks/${check.id}/check/`)
|
||||
.then(r => {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", check.id);
|
||||
this.getChecks();
|
||||
this.$q.loading.hide();
|
||||
this.notifySuccess("Check Deleted!");
|
||||
})
|
||||
.catch(e => this.notifyError("An Error Occurred while deleting"));
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.notifyError("An Error Occurred while deleting");
|
||||
});
|
||||
});
|
||||
},
|
||||
showPolicyStatus(check) {
|
||||
this.$q.dialog({
|
||||
component: PolicyStatus,
|
||||
parent: this,
|
||||
check: check,
|
||||
type: "check",
|
||||
item: check,
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getChecks();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,92 +1,75 @@
|
||||
<template>
|
||||
<q-card style="width: 60vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Edit policies assigned to {{ type }}</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-form @submit="submit" ref="form">
|
||||
<q-card-section v-if="type !== 'agent'">
|
||||
<q-select
|
||||
v-model="selectedServerPolicy"
|
||||
:options="options"
|
||||
filled
|
||||
options-selected-class="text-green"
|
||||
dense
|
||||
clearable
|
||||
label="Server Policy"
|
||||
>
|
||||
<template v-slot:option="props">
|
||||
<q-item v-bind="props.itemProps" v-on="props.itemEvents">
|
||||
<q-item-section avatar>
|
||||
<q-icon v-if="props.selected" name="check" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label v-html="props.opt.label" />
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
</q-card-section>
|
||||
<q-card-section v-if="type !== 'agent'">
|
||||
<q-select
|
||||
v-model="selectedWorkstationPolicy"
|
||||
:options="options"
|
||||
filled
|
||||
options-selected-class="text-green"
|
||||
dense
|
||||
clearable
|
||||
label="Workstation Policy"
|
||||
>
|
||||
<template v-slot:option="props">
|
||||
<q-item v-bind="props.itemProps" v-on="props.itemEvents">
|
||||
<q-item-section avatar>
|
||||
<q-icon v-if="props.selected" name="check" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label v-html="props.opt.label" />
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
</q-card-section>
|
||||
<q-card-section v-if="type === 'agent'">
|
||||
<q-select
|
||||
v-model="selectedAgentPolicy"
|
||||
:options="options"
|
||||
filled
|
||||
options-selected-class="text-green"
|
||||
dense
|
||||
clearable
|
||||
label="Policy"
|
||||
>
|
||||
<template v-slot:option="props">
|
||||
<q-item v-bind="props.itemProps" v-on="props.itemEvents">
|
||||
<q-item-section avatar>
|
||||
<q-icon v-if="props.selected" name="check" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label v-html="props.opt.label" />
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-select>
|
||||
</q-card-section>
|
||||
<q-card-section class="row items-center">
|
||||
<q-btn label="Edit Policies" color="primary" type="submit" />
|
||||
</q-card-section>
|
||||
</q-form>
|
||||
</q-card>
|
||||
<q-dialog ref="dialog" @hide="onHide">
|
||||
<q-card class="q-dialog-plugin" style="width: 60vw">
|
||||
<q-bar>
|
||||
Edit policies assigned to {{ type }}
|
||||
<q-space />
|
||||
<q-btn dense flat icon="close" v-close-popup>
|
||||
<q-tooltip content-class="bg-white text-primary">Close</q-tooltip>
|
||||
</q-btn>
|
||||
</q-bar>
|
||||
<q-form @submit="submit">
|
||||
<q-card-section v-if="options.length > 0">
|
||||
<q-select
|
||||
v-if="type !== 'agent'"
|
||||
class="q-mb-md"
|
||||
v-model="selectedServerPolicy"
|
||||
:options="options"
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
clearable
|
||||
map-options
|
||||
emit-value
|
||||
label="Server Policy"
|
||||
>
|
||||
</q-select>
|
||||
<q-select
|
||||
v-if="type !== 'agent'"
|
||||
v-model="selectedWorkstationPolicy"
|
||||
:options="options"
|
||||
outlined
|
||||
options-dense
|
||||
dense
|
||||
clearable
|
||||
map-options
|
||||
emit-value
|
||||
label="Workstation Policy"
|
||||
>
|
||||
</q-select>
|
||||
<q-select
|
||||
v-if="type === 'agent'"
|
||||
v-model="selectedAgentPolicy"
|
||||
:options="options"
|
||||
outlined
|
||||
options-dense
|
||||
dense
|
||||
clearable
|
||||
map-options
|
||||
emit-value
|
||||
label="Policy"
|
||||
>
|
||||
</q-select>
|
||||
</q-card-section>
|
||||
<q-card-section v-else>
|
||||
No Automation Policies have been setup. Go to Settings > Automation Manager
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn dense flat label="Cancel" v-close-popup />
|
||||
<q-btn v-if="options.length > 0" flat label="Submit" color="primary" type="submit" />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import mixins, { notifySuccessConfig, notifyErrorConfig } from "@/mixins/mixins";
|
||||
import mixins from "@/mixins/mixins";
|
||||
|
||||
export default {
|
||||
name: "PolicyAdd",
|
||||
props: {
|
||||
pk: Number,
|
||||
object: !Object,
|
||||
type: {
|
||||
required: true,
|
||||
type: String,
|
||||
@@ -96,6 +79,7 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
mixins: [mixins],
|
||||
data() {
|
||||
return {
|
||||
selectedWorkstationPolicy: null,
|
||||
@@ -104,95 +88,90 @@ export default {
|
||||
options: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
policies: "automation/policies",
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
// check if data was changed
|
||||
if (this.type !== "agent") {
|
||||
if (
|
||||
this.object.workstation_policy === this.selectedWorkstationPolicy &&
|
||||
this.object.server_policy === this.selectedServerPolicy
|
||||
) {
|
||||
this.hide();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (this.object.policy === this.selectedAgentPolicy) {
|
||||
this.hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.$q.loading.show();
|
||||
|
||||
let data = {};
|
||||
data.pk = this.pk;
|
||||
data.type = this.type;
|
||||
let data = {
|
||||
pk: this.object.id,
|
||||
type: this.type,
|
||||
};
|
||||
|
||||
if (this.type !== "agent") {
|
||||
data.server_policy = this.selectedServerPolicy === null ? 0 : this.selectedServerPolicy.value;
|
||||
data.workstation_policy = this.selectedWorkstationPolicy === null ? 0 : this.selectedWorkstationPolicy.value;
|
||||
data.server_policy = this.selectedServerPolicy;
|
||||
data.workstation_policy = this.selectedWorkstationPolicy;
|
||||
} else {
|
||||
data.policy = this.selectedAgentPolicy === null ? 0 : this.selectedAgentPolicy.value;
|
||||
data.policy = this.selectedAgentPolicy;
|
||||
}
|
||||
|
||||
this.$store
|
||||
.dispatch("automation/updateRelatedPolicies", data)
|
||||
console.log(data);
|
||||
this.$axios
|
||||
.post(`/automation/related/`, data)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.$emit("close");
|
||||
this.$q.notify(notifySuccessConfig("Policies Updated Successfully!"));
|
||||
this.onOk();
|
||||
this.notifySuccess("Policies Updated Successfully!");
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.$q.notify(notifyErrorConfig("Something went wrong!"));
|
||||
this.notifyError("There was an error updating policies");
|
||||
});
|
||||
},
|
||||
getPolicies() {
|
||||
this.$store
|
||||
.dispatch("automation/loadPolicies")
|
||||
.then(() => {
|
||||
this.options = this.policies.map(policy => ({
|
||||
this.$q.loading.show();
|
||||
this.$axios
|
||||
.get("/automation/policies/")
|
||||
.then(r => {
|
||||
this.options = r.data.map(policy => ({
|
||||
label: policy.name,
|
||||
value: policy.id,
|
||||
}));
|
||||
|
||||
this.$q.loading.hide();
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.$q.notify(notifyErrorConfig("Add error occured while loading"));
|
||||
this.notifyError("Add error occured while loading policies");
|
||||
});
|
||||
},
|
||||
getRelation(pk, type) {
|
||||
this.$store
|
||||
.dispatch("automation/getRelatedPolicies", { pk, type })
|
||||
.then(r => {
|
||||
if (type === "agent") {
|
||||
if (r.data.policy !== null) {
|
||||
if (r.data.policy.id !== null) {
|
||||
this.selectedAgentPolicy = {
|
||||
label: r.data.policy.name,
|
||||
value: r.data.policy.id,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type !== "agent") {
|
||||
if (r.data.server_policy !== null) {
|
||||
if (r.data.server_policy.id !== undefined) {
|
||||
this.selectedServerPolicy = {
|
||||
label: r.data.server_policy.name,
|
||||
value: r.data.server_policy.id,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (r.data.workstation_policy !== null) {
|
||||
if (r.data.workstation_policy.id !== undefined) {
|
||||
this.selectedWorkstationPolicy = {
|
||||
label: r.data.workstation_policy.name,
|
||||
value: r.data.workstation_policy.id,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.notify(notifyErrorConfig("Add error occured while loading"));
|
||||
});
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
},
|
||||
hide() {
|
||||
this.$refs.dialog.hide();
|
||||
},
|
||||
onHide() {
|
||||
this.$emit("hide");
|
||||
},
|
||||
onOk() {
|
||||
this.$emit("ok");
|
||||
this.hide();
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getPolicies();
|
||||
this.getRelation(this.pk, this.type);
|
||||
|
||||
if (this.type !== "agent") {
|
||||
this.selectedServerPolicy = this.object.server_policy;
|
||||
this.selectedWorkstationPolicy = this.object.workstation_policy;
|
||||
} else {
|
||||
this.selectedAgentPolicy = this.object.policy;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,132 +1,134 @@
|
||||
<template>
|
||||
<q-card style="width: 60vw">
|
||||
<q-form ref="form" @submit="submit">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">{{ title }}</div>
|
||||
<q-dialog ref="dialog" @hide="onHide">
|
||||
<q-card class="q-dialog-plugin" style="width: 60vw">
|
||||
<q-bar>
|
||||
{{ title }}
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-card-section v-if="copyPolicy">
|
||||
<div class="text-subtitle1">
|
||||
You are copying checks and tasks from Policy:
|
||||
<b>{{ copyPolicy.name }}</b> into a new policy.
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Name:</div>
|
||||
<div class="col-10">
|
||||
<q-input outlined dense v-model="name" :rules="[ val => !!val || '*Required']" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Description:</div>
|
||||
<div class="col-10">
|
||||
<q-input outlined dense v-model="desc" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Active:</div>
|
||||
<div class="col-10">
|
||||
<q-toggle v-model="active" color="green" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Enforced:</div>
|
||||
<div class="col-10">
|
||||
<q-toggle v-model="enforced" color="green" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row items-center">
|
||||
<q-btn :label="title" color="primary" type="submit" />
|
||||
</q-card-section>
|
||||
</q-form>
|
||||
</q-card>
|
||||
<q-btn dense flat icon="close" v-close-popup>
|
||||
<q-tooltip content-class="bg-white text-primary">Close</q-tooltip>
|
||||
</q-btn>
|
||||
</q-bar>
|
||||
<q-form @submit="submit">
|
||||
<q-card-section v-if="copyPolicy">
|
||||
<div class="text-subtitle1">
|
||||
You are copying checks and tasks from Policy:
|
||||
<b>{{ copyPolicy.name }}</b> into a new policy.
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Name:</div>
|
||||
<div class="col-10">
|
||||
<q-input outlined dense v-model="localPolicy.name" :rules="[val => !!val || '*Required']" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Description:</div>
|
||||
<div class="col-10">
|
||||
<q-input outlined dense v-model="localPolicy.desc" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Active:</div>
|
||||
<div class="col-10">
|
||||
<q-toggle v-model="localPolicy.active" color="green" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row">
|
||||
<div class="col-2">Enforced:</div>
|
||||
<div class="col-10">
|
||||
<q-toggle v-model="localPolicy.enforced" color="green" />
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right">
|
||||
<q-btn dense flat label="Cancel" v-close-popup />
|
||||
<q-btn flat label="Submit" color="primary" type="submit" />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import mixins, { notifySuccessConfig, notifyErrorConfig } from "@/mixins/mixins";
|
||||
import mixins from "@/mixins/mixins";
|
||||
|
||||
export default {
|
||||
name: "PolicyForm",
|
||||
mixins: [mixins],
|
||||
props: { pk: Number, copyPolicy: Object },
|
||||
props: { policy: Object, copyPolicy: Object },
|
||||
data() {
|
||||
return {
|
||||
name: "",
|
||||
desc: "",
|
||||
enforced: false,
|
||||
active: false,
|
||||
localPolicy: {
|
||||
name: "",
|
||||
desc: "",
|
||||
enforced: false,
|
||||
active: false,
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.pk ? "Edit Policy" : "Add Policy";
|
||||
return this.editing ? "Edit Policy" : "Add Policy";
|
||||
},
|
||||
editing() {
|
||||
return !!this.policy;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getPolicy() {
|
||||
this.$q.loading.show();
|
||||
|
||||
this.$store.dispatch("automation/loadPolicy", this.pk).then(r => {
|
||||
this.$q.loading.hide();
|
||||
|
||||
this.name = r.data.name;
|
||||
this.desc = r.data.desc;
|
||||
this.active = r.data.active;
|
||||
this.enforced = r.data.enforced;
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
if (!this.name) {
|
||||
this.$q.notify(notifySuccessConfig("Name is required!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
this.$q.loading.show();
|
||||
|
||||
let formData = {
|
||||
id: this.pk,
|
||||
name: this.name,
|
||||
desc: this.desc,
|
||||
active: this.active,
|
||||
enforced: this.enforced,
|
||||
let data = {
|
||||
...this.localPolicy,
|
||||
};
|
||||
|
||||
if (this.pk) {
|
||||
this.$store
|
||||
.dispatch("automation/editPolicy", formData)
|
||||
if (this.editing) {
|
||||
this.$axios
|
||||
.put(`/automation/policies/${data.id}/`, data)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.$emit("close");
|
||||
this.$q.notify(notifySuccessConfig("Policy edited!"));
|
||||
this.onOk();
|
||||
this.notifySuccess("Policy edited!");
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.$q.notify(notifyErrorConfig(e.response.data));
|
||||
this.notifyError("There was an error editing the policy");
|
||||
});
|
||||
} else {
|
||||
if (this.copyPolicy) {
|
||||
formData.copyId = this.copyPolicy.id;
|
||||
data.copyId = this.copyPolicy.id;
|
||||
}
|
||||
|
||||
this.$store
|
||||
.dispatch("automation/addPolicy", formData)
|
||||
this.$axios
|
||||
.post("/automation/policies/", data)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.$emit("close");
|
||||
this.$q.notify(notifySuccessConfig("Policy added! Now you can add Tasks and Checks!"));
|
||||
this.onOk();
|
||||
this.notifySuccess("Policy added. Now you can add Tasks and Checks!");
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
this.$q.notify(notifyErrorConfig(e.response.data));
|
||||
this.notifyError("There was an error adding the policy");
|
||||
});
|
||||
}
|
||||
},
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
},
|
||||
hide() {
|
||||
this.$refs.dialog.hide();
|
||||
},
|
||||
onHide() {
|
||||
this.$emit("hide");
|
||||
},
|
||||
onOk() {
|
||||
this.$emit("ok");
|
||||
this.hide();
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// If pk prop is set that means we are editting
|
||||
if (this.pk) {
|
||||
this.getPolicy();
|
||||
if (this.policy) {
|
||||
Object.assign(this.localPolicy, this.policy);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
<template>
|
||||
<q-dialog ref="dialog" @hide="onHide">
|
||||
<q-card class="q-dialog-plugin" style="width: 90vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">{{ this.title }}</div>
|
||||
<q-bar>
|
||||
{{ title.slice(0, 27) }}
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-btn dense flat icon="close" v-close-popup>
|
||||
<q-tooltip content-class="bg-white text-primary">Close</q-tooltip>
|
||||
</q-btn>
|
||||
</q-bar>
|
||||
<q-card-section>
|
||||
<q-table
|
||||
dense
|
||||
style="max-height: 35vh"
|
||||
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
||||
class="tabs-tbl-sticky"
|
||||
style="max-height: 35vh"
|
||||
:data="tableData"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination.sync="pagination"
|
||||
:rows-per-page-options="[0]"
|
||||
row-key="id"
|
||||
binary-state-sort
|
||||
:pagination.sync="pagination"
|
||||
dense
|
||||
virtual-scroll
|
||||
hide-pagination
|
||||
no-data-label="There are no agents in this policy"
|
||||
>
|
||||
@@ -130,7 +134,7 @@ export default {
|
||||
showEventLogOutput: false,
|
||||
evtLogData: {},
|
||||
scriptInfo: {},
|
||||
tableData: [],
|
||||
data: [],
|
||||
columns: [
|
||||
{ name: "agent", label: "Hostname", field: "agent", align: "left", sortable: true },
|
||||
{ name: "statusicon", align: "left" },
|
||||
@@ -151,7 +155,7 @@ export default {
|
||||
},
|
||||
],
|
||||
pagination: {
|
||||
rowsPerPage: 9999,
|
||||
rowsPerPage: 0,
|
||||
sortBy: "status",
|
||||
descending: false,
|
||||
},
|
||||
@@ -159,34 +163,34 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.item.readable_desc ? this.item.readable_desc + " Status" : this.item.name + " Status";
|
||||
return !!this.item.readable_desc ? this.item.readable_desc + " Status" : this.item.name + " Status";
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getCheckData() {
|
||||
this.$q.loading.show();
|
||||
this.$store
|
||||
.dispatch("automation/loadCheckStatus", { checkpk: this.item.id })
|
||||
this.$axios
|
||||
.patch(`/automation/policycheckstatus/${this.item.id}/check/`)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.tableData = r.data;
|
||||
this.data = r.data;
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
// TODO: Return Error message from api and display
|
||||
this.notifyError("Unable to load check status");
|
||||
});
|
||||
},
|
||||
getTaskData() {
|
||||
this.$q.loading.show();
|
||||
this.$store
|
||||
.dispatch("automation/loadAutomatedTaskStatus", { taskpk: this.item.id })
|
||||
this.$axios
|
||||
.patch(`/automation/policyautomatedtaskstatus/${this.item.id}/task/`)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.tableData = r.data;
|
||||
this.data = r.data;
|
||||
})
|
||||
.catch(e => {
|
||||
this.$q.loading.hide();
|
||||
// TODO: Return Error message from api and display
|
||||
this.notifyError("Unable to load task status");
|
||||
});
|
||||
},
|
||||
closeEventLogOutput() {
|
||||
|
||||
@@ -1,107 +1,112 @@
|
||||
<template>
|
||||
<q-card style="width: 60vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">{{ policy.name }} Relations</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-card-section class="row items-center" v-if="related.default_server_policy || related.default_workstation_policy">
|
||||
<div v-if="related.default_server_policy" class="text-body">
|
||||
<q-icon name="error_outline" color="info" size="1.5em" />This policy is set as the Default Server Policy.
|
||||
</div>
|
||||
<div v-if="related.default_workstation_policy" class="text-body">
|
||||
<q-icon name="error_outline" color="info" size="1.5em" />This policy is set as the Default Workstation Policy.
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-tabs
|
||||
v-model="tab"
|
||||
dense
|
||||
inline-label
|
||||
class="text-grey"
|
||||
active-color="primary"
|
||||
indicator-color="primary"
|
||||
align="left"
|
||||
narrow-indicator
|
||||
no-caps
|
||||
<q-dialog ref="dialog" @hide="onHide">
|
||||
<q-card style="width: 60vw">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">{{ policy.name }} Relations</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-card-section
|
||||
class="row items-center"
|
||||
v-if="related.default_server_policy || related.default_workstation_policy"
|
||||
>
|
||||
<q-tab name="clients" label="Clients" ref="clients" />
|
||||
<q-tab name="sites" label="Sites" ref="sites" />
|
||||
<q-tab name="agents" label="Agents" ref="agents" />
|
||||
</q-tabs>
|
||||
<div v-if="related.default_server_policy" class="text-body">
|
||||
<q-icon name="error_outline" color="info" size="1.5em" />This policy is set as the Default Server Policy.
|
||||
</div>
|
||||
<div v-if="related.default_workstation_policy" class="text-body">
|
||||
<q-icon name="error_outline" color="info" size="1.5em" />This policy is set as the Default Workstation Policy.
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-tabs
|
||||
v-model="tab"
|
||||
dense
|
||||
inline-label
|
||||
class="text-grey"
|
||||
active-color="primary"
|
||||
indicator-color="primary"
|
||||
align="left"
|
||||
narrow-indicator
|
||||
no-caps
|
||||
>
|
||||
<q-tab name="clients" label="Clients" />
|
||||
<q-tab name="sites" label="Sites" />
|
||||
<q-tab name="agents" label="Agents" />
|
||||
</q-tabs>
|
||||
|
||||
<q-separator />
|
||||
<q-scroll-area :thumb-style="thumbStyle" style="height: 50vh">
|
||||
<q-tab-panels v-model="tab" :animated="false">
|
||||
<q-tab-panel name="clients">
|
||||
<q-list separator padding>
|
||||
<q-item :key="item.id + 'servers'" v-for="item in related.server_clients">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Servers</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item :key="item.id + 'workstations'" v-for="item in related.workstation_clients">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Workstations</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
<q-separator />
|
||||
<q-scroll-area :thumb-style="thumbStyle" style="height: 50vh">
|
||||
<q-tab-panels v-model="tab" :animated="false">
|
||||
<q-tab-panel name="clients">
|
||||
<q-list separator padding>
|
||||
<q-item :key="item.id + 'servers'" v-for="item in related.server_clients">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Servers</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item :key="item.id + 'workstations'" v-for="item in related.workstation_clients">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Workstations</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="sites">
|
||||
<q-list separator padding>
|
||||
<q-item :key="item.id + 'servers'" v-for="item in related.server_sites">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
<q-item-label caption>{{ item.client_name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Servers</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item :key="item.id + 'workstations'" v-for="item in related.workstation_sites">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
<q-item-label caption>{{ item.client_name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Workstations</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="sites">
|
||||
<q-list separator padding>
|
||||
<q-item :key="item.id + 'servers'" v-for="item in related.server_sites">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
<q-item-label caption>{{ item.client_name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Servers</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item :key="item.id + 'workstations'" v-for="item in related.workstation_sites">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.name }}</q-item-label>
|
||||
<q-item-label caption>{{ item.client_name }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-item-label>
|
||||
<i>Applied to Workstations</i>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
|
||||
<q-tab-panel name="agents">
|
||||
<q-list separator padding>
|
||||
<q-item :key="item.pk" v-for="item in related.agents">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.hostname }}</q-item-label>
|
||||
<q-item-label caption>
|
||||
<b>{{ item.client }}</b>
|
||||
{{ item.site }}
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-scroll-area>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
<q-tab-panel name="agents">
|
||||
<q-list separator padding>
|
||||
<q-item :key="item.pk" v-for="item in related.agents">
|
||||
<q-item-section>
|
||||
<q-item-label>{{ item.hostname }}</q-item-label>
|
||||
<q-item-label caption>
|
||||
<b>{{ item.client }}</b>
|
||||
{{ item.site }}
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-scroll-area>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -126,11 +131,22 @@ export default {
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
},
|
||||
hide() {
|
||||
this.$refs.dialog.hide();
|
||||
},
|
||||
onHide() {
|
||||
this.$emit("hide");
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$q.loading.show();
|
||||
|
||||
this.$axios
|
||||
.patch(`/automation/related/`, data)
|
||||
.get(`/automation/policies/${this.policy.id}/related/`)
|
||||
.then(r => {
|
||||
this.$q.loading.hide();
|
||||
this.related = r.data;
|
||||
|
||||
@@ -73,7 +73,7 @@ export default {
|
||||
let url = "";
|
||||
if (this.type === "client") url = `/clients/${this.object.id}/client/`;
|
||||
else if (this.type === "site") url = `/clients/${this.object.id}/site/`;
|
||||
else if (this.type === "policy") url = `/automation/${this.object.id}/policy/`;
|
||||
else if (this.type === "policy") url = `/automation/policies/${this.object.id}/`;
|
||||
|
||||
const text = this.selectedTemplate ? "assigned" : "removed";
|
||||
this.$axios
|
||||
@@ -120,7 +120,7 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
this.getAlertTemplates();
|
||||
this.selectedTemplate = this.object.alertTemplate;
|
||||
this.selectedTemplate = this.object.alert_template;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<q-dialog ref="dialog" @hide="onHide">
|
||||
<q-card style="min-width: 70vw">
|
||||
<q-card style="width: 70vw; max-width: 70vw">
|
||||
<q-bar>
|
||||
{{ title }}
|
||||
<q-space />
|
||||
|
||||
@@ -77,9 +77,9 @@ export default {
|
||||
computed: {
|
||||
thresholdIsValid() {
|
||||
return (
|
||||
this.memcheck.warning_threshold === 0 ||
|
||||
this.memcheck.error_threshold === 0 ||
|
||||
this.memcheck.warning_threshold < this.memcheck.error_threshold
|
||||
this.cpuloadcheck.warning_threshold === 0 ||
|
||||
this.cpuloadcheck.error_threshold === 0 ||
|
||||
this.cpuloadcheck.warning_threshold < this.cpuloadcheck.error_threshold
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -123,9 +123,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -137,9 +137,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
@@ -148,9 +146,9 @@ export default {
|
||||
...mapGetters(["agentDisks"]),
|
||||
thresholdIsValid() {
|
||||
return (
|
||||
this.memcheck.warning_threshold === 0 ||
|
||||
this.memcheck.error_threshold === 0 ||
|
||||
this.memcheck.warning_threshold < this.memcheck.error_threshold
|
||||
!!this.diskcheck.warning_threshold ||
|
||||
!!this.diskcheck.error_threshold ||
|
||||
this.diskcheck.warning_threshold > this.diskcheck.error_threshold
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -219,9 +219,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -123,9 +123,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -104,9 +104,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -53,11 +53,6 @@
|
||||
dense
|
||||
v-model.number="scriptcheck.info_return_codes"
|
||||
label="Informational alert return codes"
|
||||
:rules="[
|
||||
val => !!val || '*Required',
|
||||
val => val >= 10 || 'Minimum is 10 seconds',
|
||||
val => val <= 86400 || 'Maximum is 86400 seconds',
|
||||
]"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
@@ -151,9 +146,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -215,9 +215,7 @@ export default {
|
||||
.catch(e => this.notifyError(e.response.data.non_field_errors));
|
||||
},
|
||||
reloadChecks() {
|
||||
if (this.policypk) {
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
} else {
|
||||
if (this.agentpk) {
|
||||
this.$store.dispatch("loadChecks", this.agentpk);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -210,9 +210,6 @@ export default {
|
||||
if (!this.policypk) {
|
||||
this.$store.dispatch("loadAutomatedTasks", this.selectedAgentPk);
|
||||
this.$store.dispatch("loadChecks", this.selectedAgentPk);
|
||||
} else {
|
||||
this.$store.dispatch("automation/loadPolicyAutomatedTasks", this.policypk);
|
||||
this.$store.dispatch("automation/loadPolicyChecks", this.policypk);
|
||||
}
|
||||
this.notifySuccess(r.data);
|
||||
})
|
||||
@@ -221,11 +218,11 @@ export default {
|
||||
},
|
||||
getScripts() {
|
||||
this.$axios.get("/scripts/scripts/").then(r => {
|
||||
this.scriptOptions = r.data.map(
|
||||
script => ({ label: script.name, value: script.id })).sort((a, b) => a.label.localeCompare(b.label)
|
||||
);
|
||||
this.scriptOptions = r.data
|
||||
.map(script => ({ label: script.name, value: script.id }))
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["selectedAgentPk"]),
|
||||
@@ -261,7 +258,7 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getScripts()
|
||||
}
|
||||
this.getScripts();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,34 +0,0 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
alerts: []
|
||||
},
|
||||
|
||||
getters: {
|
||||
getAlerts(state) {
|
||||
return state.alerts;
|
||||
},
|
||||
getNewAlerts(state) {
|
||||
return state.alerts.filter(alert => !alert.resolved || alert.snoozed_until == undefined)
|
||||
}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_ALERTS(state, alerts) {
|
||||
state.alerts = alerts;
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
getAlerts(context) {
|
||||
axios.get("/alerts/alerts/").then(r => {
|
||||
context.commit("SET_ALERTS", r.data);
|
||||
});
|
||||
},
|
||||
editAlert(context, pk) {
|
||||
return axios.put(`/alerts/alerts/${pk}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
selectedPolicy: null,
|
||||
checks: [],
|
||||
automatedTasks: {},
|
||||
policies: [],
|
||||
},
|
||||
|
||||
getters: {
|
||||
checks(state) {
|
||||
return state.checks;
|
||||
},
|
||||
tasks(state) {
|
||||
return state.automatedTasks.autotasks;
|
||||
},
|
||||
selectedPolicyPk(state) {
|
||||
return state.selectedPolicy;
|
||||
},
|
||||
policies(state) {
|
||||
return state.policies;
|
||||
}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_POLICIES(state, policies) {
|
||||
state.policies = policies;
|
||||
},
|
||||
setSelectedPolicy(state, pk) {
|
||||
state.selectedPolicy = pk;
|
||||
},
|
||||
setPolicyChecks(state, checks) {
|
||||
state.checks = checks;
|
||||
},
|
||||
setPolicyAutomatedTasks(state, tasks) {
|
||||
state.automatedTasks = tasks;
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
loadPolicies(context) {
|
||||
return axios.get("/automation/policies/").then(r => {
|
||||
context.commit("SET_POLICIES", r.data);
|
||||
})
|
||||
},
|
||||
loadPolicyAutomatedTasks(context, pk) {
|
||||
axios.get(`/automation/${pk}/policyautomatedtasks/`).then(r => {
|
||||
context.commit("setPolicyAutomatedTasks", r.data);
|
||||
});
|
||||
},
|
||||
loadPolicyChecks(context, pk) {
|
||||
axios.get(`/automation/${pk}/policychecks/`).then(r => {
|
||||
context.commit("setPolicyChecks", r.data);
|
||||
});
|
||||
},
|
||||
loadCheckStatus(context, { checkpk }) {
|
||||
return axios.patch(`/automation/policycheckstatus/${checkpk}/check/`);
|
||||
},
|
||||
loadAutomatedTaskStatus(context, { taskpk }) {
|
||||
return axios.patch(`/automation/policyautomatedtaskstatus/${taskpk}/task/`);
|
||||
},
|
||||
loadPolicy(context, pk) {
|
||||
return axios.get(`/automation/policies/${pk}/`);
|
||||
},
|
||||
addPolicy(context, data) {
|
||||
return axios.post("/automation/policies/", data);
|
||||
},
|
||||
editPolicy(context, data) {
|
||||
return axios.put(`/automation/policies/${data.id}/`, data);
|
||||
},
|
||||
deletePolicy(context, pk) {
|
||||
return axios.delete(`/automation/policies/${pk}/`).then(r => {
|
||||
context.dispatch("loadPolicies");
|
||||
});
|
||||
},
|
||||
runPolicyTask(context, pk) {
|
||||
return axios.put(`/automation/runwintask/${pk}/`);
|
||||
},
|
||||
getRelated(context, pk) {
|
||||
return axios.get(`/automation/policies/${pk}/related/`);
|
||||
},
|
||||
getRelatedPolicies(context, data) {
|
||||
return axios.patch(`/automation/related/`, data);
|
||||
},
|
||||
updateRelatedPolicies(context, data) {
|
||||
return axios.post(`/automation/related/`, data);
|
||||
},
|
||||
loadPolicyTreeData(context) {
|
||||
return axios.get("/automation/policies/overview/");
|
||||
},
|
||||
addPatchPolicy(context, data) {
|
||||
return axios.post("/automation/winupdatepolicy/", data)
|
||||
},
|
||||
editPatchPolicy(context, data) {
|
||||
return axios.put(`/automation/winupdatepolicy/${data.id}/`, data)
|
||||
},
|
||||
deletePatchPolicy(context, pk) {
|
||||
return axios.delete(`/automation/winupdatepolicy/${pk}/`)
|
||||
},
|
||||
resetPatchPolicies(context, data) {
|
||||
return axios.patch("/automation/winupdatepolicy/reset/", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
import axios from "axios";
|
||||
import { Notify } from "quasar";
|
||||
import alertsModule from "./alerts";
|
||||
import automationModule from "./automation";
|
||||
import adminModule from "./admin.js"
|
||||
|
||||
Vue.use(Vuex);
|
||||
@@ -11,8 +9,6 @@ Vue.use(Vuex);
|
||||
export default function () {
|
||||
const Store = new Vuex.Store({
|
||||
modules: {
|
||||
automation: automationModule,
|
||||
alerts: alertsModule,
|
||||
admin: adminModule
|
||||
},
|
||||
state: {
|
||||
@@ -241,9 +237,9 @@ export default function () {
|
||||
raw: `Site|${site.id}`,
|
||||
header: "generic",
|
||||
icon: "apartment",
|
||||
serverPolicy: site.server_policy,
|
||||
workstationPolicy: site.workstation_policy,
|
||||
alertTemplate: site.alert_template
|
||||
server_policy: site.server_policy,
|
||||
workstation_policy: site.workstation_policy,
|
||||
alert_template: site.alert_template
|
||||
}
|
||||
|
||||
if (site.maintenance_mode) { siteNode["color"] = "warning" }
|
||||
@@ -258,9 +254,9 @@ export default function () {
|
||||
raw: `Client|${client.id}`,
|
||||
header: "root",
|
||||
icon: "business",
|
||||
serverPolicy: client.server_policy,
|
||||
workstationPolicy: client.workstation_policy,
|
||||
alertTemplate: client.alert_template,
|
||||
server_policy: client.server_policy,
|
||||
workstation_policy: client.workstation_policy,
|
||||
alert_template: client.alert_template,
|
||||
children: childSites
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</q-menu>
|
||||
</q-chip>
|
||||
|
||||
<AlertsIcon />
|
||||
<!--<AlertsIcon />-->
|
||||
|
||||
<q-btn-dropdown flat no-caps stretch :label="user">
|
||||
<q-list>
|
||||
@@ -357,11 +357,7 @@
|
||||
@edited="refreshEntireSite"
|
||||
/>
|
||||
</q-dialog>
|
||||
<!-- add policy modal -->
|
||||
<q-dialog v-model="showPolicyAddModal">
|
||||
<PolicyAdd @close="showPolicyAddModal = false" :type="policyAddType" :pk="parseInt(policyAddPk)" />
|
||||
</q-dialog>
|
||||
<!-- add policy modal -->
|
||||
<!-- install agent modal -->
|
||||
<q-dialog v-model="showInstallAgentModal" @hide="closeInstallAgent">
|
||||
<InstallAgent @close="closeInstallAgent" :sitepk="parseInt(sitePk)" />
|
||||
</q-dialog>
|
||||
@@ -393,7 +389,6 @@ export default {
|
||||
AgentTable,
|
||||
SubTableTabs,
|
||||
AlertsIcon,
|
||||
PolicyAdd,
|
||||
ClientsForm,
|
||||
SitesForm,
|
||||
InstallAgent,
|
||||
@@ -404,13 +399,10 @@ export default {
|
||||
darkMode: true,
|
||||
showClientsFormModal: false,
|
||||
showSitesFormModal: false,
|
||||
showPolicyAddModal: false,
|
||||
deleteEditModalPk: null,
|
||||
showInstallAgentModal: false,
|
||||
sitePk: null,
|
||||
clientOp: null,
|
||||
policyAddType: null,
|
||||
policyAddPk: null,
|
||||
serverCount: 0,
|
||||
serverOfflineCount: 0,
|
||||
workstationCount: 0,
|
||||
@@ -621,13 +613,27 @@ export default {
|
||||
},
|
||||
showPolicyAdd(node) {
|
||||
if (node.children) {
|
||||
this.policyAddType = "client";
|
||||
this.policyAddPk = node.id;
|
||||
this.showPolicyAddModal = true;
|
||||
this.$q
|
||||
.dialog({
|
||||
component: PolicyAdd,
|
||||
parent: this,
|
||||
type: "client",
|
||||
object: node,
|
||||
})
|
||||
.onOk(() => {
|
||||
this.getTree();
|
||||
});
|
||||
} else {
|
||||
this.policyAddType = "site";
|
||||
this.policyAddPk = node.id;
|
||||
this.showPolicyAddModal = true;
|
||||
this.$q
|
||||
.dialog({
|
||||
component: PolicyAdd,
|
||||
parent: this,
|
||||
type: "site",
|
||||
object: node,
|
||||
})
|
||||
.onOk(() => {
|
||||
this.getTree();
|
||||
});
|
||||
}
|
||||
},
|
||||
showEditModal(node, op) {
|
||||
|
||||
Reference in New Issue
Block a user