Implement calendar-element work around for date setting sometimes setting to a date off by one
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
0a1f911d50
commit
1c43f2527e
@ -336,8 +336,8 @@
|
|||||||
tabindex
|
tabindex
|
||||||
min="[[year]]-01-01"
|
min="[[year]]-01-01"
|
||||||
max="[[year]]-12-31"
|
max="[[year]]-12-31"
|
||||||
date="{{date}}"></calendar-element>
|
on-date-changed="calendarChanged"></calendar-element>
|
||||||
<div>Pick a date on the calendar to look back in time and see photos from that day.</div>
|
<div>Pick a date on the calendar to look back in time and see photos from that day.</div>
|
||||||
<div hidden$="[[!thumbnails.length]]">
|
<div hidden$="[[!thumbnails.length]]">
|
||||||
<div>On <b>[[memoryDate]]</b>, there have been <b>[[add(thumbnails.length,pendingPhotos.length)]]</b> photos taken over <b>[[years.length]]</b> year(s).</div>
|
<div>On <b>[[memoryDate]]</b>, there have been <b>[[add(thumbnails.length,pendingPhotos.length)]]</b> photos taken over <b>[[years.length]]</b> year(s).</div>
|
||||||
</div>
|
</div>
|
||||||
@ -590,6 +590,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
calendarChanged: function(event) {
|
||||||
|
if (!this.ignoreCalendar) {
|
||||||
|
this.date = event.detail.value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
requestAccess: function(event) {
|
requestAccess: function(event) {
|
||||||
this.$.requestAccess.open();
|
this.$.requestAccess.open();
|
||||||
},
|
},
|
||||||
@ -604,21 +610,22 @@
|
|||||||
|
|
||||||
gotoToday: function() {
|
gotoToday: function() {
|
||||||
this.date = window.moment().format("YYYY-MM-DD");
|
this.date = window.moment().format("YYYY-MM-DD");
|
||||||
console.log(this.date);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
gotoRandomDay: function() {
|
gotoRandomDay: function() {
|
||||||
var day;
|
var day;
|
||||||
if (this.daysGrouped.length == 0) {
|
if (this.daysGrouped.length == 0) {
|
||||||
day = window.moment(Math.ceil(Math.random() * 365), "DDD").format("MM-DD");
|
|
||||||
this.photosToday = 0;
|
this.photosToday = 0;
|
||||||
|
day = window.moment(Math.ceil(Math.random() * 365), "DDD").format("MM-DD");
|
||||||
} else {
|
} else {
|
||||||
var groupedDay = this.daysGrouped[Math.floor(this.daysGrouped.length * Math.random())];
|
var groupedDay = this.daysGrouped[Math.floor(this.daysGrouped.length * Math.random())];
|
||||||
this.photosToday = groupedDay.count;
|
this.photosToday = groupedDay.count;
|
||||||
day = groupedDay.date;
|
day = groupedDay.date;
|
||||||
}
|
}
|
||||||
this.date = window.moment().format("YYYY-") + day;
|
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) {
|
login: function(event) {
|
||||||
@ -736,6 +743,22 @@
|
|||||||
this.resetPhotos();
|
this.resetPhotos();
|
||||||
this.memoryDate = window.moment(this.date).format("MMMM Do");
|
this.memoryDate = window.moment(this.date).format("MMMM Do");
|
||||||
this._loadPhotos();
|
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) {
|
modeChanged: function(mode) {
|
||||||
@ -1050,11 +1073,6 @@
|
|||||||
Polymer.IronResizableBehavior
|
Polymer.IronResizableBehavior
|
||||||
],
|
],
|
||||||
|
|
||||||
date: function(item) {
|
|
||||||
var datetime = item.taken || item.modified || item.added;
|
|
||||||
return datetime.replace(/T.*$/, "");
|
|
||||||
},
|
|
||||||
|
|
||||||
loadLightbox: function(el) {
|
loadLightbox: function(el) {
|
||||||
if (this.lightBoxElement) {
|
if (this.lightBoxElement) {
|
||||||
this.lightBoxElement.selected = false;
|
this.lightBoxElement.selected = false;
|
||||||
@ -1670,10 +1688,10 @@
|
|||||||
/* Build an Object with properties for each MM-DD that contains photos */
|
/* Build an Object with properties for each MM-DD that contains photos */
|
||||||
days.forEach(function(day) {
|
days.forEach(function(day) {
|
||||||
date = day.date.replace(/[0-9]*-/, "");
|
date = day.date.replace(/[0-9]*-/, "");
|
||||||
if (!grouped.date) {
|
if (!(date in grouped)) {
|
||||||
grouped[date] = day.count;
|
grouped[date] = parseInt(day.count) || 0;
|
||||||
} else {
|
} else {
|
||||||
grouped[date] += day.count;
|
grouped[date] += parseInt(day.count) || 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ router.get("/*", function(req, res/*, next*/) {
|
|||||||
console.log("Looking for daily photo counts in '" + path + "'");
|
console.log("Looking for daily photo counts in '" + path + "'");
|
||||||
return photoDB.sequelize.query(
|
return photoDB.sequelize.query(
|
||||||
"SELECT DATE(photos.taken) AS date,COUNT(photos.id) AS count FROM albums " +
|
"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", {
|
"WHERE albums.path LIKE :path GROUP BY DATE(photos.taken) ORDER BY date DESC", {
|
||||||
replacements: {
|
replacements: {
|
||||||
path: path + "%"
|
path: path + "%"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user