pull/37/head
Varun Patil 2022-08-14 23:53:26 +00:00
parent aa008dbe91
commit d04ed4d4c8
1 changed files with 36 additions and 7 deletions

View File

@ -10,7 +10,9 @@
:emit-update="true" :emit-update="true"
@update="scrollChange" @update="scrollChange"
> >
<h1 v-if="item.head" class="head">Vue is awesome!</h1> <h1 v-if="item.head" class="head">
{{ item.name }}
</h1>
<div v-else class="photo"> <div v-else class="photo">
<img v-for="img of item.photos" :src="img.src" :key="img.file_id" /> <img v-for="img of item.photos" :src="img.src" :key="img.file_id" />
</div> </div>
@ -24,12 +26,13 @@ export default {
return { return {
list: [], list: [],
count: 0, count: 0,
nrows: 0,
ncols: 5, ncols: 5,
} }
}, },
mounted() { mounted() {
this.fetchList(); this.fetchDays();
}, },
methods: { methods: {
@ -49,10 +52,36 @@ export default {
console.log('scrollChange', startIndex, endIndex); console.log('scrollChange', startIndex, endIndex);
}, },
async fetchList() { async fetchDays() {
const res = await fetch('/apps/betterphotos/api/list'); const res = await fetch('/apps/betterphotos/api/days');
const data = await res.json(); const data = await res.json();
const nrows = Math.ceil(data.length / this.ncols) + 5;
for (const day of data) {
if (day.count === 0) {
continue;
}
this.list.push({
id: ++this.nrows,
name: new Date(Number(day.day_id)*86400*1000).toLocaleDateString(
"en-US", { dateStyle: 'full', timeZone: 'UTC' }),
size: 40,
head: true,
});
const nrows = Math.ceil(day.count / this.ncols);
for (let i = 0; i < nrows; i++) {
this.list.push({
id: ++this.nrows,
photos: [],
size: 100,
});
}
}
return;
// const nrows = Math.ceil(data.length / this.ncols) + 5;
this.list.push({ this.list.push({
id: -1, id: -1,
@ -122,8 +151,8 @@ export default {
object-fit: cover; object-fit: cover;
} }
.head { .head {
height: 64px; height: 40px;
font-size: 20px; font-size: 20px;
font-weight: bold; font-weight: lighter;
} }
</style> </style>