mirror of
https://github.com/jpros/tacticalrmm-web.git
synced 2026-02-26 14:22:05 +00:00
fix alert exclusions and policy exclusion modals
This commit is contained in:
@@ -780,7 +780,7 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["selectedAgentId", "agentTableHeight", "showCommunityScripts"]),
|
||||
...mapGetters(["agentTableHeight", "showCommunityScripts"]),
|
||||
agentDblClickAction() {
|
||||
return this.$store.state.agentDblClickAction;
|
||||
},
|
||||
|
||||
@@ -105,7 +105,7 @@ export default {
|
||||
getOptions() {
|
||||
this.getClients();
|
||||
this.getSites();
|
||||
this.getAgentOptions().then(options => (this.agentOptions = Object.freeze(options)));
|
||||
this.getAgentOptions("id").then(options => (this.agentOptions = Object.freeze(options)));
|
||||
},
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
@@ -126,9 +126,9 @@ export default {
|
||||
|
||||
// copy prop data locally
|
||||
this.localPolicy.id = this.policy.id;
|
||||
this.localPolicy.excluded_clients = this.policy.excluded_clients.map(client => client.id);
|
||||
this.localPolicy.excluded_sites = this.policy.excluded_sites.map(site => site.id);
|
||||
this.localPolicy.excluded_agents = this.policy.excluded_agents.map(agent => agent.pk);
|
||||
this.localPolicy.excluded_clients = this.policy.excluded_clients;
|
||||
this.localPolicy.excluded_sites = this.policy.excluded_sites;
|
||||
this.localPolicy.excluded_agents = this.policy.excluded_agents;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -10,68 +10,37 @@
|
||||
</q-bar>
|
||||
<q-form ref="form" @submit.prevent="onSubmit">
|
||||
<q-card-section>
|
||||
<q-select
|
||||
<tactical-dropdown
|
||||
label="Excluded Clients"
|
||||
dense
|
||||
options-dense
|
||||
outlined
|
||||
multiple
|
||||
v-model="localTemplate.excluded_clients"
|
||||
:options="clientOptions"
|
||||
use-chips
|
||||
map-options
|
||||
emit-value
|
||||
mapOptions
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
<tactical-dropdown
|
||||
label="Excluded Sites"
|
||||
dense
|
||||
options-dense
|
||||
outlined
|
||||
multiple
|
||||
v-model="localTemplate.excluded_sites"
|
||||
:options="siteOptions"
|
||||
use-chips
|
||||
map-options
|
||||
emit-value
|
||||
>
|
||||
<template v-slot:option="scope">
|
||||
<q-item v-if="!scope.opt.category" v-bind="scope.itemProps" class="q-pl-lg">
|
||||
<q-item-section>
|
||||
<q-item-label v-html="scope.opt.label"></q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item-label v-if="scope.opt.category" v-bind="scope.itemProps" header class="q-pa-sm">{{
|
||||
scope.opt.category
|
||||
}}</q-item-label>
|
||||
</template>
|
||||
</q-select>
|
||||
mapOptions
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<q-select
|
||||
<tactical-dropdown
|
||||
label="Excluded Agents"
|
||||
dense
|
||||
options-dense
|
||||
outlined
|
||||
multiple
|
||||
v-model="localTemplate.excluded_agents"
|
||||
:options="agentOptions"
|
||||
use-chips
|
||||
map-options
|
||||
emit-value
|
||||
>
|
||||
<template v-slot:option="scope">
|
||||
<q-item v-if="!scope.opt.category" v-bind="scope.itemProps" class="q-pl-lg">
|
||||
<q-item-section>
|
||||
<q-item-label v-html="scope.opt.label"></q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item-label v-if="scope.opt.category" v-bind="scope.itemProps" header class="q-pa-sm">{{
|
||||
scope.opt.category
|
||||
}}</q-item-label>
|
||||
</template>
|
||||
</q-select>
|
||||
mapOptions
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section>
|
||||
@@ -90,8 +59,12 @@
|
||||
|
||||
<script>
|
||||
import mixins from "@/mixins/mixins";
|
||||
import TacticalDropdown from "@/components/ui/TacticalDropdown";
|
||||
export default {
|
||||
name: "AlertExclusions",
|
||||
components: {
|
||||
TacticalDropdown,
|
||||
},
|
||||
emits: ["hide", "ok"],
|
||||
props: { template: !Object },
|
||||
mixins: [mixins],
|
||||
@@ -144,7 +117,7 @@ export default {
|
||||
getOptions() {
|
||||
this.getClients();
|
||||
this.getSites();
|
||||
this.getAgentOptions().then(options => (this.agentOptions = Object.freeze(options)));
|
||||
this.getAgentOptions("id").then(options => (this.agentOptions = Object.freeze(options)));
|
||||
},
|
||||
show() {
|
||||
this.$refs.dialog.show();
|
||||
@@ -168,6 +141,8 @@ export default {
|
||||
this.localTemplate.excluded_clients = this.template.excluded_clients;
|
||||
this.localTemplate.excluded_sites = this.template.excluded_sites;
|
||||
this.localTemplate.excluded_agents = this.template.excluded_agents;
|
||||
this.localTemplate.exclude_servers = this.template.exclude_servers;
|
||||
this.localTemplate.exclude_workstations = this.template.exclude_workstations;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -195,11 +195,11 @@ export default {
|
||||
|
||||
return options;
|
||||
},
|
||||
async getAgentOptions() {
|
||||
async getAgentOptions(value_field = "agent_id") {
|
||||
|
||||
const { data } = await axios.get("/agents/?detail=false")
|
||||
|
||||
return formatAgentOptions(data)
|
||||
return formatAgentOptions(data, false, value_field)
|
||||
},
|
||||
getNextAgentUpdateTime() {
|
||||
const d = new Date();
|
||||
|
||||
@@ -128,12 +128,6 @@ export default function () {
|
||||
})
|
||||
.catch(e => { });
|
||||
},
|
||||
loadClients(context) {
|
||||
return axios.get("/clients/");
|
||||
},
|
||||
loadSites(context) {
|
||||
return axios.get("/clients/sites/");
|
||||
},
|
||||
loadTree({ commit, state }) {
|
||||
axios.get("/clients/").then(r => {
|
||||
|
||||
|
||||
@@ -57,17 +57,17 @@ export function formatScriptOptions(data, flat = false) {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatAgentOptions(data, flat = false) {
|
||||
export function formatAgentOptions(data, flat = false, value_field = "agent_id") {
|
||||
|
||||
if (flat) {
|
||||
// returns just agent hostnames in array
|
||||
return _formatOptions(data, { label: "hostname", value: "agent_id", flat: true, allowDuplicates: false })
|
||||
return _formatOptions(data, { label: "hostname", value: value_field, flat: true, allowDuplicates: false })
|
||||
} else {
|
||||
// returns options with categories in object format
|
||||
let options = []
|
||||
const agents = data.map(agent => ({
|
||||
label: agent.hostname,
|
||||
value: agent.agent_id,
|
||||
value: agent[value_field],
|
||||
cat: `${agent.client} > ${agent.site}`,
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user