api update

This commit is contained in:
2018-10-04 23:36:34 +02:00
parent 356bf63ed3
commit 78e5acdfcc
17 changed files with 81 additions and 77 deletions

View File

@@ -22,11 +22,11 @@ var DetailsWindow = {
success: function(data){
$("#info_file_details").html(
"<table>"
+ "<tr><td>Name<td><td>" + escapeHTML(data.file_name) + "</td></tr>"
+ "<tr><td>Name<td><td>" + escapeHTML(data.name) + "</td></tr>"
+ "<tr><td>Url<td><td><a href=\"/u/" + data.id + "\">/u/" + data.id + "</a></td></tr>"
+ "<tr><td>Mime Type<td><td>" + escapeHTML(data.mime_type) + "</td></tr>"
+ "<tr><td>Id<td><td>" + data.id + "</td></tr>"
+ "<tr><td>Size<td><td class=\"bytecounter\">" + data.file_size + "</td></tr>"
+ "<tr><td>Size<td><td class=\"bytecounter\">" + data.size + "</td></tr>"
+ "<tr><td>Upload Date<td><td>" + data.date_upload + "</td></tr>"
+ "<tr><td>Description<td><td>" + escapeHTML(file.description) + "</td></tr>"
+ "</table>"
@@ -36,10 +36,10 @@ var DetailsWindow = {
} else {
$("#info_file_details").html(
"<table>"
+ "<tr><td>Name<td><td>" + escapeHTML(file.file_name) + "</td></tr>"
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</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>Size<td><td class=\"bytecounter\">" + file.file_size + "</td></tr>"
+ "<tr><td>Size<td><td class=\"bytecounter\">" + file.size + "</td></tr>"
+ "<tr><td>Upload Date<td><td>" + file.date_upload + "</td></tr>"
+ "</table>"
);

View File

@@ -127,7 +127,7 @@ var ListNavigator = {
for (i = startPos; i <= endPos; i++){
var thumb = "/api/file/" + this.data[i].id + "/thumbnail";
var name = this.data[i].file_name;
var name = this.data[i].name;
var itemHtml = escapeHTML(name) + "<br>"
+ "<img src=\"" + thumb + "\" "
@@ -144,8 +144,8 @@ var ListNavigator = {
$.each(data, function(i, item){
var filename;
if(item.file_name !== "null"){
filename = item.file_name;
if(item.name !== "null"){
filename = item.name;
}else{
filename = "Removed File";
}

View File

@@ -6,19 +6,19 @@ var Viewer = {
isList: false,
isFile: false,
initialized: false,
init: function(type, data){
if(this.initialized){
return;
}
// On small screens the toolbar takes too much space, so it collapses automatically
if($("#filepreview").width() < 400 && Toolbar.visible){
window.setTimeout(function(){
Toolbar.toggle();
}, 800);
}
if(type === "file"){
this.isFile = true;
this.currentFile = data.id;
@@ -28,17 +28,17 @@ var Viewer = {
this.listId = data.id;
ListNavigator.init(data.data);
}
this.initialized = true;
},
setFile: function(file){
this.currentFile = file.id;
document.title = file.file_name + " ~ PixelDrain";
document.title = file.name + " ~ PixelDrain";
$.get("/u/" + file.id + "/preview", function(response){
$("#filepreview").html(response);
});
DetailsWindow.setDetails(file);
Toolbar.setViews(file.views);
}
@@ -51,4 +51,4 @@ function escapeHTML(str) {
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
}

View File

@@ -50,8 +50,8 @@ function historyAddItem(json) {
var uploadItem = '<a href="/u/'+ json.id +'" target="_blank" class="file_button">'
+ '<img src="'+ apiEndpoint + json.thumbnail_href + '"'
+ "alt=\"" + json.file_name + "\" />"
+ '<span style="color: var(--highlight_color);">'+json.file_name+'</span>'
+ "alt=\"" + json.name + "\" />"
+ '<span style="color: var(--highlight_color);">'+json.name+'</span>'
+ "<br/>"
+ date.getFullYear() + "-"
+ ("00" + (date.getMonth() + 1)).slice(-2) + "-"

View File

@@ -250,7 +250,7 @@ select{
border: none;
margin: 2px;
background: linear-gradient(var(--input_color), var(--input_color_dark));
padding: 6px 10px 6px 10px;
padding: 6px 8px 6px 8px;
box-shadow: 2px 2px 8px var(--shadow_color);
font-weight: bold;
font-size: 0.85em;

View File

@@ -50,8 +50,8 @@
{{$files := .PixelAPI.UserFiles 0 20}}
{{range $files.Files}}
<a class="file_button" href="/u/{{.ID}}" target="_blank">
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.FileName}}" />
{{.FileName}}
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.File}}" />
{{.File}}
</a>
{{end}}
</div>

View File

@@ -17,8 +17,8 @@
{{$files := .PixelAPI.UserFiles 0 1000}}
{{range $files.Files}}
<a class="file_button" href="/u/{{.ID}}" target="_blank">
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.FileName}}" />
<span style="color: var(--highlight_color);">{{.FileName}}</span>
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.Name}}" />
<span style="color: var(--highlight_color);">{{.Name}}</span>
<br/>
{{.DateUpload.Format "2006-01-02 15:04:05"}}
</a>

View File

@@ -15,8 +15,8 @@
{{$files := .PixelAPI.UserFiles 0 18}}
{{range $files.Files}}
<a class="file_button" href="/u/{{.ID}}" target="_blank">
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.FileName}}" />
<span style="color: var(--highlight_color);">{{.FileName}}</span>
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail" alt="{{.Name}}" />
<span style="color: var(--highlight_color);">{{.Name}}</span>
<br/>
{{.DateUpload.Format "2006-01-02 15:04:05"}}
</a>

View File

@@ -144,10 +144,10 @@
{
"success": true,
"id": "123abc",
"file_name": "screenshot.png",
"name": "screenshot.png",
"date_upload": 1485894987, // Timestamp
"date_last_view": 1485894987, // Timestamp
"file_size": 5694837, // Bytes
"size": 5694837, // Bytes
"views" 1234, // Amount of unique file views
"mime_type" "image/png",
"description": "File description",

View File

@@ -117,10 +117,10 @@
"file_info": {
"success": true,
"id": "Jf_u5TI9",
"file_name": "11. Lenny Kravitz - Fly away.ogg",
"name": "11. Lenny Kravitz - Fly away.ogg",
"date_upload": "2018-07-04T22:24:48Z",
"date_last_view": "2018-07-04T22:24:48Z",
"file_size": 9757269,
"size": 9757269,
"views": 0,
"mime_type": "application/ogg",
"thumbnail_href": "/file/Jf_u5TI9/thumbnail"

View File

@@ -39,9 +39,11 @@
<pre>HTTP 422: Unprocessable Entity
{
"success": false,
"value": "file_not_found",
"id": "Oh42No", // The file you tried to add with this ID does not exist
"message": "File Oh42No was not found in the database."
"value": "list_file_not_found",
"message": "File Oh42No was not found in the database.",
"extra": {
"file_not_found": "0h42No" // The file you tried to add with this ID does not exist
}
}
</pre>
<pre>HTTP 413: Payload too large
@@ -124,7 +126,7 @@
{
"detail_href": "/file/_SqVWi/info",
"id": "_SqVWi",
"file_name": "01 Holy Wars... The Punishment Due.mp3",
"name": "01 Holy Wars... The Punishment Due.mp3",
"description": "",
"date_created": 1513033304,
"date_last_view": 1513033304
@@ -132,7 +134,7 @@
{
"detail_href": "/file/RKwgZb/info",
"id": "RKwgZb",
"file_name": "02 Hangar 18.mp3",
"name": "02 Hangar 18.mp3",
"description": "",
"date_created": 1513033304,
"date_last_view": 1513033304
@@ -140,7 +142,7 @@
{
"detail_href": "/file/DRaL_e/info",
"id": "DRaL_e",
"file_name": "03 Take No Prisoners.mp3",
"name": "03 Take No Prisoners.mp3",
"description": "",
"date_created": 1513033304,
"date_last_view": 1513033304