8000 Approach for QR integration on the attendance UI by evrpress · Pull Request #1494 · WordPress/wordcamp.org · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Approach for QR integration on the attendance UI #1494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: production
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ede50a0
Approach for QR integration on the attendance UI
8000 evrpress Jun 5, 2025
0de09f5
removed qr-scanner, and worker
evrpress Jun 10, 2025
04312a6
added styles to scss file
evrpress Jun 10, 2025
b9d6d14
removed useless alert method
evrpress Jun 10, 2025
797f3f2
removed unused variable $qrscanner
evrpress Jun 10, 2025
ab3932c
initialize QR only if settings are defined and enabled
evrpress Jun 10, 2025
4cdb23c
removed unused decodedResult arg
evrpress Jun 10, 2025
f8cd0bf
better name for the variable which holds the DOM element for the reader
evrpress Jun 10, 2025
a94b1e4
register script of the qr code library
evrpress Jun 10, 2025
54257b5
bail if not a valid format
evrpress Jun 10, 2025
aa70269
removed comments
evrpress Jun 10, 2025
9d2586f
fix intention
evrpress Jun 10, 2025
4760dbf
format call to add_settings_field_helper and removed linebreaks
evrpress Jun 10, 2025
b5dd456
correctly enqueue/register scripts
evrpress Jun 10, 2025
c7511aa
change the query to search for the QR string directly in the database
evrpress Jun 10, 2025
7debcff
better verification if the result is actually a valid attendee
evrpress Jun 10, 2025
86c3217
changed markup for more clarity, increased fps and updated CSS
evrpress Jun 10, 2025
7bdfd6b
added sound to get audio feedback an valid and failed scans
evrpress Jun 10, 2025
40abc1c
better error handling, scanner pauses for 3 seconds to prevent multip…
evrpress Jun 10, 2025
1573898
better qrbox calculations for more space an required min values
evrpress Jun 10, 2025
6851937
translateable strings
evrpress Jun 11, 2025
3d1588b
better error message handling
evrpress Jun 11, 2025
3b943ac
Improve response on errors.
evrpress Jun 11, 2025
7bef3f5
qrbox should always be squared
evrpress Jun 11, 2025
ac7304d
enabling the lastScan again to prevent multiple scans of the same QR
evrpress Jun 11, 2025
41094b8
improved css for mobile
evrpress Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,32 @@ li.item .spinner:after {
font-size: 16px;
padding-left: 2px;
padding-right: 16px; }
#attendees-list-wrapper .qr-scanner {
display: none;
z-index: 400;
position: absolute;
bottom: 1em;
right: 1em;
height: auto;
width: 90vw;
width: calc(100% - 2em);
max-width: 480px;
}
#qr-reader {
min-height: 200px;
}
#qr-reader__dashboard_section {
_display: none;
position: absolute;
background: #fff;
bottom: 0;
}
.qr-scanner:hover #qr-reader__dashboard_section {
display: block;
}
.qr-scanner-active #attendees-list-wrapper .qr-scanner {
display: block;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've only added the new styles to the compiled .css file, but you should have added them to the .scss file instead and compile the .css file again.


