- Added a new AGENTS.md file to document the project structure and conventions. - Updated .gitignore to include node_modules and refined cursor rules. - Introduced new backend and frontend components for improved map interactions, including context menus and controls. - Enhanced API composables for better admin and authentication functionalities. - Refactored existing components for cleaner code and improved user experience. - Updated README.md to clarify production asset serving and user setup instructions.
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/andyleap/hnh-map/internal/app/store"
|
|
"go.etcd.io/bbolt"
|
|
)
|
|
|
|
func (a *App) HideMarker(rw http.ResponseWriter, req *http.Request) {
|
|
if a.requireAdmin(rw, req) == nil {
|
|
return
|
|
}
|
|
|
|
err := a.db.Update(func(tx *bbolt.Tx) error {
|
|
mb, err := tx.CreateBucketIfNotExists(store.BucketMarkers)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
grid, err := mb.CreateBucketIfNotExists(store.BucketMarkersGrid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
idB, err := mb.CreateBucketIfNotExists(store.BucketMarkersID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
key := idB.Get([]byte(req.FormValue("id")))
|
|
if key == nil {
|
|
return fmt.Errorf("Could not find key %s", req.FormValue("id"))
|
|
}
|
|
raw := grid.Get(key)
|
|
if raw == nil {
|
|
return fmt.Errorf("Could not find key %s", string(key))
|
|
}
|
|
m := Marker{}
|
|
json.Unmarshal(raw, &m)
|
|
m.Hidden = true
|
|
raw, _ = json.Marshal(m)
|
|
grid.Put(key, raw)
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
}
|