feat: индикатор присутствия в конфигурациях (иконка глаза)
Открытые конфигурации фиксируются в локальном SQLite (app_settings) и передаются на сервер через qt_client_schema_state.open_config_uuids при каждом цикле синхронизации. Списки конфигураций обогащаются полем viewers, в таблицах отображается иконка глаза с подсказкой при наличии других пользователей, открывших эту конфигурацию. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -996,8 +996,27 @@ func setupRouter(cfg *config.Config, local *localdb.LocalDB, connMgr *db.Connect
|
||||
return
|
||||
}
|
||||
|
||||
uuids := make([]string, len(cfgs))
|
||||
for i, cfg := range cfgs {
|
||||
uuids[i] = cfg.UUID
|
||||
}
|
||||
viewers, _ := syncService.ListActiveViewersByConfigUUIDs(uuids)
|
||||
|
||||
type cfgRow struct {
|
||||
models.Configuration
|
||||
Viewers []string `json:"viewers"`
|
||||
}
|
||||
rows := make([]cfgRow, len(cfgs))
|
||||
for i, cfg := range cfgs {
|
||||
v := viewers[cfg.UUID]
|
||||
if v == nil {
|
||||
v = []string{}
|
||||
}
|
||||
rows[i] = cfgRow{Configuration: cfg, Viewers: v}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"configurations": cfgs,
|
||||
"configurations": rows,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"per_page": perPage,
|
||||
@@ -1332,6 +1351,16 @@ func setupRouter(cfg *config.Config, local *localdb.LocalDB, connMgr *db.Connect
|
||||
}
|
||||
c.JSON(http.StatusOK, config)
|
||||
})
|
||||
|
||||
configs.POST("/:uuid/presence", func(c *gin.Context) {
|
||||
_ = local.AddOpenConfigUUID(c.Param("uuid"))
|
||||
c.JSON(http.StatusOK, gin.H{"ok": true})
|
||||
})
|
||||
|
||||
configs.DELETE("/:uuid/presence", func(c *gin.Context) {
|
||||
_ = local.RemoveOpenConfigUUID(c.Param("uuid"))
|
||||
c.JSON(http.StatusOK, gin.H{"ok": true})
|
||||
})
|
||||
}
|
||||
|
||||
projects := api.Group("/projects")
|
||||
@@ -1672,8 +1701,32 @@ func setupRouter(cfg *config.Config, local *localdb.LocalDB, connMgr *db.Connect
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
projUUIDs := make([]string, len(result.Configs))
|
||||
for i, cfg := range result.Configs {
|
||||
projUUIDs[i] = cfg.UUID
|
||||
}
|
||||
projViewers, _ := syncService.ListActiveViewersByConfigUUIDs(projUUIDs)
|
||||
|
||||
type projCfgRow struct {
|
||||
models.Configuration
|
||||
Viewers []string `json:"viewers"`
|
||||
}
|
||||
projRows := make([]projCfgRow, len(result.Configs))
|
||||
for i, cfg := range result.Configs {
|
||||
v := projViewers[cfg.UUID]
|
||||
if v == nil {
|
||||
v = []string{}
|
||||
}
|
||||
projRows[i] = projCfgRow{Configuration: cfg, Viewers: v}
|
||||
}
|
||||
|
||||
c.Header("X-Config-Status", status)
|
||||
c.JSON(http.StatusOK, result)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"project_uuid": result.ProjectUUID,
|
||||
"configurations": projRows,
|
||||
"total": result.Total,
|
||||
})
|
||||
})
|
||||
|
||||
projects.PATCH("/:uuid/configs/reorder", func(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user