- Updated the backend documentation in CONTRIBUTING.md and README.md to reflect changes in application structure and API endpoints. - Enhanced the frontend components in MapView.vue for better handling of context menu actions. - Added new types and interfaces in TypeScript for improved type safety in the frontend. - Introduced new utility classes for managing characters and markers in the map. - Updated .gitignore to include .vscode directory for better development environment management.
49 lines
989 B
Go
49 lines
989 B
Go
package app
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
"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([]byte("markers"))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
grid, err := mb.CreateBucketIfNotExists([]byte("grid"))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
idB, err := mb.CreateBucketIfNotExists([]byte("id"))
|
|
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)
|
|
}
|
|
}
|