From 54ecdf5a8c9ac20a28759cc77aee5bd7f5f16498 Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 19:46:45 +0200 Subject: [PATCH 1/8] [B.END] Added flag for private events --- getInfo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/getInfo.py b/getInfo.py index 2d3335f..38a6c3a 100755 --- a/getInfo.py +++ b/getInfo.py @@ -124,7 +124,9 @@ def getEvents(baseDay, interval): repetition['until'] = repetition['until'].date() except: repetition['until'] = None - + elif k[0] == 'CLASS': + # Store a boolean flag. True if PRIVATE + event_dict['CLASS'] = k[1].lower() == 'private' # If single event push into list if repetition['single'] == True: events += [event_dict] From 065bbec7d154d67d0aea7f5791543500653c0671 Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 20:59:05 +0200 Subject: [PATCH 2/8] [F.END] Display unconfirmed events with warning --- frontend/frontend.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/frontend.js b/frontend/frontend.js index cd30dce..39ba6d3 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -41,8 +41,20 @@ function zerocalcareDisplay() { var locationString = 'Officina Informatica'; } locationElement.appendChild(document.createTextNode('📍 ' + locationString)); - + eventElement.appendChild(titleElement); + // Check if event is not confirmed + if (typeof json_obj[i]['CLASS'] !== 'undefined' && json_obj[i]['CLASS'] == true) { + var unconfirmedElement = document.createElement('div'); + unconfirmedElement.style.fontWeight = 'bold'; + unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); + // Strike time, date and location to remark this concept + dateElement.style.textDecoration = 'line-through'; + timeElement.style.textDecoration = 'line-through'; + locationElement.style.textDecoration = 'line-through'; + + eventElement.appendChild(unconfirmedElement); + } eventElement.appendChild(dateElement); eventElement.appendChild(timeElement); eventElement.appendChild(locationElement); From a0e3bd871d4a39ddec7050341921ee09f9d09fe2 Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 21:10:11 +0200 Subject: [PATCH 3/8] [F.END] Pretty text striking --- frontend/frontend.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/frontend/frontend.js b/frontend/frontend.js index 39ba6d3..8d2086a 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -26,21 +26,30 @@ function zerocalcareDisplay() { titleElement.classList.add('widget-title'); var dateElement = document.createElement('div'); - dateElement.appendChild(document.createTextNode('📅 ' + m.format('dddd D MMMM YYYY') )); + var dateText = document.createElement('span'); + dateText.appendChild(document.createTextNode(m.format('dddd D MMMM YYYY')); + dateElement.appendChild(document.createTextNode('📅 ')); + dateElement.appendChild(dateText); var timeElement = document.createElement('div'); + var timeText = document.createElement('span'); var timeString = (json_obj[i]['ALLDAY'] == true) ? 'Tutto il giorno' : ('ore ' + m.format('HH:mm')); - timeElement.appendChild(document.createTextNode('⏰ ' + timeString)); + timeText.appendChild(document.createTextNode(timeString)); + timeElement.appendChild(document.createTextNode('⏰ ')); + timeElement.appendChild(timeText); + // add if location is not empty -- default location should be selected by backend var locationElement = document.createElement('div'); + var locationText = document.createElement('span'); if (typeof json_obj[i]['LOCATION'] !== 'undefined' && json_obj[i]['LOCATION'] != '') { - var locationString = json_obj[i]['LOCATION']; + locationText.appendChild(document.createTextNode(json_obj[i]['LOCATION'])); } else { - var locationString = 'Officina Informatica'; + locationText.appendChild(document.createTextNode('Officina Informatica')); } - locationElement.appendChild(document.createTextNode('📍 ' + locationString)); + locationElement.appendChild(document.createTextNode('📍 ')); + locationElement.appendChild(locationText); eventElement.appendChild(titleElement); // Check if event is not confirmed @@ -49,9 +58,9 @@ function zerocalcareDisplay() { unconfirmedElement.style.fontWeight = 'bold'; unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); // Strike time, date and location to remark this concept - dateElement.style.textDecoration = 'line-through'; - timeElement.style.textDecoration = 'line-through'; - locationElement.style.textDecoration = 'line-through'; + dateText.style.textDecoration = 'line-through'; + timeText.style.textDecoration = 'line-through'; + locationText.style.textDecoration = 'line-through'; eventElement.appendChild(unconfirmedElement); } From e99740cb30e48f9d1fa1b701e3a7c5706793f34a Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 21:12:26 +0200 Subject: [PATCH 4/8] [F.END] Typo --- frontend/frontend.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/frontend.js b/frontend/frontend.js index 8d2086a..4e28735 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -27,7 +27,7 @@ function zerocalcareDisplay() { var dateElement = document.createElement('div'); var dateText = document.createElement('span'); - dateText.appendChild(document.createTextNode(m.format('dddd D MMMM YYYY')); + dateText.appendChild(document.createTextNode(m.format('dddd D MMMM YYYY'))); dateElement.appendChild(document.createTextNode('📅 ')); dateElement.appendChild(dateText); From cb3a1a4a6472bec89e62109091527d4494ad943f Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 22:35:17 +0200 Subject: [PATCH 5/8] [B.END] Proper way to handle Privat/Public events, Confirmed/Cancelled --- getInfo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/getInfo.py b/getInfo.py index 38a6c3a..dd1e48b 100755 --- a/getInfo.py +++ b/getInfo.py @@ -126,7 +126,9 @@ def getEvents(baseDay, interval): repetition['until'] = None elif k[0] == 'CLASS': # Store a boolean flag. True if PRIVATE - event_dict['CLASS'] = k[1].lower() == 'private' + event_dict['CLASS'] = k[1] + elif k[0] == 'STATUS': + event_dict['STATUS'] = k[1] # If single event push into list if repetition['single'] == True: events += [event_dict] From 14b36061f57fd6eb1ca395406b8af9867626237c Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 22:35:46 +0200 Subject: [PATCH 6/8] [F.END] Adaptments to B.END changes --- frontend/frontend.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/frontend/frontend.js b/frontend/frontend.js index 4e28735..c186645 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -11,6 +11,11 @@ function zerocalcareDisplay() { } for (i in json_obj) { + // Do not display private events + if (typeof json_obj[i]['CLASS'] === 'string' && json_obj[i]['CLASS'] == 'PRIVATE') { + continue; + } + // Future improvements needed for a better backend output date in ISO format // Now we have to parse the string :( very very ugly var date = new Date(json_obj[i]['DATETIME']); @@ -53,16 +58,24 @@ function zerocalcareDisplay() { eventElement.appendChild(titleElement); // Check if event is not confirmed - if (typeof json_obj[i]['CLASS'] !== 'undefined' && json_obj[i]['CLASS'] == true) { - var unconfirmedElement = document.createElement('div'); - unconfirmedElement.style.fontWeight = 'bold'; - unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); - // Strike time, date and location to remark this concept - dateText.style.textDecoration = 'line-through'; - timeText.style.textDecoration = 'line-through'; - locationText.style.textDecoration = 'line-through'; + if (typeof json_obj[i]['STATUS'] === 'string') { + // Strike time, date and location to remark this concept + var strikeEvent = function () { + dateText.style.textDecoration = 'line-through'; + timeText.style.textDecoration = 'line-through'; + locationText.style.textDecoration = 'line-through'; + var unconfirmedElement = document.createElement('div'); + unconfirmedElement.style.fontWeight = 'bold'; + unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); + eventElement.appendChild(unconfirmedElement); + } - eventElement.appendChild(unconfirmedElement); + if (json_obj[i]['STATUS'] == 'TENTATIVE') { + strikeEvent('⚠️ Non confermato!'); + } + else if (json_obj[i]['STATUS'] == 'CANCELLED') { + strikeEvent('⚠️ Cancellato!'); + } } eventElement.appendChild(dateElement); eventElement.appendChild(timeElement); From 97dc951052248d6c5e0052184a7cb039f8cacaad Mon Sep 17 00:00:00 2001 From: giuliof Date: Fri, 17 Apr 2020 22:41:50 +0200 Subject: [PATCH 7/8] [F.END] Display cancelled/not confirmed --- frontend/frontend.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/frontend.js b/frontend/frontend.js index c186645..7c91c98 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -60,13 +60,13 @@ function zerocalcareDisplay() { // Check if event is not confirmed if (typeof json_obj[i]['STATUS'] === 'string') { // Strike time, date and location to remark this concept - var strikeEvent = function () { + var strikeEvent = function (message) { dateText.style.textDecoration = 'line-through'; timeText.style.textDecoration = 'line-through'; locationText.style.textDecoration = 'line-through'; var unconfirmedElement = document.createElement('div'); unconfirmedElement.style.fontWeight = 'bold'; - unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); + unconfirmedElement.appendChild(document.createTextNode(message)); eventElement.appendChild(unconfirmedElement); } From 92172f1ec7a2ae91fc5c68b6acdf0b78eb059a96 Mon Sep 17 00:00:00 2001 From: giuliof Date: Sat, 18 Apr 2020 21:07:24 +0200 Subject: [PATCH 8/8] [F.END] Text style for planned events --- frontend/frontend.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/frontend.js b/frontend/frontend.js index 7c91c98..a2c15f2 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -59,23 +59,31 @@ function zerocalcareDisplay() { eventElement.appendChild(titleElement); // Check if event is not confirmed if (typeof json_obj[i]['STATUS'] === 'string') { - // Strike time, date and location to remark this concept - var strikeEvent = function (message) { + if (json_obj[i]['STATUS'] == 'TENTATIVE') { + // Make the text a bit lighter and italic + dateText.style.fontStyle = + timeText.style.fontStyle = + locationText.style.fontStyle = 'italic'; + dateText.style.color = + timeText.style.color = + locationText.style.color = 'gray'; + // Add note + var unconfirmedElement = document.createElement('div'); + unconfirmedElement.style.fontWeight = 'bold'; + unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); + eventElement.appendChild(unconfirmedElement); + } + else if (json_obj[i]['STATUS'] == 'CANCELLED') { + // Strike time, date and location to remark this concept dateText.style.textDecoration = 'line-through'; timeText.style.textDecoration = 'line-through'; locationText.style.textDecoration = 'line-through'; + // Add note var unconfirmedElement = document.createElement('div'); unconfirmedElement.style.fontWeight = 'bold'; - unconfirmedElement.appendChild(document.createTextNode(message)); + unconfirmedElement.appendChild(document.createTextNode('⚠️ Cancellato!')); eventElement.appendChild(unconfirmedElement); } - - if (json_obj[i]['STATUS'] == 'TENTATIVE') { - strikeEvent('⚠️ Non confermato!'); - } - else if (json_obj[i]['STATUS'] == 'CANCELLED') { - strikeEvent('⚠️ Cancellato!'); - } } eventElement.appendChild(dateElement); eventElement.appendChild(timeElement);