diff options
| author | Onestay <[email protected]> | 2017-04-23 14:29:09 +0200 |
|---|---|---|
| committer | Onestay <[email protected]> | 2017-04-23 14:29:09 +0200 |
| commit | e5cd142347e6811cd27bd3dc8dc511d39880d59a (patch) | |
| tree | 7ffd8e72236a67563b5851a216bf657a091e5702 /public | |
| parent | only display album select when user is logged in (diff) | |
| download | host.fuwn.me-e5cd142347e6811cd27bd3dc8dc511d39880d59a.tar.xz host.fuwn.me-e5cd142347e6811cd27bd3dc8dc511d39880d59a.zip | |
Get albums and put them in the select as options
Diffstat (limited to 'public')
| -rw-r--r-- | public/js/home.js | 19 |
1 files changed, 18 insertions, 1 deletions
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'); |