fix agent drowndown in audit manager
This commit is contained in:
parent
8895994c54
commit
58f7603d4f
|
@ -35,6 +35,16 @@
|
|||
<q-item-section class="text-grey">No results</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
<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>
|
||||
</div>
|
||||
<div class="q-pa-sm col-2" v-if="filterType === 'clients'">
|
||||
|
@ -158,6 +168,7 @@
|
|||
import AuditLogDetail from "@/components/modals/logs/AuditLogDetail";
|
||||
import mixins from "@/mixins/mixins";
|
||||
import { exportFile } from "quasar";
|
||||
import { formatAgentOptions } from "@/utils/format";
|
||||
|
||||
function wrapCsvValue(val, formatFn) {
|
||||
let formatted = formatFn !== void 0 ? formatFn(val) : val;
|
||||
|
@ -327,7 +338,7 @@ export default {
|
|||
this.$axios
|
||||
.post(`logs/auditlogs/optionsfilter/`, data)
|
||||
.then(r => {
|
||||
this.getAgentOptions().then(options => (this.agentOptions = Object.freeze(options)));
|
||||
this.agentOptions = Object.freeze(formatAgentOptions(r.data));
|
||||
this.$q.loading.hide();
|
||||
})
|
||||
.catch(e => {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { Notify, date } from "quasar";
|
||||
import axios from 'axios'
|
||||
|
||||
import { formatAgentOptions } from "@/utils/format"
|
||||
|
||||
function getTimeLapse(unixtime) {
|
||||
var previous = unixtime * 1000;
|
||||
var current = new Date();
|
||||
|
@ -195,35 +197,9 @@ export default {
|
|||
},
|
||||
async getAgentOptions() {
|
||||
|
||||
let options = []
|
||||
const { data } = await axios.get("/agents/listagentsnodetail/")
|
||||
const agents = data.map(agent => ({
|
||||
label: agent.hostname,
|
||||
value: agent.pk,
|
||||
cat: `${agent.client} > ${agent.site}`,
|
||||
}));
|
||||
|
||||
let categories = [];
|
||||
agents.forEach(option => {
|
||||
if (!categories.includes(option.cat)) {
|
||||
categories.push(option.cat);
|
||||
}
|
||||
});
|
||||
|
||||
categories.sort().forEach(cat => {
|
||||
options.push({ category: cat });
|
||||
let tmp = []
|
||||
agents.forEach(agent => {
|
||||
if (agent.cat === cat) {
|
||||
tmp.push(agent);
|
||||
}
|
||||
});
|
||||
|
||||
const sorted = tmp.sort((a, b) => a.label.localeCompare(b.label));
|
||||
options.push(...sorted);
|
||||
});
|
||||
|
||||
return options;
|
||||
return formatAgentOptions(data)
|
||||
},
|
||||
getNextAgentUpdateTime() {
|
||||
const d = new Date();
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
export function formatAgentOptions(data) {
|
||||
let options = []
|
||||
const agents = data.map(agent => ({
|
||||
label: agent.hostname,
|
||||
value: agent.pk,
|
||||
cat: `${agent.client} > ${agent.site}`,
|
||||
}));
|
||||
|
||||
let categories = [];
|
||||
agents.forEach(option => {
|
||||
if (!categories.includes(option.cat)) {
|
||||
categories.push(option.cat);
|
||||
}
|
||||
});
|
||||
|
||||
categories.sort().forEach(cat => {
|
||||
options.push({ category: cat });
|
||||
let tmp = []
|
||||
agents.forEach(agent => {
|
||||
if (agent.cat === cat) {
|
||||
tmp.push(agent);
|
||||
}
|
||||
});
|
||||
|
||||
const sorted = tmp.sort((a, b) => a.label.localeCompare(b.label));
|
||||
options.push(...sorted);
|
||||
});
|
||||
|
||||
return options
|
||||
}
|
Loading…
Reference in New Issue