From b6fabf59b761bc4c07c4263ee5f29e93469aa42b Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 7 Aug 2026 21:36:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=A2=E5=BC=83=E6=95=B0=E6=8D=AE=E9=A1=B5?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E7=AE=A1=E7=90=86=EF=BC=9A=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E5=88=A0=E9=99=A4+=E4=B8=80=E9=94=AE=E6=B8=85=E7=A9=BA(Confirm?= =?UTF-8?q?DeleteModal=20=E4=BA=8C=E6=AC=A1=E7=A1=AE=E8=AE=A4)=EF=BC=8C?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=20v1.2.0=20/=20=E5=89=8D=E7=AB=AF=20v0.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/store/store_query.go | 13 ++ internal/web/web.go | 29 ++++- meshmap_frontend/src/api.ts | 8 ++ .../src/components/AdminDiscardDetails.vue | 117 +++++++++++++++++- meshmap_frontend/src/version.ts | 2 +- 5 files changed, 164 insertions(+), 5 deletions(-) diff --git a/internal/store/store_query.go b/internal/store/store_query.go index 7de7487..c02f8b3 100644 --- a/internal/store/store_query.go +++ b/internal/store/store_query.go @@ -339,6 +339,19 @@ func applyDiscardDetailsFilters(q *gorm.DB, opts ListOptions) *gorm.DB { return q } +func (s *Store) DeleteDiscardDetailsByIDs(ids []uint64) (int64, error) { + if len(ids) == 0 { + return 0, nil + } + result := s.db.Where("id IN ?", ids).Delete(&DiscardDetailsRecord{}) + return result.RowsAffected, result.Error +} + +func (s *Store) DeleteAllDiscardDetails() (int64, error) { + result := s.db.Where("1 = 1").Delete(&DiscardDetailsRecord{}) + return result.RowsAffected, result.Error +} + func (s *Store) DeleteTextMessage(id uint64) error { result := s.db.Where("id = ?", id).Delete(&TextMessageRecord{}) if result.Error != nil { diff --git a/internal/web/web.go b/internal/web/web.go index 279a0be..300966a 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -84,7 +84,7 @@ func NewRouter(cfg configpkg.WebConfig, consoleLog bool, store *storepkg.Store, return r } -const BackendVersion = "1.1.0" +const BackendVersion = "1.2.0" var CommitVersion = "dev" @@ -399,6 +399,33 @@ func registerAdminRoutes(r gin.IRouter, store *storepkg.Store, sessions *auth.Ma rows, err := store.ListLoginLogs(opts) writeListResponse(c, rows, opts, err, loginLogDTO) }) + protected.POST("/discard-details/batch-delete", func(c *gin.Context) { + var req struct { + IDs []uint64 `json:"ids"` + } + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + if len(req.IDs) == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "ids is empty"}) + return + } + count, err := store.DeleteDiscardDetailsByIDs(req.IDs) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{"status": "ok", "deleted_count": count}) + }) + protected.DELETE("/discard-details", func(c *gin.Context) { + count, err := store.DeleteAllDiscardDetails() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{"status": "ok", "deleted_count": count}) + }) protected.DELETE("/text-messages/:id", func(c *gin.Context) { id, err := strconv.ParseUint(c.Param("id"), 10, 64) if err != nil || id == 0 { diff --git a/meshmap_frontend/src/api.ts b/meshmap_frontend/src/api.ts index a99fb55..a0c3a46 100644 --- a/meshmap_frontend/src/api.ts +++ b/meshmap_frontend/src/api.ts @@ -235,6 +235,14 @@ export function getDiscardDetails(limit = 100, offset = 0): Promise>(listPath('/api/discard-details', limit, offset)) } +export function deleteDiscardDetailsByIDs(ids: number[]): Promise<{ status: string; deleted_count: number }> { + return postJSON<{ status: string; deleted_count: number }>('/api/admin/discard-details/batch-delete', { ids }) +} + +export function clearDiscardDetails(): Promise<{ status: string; deleted_count: number }> { + return deleteJSON<{ status: string; deleted_count: number }>('/api/admin/discard-details') +} + export function getTelemetry(limit = 500, offset = 0, nodeId = ''): Promise> { return getJSON>(listPath('/api/telemetry', limit, offset, nodeId)) } diff --git a/meshmap_frontend/src/components/AdminDiscardDetails.vue b/meshmap_frontend/src/components/AdminDiscardDetails.vue index 328bfd8..c82675b 100644 --- a/meshmap_frontend/src/components/AdminDiscardDetails.vue +++ b/meshmap_frontend/src/components/AdminDiscardDetails.vue @@ -1,7 +1,8 @@ @@ -45,7 +119,19 @@ onMounted(refreshItems)

Discard details

丢弃数据

- +
+ + + +

{{ error }}

@@ -53,6 +139,15 @@ onMounted(refreshItems) + @@ -67,6 +162,13 @@ onMounted(refreshItems) + @@ -90,5 +192,14 @@ onMounted(refreshItems) + + diff --git a/meshmap_frontend/src/version.ts b/meshmap_frontend/src/version.ts index 2b17820..8c81056 100644 --- a/meshmap_frontend/src/version.ts +++ b/meshmap_frontend/src/version.ts @@ -1 +1 @@ -export const FRONTEND_VERSION = '0.2.0' +export const FRONTEND_VERSION = '0.3.0'
+ + 时间 Topic Error
+ + {{ formatTime(item.created_at) }} {{ item.topic || '-' }} {{ item.error || '-' }}