added relation view and a number of bug fixes

This commit is contained in:
sadnub
2021-02-02 19:03:01 -05:00
parent dbebd12f8a
commit 1fbd044260
10 changed files with 611 additions and 455 deletions

View File

@@ -228,7 +228,7 @@
<q-item-section side>
<q-icon size="xs" name="policy" />
</q-item-section>
<q-item-section>Edit Policies</q-item-section>
<q-item-section>Assign Automation Policy</q-item-section>
</q-item>
<q-item clickable v-close-popup @click.stop.prevent="showAgentRecovery = true">

View File

@@ -143,9 +143,21 @@
</q-icon>
</q-td>
<!-- name -->
<q-td>{{ props.row.name }}</q-td>
<q-td
>{{ props.row.name }}
<q-chip v-if="props.row.default_template" color="primary" text-color="white" size="sm"
>Default</q-chip
>
</q-td>
<!-- applied to -->
<q-td>Applied To Placeholder</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showTemplateApplied(props.row)"
>Show where template is applied ({{ props.row.applied_count }})</span
></q-td
>
<!-- alert exclusions -->
<q-td>
<span
@@ -174,6 +186,7 @@
import mixins from "@/mixins/mixins";
import AlertTemplateForm from "@/components/modals/alerts/AlertTemplateForm";
import AlertExclusions from "@/components/modals/alerts/AlertExclusions";
import AlertTemplateRelated from "@/components/modals/alerts/AlertTemplateRelated";
export default {
name: "AlertsManager",
@@ -290,6 +303,13 @@ export default {
this.refresh();
});
},
showTemplateApplied(template) {
this.$q.dialog({
component: AlertTemplateRelated,
parent: this,
template: template,
});
},
toggleEnabled(template) {
let text = template.is_active ? "Template enabled successfully" : "Template disabled successfully";

View File

@@ -107,147 +107,48 @@
</template>
</q-input>
</div>
<!-- List View -->
<q-tree
ref="folderTree"
v-if="!tableView"
style="min-height: 65vh; max-height: 65vh"
class="scroll"
:nodes="tree"
:filter="search"
no-connectors
node-key="id"
:expanded.sync="expanded"
@update:selected="nodeSelected"
:selected.sync="selected"
no-results-label="No Scripts Found"
no-nodes-label="No Scripts Found"
>
<template v-slot:header-script="props">
<div :class="props.node.id === props.tree.selected ? 'text-primary' : ''">
<q-icon v-if="props.node.favorite" color="yellow-8" name="star" size="sm" class="q-px-sm" />
<q-icon v-else color="yellow-8" name="star_outline" size="sm" class="q-px-sm" />
<div class="scroll" style="min-height: 65vh; max-height: 65vh">
<!-- List View -->
<q-tree
ref="folderTree"
v-if="!tableView"
:nodes="tree"
:filter="search"
no-connectors
node-key="id"
:expanded.sync="expanded"
@update:selected="nodeSelected"
:selected.sync="selected"
no-results-label="No Scripts Found"
no-nodes-label="No Scripts Found"
>
<template v-slot:header-script="props">
<div :class="props.node.id === props.tree.selected ? 'text-primary' : ''">
<q-icon v-if="props.node.favorite" color="yellow-8" name="star" size="sm" class="q-px-sm" />
<q-icon v-else color="yellow-8" name="star_outline" size="sm" class="q-px-sm" />
<q-icon v-if="props.node.shell === 'powershell'" name="mdi-powershell" color="primary">
<q-tooltip> Powershell </q-tooltip>
</q-icon>
<q-icon v-else-if="props.node.shell === 'python'" name="mdi-language-python" color="primary">
<q-tooltip> Python </q-tooltip>
</q-icon>
<q-icon v-else-if="props.node.shell === 'cmd'" name="mdi-script-text" color="primary">
<q-tooltip> Batch </q-tooltip>
</q-icon>
<q-icon v-if="props.node.shell === 'powershell'" name="mdi-powershell" color="primary">
<q-tooltip> Powershell </q-tooltip>
</q-icon>
<q-icon v-else-if="props.node.shell === 'python'" name="mdi-language-python" color="primary">
<q-tooltip> Python </q-tooltip>
</q-icon>
<q-icon v-else-if="props.node.shell === 'cmd'" name="mdi-microsoft-windows" color="primary">
<q-tooltip> Batch </q-tooltip>
</q-icon>
<span class="q-pl-xs text-weight-bold">{{ props.node.name }}</span>
<span class="q-pl-xs">{{ props.node.description }}</span>
</div>
<span class="q-pl-xs text-weight-bold">{{ props.node.name }}</span>
<span class="q-pl-xs">{{ props.node.description }}</span>
</div>
<!-- Context Menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item
clickable
v-close-popup
@click="editScript(props.node)"
id="context-edit"
v-if="props.node.script_type !== 'builtin'"
>
<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="deleteScript(props.node.id)"
id="context-delete"
v-if="props.node.script_type !== 'builtin'"
>
<q-item-section side>
<q-icon name="delete" />
</q-item-section>
<q-item-section>Delete</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="favoriteScript(props.node)">
<q-item-section side>
<q-icon name="star" />
</q-item-section>
<q-item-section>{{ favoriteText(props.node.favorite) }}</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup @click="viewCode(props.node)" id="context-view">
<q-item-section side>
<q-icon name="remove_red_eye" />
</q-item-section>
<q-item-section>View Code</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="downloadScript(props.node)" id="context-download">
<q-item-section side>
<q-icon name="cloud_download" />
</q-item-section>
<q-item-section>Download Script</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup>
<q-item-section>Close</q-item-section>
</q-item>
</q-list>
</q-menu>
</template>
</q-tree>
<q-table
v-if="tableView"
style="min-height: 65vh; max-height: 65vh"
dense
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
class="settings-tbl-sticky scroll"
:data="visibleScripts"
:columns="columns"
:visible-columns="visibleColumns"
:pagination.sync="pagination"
:filter="search"
row-key="id"
binary-state-sort
hide-pagination
virtual-scroll
flat
:rows-per-page-options="[0]"
no-data-label="No Scripts Found"
>
<template v-slot:header-cell-favorite="props">
<q-th :props="props" auto-width>
<q-icon name="star" color="yellow-8" size="sm" />
</q-th>
</template>
<template v-slot:header-cell-shell="props">
<q-th :props="props" auto-width> Shell </q-th>
</template>
<template slot="body" slot-scope="props" :props="props">
<!-- Table View -->
<q-tr
:class="`${rowSelectedClass(props.row.id)} cursor-pointer`"
@click="selectedScript = props.row"
@contextmenu="selectedScript = props.row"
>
<!-- Context Menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item
clickable
v-close-popup
@click="editScript(props.row)"
id="context-edit"
v-if="props.row.script_type !== 'builtin'"
@click="editScript(props.node)"
v-if="props.node.script_type !== 'builtin'"
>
<q-item-section side>
<q-icon name="edit" />
@@ -258,9 +159,8 @@
<q-item
clickable
v-close-popup
@click="deleteScript(props.row.id)"
id="context-delete"
v-if="props.row.script_type !== 'builtin'"
@click="deleteScript(props.node.id)"
v-if="props.node.script_type !== 'builtin'"
>
<q-item-section side>
<q-icon name="delete" />
@@ -268,23 +168,23 @@
<q-item-section>Delete</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="favoriteScript(props.row)">
<q-item clickable v-close-popup @click="favoriteScript(props.node)">
<q-item-section side>
<q-icon name="star" />
</q-item-section>
<q-item-section>{{ favoriteText(props.row.favorite) }}</q-item-section>
<q-item-section>{{ favoriteText(props.node.favorite) }}</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup @click="viewCode(props.row)" id="context-view">
<q-item clickable v-close-popup @click="viewCode(props.node)">
<q-item-section side>
<q-icon name="remove_red_eye" />
</q-item-section>
<q-item-section>View Code</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="downloadScript(props.row)" id="context-download">
<q-item clickable v-close-popup @click="downloadScript(props.node)">
<q-item-section side>
<q-icon name="cloud_download" />
</q-item-section>
@@ -298,34 +198,126 @@
</q-item>
</q-list>
</q-menu>
<q-td>
<q-icon v-if="props.row.favorite" color="yellow-8" name="star" size="sm" />
</q-td>
<q-td>
<q-icon v-if="props.row.shell === 'powershell'" name="mdi-powershell" color="primary" size="sm">
<q-tooltip> Powershell </q-tooltip>
</q-icon>
<q-icon v-else-if="props.row.shell === 'python'" name="mdi-language-python" color="primary" size="sm">
<q-tooltip> Python </q-tooltip>
</q-icon>
<q-icon v-else-if="props.row.shell === 'cmd'" name="mdi-script-text" color="primary" size="sm">
<q-tooltip> Batch </q-tooltip>
</q-icon>
</q-td>
<q-td>{{ props.row.name }}</q-td>
<q-td>{{ props.row.category }}</q-td>
<q-td>
{{ truncateText(props.row.description) }}
<q-tooltip v-if="props.row.description.length >= 60" content-style="font-size: 12px">{{
props.row.description
}}</q-tooltip>
</q-td>
</q-tr>
</template>
</q-table>
</template>
</q-tree>
<q-table
v-if="tableView"
dense
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
class="settings-tbl-sticky"
:data="visibleScripts"
:columns="columns"
:visible-columns="visibleColumns"
:pagination.sync="pagination"
:filter="search"
row-key="id"
binary-state-sort
hide-pagination
virtual-scroll
:rows-per-page-options="[0]"
>
<template v-slot:header-cell-favorite="props">
<q-th :props="props" auto-width>
<q-icon name="star" color="yellow-8" size="sm" />
</q-th>
</template>
<template v-slot:header-cell-shell="props">
<q-th :props="props" auto-width> Shell </q-th>
</template>
<template v-slot:no-data> No Scripts Found </template>
<template slot="body" slot-scope="props" :props="props">
<!-- Table View -->
<q-tr
:class="`${rowSelectedClass(props.row.id)} cursor-pointer`"
@click="selectedScript = props.row"
@contextmenu="selectedScript = props.row"
>
<!-- Context Menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item
clickable
v-close-popup
@click="editScript(props.row)"
v-if="props.row.script_type !== 'builtin'"
>
<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="deleteScript(props.row.id)"
v-if="props.row.script_type !== 'builtin'"
>
<q-item-section side>
<q-icon name="delete" />
</q-item-section>
<q-item-section>Delete</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="favoriteScript(props.row)">
<q-item-section side>
<q-icon name="star" />
</q-item-section>
<q-item-section>{{ favoriteText(props.row.favorite) }}</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup @click="viewCode(props.row)">
<q-item-section side>
<q-icon name="remove_red_eye" />
</q-item-section>
<q-item-section>View Code</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="downloadScript(props.row)">
<q-item-section side>
<q-icon name="cloud_download" />
</q-item-section>
<q-item-section>Download Script</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup>
<q-item-section>Close</q-item-section>
</q-item>
</q-list>
</q-menu>
<q-td>
<q-icon v-if="props.row.favorite" color="yellow-8" name="star" size="sm" />
</q-td>
<q-td>
<q-icon v-if="props.row.shell === 'powershell'" name="mdi-powershell" color="primary" size="sm">
<q-tooltip> Powershell </q-tooltip>
</q-icon>
<q-icon v-else-if="props.row.shell === 'python'" name="mdi-language-python" color="primary" size="sm">
<q-tooltip> Python </q-tooltip>
</q-icon>
<q-icon v-else-if="props.row.shell === 'cmd'" name="mdi-microsoft-windows" color="primary" size="sm">
<q-tooltip> Batch </q-tooltip>
</q-icon>
</q-td>
<q-td>{{ props.row.name }}</q-td>
<q-td>{{ props.row.category }}</q-td>
<q-td>
{{ truncateText(props.row.description) }}
<q-tooltip v-if="props.row.description.length >= 60" content-style="font-size: 12px">{{
props.row.description
}}</q-tooltip>
</q-td>
</q-tr>
</template>
</q-table>
</div>
</div>
<q-separator />
<q-card-section></q-card-section>
</q-card>
<q-dialog v-model="showScriptUploadModal">
<ScriptUploadModal
@@ -542,7 +534,7 @@ export default {
return this.selectedScript.id !== null && this.selectedScript.id !== undefined;
},
tree() {
if (this.tableView) {
if (this.tableView || this.visibleScripts.length === 0) {
return [];
} else {
let nodes = [];

View File

@@ -10,214 +10,215 @@
</q-btn>
</q-bar>
<div class="q-pa-md">
<div class="q-gutter-sm">
<q-btn label="New" dense flat push unelevated no-caps icon="add" @click="showAddPolicyForm" />
<q-btn
label="Edit"
:disable="!selectedPolicy"
<q-card-section style="min-height: 35vh; max-height: 35vh">
<div class="q-gutter-sm">
<q-btn label="New" dense flat push unelevated no-caps icon="add" @click="showAddPolicyForm" />
<q-btn
label="Edit"
:disable="!selectedPolicy"
dense
flat
push
unelevated
no-caps
icon="edit"
@click="showEditPolicyForm(selectedPolicy)"
/>
<q-btn
label="Delete"
:disable="!selectedPolicy"
dense
flat
push
unelevated
no-caps
icon="delete"
@click="deletePolicy(selectedPolicy)"
/>
<q-btn
label="Policy Overview"
dense
flat
push
unelevated
no-caps
icon="remove_red_eye"
@click="showPolicyOverview"
/>
</div>
<q-table
: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
flat
push
unelevated
no-caps
icon="edit"
@click="showEditPolicyForm(selectedPolicy)"
/>
<q-btn
label="Delete"
:disable="!selectedPolicy"
dense
flat
push
unelevated
no-caps
icon="delete"
@click="deletePolicy(selectedPolicy)"
/>
<q-btn
label="Policy Overview"
dense
flat
push
unelevated
no-caps
icon="remove_red_eye"
@click="showPolicyOverview"
/>
</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
no-data-label="No Policies"
>
<!-- header slots -->
<template v-slot:header-cell-active="props">
<q-th :props="props" auto-width>
<q-icon name="power_settings_new" size="1.5em">
<q-tooltip>Enable Policy</q-tooltip>
</q-icon>
</q-th>
</template>
<template v-slot:header-cell-enforced="props">
<q-th :props="props" auto-width>
<q-icon name="security" size="1.5em">
<q-tooltip>Enforce Policy (Will override Agent tasks/checks)</q-tooltip>
</q-icon>
</q-th>
</template>
<!-- body slots -->
<template v-slot:body="props">
<q-tr
:props="props"
class="cursor-pointer"
:class="rowSelectedClass(props.row.id, selectedPolicy)"
@click="selectedPolicy = props.row"
@contextmenu="selectedPolicy = props.row"
@dblclick="showEditPolicyForm(props.row)"
>
<!-- context menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item clickable v-close-popup @click="showEditPolicyForm(props.row)">
<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="showCopyPolicyForm(props.row)">
<q-item-section side>
<q-icon name="content_copy" />
</q-item-section>
<q-item-section>Copy</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="deletePolicy(props.row)">
<q-item-section side>
<q-icon name="delete" />
</q-item-section>
<q-item-section>Delete</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup @click="showRelations(props.row)">
<q-item-section side>
<q-icon name="account_tree" />
</q-item-section>
<q-item-section>Show Relations</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="showPatchPolicyForm(props.row)">
<q-item-section side>
<q-icon name="system_update" />
</q-item-section>
<q-item-section>{{ patchPolicyText(props.row) }}</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="showAlertTemplateAdd(props.row)">
<q-item-section side>
<q-icon name="warning" />
</q-item-section>
<q-item-section>{{ alertTemplateText(props.row) }}</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup>
<q-item-section>Close</q-item-section>
</q-item>
</q-list>
</q-menu>
<!-- enabled checkbox -->
<q-td>
<q-checkbox dense @input="toggleCheckbox(props.row, 'Active')" v-model="props.row.active" />
</q-td>
<!-- enforced checkbox -->
<q-td>
<q-checkbox dense @input="toggleCheckbox(props.row, 'Enforced')" v-model="props.row.enforced" />
</q-td>
<q-td>
{{ props.row.name }}
<q-chip v-if="props.row.default_server_policy" color="primary" text-color="white" size="sm"
>Default Server</q-chip
>
<q-chip v-if="props.row.default_workstation_policy" color="primary" text-color="white" size="sm"
>Default Workstation</q-chip
>
</q-td>
<q-td>{{ props.row.desc }}</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showRelations(props.row)"
>{{ `Show Relations (${props.row.agents_count}+)` }}</span
>
</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showPatchPolicyForm(props.row)"
>{{ patchPolicyText(props.row) }}</span
>
</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showAlertTemplateAdd(props.row)"
>{{ alertTemplateText(props.row) }}</span
>
</q-td>
<q-td>
<q-icon name="content_copy" size="1.5em" @click="showCopyPolicyForm(props.row)">
<q-tooltip>Create a copy of this policy</q-tooltip>
row-key="id"
binary-state-sort
hide-pagination
virtual-scroll
no-data-label="No Policies"
>
<!-- header slots -->
<template v-slot:header-cell-active="props">
<q-th :props="props" auto-width>
<q-icon name="power_settings_new" size="1.5em">
<q-tooltip>Enable Policy</q-tooltip>
</q-icon>
</q-td>
</q-tr>
</template>
</q-table>
</div>
</q-th>
</template>
<q-card-section>
<q-tabs
v-model="subtab"
dense
inline-label
class="text-grey"
active-color="primary"
indicator-color="primary"
align="left"
narrow-indicator
no-caps
>
<q-tab name="checks" icon="fas fa-check-double" label="Checks" />
<q-tab name="tasks" icon="fas fa-tasks" label="Tasks" />
</q-tabs>
<q-separator />
<q-tab-panels v-model="subtab" :animated="false">
<q-tab-panel name="checks">
<PolicyChecksTab v-if="!!selectedPolicy" :selectedPolicy="selectedPolicy.id" />
</q-tab-panel>
<q-tab-panel name="tasks">
<PolicyAutomatedTasksTab v-if="!!selectedPolicy" :selectedPolicy="selectedPolicy.id" />
</q-tab-panel>
</q-tab-panels>
</q-card-section>
<template v-slot:header-cell-enforced="props">
<q-th :props="props" auto-width>
<q-icon name="security" size="1.5em">
<q-tooltip>Enforce Policy (Will override Agent tasks/checks)</q-tooltip>
</q-icon>
</q-th>
</template>
<!-- body slots -->
<template v-slot:body="props">
<q-tr
:props="props"
class="cursor-pointer"
:class="rowSelectedClass(props.row.id, selectedPolicy)"
@click="selectedPolicy = props.row"
@contextmenu="selectedPolicy = props.row"
@dblclick="showEditPolicyForm(props.row)"
>
<!-- context menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item clickable v-close-popup @click="showEditPolicyForm(props.row)">
<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="showCopyPolicyForm(props.row)">
<q-item-section side>
<q-icon name="content_copy" />
</q-item-section>
<q-item-section>Copy</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="deletePolicy(props.row)">
<q-item-section side>
<q-icon name="delete" />
</q-item-section>
<q-item-section>Delete</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup @click="showRelations(props.row)">
<q-item-section side>
<q-icon name="account_tree" />
</q-item-section>
<q-item-section>Show Relations</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="showPatchPolicyForm(props.row)">
<q-item-section side>
<q-icon name="system_update" />
</q-item-section>
<q-item-section>{{ patchPolicyText(props.row) }}</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="showAlertTemplateAdd(props.row)">
<q-item-section side>
<q-icon name="warning" />
</q-item-section>
<q-item-section>{{ alertTemplateText(props.row) }}</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup>
<q-item-section>Close</q-item-section>
</q-item>
</q-list>
</q-menu>
<!-- enabled checkbox -->
<q-td>
<q-checkbox dense @input="toggleCheckbox(props.row, 'Active')" v-model="props.row.active" />
</q-td>
<!-- enforced checkbox -->
<q-td>
<q-checkbox dense @input="toggleCheckbox(props.row, 'Enforced')" v-model="props.row.enforced" />
</q-td>
<q-td>
{{ props.row.name }}
<q-chip v-if="props.row.default_server_policy" color="primary" text-color="white" size="sm"
>Default Server</q-chip
>
<q-chip v-if="props.row.default_workstation_policy" color="primary" text-color="white" size="sm"
>Default Workstation</q-chip
>
</q-td>
<q-td>{{ props.row.desc }}</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showRelations(props.row)"
>{{ `Show Relations (${props.row.agents_count})` }}</span
>
</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showPatchPolicyForm(props.row)"
>{{ patchPolicyText(props.row) }}</span
>
</q-td>
<q-td>
<span
style="cursor: pointer; text-decoration: underline"
class="text-primary"
@click="showAlertTemplateAdd(props.row)"
>{{ alertTemplateText(props.row) }}</span
>
</q-td>
<q-td>
<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>
</q-tr>
</template>
</q-table>
</q-card-section>
<q-card-section style="min-height: 35vh; max-height: 35vh">
<q-tabs
v-model="subtab"
dense
inline-label
class="text-grey"
active-color="primary"
indicator-color="primary"
align="left"
narrow-indicator
no-caps
>
<q-tab name="checks" icon="fas fa-check-double" label="Checks" />
<q-tab name="tasks" icon="fas fa-tasks" label="Tasks" />
</q-tabs>
<q-separator />
<q-tab-panels v-model="subtab" :animated="false">
<q-tab-panel name="checks">
<PolicyChecksTab v-if="!!selectedPolicy" :selectedPolicy="selectedPolicy.id" />
</q-tab-panel>
<q-tab-panel name="tasks">
<PolicyAutomatedTasksTab v-if="!!selectedPolicy" :selectedPolicy="selectedPolicy.id" />
</q-tab-panel>
</q-tab-panels>
</q-card-section>
</div>
</q-card>
</div>
</q-dialog>

View File

@@ -317,7 +317,8 @@ export default {
this.editCheckPK = check.id;
this.showDialog = true;
},
hideDialog(component) {
hideDialog() {
this.getChecks();
this.showDialog = false;
this.dialogComponent = null;
this.editCheckPK = null;
@@ -331,7 +332,7 @@ export default {
})
.onOk(() => {
this.$q.loading.show();
this.axios
this.$axios
.delete(`/checks/${check.id}/check/`)
.then(r => {
this.getChecks();

View File

@@ -1,11 +1,13 @@
<template>
<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-bar>
{{ policy.name }} Relations
<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
class="row items-center"
v-if="related.default_server_policy || related.default_workstation_policy"

View File

@@ -0,0 +1,112 @@
<template>
<q-dialog ref="dialog" @hide="onHide">
<q-card style="width: 60vw">
<q-bar>
Assigned to {{ template.name }}
<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-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="policies" label="Policies" />
<q-tab name="clients" label="Clients" />
<q-tab name="sites" label="Sites" />
</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="policies">
<q-list separator padding>
<q-item :key="policy.id" v-for="policy in related.policies">
<q-item-section>
<q-item-label>{{ policy.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-tab-panel>
<q-tab-panel name="clients">
<q-list separator padding>
<q-item :key="client.id" v-for="client in related.clients">
<q-item-section>
<q-item-label>{{ client.name }}</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="site.id" v-for="site in related.sites">
<q-item-section>
<q-item-label>{{ site.name }}</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>
export default {
name: "AlertTemplateRelated",
props: {
template: !Object,
},
data() {
return {
tab: "policies",
related: {},
thumbStyle: {
right: "2px",
borderRadius: "5px",
backgroundColor: "#027be3",
width: "5px",
opacity: 0.75,
},
};
},
methods: {
show() {
this.$refs.dialog.show();
},
hide() {
this.$refs.dialog.hide();
},
onHide() {
this.$emit("hide");
},
},
mounted() {
this.$q.loading.show();
this.$axios
.get(`/alerts/alerttemplates/${this.template.id}/related/`)
.then(r => {
this.$q.loading.hide();
this.related = r.data;
})
.catch(e => {
this.$q.loading.hide();
this.notifyError("There was an error getting related templates");
});
},
};
</script>

View File

@@ -90,7 +90,7 @@
<q-card-section class="row">
<div class="col-4">Reset Patch Policy on Agents:</div>
<div class="col-2"></div>
<q-btn color="negative" label="Reset" @click="resetPatchPolicyModal" />
<q-btn color="negative" label="Reset" @click="showResetPatchPolicy" />
</q-card-section>
</q-tab-panel>
<!-- email alerts -->
@@ -305,26 +305,20 @@
</q-form>
</template>
</q-splitter>
<q-dialog v-model="showResetPatchPolicyModal">
<ResetPatchPolicy @close="showResetPatchPolicyModal = false" />
</q-dialog>
</q-card>
</template>
<script>
import mixins from "@/mixins/mixins";
import { mapState } from "vuex";
import ResetPatchPolicy from "@/components/modals/coresettings/ResetPatchPolicy";
export default {
name: "EditCoreSettings",
components: { ResetPatchPolicy },
mixins: [mixins],
data() {
return {
showResetPatchPolicyModal: false,
ready: false,
policies: [],
settings: {},
email: null,
tab: "general",
@@ -351,15 +345,29 @@ export default {
});
},
getPolicies() {
this.$store.dispatch("automation/loadPolicies").catch(e => {
this.notifyError(e.response.data);
});
this.$q.loading.show();
this.$axios
.get("/automation/policies/")
.then(r => {
this.policies = r.data.map(policy => ({ label: policy.name, value: policy.id }));
this.$q.loading.hide();
})
.catch(e => {
this.$q.loading.hide();
this.notifyError("Unable to get policies");
});
},
getAlertTemplates() {
this.$axios.get("alerts/alerttemplates").then(r => {
this.alertTemplateOptions = r.data.map(template => ({ label: template.name, value: template.id }));
});
},
showResetPatchPolicy() {
this.$q.dialog({
component: ResetPatchPolicy,
parent: this,
});
},
toggleAddEmail() {
this.$q
.dialog({
@@ -403,9 +411,6 @@ export default {
const removed = this.settings.sms_alert_recipients.filter(k => k !== num);
this.settings.sms_alert_recipients = removed;
},
resetPatchPolicyModal() {
this.showResetPatchPolicyModal = true;
},
editSettings() {
this.$q.loading.show();
delete this.settings.all_timezones;
@@ -439,11 +444,6 @@ export default {
});
},
},
computed: {
...mapState({
policies: state => state.automation.policies.map(policy => ({ label: policy.name, value: policy.id })),
}),
},
created() {
this.getCoreSettings();
this.getPolicies();

View File

@@ -1,56 +1,54 @@
<template>
<q-card style="min-width: 400px">
<q-card-section class="row">
<q-card-actions align="left">
<div class="text-h6">Reset Agent Patch Policy</div>
</q-card-actions>
<q-space />
<q-card-actions align="right">
<q-btn v-close-popup flat round dense icon="close" />
</q-card-actions>
</q-card-section>
<q-card-section>
<div class="text-subtitle3">
Reset the patch policies for agents in a specific client or site. You can also leave the client and site blank
to reset the patch policy for all agents. (This might take a while)
</div>
<q-form @submit.prevent="submit">
<q-card-section>
<q-select
label="Clients"
@clear="clearClient"
clearable
options-dense
outlined
v-model="client"
:options="client_options"
@input="client !== null ? (site = site_options[0]) : () => {}"
/>
</q-card-section>
<q-card-section>
<q-select
:disabled="client === null"
@clear="clearSite"
label="Sites"
clearable
options-dense
outlined
v-model="site"
:options="site_options"
/>
</q-card-section>
<q-card-actions align="right">
<q-btn :label="buttonText" color="primary" type="submit" />
<q-btn label="Cancel" v-close-popup />
</q-card-actions>
</q-form>
</q-card-section>
</q-card>
<q-dialog ref="dialog" @hide="onHide">
<q-card class="q-dialog-plugin" style="min-width: 400px">
<q-bar>
Reset Agent Patch Policy
<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-card-section>
<div class="text-subtitle3">
Reset the patch policies for agents in a specific client or site. You can also leave the client and site blank
to reset the patch policy for all agents. (This might take a while)
</div>
<q-form @submit.prevent="submit">
<q-card-section>
<q-select
label="Clients"
@clear="clearClient"
clearable
options-dense
outlined
v-model="client"
:options="client_options"
/>
</q-card-section>
<q-card-section>
<q-select
:disabled="client === null"
@clear="clearSite"
label="Sites"
clearable
options-dense
outlined
v-model="site"
:options="site_options"
/>
</q-card-section>
<q-card-actions align="right">
<q-btn :label="buttonText" color="primary" type="submit" />
<q-btn label="Cancel" v-close-popup />
</q-card-actions>
</q-form>
</q-card-section>
</q-card>
</q-dialog>
</template>
<script>
import mixins from "@/mixins/mixins";
import { notifySuccessConfig, notifyErrorConfig } from "@/mixins/mixins";
export default {
name: "ResetPatchPolicy",
@@ -76,16 +74,16 @@ export default {
data.site = this.site.value;
}
this.$store
.dispatch("automation/resetPatchPolicies", data)
this.$axios
.patch("automation/winupdatepolicy/reset/", data)
.then(r => {
this.$q.loading.hide();
this.$q.notify(notifySuccessConfig("The agent policies were reset successfully!"));
this.$emit("close");
this.notifySuccess("The agent policies were reset successfully!");
this.onOk();
})
.catch(e => {
this.$q.loading.hide();
this.$q.notify(notifyErrorConfig("There was an error reseting policies"));
this.notifyError("There was an error reseting policies");
});
},
getClients() {
@@ -95,7 +93,7 @@ export default {
this.client_options = this.formatClientOptions(r.data);
})
.catch(e => {
this.$q.notify(notifyErrorConfig("There was an error loading the clients!"));
this.notifyError("There was an error loading the clients!");
});
},
clearClient() {
@@ -105,6 +103,19 @@ export default {
clearSite() {
this.site = null;
},
show() {
this.$refs.dialog.show();
},
hide() {
this.$refs.dialog.hide();
},
onHide() {
this.$emit("hide");
},
onOk() {
this.$emit("ok");
this.hide();
},
},
computed: {
site_options() {

View File

@@ -185,6 +185,7 @@ export default {
timeout: 120,
alert_severity: "info",
},
policyChecks: [],
severityOptions: [
{ label: "Informational", value: "info" },
{ label: "Warning", value: "warning" },
@@ -241,12 +242,24 @@ export default {
.sort((a, b) => a.label.localeCompare(b.label));
});
},
getPolicyChecks() {
this.$axios
.get(`/automation/${this.policypk}/policychecks/`)
.then(r => {
this.policyChecks = r.data;
this.$q.loading.hide();
})
.catch(e => {
this.$q.loading.hide();
this.notifyError("Unable to get policy checks");
});
},
},
computed: {
...mapGetters(["selectedAgentPk"]),
checks() {
return this.policypk
? this.$store.state.automation.checks
? this.policyChecks
: this.$store.state.agentChecks.filter(check => check.managed_by_policy === false);
},
checksOptions() {
@@ -277,6 +290,10 @@ export default {
},
created() {
this.getScripts();
if (this.policypk) {
this.getPolicyChecks();
}
},
};
</script>