From 81f17078351926ed37041bd43d23bea8a79259e1 Mon Sep 17 00:00:00 2001 From: Onestay Date: Sun, 23 Apr 2017 14:09:44 +0200 Subject: [PATCH 1/8] only display album select when user is logged in It still needs additional styling and stuff --- pages/home.html | 17 ++++++++++++++--- public/js/home.js | 7 +++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pages/home.html b/pages/home.html index 7338c57..14d1610 100644 --- a/pages/home.html +++ b/pages/home.html @@ -45,16 +45,27 @@

- +

loli-safe

A modern self-hosted file upload service

-

+

-
+
Running in private mode. Log in to upload. +
diff --git a/public/js/home.js b/public/js/home.js index 6253c10..a3725e0 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -16,7 +16,6 @@ upload.checkIfPublic = function(){ return swal("An error ocurred", 'There was an error with the request, please check the console for more information.', "error"); console.log(error); }); - } upload.preparePage = function(){ @@ -61,6 +60,10 @@ upload.verifyToken = function(token, reloadOnError){ } upload.prepareUpload = function(){ + + if (upload.token) { + document.getElementById('albumDiv').style.display = 'block'; + } div = document.createElement('div'); div.id = 'dropzone'; @@ -74,7 +77,7 @@ upload.prepareUpload = function(){ document.getElementById('loginLinkText').innerHTML = 'Create an account and keep track of your uploads'; document.getElementById('uploadContainer').appendChild(div); - + upload.prepareDropzone(); } From e5cd142347e6811cd27bd3dc8dc511d39880d59a Mon Sep 17 00:00:00 2001 From: Onestay Date: Sun, 23 Apr 2017 14:29:09 +0200 Subject: [PATCH 2/8] Get albums and put them in the select as options --- public/js/home.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/public/js/home.js b/public/js/home.js index a3725e0..35d1e22 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -62,7 +62,24 @@ upload.verifyToken = function(token, reloadOnError){ upload.prepareUpload = function(){ if (upload.token) { - document.getElementById('albumDiv').style.display = 'block'; + const select = document.querySelector('select'); + axios.get('/api/albums', { headers: { token: upload.token }}) + .then((res) => { + console.log(res); + let albums = res.data.albums; + + if (albums.length === 0) return; + for (let i = 0; i < albums.length; i++) { + let opt = document.createElement('option'); + opt.value = albums[i].id; + opt.innerHTML = albums[i].name; + select.appendChild(opt); + } + document.getElementById('albumDiv').style.display = 'block'; + }) + .catch((e) => { + console.log(e); + }) } div = document.createElement('div'); From 7d71546388849ed28a9fc6d20e4cde929108b429 Mon Sep 17 00:00:00 2001 From: Onestay Date: Sun, 23 Apr 2017 14:29:19 +0200 Subject: [PATCH 3/8] Add none option --- pages/home.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pages/home.html b/pages/home.html index 14d1610..dd11d22 100644 --- a/pages/home.html +++ b/pages/home.html @@ -60,8 +60,7 @@

From b9fd64c620f1cd47ce2e2532c86a4dc0448e87eb Mon Sep 17 00:00:00 2001 From: Onestay Date: Sun, 23 Apr 2017 15:19:10 +0200 Subject: [PATCH 4/8] added a bit of styling --- pages/home.html | 2 +- public/css/style.css | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/home.html b/pages/home.html index dd11d22..82433a5 100644 --- a/pages/home.html +++ b/pages/home.html @@ -57,7 +57,7 @@ Running in private mode. Log in to upload.