Fix timeline size

pull/37/head
Varun Patil 2022-08-15 03:48:52 +00:00
parent ee41e8441d
commit 3c6a5036d4
2 changed files with 27 additions and 6 deletions

View File

@ -17,7 +17,8 @@
<style scoped> <style scoped>
.outer { .outer {
padding: 0 0 20px 44px; padding: 0 0 0 44px;
height: 100%;
} }
</style> </style>

View File

@ -1,6 +1,7 @@
<template> <template>
<div> <div class="container" ref="container">
<RecycleScroller <RecycleScroller
ref="scroller"
class="scroller" class="scroller"
:items="list" :items="list"
size-field="size" size-field="size"
@ -35,10 +36,16 @@ export default {
}, },
mounted() { mounted() {
this.handleResize();
this.fetchDays(); this.fetchDays();
}, },
methods: { methods: {
handleResize() {
let height = this.$refs.container.clientHeight;
this.$refs.scroller.$el.style.height = (height - 4) + 'px';
},
scrollChange(startIndex, endIndex) { scrollChange(startIndex, endIndex) {
if (startIndex === this.currentStart && endIndex === this.currentEnd) { if (startIndex === this.currentStart && endIndex === this.currentEnd) {
return; return;
@ -54,7 +61,6 @@ export default {
}, },
loadChanges(startIndex, endIndex) { loadChanges(startIndex, endIndex) {
console.log(startIndex, endIndex);
for (let i = startIndex; i <= endIndex; i++) { for (let i = startIndex; i <= endIndex; i++) {
let item = this.list[i]; let item = this.list[i];
if (!item) { if (!item) {
@ -74,14 +80,23 @@ export default {
const data = await res.json(); const data = await res.json();
for (const day of data) { for (const day of data) {
// Nothing here
if (day.count === 0) { if (day.count === 0) {
continue; continue;
} }
// Make date string
const dateTaken = new Date(Number(day.day_id)*86400*1000);
let dateStr = dateTaken.toLocaleDateString("en-US", { dateStyle: 'full', timeZone: 'UTC' });
if (dateTaken.getUTCFullYear() === new Date().getUTCFullYear()) {
// hack: remove last 6 characters of date string
dateStr = dateStr.substring(0, dateStr.length - 6);
}
// Add header to list
const head = { const head = {
id: ++this.nrows, id: ++this.nrows,
name: new Date(Number(day.day_id)*86400*1000).toLocaleDateString( name: dateStr,
"en-US", { dateStyle: 'full', timeZone: 'UTC' }),
size: 60, size: 60,
head: true, head: true,
loaded: false, loaded: false,
@ -90,6 +105,7 @@ export default {
this.heads[day.day_id] = head; this.heads[day.day_id] = head;
this.list.push(head); this.list.push(head);
// Add rows
const nrows = Math.ceil(day.count / this.ncols); const nrows = Math.ceil(day.count / this.ncols);
for (let i = 0; i < nrows; i++) { for (let i = 0; i < nrows; i++) {
this.list.push({ this.list.push({
@ -156,8 +172,12 @@ export default {
</script> </script>
<style scoped> <style scoped>
.container {
height: 100%;
}
.scroller { .scroller {
height: 600px; height: 300px;
width: 100%; width: 100%;
} }