Bugzilla – Attachment 99015 Details for
Bug 6815
Capture member photo via webcam
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6815: Add a 'Take Patron Image' ability
Bug-6815-Add-a-Take-Patron-Image-ability.patch (text/plain), 8.38 KB, created by
Lisette Scheer
on 2020-02-14 18:46:11 UTC
(
hide
)
Description:
Bug 6815: Add a 'Take Patron Image' ability
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2020-02-14 18:46:11 UTC
Size:
8.38 KB
patch
obsolete
>From 9269a320d75ee9bfbde6b9f5f4e23d83f8839a5d Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Fri, 5 Jul 2019 00:51:37 +0000 >Subject: [PATCH] Bug 6815: Add a 'Take Patron Image' ability > >This does not just click in place, which would be >nice. But it does take the picture, download to a file, >and then let's the user use the existing upload >functionality to add the photo. > >If wording or formating is ugly, feel free to tweak. > >TEST PLAN >--------- >1) the 'patronimages' system preference in Patrons system preferences > must be set to 'Allow'. >2) apply the patch >3) go to any patron >4) click the 'Take' button. > -- it is in the text area on the right, and not the > hover over the image area. Adding here would require > CSS changes, which are now difficult and ugly to do. > -- new tab should open. If you have a working webcam, > you should see it playing 'live'. >5) click the "Take the Patron's Picture" button > -- this should download a photo SamplePhoto.jpg or some > variation of that. >6) close this tab, and click the 'Edit' or 'Add' button for > the patron image. >7) click 'Choose File' and choose the file that was created >8) click 'Upload' > -- the webcam photo should now be used. >9) run koha qa test tools > >Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org> >--- > .../prog/en/modules/members/member-webcam.tt | 107 +++++++++++++++++++++ > .../prog/en/modules/members/moremember.tt | 4 + > members/webcam.pl | 37 +++++++ > 3 files changed, 148 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/member-webcam.tt > create mode 100755 members/webcam.pl > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-webcam.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-webcam.tt >new file mode 100644 >index 0000000000..7c254e2654 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-webcam.tt >@@ -0,0 +1,107 @@ >+<!DOCTYPE html> >+<html lang="en" dir="ltr"> >+ >+ <head> >+ <meta charset="utf-8" /> >+ <title>Koha Patron Image Via Webcam</title> >+ <meta name="description" >+ content="Attempt to take a patron picture using the webcam" /> >+ </head> >+ >+ <body> >+ <h1>Koha Patron Image Taker</h1> >+ <p>Ask the patron to face the webcam to take their picture.</p> >+ <p>WARNING: If your machine does not have a webcam, >+ your browser is not allowed camera access, your operating >+ system blocks the browser app from accessing the camera, >+ or your browser does not support the javascript used >+ in this page, this may not work and likely looks like >+ a empty page. If this is working you will see a video >+ playing of what the webcam sees.</p> >+ >+ <!-- display what will be captured --> >+ <video id="video" width="640" height="480" autoplay></video><br> >+ <!-- button to trigger cascading clicks resulting in a saved file --> >+ <!-- first stick the image into a hidden canvas below --> >+ <button id="snap">Take the Patron's Picture</button> >+ <canvas id="canvas" width="640" height="480" style="display:none"></canvas> >+ <!-- then change the href in a hidden link to the picture data --> >+ <button id="save" style="display:none">Save the Patron's Picture</button> >+ <!-- which will get programmatically clicked forcing the download --> >+ <a href="#" id="download" style="display:none">Download the Patron's Picture</a> >+ >+ <!-- the javascript magic that makes it happen --> >+ <script> >+ // Put event listeners into place >+ window.addEventListener("DOMContentLoaded", >+ function() { >+ // Grab elements, create settings, etc. >+ var canvas = document.getElementById('canvas'); >+ var context = canvas.getContext('2d'); >+ var video = document.getElementById('video'); >+ var mediaConfig = { video: true }; >+ var errBack = function(e) { >+ alert('An error has occurred!'); >+ }; >+ >+ // Put video listeners into place >+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { >+ navigator.mediaDevices.getUserMedia(mediaConfig).then( >+ function(stream) { >+ video.srcObject = stream; >+ video.play(); >+ } >+ ); >+ } >+ /* Legacy code below! */ >+ else if (navigator.getUserMedia) { // Standard >+ navigator.getUserMedia(mediaConfig, >+ function(stream) { >+ video.src = stream; >+ video.play(); >+ }, >+ errBack >+ ); >+ } else if (navigator.webkitGetUserMedia) { // WebKit-prefixed >+ navigator.webkitGetUserMedia(mediaConfig, >+ function(stream) { >+ video.src = window.webkitURL.createObjectURL(stream); >+ video.play(); >+ }, >+ errBack >+ ); >+ } else if (navigator.mozGetUserMedia) { // Mozilla-prefixed >+ navigator.mozGetUserMedia(mediaConfig, >+ function(stream) { >+ video.src = window.URL.createObjectURL(stream); >+ video.play(); >+ }, >+ errBack >+ ); >+ } >+ >+ // Trigger photo take >+ document.getElementById('snap').addEventListener('click', >+ function() { >+ context.drawImage(video, 0, 0, 640, 480); >+ var save_button = document.getElementById('save'); >+ save_button.click(); >+ } >+ ); >+ >+ // Save photo taken >+ document.getElementById('save').addEventListener('click', >+ function() { >+ var download_anchor = document.getElementById('download'); >+ download_anchor.href = canvas.toDataURL('image/jpeg'); >+ download_anchor.download = "SamplePhoto.jpg"; >+ download_anchor.click(); >+ } >+ ); >+ }, >+ false >+ ); >+ >+ </script> >+ </body> >+</html> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 19e573752d..bc4bfe2e01 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -320,6 +320,10 @@ > <a href="#" id="cancel-picture-upload" class="cancel">Cancel</a> > </div> > </form> >+ <div class="patroninfo-heading"> >+ <h3>Take patron image</h3> >+ <a class="btn btn-default btn-xs" id="trigger-webcam" href="/cgi-bin/koha/members/webcam.pl" target="_blank"><i class="fa fa-camera"></i> Take</a> >+ </div> > </div> [% # /div#manage-patron-image %] > [% END %] > [% END %] >diff --git a/members/webcam.pl b/members/webcam.pl >new file mode 100755 >index 0000000000..afc52b2a49 >--- /dev/null >+++ b/members/webcam.pl >@@ -0,0 +1,37 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2019 Mark Tompsett >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI qw ( -utf8 ); >+use C4::Auth; >+use C4::Output; >+ >+my $input = new CGI; >+ >+my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( >+ { template_name => "members/member-webcam.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { borrowers => 'edit_borrowers' }, >+ } >+); >+ >+output_html_with_http_headers( $input, $cookie, $template->output ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6815
:
22623
|
29613
|
38518
|
91302
|
91303
|
91335
|
99015
|
99016
|
99757
|
106774
|
106775
|
106776
|
106777
|
106782
|
106783
|
106787
|
106788
|
106789
|
106790
|
106791
|
106792
|
106793
|
106794
|
106795
|
106796
|
106797
|
106798
|
106799
|
106800
|
106801
|
106802
|
106803
|
106804
|
106938
|
106939
|
106940
|
131174
|
131554
|
131985
|
131987
|
131988
|
131999
|
132000
|
132001