From 3035c0712a04180c5bf78bd00e5bba5d52dc39e1 Mon Sep 17 00:00:00 2001 From: sadnub Date: Thu, 14 Oct 2021 12:40:23 -0400 Subject: [PATCH] fix debug log and change agent dropdown to use agent_id versus pk --- api/tacticalrmm/logs/urls.py | 4 +- api/tacticalrmm/logs/views.py | 4 +- web/src/api/logs.js | 4 +- .../components/agents/AutomatedTasksTab.vue | 1 + web/src/components/agents/ChecksTab.vue | 1 + web/src/components/agents/DebugTab.vue | 4 +- web/src/components/agents/HistoryTab.vue | 12 +- web/src/components/agents/NotesTab.vue | 1 + web/src/components/agents/SoftwareTab.vue | 1 + web/src/components/logs/DebugLog.vue | 121 ++++++++++-------- web/src/composables/agents.js | 2 +- web/src/utils/format.js | 5 +- 12 files changed, 98 insertions(+), 62 deletions(-) diff --git a/api/tacticalrmm/logs/urls.py b/api/tacticalrmm/logs/urls.py index 015d47c5..98d839a7 100644 --- a/api/tacticalrmm/logs/urls.py +++ b/api/tacticalrmm/logs/urls.py @@ -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()), ] diff --git a/api/tacticalrmm/logs/views.py b/api/tacticalrmm/logs/views.py index 4dec039d..5875528b 100644 --- a/api/tacticalrmm/logs/views.py +++ b/api/tacticalrmm/logs/views.py @@ -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) diff --git a/web/src/api/logs.js b/web/src/api/logs.js index 73ad0f10..5d1da43c 100644 --- a/web/src/api/logs.js +++ b/web/src/api/logs.js @@ -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) { } } diff --git a/web/src/components/agents/AutomatedTasksTab.vue b/web/src/components/agents/AutomatedTasksTab.vue index 977619ac..41948570 100644 --- a/web/src/components/agents/AutomatedTasksTab.vue +++ b/web/src/components/agents/AutomatedTasksTab.vue @@ -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]" diff --git a/web/src/components/agents/ChecksTab.vue b/web/src/components/agents/ChecksTab.vue index 45d67084..44b0b76c 100644 --- a/web/src/components/agents/ChecksTab.vue +++ b/web/src/components/agents/ChecksTab.vue @@ -13,6 +13,7 @@ v-model:pagination="pagination" :loading="loading" :rows-per-page-options="[0]" + virtual-scroll no-data-label="No checks" > diff --git a/web/src/components/agents/DebugTab.vue b/web/src/components/agents/DebugTab.vue index 5e85fab5..591d259b 100644 --- a/web/src/components/agents/DebugTab.vue +++ b/web/src/components/agents/DebugTab.vue @@ -1,7 +1,7 @@ @@ -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, }; }, }; diff --git a/web/src/components/agents/HistoryTab.vue b/web/src/components/agents/HistoryTab.vue index 79a37ec5..ef9d6d9a 100644 --- a/web/src/components/agents/HistoryTab.vue +++ b/web/src/components/agents/HistoryTab.vue @@ -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 > @@ -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, diff --git a/web/src/components/agents/NotesTab.vue b/web/src/components/agents/NotesTab.vue index fde982e3..d62e5018 100644 --- a/web/src/components/agents/NotesTab.vue +++ b/web/src/components/agents/NotesTab.vue @@ -12,6 +12,7 @@ :rows-per-page-options="[0]" :loading="loading" hide-bottom + virtual-scroll no-data-label="No notes" > @@ -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, diff --git a/web/src/composables/agents.js b/web/src/composables/agents.js index 959d0b1e..d3802139 100644 --- a/web/src/composables/agents.js +++ b/web/src/composables/agents.js @@ -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 { diff --git a/web/src/utils/format.js b/web/src/utils/format.js index b2c24be5..105e4609 100644 --- a/web/src/utils/format.js +++ b/web/src/utils/format.js @@ -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}`, }));