fix debug log and change agent dropdown to use agent_id versus pk
This commit is contained in:
@@ -4,6 +4,6 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("pendingactions/", views.PendingActions.as_view()),
|
path("pendingactions/", views.PendingActions.as_view()),
|
||||||
path("auditlogs/", views.GetAuditLogs.as_view()),
|
path("audit/", views.GetAuditLogs.as_view()),
|
||||||
path("debuglog/", views.GetDebugLog.as_view()),
|
path("debug/", views.GetDebugLog.as_view()),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class GetDebugLog(APIView):
|
|||||||
logLevelFilter = Q(log_level=request.data["logLevelFilter"])
|
logLevelFilter = Q(log_level=request.data["logLevelFilter"])
|
||||||
|
|
||||||
if "agentFilter" in request.data:
|
if "agentFilter" in request.data:
|
||||||
agentFilter = Q(agent=request.data["agentFilter"])
|
agentFilter = Q(agent__agent_id=request.data["agentFilter"])
|
||||||
|
|
||||||
debug_logs = (
|
debug_logs = (
|
||||||
DebugLog.objects.prefetch_related("agent")
|
DebugLog.objects.prefetch_related("agent")
|
||||||
@@ -160,5 +160,5 @@ class GetDebugLog(APIView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
ctx = {"default_tz": get_default_timezone()}
|
ctx = {"default_tz": get_default_timezone()}
|
||||||
ret = DebugLogSerializer(debug_logs, many=True, context=ctx).data
|
ret = DebugLogSerializer(debug_logs.order_by("-entry_time")[0:1000], many=True, context=ctx).data
|
||||||
return Response(ret)
|
return Response(ret)
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ const baseUrl = "/logs"
|
|||||||
|
|
||||||
export async function fetchDebugLog(payload) {
|
export async function fetchDebugLog(payload) {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.patch(`${baseUrl}/debuglog/`, payload)
|
const { data } = await axios.patch(`${baseUrl}/debug/`, payload)
|
||||||
return data
|
return data
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchAuditLog(payload) {
|
export async function fetchAuditLog(payload) {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.patch(`${baseUrl}/auditlogs/`, payload)
|
const { data } = await axios.patch(`${baseUrl}/audit/`, payload)
|
||||||
return data
|
return data
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
binary-state-sort
|
binary-state-sort
|
||||||
|
virtual-scroll
|
||||||
v-model:pagination="pagination"
|
v-model:pagination="pagination"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:rows-per-page-options="[0]"
|
:rows-per-page-options="[0]"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
v-model:pagination="pagination"
|
v-model:pagination="pagination"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:rows-per-page-options="[0]"
|
:rows-per-page-options="[0]"
|
||||||
|
virtual-scroll
|
||||||
no-data-label="No checks"
|
no-data-label="No checks"
|
||||||
>
|
>
|
||||||
<!-- table top slot -->
|
<!-- table top slot -->
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="!selectedAgent" class="q-pa-sm">No agent selected</div>
|
<div v-if="!selectedAgent" class="q-pa-sm">No agent selected</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<DebugLog :agentpk="selectedAgent" />
|
<DebugLog :agent="selectedAgent" :tabHeight="tabHeight" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -21,10 +21,12 @@ export default {
|
|||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const selectedAgent = computed(() => store.state.selectedRow);
|
const selectedAgent = computed(() => store.state.selectedRow);
|
||||||
|
const tabHeight = computed(() => store.state.tabHeight);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// computed
|
// computed
|
||||||
selectedAgent,
|
selectedAgent,
|
||||||
|
tabHeight,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,15 +5,23 @@
|
|||||||
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
||||||
:rows="history"
|
:rows="history"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:pagination="{ sortBy: 'time', descending: true, rowsPerPage: 10 }"
|
:pagination="{ sortBy: 'time', descending: true, rowsPerPage: 0 }"
|
||||||
:style="{ 'max-height': tabHeight }"
|
:style="{ 'max-height': tabHeight }"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
:rows-per-page-options="[0]"
|
||||||
|
:filter="filter"
|
||||||
|
virtual-scroll
|
||||||
dense
|
dense
|
||||||
binary-state-sort
|
binary-state-sort
|
||||||
>
|
>
|
||||||
<template v-slot:top>
|
<template v-slot:top>
|
||||||
<q-btn dense flat push @click="getHistory" icon="refresh" />
|
<q-btn dense flat push @click="getHistory" icon="refresh" />
|
||||||
<q-space />
|
<q-space />
|
||||||
|
<q-input v-model="filter" outlined label="Search" dense clearable class="q-pr-sm">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<q-icon name="search" color="primary" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
<export-table-btn :data="history" :columns="columns" />
|
<export-table-btn :data="history" :columns="columns" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -114,6 +122,7 @@ export default {
|
|||||||
// setup main history functionality
|
// setup main history functionality
|
||||||
const history = ref([]);
|
const history = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const filter = ref("");
|
||||||
|
|
||||||
async function getHistory() {
|
async function getHistory() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@@ -147,6 +156,7 @@ export default {
|
|||||||
history,
|
history,
|
||||||
loading,
|
loading,
|
||||||
tabHeight,
|
tabHeight,
|
||||||
|
filter,
|
||||||
|
|
||||||
// non-reactive data
|
// non-reactive data
|
||||||
columns,
|
columns,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
:rows-per-page-options="[0]"
|
:rows-per-page-options="[0]"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
hide-bottom
|
hide-bottom
|
||||||
|
virtual-scroll
|
||||||
no-data-label="No notes"
|
no-data-label="No notes"
|
||||||
>
|
>
|
||||||
<template v-slot:top>
|
<template v-slot:top>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
v-model:pagination="pagination"
|
v-model:pagination="pagination"
|
||||||
binary-state-sort
|
binary-state-sort
|
||||||
row-key="id"
|
row-key="id"
|
||||||
|
virtual-scroll
|
||||||
:rows-per-page-options="[0]"
|
:rows-per-page-options="[0]"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,51 +7,67 @@
|
|||||||
<q-tooltip content-class="bg-white text-primary">Close</q-tooltip>
|
<q-tooltip content-class="bg-white text-primary">Close</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</q-bar>
|
</q-bar>
|
||||||
<q-card-section class="row">
|
<q-table
|
||||||
<q-btn v-if="agentpk" dense flat push @click="getDebugLog" icon="refresh" />
|
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
||||||
<tactical-dropdown
|
class="tabs-tbl-sticky"
|
||||||
v-if="!agentpk"
|
:style="{ 'max-height': tabHeight ? tabHeight : `${$q.screen.height - 32}px` }"
|
||||||
class="col-2 q-pr-sm"
|
:rows="debugLog"
|
||||||
v-model="agentFilter"
|
:columns="columns"
|
||||||
label="Agents Filter"
|
:title="modal ? 'Debug Logs' : ''"
|
||||||
:options="agentOptions"
|
:pagination="{ sortBy: 'entry_time', descending: true, rowsPerPage: 0 }"
|
||||||
mapOptions
|
:loading="loading"
|
||||||
outlined
|
:filter="filter"
|
||||||
clearable
|
virtual-scroll
|
||||||
/>
|
dense
|
||||||
<tactical-dropdown
|
binary-state-sort
|
||||||
class="col-2 q-pr-sm"
|
:rows-per-page-options="[0]"
|
||||||
v-model="logTypeFilter"
|
>
|
||||||
label="Log Type Filter"
|
<template v-slot:top>
|
||||||
:options="logTypeOptions"
|
<q-btn v-if="agent" class="q-pr-sm" dense flat push @click="getDebugLog" icon="refresh" />
|
||||||
mapOptions
|
<tactical-dropdown
|
||||||
outlined
|
v-if="!agent"
|
||||||
clearable
|
class="q-pr-sm"
|
||||||
/>
|
style="width: 250px"
|
||||||
<q-radio v-model="logLevelFilter" color="cyan" val="info" label="Info" />
|
v-model="agentFilter"
|
||||||
<q-radio v-model="logLevelFilter" color="red" val="critical" label="Critical" />
|
label="Agents Filter"
|
||||||
<q-radio v-model="logLevelFilter" color="red" val="error" label="Error" />
|
:options="agentOptions"
|
||||||
<q-radio v-model="logLevelFilter" color="yellow" val="warning" label="Warning" />
|
mapOptions
|
||||||
<q-space />
|
outlined
|
||||||
<export-table-btn v-if="!modal" :data="debugLog" :columns="columns" />
|
clearable
|
||||||
</q-card-section>
|
filterable
|
||||||
<q-separator />
|
/>
|
||||||
<q-card-section>
|
<tactical-dropdown
|
||||||
<q-table
|
class="q-pr-sm"
|
||||||
:table-class="{ 'table-bgcolor': !$q.dark.isActive, 'table-bgcolor-dark': $q.dark.isActive }"
|
style="width: 250px"
|
||||||
:rows="debugLog"
|
v-model="logTypeFilter"
|
||||||
:columns="columns"
|
label="Log Type Filter"
|
||||||
:title="modal ? 'Debug Logs' : ''"
|
:options="logTypeOptions"
|
||||||
:pagination="{ sortBy: 'entry_time', descending: true }"
|
mapOptions
|
||||||
:loading="loading"
|
outlined
|
||||||
dense
|
clearable
|
||||||
binary-state-sort
|
/>
|
||||||
>
|
<q-radio v-model="logLevelFilter" color="cyan" val="info" label="Info" />
|
||||||
<template v-slot:top-right>
|
<q-radio v-model="logLevelFilter" color="red" val="critical" label="Critical" />
|
||||||
<export-table-btn v-if="modal" :data="debugLog" :columns="columns" />
|
<q-radio v-model="logLevelFilter" color="red" val="error" label="Error" />
|
||||||
</template>
|
<q-radio v-model="logLevelFilter" color="yellow" val="warning" label="Warning" />
|
||||||
</q-table>
|
<q-space />
|
||||||
</q-card-section>
|
<q-input v-model="filter" outlined label="Search" dense clearable class="q-pr-sm">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<q-icon name="search" color="primary" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
<export-table-btn :data="debugLog" :columns="columns" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:top-row>
|
||||||
|
<q-tr v-if="debugLog.length === 1000">
|
||||||
|
<q-td colspan="100%">
|
||||||
|
<q-icon name="warning" color="warning" />
|
||||||
|
Results are limited to 1000 rows.
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -104,7 +120,8 @@ export default {
|
|||||||
ExportTableBtn,
|
ExportTableBtn,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
agentpk: Number,
|
agent: String,
|
||||||
|
tabHeight: String,
|
||||||
modal: {
|
modal: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
@@ -120,6 +137,7 @@ export default {
|
|||||||
const logLevelFilter = ref("info");
|
const logLevelFilter = ref("info");
|
||||||
const logTypeFilter = ref(null);
|
const logTypeFilter = ref(null);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const filter = ref("");
|
||||||
|
|
||||||
async function getDebugLog() {
|
async function getDebugLog() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@@ -133,13 +151,13 @@ export default {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.agentpk) {
|
if (props.agent) {
|
||||||
agentFilter.value = props.agentpk;
|
agentFilter.value = props.agent;
|
||||||
watch(
|
watch(
|
||||||
() => props.agentpk,
|
() => props.agent,
|
||||||
(newValue, oldValue) => {
|
(newValue, oldValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
agentFilter.value = props.agentpk;
|
agentFilter.value = props.agent;
|
||||||
getDebugLog();
|
getDebugLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +169,7 @@ export default {
|
|||||||
|
|
||||||
// vue component hooks
|
// vue component hooks
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!props.agentpk) getAgentOptions();
|
if (!props.agent) getAgentOptions();
|
||||||
getDebugLog();
|
getDebugLog();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,6 +181,7 @@ export default {
|
|||||||
agentFilter,
|
agentFilter,
|
||||||
agentOptions,
|
agentOptions,
|
||||||
loading,
|
loading,
|
||||||
|
filter,
|
||||||
|
|
||||||
// non-reactive data
|
// non-reactive data
|
||||||
columns,
|
columns,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function useAgentDropdown() {
|
|||||||
|
|
||||||
// specifing flat returns an array of hostnames versus {value:id, label: hostname}
|
// specifing flat returns an array of hostnames versus {value:id, label: hostname}
|
||||||
async function getAgentOptions(flat = false) {
|
async function getAgentOptions(flat = false) {
|
||||||
agentOptions.value = formatAgentOptions(await fetchAgents(), flat)
|
agentOptions.value = formatAgentOptions(await fetchAgents({ detail: false }), flat)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { date } from "quasar";
|
||||||
|
|
||||||
// dropdown options formatting
|
// dropdown options formatting
|
||||||
|
|
||||||
@@ -60,13 +61,13 @@ export function formatAgentOptions(data, flat = false) {
|
|||||||
|
|
||||||
if (flat) {
|
if (flat) {
|
||||||
// returns just agent hostnames in array
|
// returns just agent hostnames in array
|
||||||
return _formatOptions(data, { label: "hostname", value: "pk", flat: true, allowDuplicates: false })
|
return _formatOptions(data, { label: "hostname", value: "agent_id", flat: true, allowDuplicates: false })
|
||||||
} else {
|
} else {
|
||||||
// returns options with categories in object format
|
// returns options with categories in object format
|
||||||
let options = []
|
let options = []
|
||||||
const agents = data.map(agent => ({
|
const agents = data.map(agent => ({
|
||||||
label: agent.hostname,
|
label: agent.hostname,
|
||||||
value: agent.pk,
|
value: agent.agent_id,
|
||||||
cat: `${agent.client} > ${agent.site}`,
|
cat: `${agent.client} > ${agent.site}`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user