Moveing of objects
This commit is contained in:
parent
cfd5bfd719
commit
25bbc0c748
7 changed files with 167 additions and 16 deletions
29
webserver.go
29
webserver.go
|
|
@ -39,6 +39,7 @@ func initWebserver() (err error) {
|
|||
http.HandleFunc("/nodes/rename/{nodeID}", actionNodeRename)
|
||||
http.HandleFunc("/nodes/delete/{nodeID}", actionNodeDelete)
|
||||
http.HandleFunc("/nodes/create", actionNodeCreate)
|
||||
http.HandleFunc("/nodes/move", actionNodeMove)
|
||||
http.HandleFunc("/types/{typeID}", actionType)
|
||||
http.HandleFunc("/types/", actionTypesAll)
|
||||
|
||||
|
|
@ -234,6 +235,34 @@ func actionNodeDelete(w http.ResponseWriter, r *http.Request) { // {{{
|
|||
j, _ := json.Marshal(out)
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
func actionNodeMove(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
var req struct {
|
||||
NewParentID int
|
||||
NodeIDs []int
|
||||
}
|
||||
data, _ := io.ReadAll(r.Body)
|
||||
err := json.Unmarshal(data, &req)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = MoveNodes(req.NewParentID, req.NodeIDs)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
out := struct {
|
||||
OK bool
|
||||
}{
|
||||
true,
|
||||
}
|
||||
j, _ := json.Marshal(out)
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
func actionType(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
typeID := 0
|
||||
typeIDStr := r.PathValue("typeID")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue