blob: ccadb4b553490edf9aa7c1aa11fe17bfa7e79356 [file] [log] [blame]
giolekva0f503aa2020-04-20 22:41:06 +04001async function fetchAllPhotos() {
2 return await fetch("/graphql?query={queryImage(){objectPath}}")
3 .then(resp => resp.json())
4 .then(resp => resp.data.queryImage)
5 .catch(error => {
6 alert(error);
7 return [];
8 });
9
10}
11
12async function initGallery(gallery_elem_id) {
13 imgs = await fetchAllPhotos();
14 console.log(imgs);
15 img_list = "<ul>";
16 for (img of imgs) {
17 img_list += "<li><a href='/photo/" + img.id + "'><img style='max-width: 300px' src='http://localhost:9000/" + img.objectPath + "' /></a></li>";
18 }
19 img_list += "</ul>";
20 console.log(img_list);
21 document.getElementById(gallery_elem_id).innerHTML = img_list;
22}