diff --git a/res/include/script/user_home.js b/res/include/script/user_home.js deleted file mode 100644 index bc28dfe..0000000 --- a/res/include/script/user_home.js +++ /dev/null @@ -1,92 +0,0 @@ -function loadGraph(graph, stat, minutes, interval) { - let today = new Date() - let start = new Date() - start.setMinutes(start.getMinutes() - minutes) - - fetch( - apiEndpoint + "/user/time_series/" + stat + - "?start=" + start.toISOString() + - "&end=" + today.toISOString() + - "&interval=" + interval - ).then(resp => { - if (!resp.ok) { return Promise.reject("Error: " + resp.status); } - return resp.json(); - }).then(resp => { - resp.timestamps.forEach((val, idx) => { - let date = new Date(val); - let dateStr = ("00" + (date.getMonth() + 1)).slice(-2); - dateStr += "-" + ("00" + date.getDate()).slice(-2); - dateStr += " " + ("00" + date.getHours()).slice(-2); - dateStr += ":" + ("00" + date.getMinutes()).slice(-2); - resp.timestamps[idx] = " " + dateStr + " "; // Poor man's padding - }); - graph.data.labels = resp.timestamps; - graph.data.datasets[0].data = resp.amounts; - graph.update(); - - document.getElementById("time_start").innerText = resp.timestamps[0]; - document.getElementById("time_end").innerText = resp.timestamps.slice(-1)[0]; - let total = 0 - resp.amounts.forEach(e => { total += e; }); - - if (stat == "views") { - document.getElementById("total_views").innerText = formatThousands(total); - } else if (stat == "downloads") { - document.getElementById("total_downloads").innerText = formatThousands(total); - } else if (stat == "bandwidth") { - document.getElementById("total_bandwidth").innerText = formatDataVolume(total, 3); - } else if (stat == "direct_bandwidth") { - document.getElementById("total_direct_bandwidth").innerText = formatDataVolume(total, 3); - } - }).catch(e => { - console.error("Error requesting time series: " + e); - }) -} - -function loadDirectBW() { - let today = new Date() - let start = new Date() - start.setDate(start.getDate() - 30) - - fetch( - apiEndpoint + "/user/time_series/direct_bandwidth" + - "?start=" + start.toISOString() + - "&end=" + today.toISOString() + - "&interval=60" - ).then(resp => { - if (!resp.ok) { return Promise.reject("Error: " + resp.status); } - return resp.json(); - }).then(resp => { - let total = resp.amounts.reduce((accum, val) => accum += val, 0); - document.getElementById("direct_bandwidth_progress").style.width = (total / window.user.subscription.direct_linking_bandwidth) * 100 + "%" - document.getElementById("direct_bandwidth_text").innerText = formatDataVolume(total, 3) + " out of " + formatDataVolume(window.user.subscription.direct_linking_bandwidth, 3) - - document.getElementById("storage_progress").style.width = (window.user.storage_space_used / window.user.subscription.storage_space) * 100 + "%" - document.getElementById("storage_text").innerText = formatDataVolume(window.user.storage_space_used, 3) + " out of " + formatDataVolume(window.user.subscription.storage_space, 3) - - }).catch(e => { - console.error("Error requesting time series: " + e); - }) -} - -let graphViews = drawGraph(document.getElementById("views_chart"), "Views", "number"); -let graphDownloads = drawGraph(document.getElementById("downloads_chart"), "Downloads", "number"); -let graphBandwidth = drawGraph(document.getElementById("bandwidth_chart"), "Bandwidth", "bytes"); -let graphDirectBandwidth = drawGraph(document.getElementById("direct_bandwidth_chart"), "Direct Bandwidth", "bytes"); -let graphTimeout = null; - -function updateGraphs(minutes, interval, live) { - if (graphTimeout !== null) { clearTimeout(graphTimeout) } - if (live) { - graphTimeout = setTimeout(() => { updateGraphs(minutes, interval, true) }, 10000) - } - - loadGraph(graphViews, "views", minutes, interval); - loadGraph(graphDownloads, "downloads", minutes, interval); - loadGraph(graphBandwidth, "bandwidth", minutes, interval); - loadGraph(graphDirectBandwidth, "direct_bandwidth", minutes, interval); - loadDirectBW() -} - -// Default -updateGraphs(1440, 1, true); diff --git a/res/template/account/user_home.html b/res/template/account/user_home.html index f5d00f5..43ccf41 100644 --- a/res/template/account/user_home.html +++ b/res/template/account/user_home.html @@ -3,24 +3,14 @@ {{template "meta_tags" .User.Username}} {{template "user_style" .}} + - - + + @@ -28,148 +18,10 @@

Welcome home, {{.User.Username}}!

-
-
-

Account information

- - -

Limits

- Storage:
-
-
-
-
- Direct link bandwidth: - (More information about direct linking) -
-
-
-
- -

Settings

-
- - edit - Change account settings - - - list - Export uploaded files to CSV - - - list - Export created lists to CSV - -
- -

Statistics

-

- Here you can see how often your files are viewed, downloaded - and how much bandwidth they consume. The buttons at the top - can be pressed to adjust the timeframe. If you choose 'Day' - the statistics will be updated periodically. No need to - refresh the page. -

-
-
- - - - - - - -
-
-

Views

-

- A view is counted when someone visits the download page of one - of your files. Views are unique per user per file. -

-
-
- -
-
-

Downloads

-

- Downloads are counted when a user clicks the download button - on one of your files. It does not matter whether the - download is completed or not, only the start of the download - is counted. -

-
-
- -
-
-

Bandwidth

-

- This is how much bandwidth your files are using in total. - Bandwidth is used when a file is tranferred from a - pixeldrain server to a user who is downloading the file. - When a 5 MB file is downloaded 8 times it has used 40 MB of - bandwidth. -

-
-
- -
-
-

Direct link bandwidth

-

- When a file is downloaded without going through pixeldrain's - download page it counts as a direct download. Because direct - downloads cost us bandwidth and don't generate any ad - revenue we have to limit them. When your direct link - bandwidth runs out people will be asked to do a test before - they can download your files. See our - subscription options to get more direct - linking bandwidth. -

-
-
- -
-
- Total usage from to
- views, - downloads, - bandwidth and - direct link bandwidth -
-
+
{{template "page_bottom" .}} - {{template "analytics"}} - - - {{end}} diff --git a/res/template/account/user_home_svelte.html b/res/template/account/user_home_svelte.html deleted file mode 100644 index 35cdc28..0000000 --- a/res/template/account/user_home_svelte.html +++ /dev/null @@ -1,27 +0,0 @@ -{{define "user_home_svelte"}} - - - {{template "meta_tags" .User.Username}} - {{template "user_style" .}} - - - - - - - - {{template "page_top" .}} - -

Welcome home, {{.User.Username}}!

- -
- - {{template "page_bottom" .}} - {{template "analytics"}} - - -{{end}} diff --git a/webcontroller/admin_panel.go b/webcontroller/admin_panel.go index 7d79166..3dc98ae 100644 --- a/webcontroller/admin_panel.go +++ b/webcontroller/admin_panel.go @@ -90,65 +90,3 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f } return f } - -func (wc *WebController) adminAbuseForm(td *TemplateData, r *http.Request) (f Form) { - if !td.Authenticated || !td.User.IsAdmin { - return Form{Title: ";-)"} - } - - f = Form{ - Name: "admin_file_removal", - Title: "Admin file removal", - PreFormHTML: template.HTML("

Paste any pixeldrain file links in here to remove them

"), - Fields: []Field{ - { - Name: "text", - Label: "Files to delete", - Type: FieldTypeTextarea, - }, { - Name: "type", - Label: "Type", - DefaultValue: "unknown", - Type: FieldTypeRadio, - RadioValues: []string{ - "unknown", - "copyright", - "child_abuse", - "terrorism", - "gore", - "malware", - }, - }, { - Name: "reporter", - Label: "Reporter", - DefaultValue: "Anonymous tip", - Type: FieldTypeText, - }, - }, - BackLink: "/admin", - SubmitLabel: "Submit", - } - - if f.ReadInput(r) { - resp, err := td.PixelAPI.AdminBlockFiles( - f.FieldVal("text"), - f.FieldVal("type"), - f.FieldVal("reporter"), - ) - if err != nil { - formAPIError(err, &f) - return - } - - successMsg := template.HTML("The following files were blocked: