diff --git a/app/__init__.py b/.lifetracker-python/__init__.py similarity index 100% rename from app/__init__.py rename to .lifetracker-python/__init__.py diff --git a/app/__pycache__/__init__.cpython-310.pyc b/.lifetracker-python/__pycache__/__init__.cpython-310.pyc similarity index 100% rename from app/__pycache__/__init__.cpython-310.pyc rename to .lifetracker-python/__pycache__/__init__.cpython-310.pyc diff --git a/app/__pycache__/app.cpython-310.pyc b/.lifetracker-python/__pycache__/app.cpython-310.pyc similarity index 100% rename from app/__pycache__/app.cpython-310.pyc rename to .lifetracker-python/__pycache__/app.cpython-310.pyc diff --git a/app/__pycache__/models.cpython-310.pyc b/.lifetracker-python/__pycache__/models.cpython-310.pyc similarity index 100% rename from app/__pycache__/models.cpython-310.pyc rename to .lifetracker-python/__pycache__/models.cpython-310.pyc diff --git a/app/__pycache__/tracker.cpython-310.pyc b/.lifetracker-python/__pycache__/tracker.cpython-310.pyc similarity index 100% rename from app/__pycache__/tracker.cpython-310.pyc rename to .lifetracker-python/__pycache__/tracker.cpython-310.pyc diff --git a/app/__pycache__/views.cpython-310.pyc b/.lifetracker-python/__pycache__/views.cpython-310.pyc similarity index 100% rename from app/__pycache__/views.cpython-310.pyc rename to .lifetracker-python/__pycache__/views.cpython-310.pyc diff --git a/app/codes.csv b/.lifetracker-python/codes.csv similarity index 100% rename from app/codes.csv rename to .lifetracker-python/codes.csv diff --git a/app/export.csv b/.lifetracker-python/export.csv similarity index 100% rename from app/export.csv rename to .lifetracker-python/export.csv diff --git a/app/models.py b/.lifetracker-python/models.py similarity index 100% rename from app/models.py rename to .lifetracker-python/models.py diff --git a/app/sqlite.db b/.lifetracker-python/sqlite.db similarity index 100% rename from app/sqlite.db rename to .lifetracker-python/sqlite.db diff --git a/app/static/ltx.css b/.lifetracker-python/static/ltx.css similarity index 100% rename from app/static/ltx.css rename to .lifetracker-python/static/ltx.css diff --git a/app/templates/categories.html b/.lifetracker-python/templates/categories.html similarity index 100% rename from app/templates/categories.html rename to .lifetracker-python/templates/categories.html diff --git a/app/templates/colors.css b/.lifetracker-python/templates/colors.css similarity index 100% rename from app/templates/colors.css rename to .lifetracker-python/templates/colors.css diff --git a/app/templates/forms/select-color.html b/.lifetracker-python/templates/forms/select-color.html similarity index 100% rename from app/templates/forms/select-color.html rename to .lifetracker-python/templates/forms/select-color.html diff --git a/app/templates/forms/update-entry.html b/.lifetracker-python/templates/forms/update-entry.html similarity index 100% rename from app/templates/forms/update-entry.html rename to .lifetracker-python/templates/forms/update-entry.html diff --git a/app/templates/layout.html b/.lifetracker-python/templates/layout.html similarity index 100% rename from app/templates/layout.html rename to .lifetracker-python/templates/layout.html diff --git a/app/templates/table.html b/.lifetracker-python/templates/table.html similarity index 100% rename from app/templates/table.html rename to .lifetracker-python/templates/table.html diff --git a/app/templates/table2.html b/.lifetracker-python/templates/table2.html similarity index 100% rename from app/templates/table2.html rename to .lifetracker-python/templates/table2.html diff --git a/app/templates/table_.html b/.lifetracker-python/templates/table_.html similarity index 100% rename from app/templates/table_.html rename to .lifetracker-python/templates/table_.html diff --git a/app/tracker.py b/.lifetracker-python/tracker.py similarity index 100% rename from app/tracker.py rename to .lifetracker-python/tracker.py diff --git a/app/views.py b/.lifetracker-python/views.py similarity index 100% rename from app/views.py rename to .lifetracker-python/views.py diff --git a/lifetracker-vue/src/assets/base.css b/lifetracker-vue/src/assets/base.css index 4482825..2461aeb 100644 --- a/lifetracker-vue/src/assets/base.css +++ b/lifetracker-vue/src/assets/base.css @@ -98,4 +98,11 @@ a.router-link-active{ } a:hover{ color: white; +} + +div#app{ + height: 95vh; +} +div#table{ + height: 100%; } \ No newline at end of file diff --git a/lifetracker-vue/src/assets/colors.css b/lifetracker-vue/src/assets/colors.css index 4d53de5..826bfe5 100644 --- a/lifetracker-vue/src/assets/colors.css +++ b/lifetracker-vue/src/assets/colors.css @@ -17,6 +17,10 @@ text-align: left !important; } +.ht__active_highlight, .ht__highlight { + background: unset; +} + .highlight { filter: contrast(85%); } @@ -24,6 +28,9 @@ .invert { filter: invert(); } +.active-hour{ + background: white !important; +} .day-of-week{ text-transform: uppercase; diff --git a/lifetracker-vue/src/services/appwrite.js b/lifetracker-vue/src/services/appwrite.js index 64d6af6..5226268 100644 --- a/lifetracker-vue/src/services/appwrite.js +++ b/lifetracker-vue/src/services/appwrite.js @@ -41,10 +41,17 @@ class AppwriteService { return await this.getUser(); } - getEntries = async (date=null, numEntries=25) => { - if(date == null){date = DateTime.now()} - - date = DateTime.fromISO(date); + getEntries = async (date=null, numEntries=null) => { + if(date == null){ + date = DateTime.fromObject({ + year: DateTime.now().toFormat("y"), + month: 1, + day: 2 + }); + } + else{ + date = DateTime.fromISO(date); + } var firstEntry = (await this.database.listDocuments( this.databaseId, this.collectionId, @@ -54,6 +61,10 @@ class AppwriteService { var offset = Math.floor(date.diff(referenceDate).as("days")) - 1; + if (numEntries == null) { + numEntries = Math.floor(DateTime.now().diff(referenceDate).as("days")) + 7; + } + return (await this.database.listDocuments( this.databaseId, this.collectionId, [ diff --git a/lifetracker-vue/src/views/TableView.vue b/lifetracker-vue/src/views/TableView.vue index 353e059..4d0f752 100644 --- a/lifetracker-vue/src/views/TableView.vue +++ b/lifetracker-vue/src/views/TableView.vue @@ -45,7 +45,7 @@ function getHourClass(i) { 10: "lime" } if(i > 10){ - i = Math.round(i/10) - 1 + i = Math.ceil(i/10) - 1 } if (i == null) { return ""; @@ -117,7 +117,7 @@ const ExampleComponent = defineComponent({ rowHeaders: false, readOnly: false, width: '100%', - height: 'auto', + height: '100%', rowHeights: '22px', colWidths(i) { if((i > 1) && (i < 26)){ @@ -149,23 +149,59 @@ const ExampleComponent = defineComponent({ }, async mounted(){ this.user = await appwrite.getUser(); - this.entries = await appwrite.getEntries(null,5); + this.entries = await appwrite.getEntries(); this.updateTable(); this.subscribe(); this.fixSelectionBug(); + //this.lazyLoadEntries(); + this.scrollToEnd(); + this.selectCurrentCell(); }, created () { - window.addEventListener('wheel', debounce(this.handleScroll, 500, true)); + // window.addEventListener('wheel', debounce(this.handleScroll, 500, true)); }, unmounted () { - window.removeEventListener('wheel', debounce(this.handleScroll, 500, true)); + // window.removeEventListener('wheel', debounce(this.handleScroll, 500, true)); + }, + updated() { + this.scrollToEnd(); }, methods: { + selectCurrentCell(){ + var nowRow = this.entries.findIndex((e) => + DateTime.fromISO(e.date).toISODate() == DateTime.now().toISODate()) - 1; + var nowCol = parseInt(DateTime.now().toFormat("HH")) + 1; + this.hotRef.selectCell(nowRow, nowCol); + }, + scrollToEnd() { + this.hotRef.scrollViewportTo( + this.entries.length - 10 + ); + }, + async lazyLoadEntries(){ + var earliestDate = DateTime.fromObject({ + year: DateTime.now().toFormat("y"), + month: 1, + day: 1 + }); + var numEntries = Math.floor(DateTime.now().diff(earliestDate).as("days")); + console.log("Grabbing " + numEntries + " entries starting from " + earliestDate.toISODate()); + var newEntries = await appwrite.getEntries( + earliestDate.plus({days: 1}), + numEntries); + var entries = this.entries; + newEntries.reverse().forEach((e) => { + entries.unshift(e); + }) + this.entries = entries; + this.hotRef.scrollViewportTo(129); + }, setActiveHourHeader(){ - var timeString = DateTime.now().toFormat("hh a"); - var currentTimeHeader = Array.from(document.querySelectorAll("th")) - .find(el => el.innerText == timeString); - currentTimeHeader.className = "invert"; + var timeString = DateTime.now().toFormat("h a"); + console.log(timeString); + var moot = Array.from(document.querySelectorAll("th")); + var poot = moot.filter((e) => { return e.innerText == timeString}); + poot[0].classList.add("active-hour"); }, async handleScroll(e){ if(e.deltaY > 0){ @@ -235,6 +271,23 @@ const ExampleComponent = defineComponent({ updateTable(){ this.hotRef = this.$refs.wrapper.hotInstance; this.hotRef.loadData(this.entries); + }, + rewrite(d){ + var emptyEntry = { + date: d.toISODate(), + hours: [], + mood: null, + comments: "" + } + appwrite.updateEntry(emptyEntry); + console.log("Updated " + d.toISODate()); + }, + rewriteEntries(){ + const startDate = DateTime.fromISO("2023-12-10"); + const endDate = DateTime.fromISO("2023-12-31"); + for(var d = startDate; d <= endDate; d = d.plus({days: 1})){ + setTimeout(this.rewrite(d), 500); + } } }, components: { @@ -247,7 +300,7 @@ export default ExampleComponent;