diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html
index bd0819f..f841411 100755
--- a/frontend/src/ketr-photos/ketr-photos.html
+++ b/frontend/src/ketr-photos/ketr-photos.html
@@ -336,8 +336,8 @@
tabindex
min="[[year]]-01-01"
max="[[year]]-12-31"
- date="{{date}}">
-
Pick a date on the calendar to look back in time and see photos from that day.
+ on-date-changed="calendarChanged">
+ Pick a date on the calendar to look back in time and see photos from that day.
On [[memoryDate]], there have been [[add(thumbnails.length,pendingPhotos.length)]] photos taken over [[years.length]] year(s).
@@ -590,6 +590,12 @@
}
},
+ calendarChanged: function(event) {
+ if (!this.ignoreCalendar) {
+ this.date = event.detail.value;
+ }
+ },
+
requestAccess: function(event) {
this.$.requestAccess.open();
},
@@ -604,21 +610,22 @@
gotoToday: function() {
this.date = window.moment().format("YYYY-MM-DD");
- console.log(this.date);
},
gotoRandomDay: function() {
var day;
if (this.daysGrouped.length == 0) {
- day = window.moment(Math.ceil(Math.random() * 365), "DDD").format("MM-DD");
this.photosToday = 0;
+ day = window.moment(Math.ceil(Math.random() * 365), "DDD").format("MM-DD");
} else {
var groupedDay = this.daysGrouped[Math.floor(this.daysGrouped.length * Math.random())];
this.photosToday = groupedDay.count;
day = groupedDay.date;
}
this.date = window.moment().format("YYYY-") + day;
- console.log(this.date, this.photosToday);
+ if (this.date != this.$.calendar.date) {
+ console.log(this.date + " != " + this.$.calendar.date + ": calendar-element work around will be used.");
+ }
},
login: function(event) {
@@ -736,6 +743,22 @@
this.resetPhotos();
this.memoryDate = window.moment(this.date).format("MMMM Do");
this._loadPhotos();
+
+ this.ignoreCalendar = true;
+ this.$.calendar.date = date;
+ /* There is a bug in calendar-element that sets the wrong date */
+ if (this.$.calendar.date != date) {
+ this.async(function() {
+ console.log("calendar-element work-around attempt");
+ this.$.calendar.date = this.date;
+ this.ignoreCalendar = false;
+ }, 100);
+
+ /* Keep ignoring the calendar change until the async call
+ * finishes */
+ return;
+ }
+ this.ignoreCalendar = false;
},
modeChanged: function(mode) {
@@ -1050,11 +1073,6 @@
Polymer.IronResizableBehavior
],
- date: function(item) {
- var datetime = item.taken || item.modified || item.added;
- return datetime.replace(/T.*$/, "");
- },
-
loadLightbox: function(el) {
if (this.lightBoxElement) {
this.lightBoxElement.selected = false;
@@ -1670,10 +1688,10 @@
/* Build an Object with properties for each MM-DD that contains photos */
days.forEach(function(day) {
date = day.date.replace(/[0-9]*-/, "");
- if (!grouped.date) {
- grouped[date] = day.count;
+ if (!(date in grouped)) {
+ grouped[date] = parseInt(day.count) || 0;
} else {
- grouped[date] += day.count;
+ grouped[date] += parseInt(day.count) || 0;
}
});
diff --git a/server/routes/days.js b/server/routes/days.js
index 9fbd202..5b6f794 100644
--- a/server/routes/days.js
+++ b/server/routes/days.js
@@ -30,7 +30,7 @@ router.get("/*", function(req, res/*, next*/) {
console.log("Looking for daily photo counts in '" + path + "'");
return photoDB.sequelize.query(
"SELECT DATE(photos.taken) AS date,COUNT(photos.id) AS count FROM albums " +
- "JOIN photos ON photos.deleted!=1 AND photos.duplicate=0 AND photos.taken IS NOT NULL AND photos.albumId=albums.id " +
+ "JOIN photos ON photos.deleted=0 AND photos.duplicate=0 AND photos.taken IS NOT NULL AND photos.albumId=albums.id " +
"WHERE albums.path LIKE :path GROUP BY DATE(photos.taken) ORDER BY date DESC", {
replacements: {
path: path + "%"