remove redundant request to file info
This commit is contained in:
@@ -82,3 +82,11 @@ function copyText(text) {
|
|||||||
document.body.removeChild(ta); // Remove the textarea
|
document.body.removeChild(ta); // Remove the textarea
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function domainURL() {
|
||||||
|
let url = window.location.protocol+"//"+window.location.hostname;
|
||||||
|
if (window.location.port != "") {
|
||||||
|
url = url+":"+window.location.port;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
@@ -46,40 +46,20 @@ class DetailsWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDetails(file) {let dw = this;
|
setDetails(file) {let dw = this;
|
||||||
|
let desc = "";
|
||||||
if (dw.viewer.isList) {
|
if (dw.viewer.isList) {
|
||||||
// Lists give incomplete file information, so we have to request
|
desc = file.description;
|
||||||
// more details in the background. File descriptions only exist in
|
|
||||||
// lists, so for that we use the data provided in the page source
|
|
||||||
fetch(apiEndpoint + "/file/" + file.id + "/info").then(resp => {
|
|
||||||
if (!resp.ok) {return;}
|
|
||||||
return resp.json();
|
|
||||||
}).then(resp => {
|
|
||||||
dw.fileID = resp.id;
|
|
||||||
dw.divFileDetails.innerHTML = "<table>"
|
|
||||||
+ "<tr><td>Name<td><td>" + escapeHTML(resp.name) + "</td></tr>"
|
|
||||||
+ "<tr><td>URL<td><td><a href=\"/u/" + resp.id + "\">/u/" + resp.id + "</a></td></tr>"
|
|
||||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(resp.mime_type) + "</td></tr>"
|
|
||||||
+ "<tr><td>ID<td><td>" + resp.id + "</td></tr>"
|
|
||||||
+ "<tr><td>Size<td><td>" + formatDataVolume(resp.size) + "</td></tr>"
|
|
||||||
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(resp.bandwidth_used) + "</td></tr>"
|
|
||||||
+ "<tr><td>Upload Date<td><td>" + resp.date_upload + "</td></tr>"
|
|
||||||
+ "<tr><td>Description<td><td>" + escapeHTML(file.description) + "</td></tr>"
|
|
||||||
+ "</table>";
|
|
||||||
|
|
||||||
dw.viewer.toolbar.setStats(resp.views, resp.bandwidth_used/resp.size);
|
|
||||||
if(dw.visible) {
|
|
||||||
dw.updateGraph(dw.fileID);
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
} else {
|
|
||||||
dw.fileID = file.id;
|
dw.fileID = file.id;
|
||||||
dw.divFileDetails.innerHTML = "<table>"
|
dw.divFileDetails.innerHTML = "<table>"
|
||||||
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</td></tr>"
|
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</td></tr>"
|
||||||
|
+ "<tr><td>URL<td><td><a href=\"/u/" + file.id + "\">"+domainURL()+"/u/" + file.id + "</a></td></tr>"
|
||||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(file.mime_type) + "</td></tr>"
|
+ "<tr><td>Mime Type<td><td>" + escapeHTML(file.mime_type) + "</td></tr>"
|
||||||
+ "<tr><td>ID<td><td>" + file.id + "</td></tr>"
|
+ "<tr><td>ID<td><td>" + file.id + "</td></tr>"
|
||||||
+ "<tr><td>Size<td><td>" + formatDataVolume(file.size) + "</td></tr>"
|
+ "<tr><td>Size<td><td>" + formatDataVolume(file.size) + "</td></tr>"
|
||||||
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(file.bandwidth_used) + "</td></tr>"
|
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(file.bandwidth_used) + "</td></tr>"
|
||||||
+ "<tr><td>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
+ "<tr><td>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
||||||
|
+ "<tr><td>Description<td><td>" + escapeHTML(desc) + "</td></tr>"
|
||||||
+ "</table>";
|
+ "</table>";
|
||||||
|
|
||||||
dw.viewer.toolbar.setStats(file.views, file.bandwidth_used/file.size);
|
dw.viewer.toolbar.setStats(file.views, file.bandwidth_used/file.size);
|
||||||
@@ -87,7 +67,6 @@ class DetailsWindow {
|
|||||||
dw.updateGraph(file.id);
|
dw.updateGraph(file.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
updateGraph(fileID) {let dw = this;
|
updateGraph(fileID) {let dw = this;
|
||||||
console.log("updating graph "+fileID);
|
console.log("updating graph "+fileID);
|
||||||
|
@@ -87,14 +87,6 @@ function handleUploads(files) {
|
|||||||
hideShareButtons();
|
hideShareButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
function domainURL() {
|
|
||||||
let url = window.location.protocol+"//"+window.location.hostname;
|
|
||||||
if (window.location.port != "") {
|
|
||||||
url = url+":"+window.location.port;
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function uploadsFinished() {
|
function uploadsFinished() {
|
||||||
shareLink = ""
|
shareLink = ""
|
||||||
shareTitle = ""
|
shareTitle = ""
|
||||||
|
Reference in New Issue
Block a user