Torrent Mass Edit Api (WIP)
* Torrents can be deleted in mass from frontend with api post request * Torrents status can be edited from frontend with api post request -- Look to function doc for more info on how to use it It is a WIP so it might not work =D
Cette révision appartient à :
Parent
d35c495d59
révision
d2617c9c5d
2 fichiers modifiés avec 24 ajouts et 0 suppressions
|
@ -1,6 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html"
|
||||
"net/http"
|
||||
|
@ -342,6 +343,28 @@ func TorrentsPostListPanel(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is used on the frontend for the mass
|
||||
* Query is: action=move|delete
|
||||
* moveto=0|1|2|3|4 according to config/torrent.go (can be omitted if action=delete)
|
||||
* torrent_id[] Ids of torrents in checkboxes of name torrent_id
|
||||
*/
|
||||
func ApiMassMod(w http.ResponseWriter, r *http.Request) {
|
||||
torrentManyAction(r)
|
||||
messages := msg.GetMessages(r) // new util for errors and infos
|
||||
var apiJson []byte
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if !messages.HasErrors() {
|
||||
mapOk := map[string]bool{"ok": true, "errors": false}
|
||||
apiJson, _ = json.Marshal(mapOk)
|
||||
} else { // We need to show error messages
|
||||
mapNotOk := map[string]interface{}{"ok": false, "errors": messages.GetAllErrors()}
|
||||
apiJson, _ = json.Marshal(mapNotOk)
|
||||
}
|
||||
|
||||
w.Write(apiJson)
|
||||
}
|
||||
|
||||
/*
|
||||
* Controller to modify multiple torrents and can be used by the owner of the torrent or admin
|
||||
|
|
|
@ -95,6 +95,7 @@ func init() {
|
|||
Router.HandleFunc("/mod/comment/delete", WrapModHandler(CommentDeleteModPanel)).Name("mod_cdelete")
|
||||
Router.HandleFunc("/mod/reassign", WrapModHandler(TorrentReassignModPanel)).Name("mod_treassign").Methods("GET")
|
||||
Router.HandleFunc("/mod/reassign", WrapModHandler(TorrentPostReassignModPanel)).Name("mod_treassign").Methods("POST")
|
||||
Router.HandleFunc("/mod/api/torrents", WrapModHandler(ApiMassMod)).Name("mod_tapi").Methods("POST")
|
||||
|
||||
//reporting a torrent
|
||||
Router.HandleFunc("/report/{id}", ReportTorrentHandler).Methods("POST").Name("torrent_report")
|
||||
|
|
Référencer dans un nouveau ticket