add admin page to block files
This commit is contained in:
@@ -10,7 +10,12 @@
|
|||||||
{{template "page_top" .}}
|
{{template "page_top" .}}
|
||||||
<div class="page_content">
|
<div class="page_content">
|
||||||
{{if $isAdmin}}
|
{{if $isAdmin}}
|
||||||
|
|
||||||
|
<div class="limit_width">
|
||||||
|
<a class="button" href="/admin/globals">Update global settings</a>
|
||||||
|
<a class="button" href="/admin/abuse">Block files</a>
|
||||||
<h3>Bandwidth and views</h3>
|
<h3>Bandwidth and views</h3>
|
||||||
|
</div>
|
||||||
<div class="highlight_dark">
|
<div class="highlight_dark">
|
||||||
<button onclick="loadGraph(360, 1, true);">Live</button>
|
<button onclick="loadGraph(360, 1, true);">Live</button>
|
||||||
<button onclick="loadGraph(1440, 10, true);">Day</button>
|
<button onclick="loadGraph(1440, 10, true);">Day</button>
|
||||||
@@ -29,8 +34,6 @@
|
|||||||
<span id="total_bandwidth"></span> bandwidth and <span id="total_views"></span> views
|
<span id="total_bandwidth"></span> bandwidth and <span id="total_views"></span> views
|
||||||
</div>
|
</div>
|
||||||
<div class="limit_width">
|
<div class="limit_width">
|
||||||
<br/>
|
|
||||||
<a href="/admin/globals">Update global settings</a>
|
|
||||||
<h3>Database connection statistics</h3>
|
<h3>Database connection statistics</h3>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@@ -96,44 +96,62 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (wc *WebController) adminFileDeleteForm(td *TemplateData, r *http.Request) (f Form) {
|
func (wc *WebController) adminAbuseForm(td *TemplateData, r *http.Request) (f Form) {
|
||||||
// if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
||||||
// td.Title = err.Error()
|
td.Title = err.Error()
|
||||||
// return Form{Title: td.Title}
|
return Form{Title: td.Title}
|
||||||
// } else if !isAdmin.IsAdmin {
|
} else if !isAdmin {
|
||||||
// td.Title = ";)"
|
td.Title = ";)"
|
||||||
// return Form{Title: td.Title}
|
return Form{Title: td.Title}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// td.Title = "Admin file removal"
|
td.Title = "Admin file removal"
|
||||||
// f = Form{
|
f = Form{
|
||||||
// Name: "admin_file_removal",
|
Name: "admin_file_removal",
|
||||||
// Title: td.Title,
|
Title: td.Title,
|
||||||
// PreFormHTML: template.HTML("<p>Paste any pixeldrain file links in here to remove them</p>"),
|
PreFormHTML: template.HTML("<p>Paste any pixeldrain file links in here to remove them</p>"),
|
||||||
// Fields: []Field{
|
Fields: []Field{
|
||||||
// {
|
{
|
||||||
// Name: "files",
|
Name: "text",
|
||||||
// Label: "Files to delete",
|
Label: "Files to delete",
|
||||||
// Type: FieldTypeTextarea,
|
Type: FieldTypeTextarea,
|
||||||
// },
|
}, {
|
||||||
// },
|
Name: "type",
|
||||||
// BackLink: "/admin",
|
Label: "Type",
|
||||||
// SubmitLabel: "Submit",
|
DefaultValue: "unknown",
|
||||||
// }
|
Description: "Can be 'unknown', 'copyright', 'terrorism' or 'child_abuse'",
|
||||||
|
Type: FieldTypeText,
|
||||||
|
}, {
|
||||||
|
Name: "reporter",
|
||||||
|
Label: "Reporter",
|
||||||
|
DefaultValue: "pixeldrain",
|
||||||
|
Type: FieldTypeText,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
BackLink: "/admin",
|
||||||
|
SubmitLabel: "Submit",
|
||||||
|
}
|
||||||
|
|
||||||
// if f.ReadInput(r) {
|
if f.ReadInput(r) {
|
||||||
// filesText := f.FieldVal("files")
|
resp, err := td.PixelAPI.AdminBlockFiles(
|
||||||
|
f.FieldVal("text"),
|
||||||
|
f.FieldVal("type"),
|
||||||
|
f.FieldVal("reporter"),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
formAPIError(err, &f)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// // Get all links from the text
|
successMsg := template.HTML("The following files were blocked:<br/><ul>")
|
||||||
// strings.Index(filesText, "/u/")
|
for _, v := range resp.FilesBlocked {
|
||||||
|
successMsg += template.HTML("<li>pixeldrain.com/u/" + v + "</li>")
|
||||||
|
}
|
||||||
|
successMsg += "<ul>"
|
||||||
|
|
||||||
// if len(f.SubmitMessages) == 0 {
|
// Request was a success
|
||||||
// // Request was a success
|
f.SubmitSuccess = true
|
||||||
// f.SubmitSuccess = true
|
f.SubmitMessages = []template.HTML{successMsg}
|
||||||
// f.SubmitMessages = []template.HTML{template.HTML(
|
}
|
||||||
// fmt.Sprintf("Success! %d values updated", successfulUpdates),
|
return f
|
||||||
// )}
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return f
|
|
||||||
// }
|
|
||||||
|
@@ -128,6 +128,8 @@ func New(
|
|||||||
r.GET(p+"/admin" /* */, wc.serveTemplate("admin_panel", true))
|
r.GET(p+"/admin" /* */, wc.serveTemplate("admin_panel", true))
|
||||||
r.GET(p+"/admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, true))
|
r.GET(p+"/admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, true))
|
||||||
r.POST(p+"/admin/globals" /**/, wc.serveForm(wc.adminGlobalsForm, true))
|
r.POST(p+"/admin/globals" /**/, wc.serveForm(wc.adminGlobalsForm, true))
|
||||||
|
r.GET(p+"/admin/abuse" /* */, wc.serveForm(wc.adminAbuseForm, true))
|
||||||
|
r.POST(p+"/admin/abuse" /**/, wc.serveForm(wc.adminAbuseForm, true))
|
||||||
|
|
||||||
// Advertising related
|
// Advertising related
|
||||||
r.GET(p+"/click/:id" /* */, wc.serveAdClick)
|
r.GET(p+"/click/:id" /* */, wc.serveAdClick)
|
||||||
|
Reference in New Issue
Block a user