mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-10 20:42:32 +02:00
chore: code quality
This commit is contained in:
@@ -36,6 +36,7 @@ class AuditFilters(FilterModel):
|
|||||||
"path",
|
"path",
|
||||||
"request_method",
|
"request_method",
|
||||||
"response_code",
|
"response_code",
|
||||||
|
"component",
|
||||||
]
|
]
|
||||||
__sort_fields__ = [
|
__sort_fields__ = [
|
||||||
"created_at",
|
"created_at",
|
||||||
@@ -47,6 +48,7 @@ class AuditFilters(FilterModel):
|
|||||||
path: Optional[str] = None
|
path: Optional[str] = None
|
||||||
request_method: Optional[str] = None
|
request_method: Optional[str] = None
|
||||||
response_code: Optional[str] = None
|
response_code: Optional[str] = None
|
||||||
|
component: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class AuditCountStat(BaseModel):
|
class AuditCountStat(BaseModel):
|
||||||
|
@@ -156,7 +156,7 @@ class AuditMiddleware(BaseHTTPMiddleware):
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
http_method = request.scope.get("method", None)
|
http_method = request.scope.get("method", None)
|
||||||
path = request.scope.get("path", None)
|
path: Optional[str] = getattr(request.scope.get("route", {}), "path", None)
|
||||||
response_code = str(response.status_code) if response else None
|
response_code = str(response.status_code) if response else None
|
||||||
if not settings.audit_http_request(http_method, path, response_code):
|
if not settings.audit_http_request(http_method, path, response_code):
|
||||||
return None
|
return None
|
||||||
@@ -168,7 +168,6 @@ class AuditMiddleware(BaseHTTPMiddleware):
|
|||||||
user_id = request.scope.get("user_id", None)
|
user_id = request.scope.get("user_id", None)
|
||||||
if settings.is_super_user(user_id):
|
if settings.is_super_user(user_id):
|
||||||
user_id = "super_user"
|
user_id = "super_user"
|
||||||
path: Optional[str] = getattr(request.scope.get("route", {}), "path", None)
|
|
||||||
component = "core"
|
component = "core"
|
||||||
if path and not path.startswith("/api"):
|
if path and not path.startswith("/api"):
|
||||||
component = path.split("/")[1]
|
component = path.split("/")[1]
|
||||||
|
@@ -106,13 +106,13 @@ window.app = Vue.createApp({
|
|||||||
methods: {
|
methods: {
|
||||||
async fetchAudit(props) {
|
async fetchAudit(props) {
|
||||||
try {
|
try {
|
||||||
console.log("### fetchAudit", this.searchData)
|
console.log('### fetchAudit', this.searchData)
|
||||||
const params = LNbits.utils.prepareFilterQuery(this.auditTable, props)
|
const params = LNbits.utils.prepareFilterQuery(this.auditTable, props)
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
`/audit/api/v1?${params}`
|
`/audit/api/v1?${params}`
|
||||||
)
|
)
|
||||||
console.log("### data", data)
|
console.log('### data', data)
|
||||||
this.auditTable.pagination.rowsNumber = data.total
|
this.auditTable.pagination.rowsNumber = data.total
|
||||||
this.auditEntries = data.data
|
this.auditEntries = data.data
|
||||||
await this.fetchAuditStats(props)
|
await this.fetchAuditStats(props)
|
||||||
@@ -132,7 +132,9 @@ window.app = Vue.createApp({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const request_methods = data.request_method.map(rm => rm.field)
|
const request_methods = data.request_method.map(rm => rm.field)
|
||||||
this.searchOptions.request_method = request_methods
|
this.searchOptions.request_method = [
|
||||||
|
...new Set(this.searchOptions.request_method.concat(request_methods))
|
||||||
|
]
|
||||||
this.requestMethodChart.data.labels = request_methods
|
this.requestMethodChart.data.labels = request_methods
|
||||||
this.requestMethodChart.data.datasets[0].data = data.request_method.map(
|
this.requestMethodChart.data.datasets[0].data = data.request_method.map(
|
||||||
rm => rm.total
|
rm => rm.total
|
||||||
@@ -140,7 +142,9 @@ window.app = Vue.createApp({
|
|||||||
this.requestMethodChart.update()
|
this.requestMethodChart.update()
|
||||||
|
|
||||||
const response_codes = data.response_code.map(rm => rm.field)
|
const response_codes = data.response_code.map(rm => rm.field)
|
||||||
this.searchOptions.response_code = response_codes
|
this.searchOptions.response_code = [
|
||||||
|
...new Set(this.searchOptions.response_code.concat(response_codes))
|
||||||
|
]
|
||||||
this.responseCodeChart.data.labels = response_codes
|
this.responseCodeChart.data.labels = response_codes
|
||||||
this.responseCodeChart.data.datasets[0].data = data.response_code.map(
|
this.responseCodeChart.data.datasets[0].data = data.response_code.map(
|
||||||
rm => rm.total
|
rm => rm.total
|
||||||
@@ -148,7 +152,9 @@ window.app = Vue.createApp({
|
|||||||
this.responseCodeChart.update()
|
this.responseCodeChart.update()
|
||||||
|
|
||||||
const components = data.component.map(rm => rm.field)
|
const components = data.component.map(rm => rm.field)
|
||||||
this.searchOptions.component = components
|
this.searchOptions.component = [
|
||||||
|
...new Set(this.searchOptions.component.concat(components))
|
||||||
|
]
|
||||||
this.componentUseChart.data.labels = components
|
this.componentUseChart.data.labels = components
|
||||||
this.componentUseChart.data.datasets[0].data = data.component.map(
|
this.componentUseChart.data.datasets[0].data = data.component.map(
|
||||||
rm => rm.total
|
rm => rm.total
|
||||||
@@ -249,7 +255,7 @@ window.app = Vue.createApp({
|
|||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
plugins: {
|
plugins: {
|
||||||
title: {
|
title: {
|
||||||
display: false,
|
display: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user