diff --git a/pages/dashboard.html b/pages/dashboard.html
index b864ab6..9739dee 100644
--- a/pages/dashboard.html
+++ b/pages/dashboard.html
@@ -38,7 +38,90 @@
-
+
+
diff --git a/public/css/style.css b/public/css/style.css
index ac3959d..8f5e857 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -41,7 +41,7 @@ section#home div#dropzone {
padding-left: .75em;
padding-right: .75em;
text-align: center;
- cursor: pointer;
+ cursor: pointer;
}
section#home div#uploads, section#home p#tokenContainer, section#home a#panel { display: none; }
@@ -110,3 +110,40 @@ section#dashboard div#table div.column a img { width:200px; }
text-align: center;
margin-bottom: 10px;
}
+
+/** Based on KDE Breeze Dark **/
+
+.hero {
+ background-color: #232629;
+ color: #eff0f1;
+}
+
+.title {
+ color: #eff0f1;
+}
+
+.subtitle {
+ color: #bdc3c7;
+}
+
+.subtitle strong {
+ color: #bdc3c7;
+}
+
+a {
+ color: #2980b9;
+}
+
+a:hover {
+ color: #3daee9;
+}
+
+section#home h3#links span {
+ color: #4d4d4d;
+}
+
+section#home #b {
+ width: 200px;
+ height: 200px;
+ border-radius: 100%;
+}
diff --git a/public/js/auth.js b/public/js/auth.js
index ecc7c7c..56eea32 100644
--- a/public/js/auth.js
+++ b/public/js/auth.js
@@ -1,56 +1,44 @@
var page = {};
-page.do = function(dest){
-
+page.do = function(dest) {
var user = document.getElementById('user').value;
var pass = document.getElementById('pass').value;
- if(user === undefined || user === null || user === '')
- return swal('Error', 'You need to specify a username', 'error');
- if(pass === undefined || pass === null || pass === '')
- return swal('Error', 'You need to specify a username', 'error');
+ if (user === undefined || user === null || user === '') { return swal('Error', 'You need to specify a username', 'error'); }
+ if (pass === undefined || pass === null || pass === '') { return swal('Error', 'You need to specify a username', 'error'); }
- axios.post('/api/' + dest, {
+ axios.post(`/api/${dest}`, {
username: user,
password: pass
})
- .then(function (response) {
+ .then(response => {
+ if (response.data.success === false) { return swal('Error', response.data.description, 'error'); }
- if(response.data.success === false)
- return swal('Error', response.data.description, 'error');
-
- localStorage.token = response.data.token;
- window.location = '/dashboard';
+ localStorage.token = response.data.token;
+ window.location = '/dashboard';
+ })
+ .catch(error => {
+ return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
+ console.log(error);
+ });
+};
- })
- .catch(function (error) {
- return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
- console.log(error);
- });
-}
-
-page.verify = function(){
+page.verify = function() {
page.token = localStorage.token;
- if(page.token === undefined) return;
+ if (page.token === undefined) return;
- axios.post('/api/tokens/verify', {
- token: page.token
- })
- .then(function (response) {
+ axios.post('/api/tokens/verify', { token: page.token })
+ .then(response => {
+ if (response.data.success === false) { return swal('Error', response.data.description, 'error'); }
- if(response.data.success === false)
- return swal('Error', response.data.description, 'error');
-
- window.location = '/dashboard';
+ window.location = '/dashboard';
+ })
+ .catch(error => {
+ return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
+ console.log(error);
+ });
+};
- })
- .catch(function (error) {
- return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
- console.log(error);
- });
-
-}
-
-window.onload = function () {
+window.onload = function() {
page.verify();
-}
\ No newline at end of file
+};
diff --git a/public/js/dashboard.js b/public/js/dashboard.js
index 7309908..3238f7b 100644
--- a/public/js/dashboard.js
+++ b/public/js/dashboard.js
@@ -1,104 +1,95 @@
-let panel = {}
+let panel = {};
panel.page;
panel.username;
panel.token = localStorage.token;
panel.filesView = localStorage.filesView;
-panel.preparePage = function(){
- if(!panel.token) return window.location = '/auth';
+panel.preparePage = function() {
+ if (!panel.token) return window.location = '/auth';
panel.verifyToken(panel.token, true);
-}
+};
-panel.verifyToken = function(token, reloadOnError){
- if(reloadOnError === undefined)
- reloadOnError = false;
+panel.verifyToken = function(token, reloadOnError) {
+ if (reloadOnError === undefined) { reloadOnError = false; }
- axios.post('/api/tokens/verify', {
- token: token
- })
- .then(function (response) {
+ axios.post('/api/tokens/verify', { token: token })
+ .then(response => {
+ if (response.data.success === false) {
+ swal({
+ title: 'An error ocurred',
+ text: response.data.description,
+ type: 'error'
+ }, () => {
+ if (reloadOnError) {
+ localStorage.removeItem('token');
+ location.location = '/auth';
+ }
+ });
+ return;
+ }
- if(response.data.success === false){
- swal({
- title: "An error ocurred",
- text: response.data.description,
- type: "error"
- }, function(){
- if(reloadOnError){
- localStorage.removeItem("token");
- location.location = '/auth';
- }
- })
- return;
- }
+ axios.defaults.headers.common.token = token;
+ localStorage.token = token;
+ panel.token = token;
+ panel.username = response.data.username;
+ return panel.prepareDashboard();
+ })
+ .catch(error => {
+ return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
+ console.log(error);
+ });
+};
- axios.defaults.headers.common['token'] = token;
- localStorage.token = token;
- panel.token = token;
- panel.username = response.data.username;
- return panel.prepareDashboard();
-
- })
- .catch(function (error) {
- return swal("An error ocurred", 'There was an error with the request, please check the console for more information.', "error");
- console.log(error);
- });
-
-}
-
-panel.prepareDashboard = function(){
+panel.prepareDashboard = function() {
panel.page = document.getElementById('page');
document.getElementById('auth').style.display = 'none';
document.getElementById('dashboard').style.display = 'block';
- document.getElementById('itemUploads').addEventListener('click', function(){
+ document.getElementById('itemUploads').addEventListener('click', function() {
panel.setActiveMenu(this);
});
- document.getElementById('itemManageGallery').addEventListener('click', function(){
+ document.getElementById('itemManageGallery').addEventListener('click', function() {
panel.setActiveMenu(this);
});
- document.getElementById('itemTokens').addEventListener('click', function(){
+ document.getElementById('itemTokens').addEventListener('click', function() {
panel.setActiveMenu(this);
});
- document.getElementById('itemPassword').addEventListener('click', function(){
+ document.getElementById('itemPassword').addEventListener('click', function() {
panel.setActiveMenu(this);
});
document.getElementById('itemLogout').innerHTML = `Logout ( ${panel.username} )`;
panel.getAlbumsSidebar();
-}
+};
-panel.logout = function(){
- localStorage.removeItem("token");
+panel.logout = function() {
+ localStorage.removeItem('token');
location.reload('/');
-}
+};
-panel.getUploads = function(album = undefined, page = undefined){
+panel.getUploads = function(album = undefined, page = undefined) {
+ if (page === undefined) page = 0;
- if(page === undefined) page = 0;
+ let url = `/api/uploads/${page}`;
+ if (album !== undefined) { url = `/api/album/${album}/${page}`; }
- let url = '/api/uploads/' + page
- if(album !== undefined)
- url = '/api/album/' + album + '/' + page
-
- axios.get(url).then(function (response) {
- if(response.data.success === false){
- if(response.data.description === 'No token provided') return panel.verifyToken(panel.token);
- else return swal("An error ocurred", response.data.description, "error");
+ axios.get(url).then(response => {
+ if (response.data.success === false) {
+ if (response.data.description === 'No token provided') return panel.verifyToken(panel.token);
+ else return swal('An error ocurred', response.data.description, 'error');
}
-
+
var prevPage = 0;
var nextPage = page + 1;
- if(response.data.files.length < 25)
- nextPage = page;
-
- if(page > 0) prevPage = page - 1;
+ if (response.data.files.length < 25) { nextPage = page; }
+
+ if (page > 0) prevPage = page - 1;
panel.page.innerHTML = '';
var container = document.createElement('div');
@@ -120,10 +111,9 @@ panel.getUploads = function(album = undefined, page = undefined){
-
`
-
- if(panel.filesView === 'thumbs'){
+ `;
+ if (panel.filesView === 'thumbs') {
container.innerHTML = `
${pagination}