diff --git a/src/api/agents.js b/src/api/agents.js
new file mode 100644
index 0000000..32e283c
--- /dev/null
+++ b/src/api/agents.js
@@ -0,0 +1,9 @@
+import axios from "axios"
+
+const baseUrl = "/agents"
+
+export async function fetchAgents() {
+ const { data } = await axios.get(`${baseUrl}/listagentsnodetail/`)
+
+ return data
+}
\ No newline at end of file
diff --git a/src/api/logs.js b/src/api/logs.js
index be0a4e3..483ebf6 100644
--- a/src/api/logs.js
+++ b/src/api/logs.js
@@ -1,20 +1,9 @@
import axios from "axios"
-const baseUrl = "/logs"
+const baseUrl = "/logs/debuglog/"
-export async function downloadDebugLog() {
+export async function fetchDebugLog(payload) {
+ const { data } = await axios.patch(`${baseUrl}`, payload)
- const { data } = await axios.get(`${baseUrl}/downloadlog/`, { responseType: "blob" })
-
- const blob = new Blob([data], { type: "text/plain" });
- let link = document.createElement("a");
- link.href = window.URL.createObjectURL(blob);
- link.download = "debug.log";
- link.click();
-
-}
-
-export async function fetchDebugLog(level, agent, order) {
- const { data } = await axios.get(`${baseUrl}/debuglog/${level}/${agent}/${order}/`)
- return data
+ return data
}
\ No newline at end of file
diff --git a/src/components/AuditManager.vue b/src/components/AuditManager.vue
index 5530451..e7ad329 100644
--- a/src/components/AuditManager.vue
+++ b/src/components/AuditManager.vue
@@ -167,24 +167,8 @@
\ No newline at end of file
diff --git a/src/components/modals/logs/DebugLogModal.vue b/src/components/modals/logs/DebugLogModal.vue
index 1eda43e..5fccf8f 100644
--- a/src/components/modals/logs/DebugLogModal.vue
+++ b/src/components/modals/logs/DebugLogModal.vue
@@ -2,64 +2,101 @@
- Debug Log
-
-
+ Debug Log
Close
-
-
-
-
-
-
+
+
+
+
+
+
+
-
- {{ debugLog }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/composables/agents.js b/src/composables/agents.js
new file mode 100644
index 0000000..38031a1
--- /dev/null
+++ b/src/composables/agents.js
@@ -0,0 +1,21 @@
+
+import { ref } from "vue"
+import { fetchAgents } from "@/api/agents"
+import { formatAgentOptions } from "@/utils/format"
+
+export function useAgentDropdown() {
+
+ const agentOptions = ref([])
+
+ const getAgentOptions = async () => {
+ agentOptions.value = formatAgentOptions(await fetchAgents())
+ }
+
+ return {
+ //data
+ agentOptions,
+
+ //methods
+ getAgentOptions
+ }
+}
\ No newline at end of file
diff --git a/src/composables/logs.js b/src/composables/logs.js
index 22e4e83..28dd938 100644
--- a/src/composables/logs.js
+++ b/src/composables/logs.js
@@ -1,31 +1,63 @@
-import { ref, watch, onMounted } from "vue"
-import { fetchDebugLog } from "@/api/logs.js"
+import { ref } from "vue"
+import { fetchDebugLog } from "@/api/logs"
+import { formatDate, formatTableColumnText } from "@/utils/format"
+// debug log
export function useDebugLog() {
- const debugLog = ref("")
- const logLevel = ref("info")
- const agent = ref("all")
- const order = ref("latest")
+ const debugLog = ref([])
+ const agentFilter = ref(null)
+ const logLevelFilter = ref("info")
+ const logTypeFilter = ref(null)
const getDebugLog = async () => {
- debugLog.value = await fetchDebugLog(logLevel.value, agent.value, order.value)
+ const data = {
+ logLevelFilter: logLevelFilter.value
+ }
+ if (agentFilter.value) data["agentFilter"] = agentFilter.value
+ if (logTypeFilter.value) data["logTypeFilter"] = logTypeFilter.value
+
+ debugLog.value = await fetchDebugLog(data)
}
- watch(logLevel, getDebugLog)
- watch(agent, getDebugLog)
- watch(order, getDebugLog)
-
- onMounted(getDebugLog)
-
return {
- //data
- logLevel,
- agent,
- order,
+ // data
+ logLevelFilter,
+ logTypeFilter,
+ agentFilter,
debugLog,
- //methods
+ // methods
getDebugLog
}
-}
\ No newline at end of file
+}
+
+useDebugLog.logTypeOptions = [
+ { label: "Agent Update", value: "agent_value" },
+ { label: "Agent Issues", value: "agent_issues" },
+ { label: "Windows Updates", value: "windows_updates" },
+ { label: "System Issues", value: "system_issues" },
+ { label: "Scripting", value: "scripting" }
+]
+
+useDebugLog.debugLogTableColumns = [
+ {
+ name: "entry_time",
+ label: "Time",
+ field: "entry_time",
+ align: "left",
+ sortable: true,
+ format: (val, row) => formatDate(val, true),
+ },
+ { name: "log_level", label: "Log Level", field: "log_level", align: "left", sortable: true },
+ { name: "agent", label: "Agent", field: "agent", align: "left", sortable: true },
+ {
+ name: "log_type",
+ label: "Log Type",
+ field: "log_type",
+ align: "left",
+ sortable: true,
+ format: (val, row) => formatTableColumnText(val),
+ },
+ { name: "message", label: "Message", field: "message", align: "left", sortable: true },
+]
\ No newline at end of file
diff --git a/src/utils/csv.js b/src/utils/csv.js
new file mode 100644
index 0000000..c5f385c
--- /dev/null
+++ b/src/utils/csv.js
@@ -0,0 +1,45 @@
+import { exportFile, Notify } from "quasar";
+
+function _wrapCsvValue(val, formatFn) {
+ let formatted = formatFn !== void 0 ? formatFn(val) : val;
+
+ formatted = formatted === void 0 || formatted === null ? "" : String(formatted);
+
+ formatted = formatted.split('"').join('""');
+ /**
+ * Excel accepts \n and \r in strings, but some other CSV parsers do not
+ * Uncomment the next two lines to escape new lines
+ */
+ // .split('\n').join('\\n')
+ // .split('\r').join('\\r')
+
+ return `"${formatted}"`;
+}
+
+export function exportTableToCSV(rows, columns) {
+ // naive encoding to csv format
+ const content = [columns.map(col => _wrapCsvValue(col.label))]
+ .concat(
+ rows.map(row =>
+ columns
+ .map(col =>
+ _wrapCsvValue(
+ typeof col.field === "function" ? col.field(row) : row[col.field === void 0 ? col.name : col.field],
+ col.format
+ )
+ )
+ .join(",")
+ )
+ )
+ .join("\r\n");
+
+ const status = exportFile("export.csv", content, "text/csv");
+
+ if (status !== true) {
+ Notify({
+ message: "Browser denied file download...",
+ color: "negative",
+ icon: "warning",
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/utils/format.js b/src/utils/format.js
index 1e25277..5ef6f9c 100644
--- a/src/utils/format.js
+++ b/src/utils/format.js
@@ -28,4 +28,34 @@ export function formatAgentOptions(data) {
});
return options
+}
+
+function _appendLeadingZeroes(n) {
+ if (n <= 9) {
+ return "0" + n;
+ }
+ return n
+}
+
+export function formatDate(date, includeSeconds = false) {
+ if (!date) return
+ const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+ let dt = new Date(date)
+ let formatted = months[dt.getMonth()] + "-" + _appendLeadingZeroes(dt.getDate()) + "-" + _appendLeadingZeroes(dt.getFullYear()) + " - " + _appendLeadingZeroes(dt.getHours()) + ":" + _appendLeadingZeroes(dt.getMinutes())
+
+ return includeSeconds ? formatted + ":" + _appendLeadingZeroes(dt.getSeconds()) : formatted
+}
+
+export function capitalize(string) {
+ return string[0].toUpperCase() + string.substring(1);
+}
+
+export function formatTableColumnText(text) {
+
+ let string = ""
+ // split at underscore if exists
+ const words = text.split("_")
+ words.forEach(word => string = string + " " + capitalize(word))
+
+ return string.trim()
}
\ No newline at end of file