.attendee-toggle-wrap {
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,13 @@ jQuery(document).ready(function($){
* Main Application events/controls.
*/
events: {
'fastClick .dashicons-menu': 'menu',
'fastClick .submenu .search': 'searchView',
'fastClick header h1': 'searchView',
'fastClick .submenu .sort': 'sortView',
'fastClick .submenu .refresh': 'refresh',
'fastClick .submenu .filter': 'filterView'
'click .dashicons-menu': 'menu',
'click .submenu .search': 'searchView',
'click header h1': 'searchView',
'click .submenu .sort': 'sortView',
'click .submenu .refresh': 'refresh',
'click .submenu .qr': 'qr',
'click .submenu .filter': 'filterView',
},

/**
Expand All @@ -421,8 +422,8 @@ jQuery(document).ready(function($){

this.render();

this.$header = this.$el.find( 'header' );
this.$menu = this.$header.find( '.menu' );
this.$header = this.$el.find('header');
this.$menu = this.$header.find('.menu');

this.scroll = _.chain( this.scroll ).bind( this ).value();
this.$list = this.$el.find( '.attendees-list' );
Expand All @@ -435,6 +436,14 @@ jQuery(document).ready(function($){
this.on( 'filter', this.filter, this );

this.setupCollection();

if (
_camptixAttendanceQRScanning !== undefined &&
_camptixAttendanceQRScanning
) {
this.qr();
}

},

/**
Expand Down Expand Up @@ -574,6 +583,99 @@ jQuery(document).ready(function($){
return false;
},

qr: function () {
this.$el.toggleClass('qr-scanner-active');
this.$menu.removeClass('dropdown');

let that = this;

let html5QrcodeScanner;
let lastScan;
let toggleView;
let lastScanTimeout;

function onScanSuccess(decodedText) {
if (lastScan === decodedText) {
return;
}

lastScan = decodedText;
lastScanTimeout && clearTimeout(lastScanTimeout);

if (toggleView) toggleView.close();
let method = 'read';
let model = that.collection;
let options = {
data: { qrcode: decodedText },
};
let attendeeModel;

that.collection
.sync(method, model, options)
.done(
function (res) {
// not sure why this is an array
attendeeModel = new camptix.models.Attendee(res[0]);
toggleView = new camptix.views.AttendeeToggleView({
model: attendeeModel,
controller: that,
});
$(document.body).append(toggleView.render().el);
}.bind(that)
)
.fail(function (res) {
console.error(res);
// play the sound to indicate that the scan is bad
window._camptixAttendanceSounds.blm();

// let the sound play before showing the alert
setTimeout(function () {
if (typeof res === 'string') {
alert(res);
} else {
alert('[' + res.status + '] ' + res.statusText);
}
lastScan = null;
html5QrcodeScanner.resume();
}, 100);

})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write some more helpful debug output or better remove it completely, when the PR is finished.

.then(() => {
// play the sound to indicate that the scan is good
window._camptixAttendanceSounds.beep();
setTimeout(() => {
html5QrcodeScanner.resume();
//lastScan = null;
//that.refresh();
}, 3000);
})
.always(() => {
lastScanTimeout = setTimeout(() => {
// clear last scan to allow for new scan
lastScan = null;
// play the sound to indicate that the scan is over
//window._camptixAttendanceSounds.bob();
}, 15000);
});

html5QrcodeScanner.pause();
}

let qrReader = document.getElementById('qr-scanner').getBoundingClientRect();

let smallerSide = Math.min(qrReader.width, qrReader.height);

let qrbox = {
width: Math.max(smallerSide * 0.9, 50),
height: Math.max(smallerSide * 0.9, 50),
};

html5QrcodeScanner = new Html5QrcodeScanner('qr-scanner', { fps: 10, qrbox: qrbox }, false);
html5QrcodeScanner.render(onScanSuccess);

return false;
},

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply WordPress coding styles on this hunk (and the rest of your changes in the file).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need more help on setting this up in my editor (Cursor/VsCode). I always break things in trying to do so 😬

/**
* Re-initialize a calloction with a search term.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ header {
color: white;
padding-left: 16px;

z-index: 100;
z-index: 300;
}

header h1,
Expand Down Expand Up @@ -221,6 +221,20 @@ li.item {
display: block;
margin-right: 50px;
margin-left: 50px;

.previews {
position: fixed;
bottom: 1em;
left: 1em;
right: 1em;

video {
max-height: 8em;
max-width: 8em;
width: 8em;
float: right;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While there were changes in the .css file only before, these changes are only in the .scss file. It's not clear which library was used to compile the .css file, but I'd assume some older Sass version with the default settings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure where this is comming from, I'll keep it for now

}

.attendee-search-view input {
Expand Down Expand Up @@ -412,6 +426,72 @@ li.item {
}
}

.qr-scanner-wrap {
display: none;
z-index: 299;
position: absolute;
bottom: 1em;
right: 1em;
width: calc(100% - 2em);
aspect-ratio: 4/3;
max-width: 480px;
background: #ccc;

#qr-scanner {
height: 100%;
}
#qr-scanner__scan_region{
display: flex;
align-self: center;
justify-content: center;
position: absolute;
inset: 0;
}
#qr-scanner__dashboard {
display: none;
position: absolute;
background: #fff;
bottom: 0;

button{
height: 50px;
display: block;
width: calc(100% - 2em);
margin:1em;
line-height: 50px;
font-size: 16px;
background: #333;
color: white;
text-decoration: none;
-webkit-appearance: none;
cursor: pointer;
}
#html5-qrcode-anchor-scan-type-change{
display: none !important;
}
}
&:hover #qr-scanner__dashboard {
display: block;
}

}
@media screen and (max-width: 480px) {
.qr-scanner-wrap {
position: fixed;
inset:60px 1em 1em;
width: calc(100% - 2em);
height: calc(100% - 2em - 60px);
margin: 0;
#qr-scanner__dashboard {
display: block;
}
}
}

.qr-scanner-active .qr-scanner-wrap {
display: block;
}

/** Animations, courtesy of https://github.com/lukehaas/css-loaders **/

@-webkit-keyframes load1 {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<script>
_camptixAttendanceSecret = '<?php echo esc_js( $_GET['camptix-attendance'] ); ?>';
_camptixAttendanceTickets = [ <?php echo esc_js( implode( ', ', array_map( 'absint', wp_list_pluck( $camptix_tickets, 'ID' ) ) ) ); ?> ];
_camptixAttendanceQRScanning = <?php echo ! empty( $camptix_options['attendance-qr-enabled'] ) ? 'true' : 'false'; ?>;
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
Expand Down Expand Up @@ -76,6 +77,7 @@
<a href="#" class="search">Search</a>
<a href="#" class="filter">Sort & Filter</a>
<a href="#" class="refresh">Refresh</a>
<a href="#" class="qr">QR Scanner</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a condition to only show this when the QR code scanner is enabled (or use a CSS class, switched by JS, to hide it - but better not render it at all).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was supposed to be always there (the menu entry): The settings should just show the camera field by default, so you don't have to open it manually every time.

Since it's in the menu entry, I would keep it as it is and just show the camera, depending on the setting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so if the setting is set to "On", the camera would always show, and with "Off", only when accessed thought the menu?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so if you reload the page you don't have to click into the menu. We can change this behavior of course

</div>
</div>
<h1><?php echo esc_html( $camptix_options['event_name'] ); ?></h1>
Expand All @@ -88,13 +90,15 @@
<span>Loading...</span>
</li>
</ul>
<div class="qr-scanner-wrap"><div id="qr-scanner"></div></div>
</div>
</script>

<script id="tmpl-attendee-search" type="text/template">
<a href="#" class="close dashicons dashicons-no"></a>
<div class="wrapper">
<input type="text" autocomplete="off" placeholder="Search" />
<div class="previews"></div>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is here. It's also referenced in the scss above. I'll keep it for now

</div>
</script>

Expand Down
Loading
Loading
0