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