move meta tags to template, begin of user portal

This commit is contained in:
2018-06-25 23:05:18 +02:00
parent 24b74a1b60
commit 12d2560133
20 changed files with 136 additions and 423 deletions

View File

@@ -26,7 +26,7 @@ var UploadProgressBar = /** @class */ (function () {
this.uploadDiv.setAttribute('style', 'background: #111');
this.uploadDiv.setAttribute('href', '/u/' + id);
this.uploadDiv.setAttribute("target", "_blank");
this.uploadDivJQ.html('<img src="/api/file/' + id + '/thumbnail" alt="' + this.file.name + '"/>'
this.uploadDivJQ.html('<img src="' + apiEndpoint + '/file/' + id + '/thumbnail" alt="' + this.file.name + '"/>'
+ this.file.name + '<br/>'
+ '<span style="color: var(--highlight_color);">' + window.location.hostname + '/u/' + id + '</span>');
};
@@ -161,7 +161,7 @@ var UploadWorker = /** @class */ (function () {
var that = this; // jquery changes the definiton of "this"
$.ajax({
type: 'POST',
url: "/api/file",
url: apiEndpoint + "/file",
data: formData,
timeout: 7200000,
cache: false,

View File

@@ -1,6 +1,3 @@
/* global API_URL */
var uploads;
$(document).ready(function () {
@@ -17,7 +14,7 @@ $(document).ready(function () {
$.ajax({
type: "GET",
dataType: "json",
url: APIURL + "/file/" + id + "/info",
url: apiEndpoint + "/file/" + id + "/info",
async: true,
success: function(data) {
historyAddItem(data);
@@ -45,19 +42,21 @@ function historyAddItem(json) {
+ "</div>";
$("#uploadedFiles").append($(uploadItem).hide().fadeIn(400));
return;
}
var date = new Date(json.date_upload * 1000);
var date = new Date(json.date_upload);
var uploadItem = '<a href="/u/'+ json.id +'" target="_blank" class="file_button">'
+ '<img src="'+ APIURL + json.thumbnail_href + '"'
+ '<img src="'+ apiEndpoint + json.thumbnail_href + '"'
+ "alt=\"" + json.file_name + "\" />"
+ '<span style="color: var(--highlight_color);">'+json.file_name+'</span>'
+ "<br/>"
+ date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate()
+ date.getFullYear() + "-"
+ ("00" + (date.getMonth() + 1)).slice(-2) + "-"
+ ("00" + date.getDate()).slice(-2)
+ "</a>";
$("#uploadedFiles").append($(uploadItem).hide().fadeIn(400));
}
}

View File

@@ -1,3 +1,4 @@
declare var apiEndpoint: string;
var uploader: UploadManager|null = null;
var finishedUploads: Array<string> = new Array()
var totalUploads: number = 0
@@ -29,7 +30,7 @@ class UploadProgressBar implements FileUpload {
public onProgress(progress: number){
this.uploadDiv.innerText = "Uploading... " + Math.round(progress*1000)/10 + "%\n" + this.file.name
this.uploadDiv.setAttribute(
'style',
'style',
'background: linear-gradient('
+'to right, '
+'#111 0%, '
@@ -44,7 +45,7 @@ class UploadProgressBar implements FileUpload {
this.uploadDiv.setAttribute('href', '/u/'+id)
this.uploadDiv.setAttribute("target", "_blank");
this.uploadDivJQ.html(
'<img src="/api/file/'+id+'/thumbnail" alt="'+this.file.name+'"/>'
'<img src="'+apiEndpoint+'/file/'+id+'/thumbnail" alt="'+this.file.name+'"/>'
+ this.file.name+'<br/>'
+ '<span style="color: var(--highlight_color);">'+window.location.hostname+'/u/'+id+'</span>'
)
@@ -82,7 +83,7 @@ $("#select_file_button").click(function(){$("#file_input_field").click()})
$("#file_input_field").change(function(evt){
handleUploads((<HTMLInputElement>evt.target).files)
// This resets the file input field
// http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery
$('#file_name').html("")
@@ -109,4 +110,4 @@ document.addEventListener('drop', function(e: DragEvent){
handleUploads(e.dataTransfer.files)
}
})
})

View File

@@ -1,3 +1,5 @@
declare var apiEndpoint: string;
interface FileUpload {
file: Blob
name: string
@@ -56,7 +58,7 @@ class UploadWorker {
console.debug("No files left in queue")
return // Stop the thread
}
this.uploading = true
this.tries = 0
this.upload(<FileUpload>file)
@@ -73,7 +75,7 @@ class UploadWorker {
$.ajax({
type: 'POST',
url: "/api/file",
url: apiEndpoint+"/file",
data: formData,
timeout: 7200000, // 2 hours
cache: false,
@@ -117,13 +119,13 @@ class UploadWorker {
private setHistoryCookie(id: string){
var uc = Cookie.read("pduploads")
// First upload in this browser
if (uc === null) {
Cookie.write("pduploads", id + ".", undefined)
return
}
if (uc.length > 2000){
// Cookie is becoming too long, drop the oldest two files
uc = uc.substring(
@@ -132,7 +134,7 @@ class UploadWorker {
uc.indexOf(".") + 1
)
}
Cookie.write("pduploads", uc + id + ".", undefined)
}
}
}