-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…earch
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { GET, PUT } from './util/Client.js'; | ||
import { requireLogin } from './util/Auth.js'; | ||
import { GET, PUT, sendGmail } from './util/Client.js'; | ||
import { requireLogin, getCurrentUser, requestGoogleCredential } from './util/Auth.js'; | ||
import { sanitizeText } from './util/util.js'; | ||
import { Popup } from './components/Popup.js'; | ||
const $ = window.$; | ||
const user = await getCurrentUser(); | ||
await requireLogin(); | ||
|
||
$('#calendar').evoCalendar(); | ||
|
@@ -146,11 +147,48 @@ window.markAbsent = async (businessId, eventId) => { | |
await Popup.alert(await res.text(), 'var(--error)'); | ||
return; | ||
} | ||
await Popup.alert('You have been marked absent!'); | ||
await Popup.alert( | ||
'You have been marked absent! Close this popup and click on your email account to send notifications to the event host(s).', | ||
'var(--success)', | ||
); | ||
|
||
// Send email notification to business owner and admins | ||
const credential = await requestGoogleCredential([ | ||
'https://www.googleapis.com/auth/gmail.send', | ||
]); | ||
let success = true; | ||
const res1 = await GET(`/businesses/${businessId}/writemembers`); | ||
const writeMembers = await res1.json(); | ||
console.log(writeMembers); | ||
|
||
for (const member of writeMembers) { | ||
const res = await sendGmail( | ||
member.email, | ||
'Attendance Scanner Notification of Absence', | ||
'Hi ' + | ||
member.name + | ||
',\n\n' + | ||
user.name + | ||
' has marked themselves absent from the event.\n\n(automatically sent via Attendance Scanner QR)', | ||
credential, | ||
); | ||
if (!res.ok) { | ||
success = false; | ||
const obj = await res.json(); | ||
const message = obj.error.message; | ||
Popup.alert( | ||
`Email to ${sanitizeText(member[1])} failed to send. ` + message, | ||
'var(--error)', | ||
); | ||
} | ||
} | ||
if (success) { | ||
Popup.alert('Emails sent successfully!', 'var(--success)'); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SanderGi
Collaborator
|
||
|
||
// manually change html since evo-calendar is broken when adding/removing or updating events | ||
const badge = document.createElement('span'); | ||
badge.textContent = 'ABSENT(self-marked)'; | ||
badge.textContent = 'ABSENT(self)'; | ||
document | ||
.querySelector(`[data-event-index="${eventId}"]`) | ||
.getElementsByClassName('event-title')[0] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Component } from '../util/Component.js'; | ||
import { calcSimilarity } from '../util/util.js'; | ||
|
||
/** | ||
* A table component with pagination, sorting and selection. | ||
|
@@ -87,10 +88,12 @@ export class DataTable extends Component { | |
html += `<th>${this.formatHeader(col)}`; | ||
} else { | ||
html += `<th data-colIx="${i}"> | ||
${this.formatHeader(col)} <i class="fa-solid fa-sort"></i>`; | ||
<p style="display: inline;" class="sort-group">${this.formatHeader( | ||
col, | ||
)} <i class="fa-solid fa-sort"></i></p>`; | ||
} | ||
if (this.searchableColumns.includes(col)) { | ||
html += ' <i class="fa-solid fa-magnifying-glass"></i></th>'; | ||
html += ' <i class="search fa-solid fa-magnifying-glass"></i></th>'; | ||
} else { | ||
html += '</th>'; | ||
} | ||
|
@@ -306,16 +309,60 @@ export class DataTable extends Component { | |
search.type = 'search'; | ||
search.placeholder = 'Search NAME'; | ||
th.replaceChildren(search); | ||
let initialRows = this.rows.filter(row => | ||
row[header].toLowerCase().includes(search.value.toLowerCase()), | ||
); | ||
search.oninput = () => { | ||
const searchValue = search.value; | ||
this.rows = initialRows.filter(row => | ||
row[header].toLowerCase().includes(searchValue.toLowerCase()), | ||
); | ||
this.showPage(1); | ||
search.oninput = e => { | ||
let switching = true; | ||
while (switching) { | ||
let i; | ||
switching = false; | ||
let shouldSwitch = false; | ||
let rows = this.shadowRoot.getElementById('table').querySelectorAll('tr'); | ||
/* Loop through all table rows (except the | ||
first, which contains table headers): */ | ||
for (i = 1; i < rows.length - 1; i++) { | ||
/* Start by saying there should be no switching: */ | ||
shouldSwitch = false; | ||
/* Get the two elements you want to compare, | ||
one from current row and one from the next: */ | ||
let x = rows[i].querySelectorAll('td')[1]; | ||
let y = rows[i + 1].querySelectorAll('td')[1]; | ||
/* Check if the two rows should switch place, | ||
based on the direction, asc or desc: */ | ||
if (e.target.value) { | ||
if ( | ||
calcSimilarity(x.textContent, e.target.value) < | ||
calcSimilarity(y.textContent, e.target.value) | ||
) { | ||
/* If so, mark as a switch and break the loop: */ | ||
shouldSwitch = true; | ||
break; | ||
} | ||
} else { | ||
if (x.textContent.toLowerCase() > y.textContent.toLowerCase()) { | ||
/* If so, mark as a switch and break the loop: */ | ||
shouldSwitch = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (shouldSwitch) { | ||
/* If a switch has been marked, make the switch | ||
and mark the switch as done: */ | ||
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); | ||
switching = true; | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
SanderGi
Collaborator
|
||
}; | ||
|
||
// let initialRows = this.rows.filter(row => | ||
// row[header].toLowerCase().includes(search.value.toLowerCase()), | ||
// ); | ||
// search.oninput = () => { | ||
// const searchValue = search.value; | ||
// this.rows = initialRows.filter(row => | ||
// row[header].toLowerCase().includes(searchValue.toLowerCase()), | ||
// ); | ||
// this.showPage(1); | ||
// }; | ||
This comment has been minimized.
Sorry, something went wrong.
SanderGi
Collaborator
|
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ <h3 style="margin-bottom: 3px">Free Plan</h3> | |
<hr /> | ||
<ul style="text-align: center; max-width: 80%; margin: auto"> | ||
<li>Fixed Monthly Price: $0.00</li> | ||
<li>Up to 50 members</li> | ||
<li>Up to 150 members</li> | ||
<li>Unlimited role and user privilege management</li> | ||
<li> | ||
<a href="https://github.com/clr-li/AttendanceScanner/issues" | ||
|
@@ -67,11 +67,15 @@ <h3 style="margin-bottom: 3px">Standard Plan</h3> | |
<hr /> | ||
<ul style="text-align: center; max-width: 80%; margin: auto"> | ||
<li>Fixed Monthly Price: $7.00</li> | ||
<li>Up to 100 members</li> | ||
<li>Up to 500 members</li> | ||
<li>Unlimited role and user privilege management</li> | ||
<li>Email+Community support</li> | ||
<li>API+Google Sheets integration</li> | ||
<li>Gmail+Email invites and notifications</li> | ||
<li>Email + | ||
<a href="https://github.com/clr-li/AttendanceScanner/issues" | ||
>Community support</a | ||
> | ||
</li> | ||
<li>Export/import custom data via CSV</li> | ||
<li>Gmail invites and notifications</li> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SanderGi
Collaborator
|
||
</ul> | ||
</div> | ||
</section> | ||
|
I have a feeling that receiving email notifications every time someone marks themselves absent could get annoying. Should we perhaps make this a setting?