* Display app version.
* Fix: FPrint enroll start/stop toggle.
This commit is contained in:
@@ -5,7 +5,8 @@ import base64
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
gi.require_version("FPrint", "2.0")
|
gi.require_version("FPrint", "2.0")
|
||||||
gi.require_version("Gio", "2.0")
|
gi.require_version("Gio", "2.0")
|
||||||
@@ -46,7 +47,10 @@ def progress(device, completed_stages, prnt, sessionId, error):
|
|||||||
else:
|
else:
|
||||||
print('Completed with an error.')
|
print('Completed with an error.')
|
||||||
|
|
||||||
def enroll(sessionId, data):
|
enroll_canceller = None;
|
||||||
|
def enroll_start(sessionId, data):
|
||||||
|
global enroll_canceller;
|
||||||
|
|
||||||
ctx = FPrint.Context()
|
ctx = FPrint.Context()
|
||||||
devices = ctx.get_devices()
|
devices = ctx.get_devices()
|
||||||
if (len(devices) == 0):
|
if (len(devices) == 0):
|
||||||
@@ -64,14 +68,20 @@ def enroll(sessionId, data):
|
|||||||
print('Opening...')
|
print('Opening...')
|
||||||
try:
|
try:
|
||||||
prt = FPrint.Print.new(device)
|
prt = FPrint.Print.new(device)
|
||||||
prt = device.enroll_sync(prt, None, progress_cb=progress, progress_data=sessionId)
|
enroll_canceller = Gio.Cancellable.new();
|
||||||
|
prt = device.enroll_sync(prt, enroll_canceller, progress_cb=progress, progress_data=sessionId)
|
||||||
img = prt.serialize()
|
img = prt.serialize()
|
||||||
sio.emit('fprint-enroll-done', { 'ok': True, "fingerprint": base64.b64encode(img).decode('utf-8'), 'id': str(uuid.uuid4()), 'data': data })
|
sio.emit('fprint-enroll-done', { 'ok': True, "fingerprint": base64.b64encode(img).decode('utf-8'), 'id': str(uuid.uuid4()), 'data': data })
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print({'error': e});
|
print({'error': e});
|
||||||
sio.emit('fprint-enroll-done', { 'ok': False, 'message': e})
|
sio.emit('fprint-enroll-done', { 'ok': False, 'message': e.message})
|
||||||
finally:
|
finally:
|
||||||
device.close_sync()
|
try:
|
||||||
|
device.close_sync()
|
||||||
|
except:
|
||||||
|
print('An error occured while closing device.');
|
||||||
|
finally:
|
||||||
|
print('It appears device has already been removed.')
|
||||||
|
|
||||||
is_verify_active = False
|
is_verify_active = False
|
||||||
device = None;
|
device = None;
|
||||||
@@ -208,6 +218,14 @@ def stop_fprint_identify():
|
|||||||
|
|
||||||
sio.emit("fprint-identify-stop-done", { 'ok': True, 'message': 'Identification stopped.' })
|
sio.emit("fprint-identify-stop-done", { 'ok': True, 'message': 'Identification stopped.' })
|
||||||
is_identify_active = False;
|
is_identify_active = False;
|
||||||
|
|
||||||
|
def stop_fprint_enroll():
|
||||||
|
global enroll_canceller;
|
||||||
|
|
||||||
|
if enroll_canceller:
|
||||||
|
enroll_canceller.cancel()
|
||||||
|
|
||||||
|
sio.emit("fprint-enroll-done", { 'ok': False, 'message': 'Enrollment stopped.' })
|
||||||
|
|
||||||
@sio.on("fprint-identify-start")
|
@sio.on("fprint-identify-start")
|
||||||
def fprint_identify_start(sid, data):
|
def fprint_identify_start(sid, data):
|
||||||
@@ -218,11 +236,15 @@ def fprint_identify_stop(sid, data):
|
|||||||
stop_fprint_identify()
|
stop_fprint_identify()
|
||||||
|
|
||||||
@sio.on("fprint-enroll")
|
@sio.on("fprint-enroll")
|
||||||
def fprint_enroll(sid, data):
|
def fprint_enroll_start(sid, data):
|
||||||
print('Enrolling {}'.format(data['finger']))
|
print('Enrolling {}'.format(data['finger']))
|
||||||
enroll(sid, data)
|
enroll_start(sid, data)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@sio.on("fprint-enroll-stop")
|
||||||
|
def fprint_enroll_stop(sid, data):
|
||||||
|
stop_fprint_enroll()
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def capture(sid, data):
|
def capture(sid, data):
|
||||||
print(data)
|
print(data)
|
||||||
@@ -231,6 +253,7 @@ def capture(sid, data):
|
|||||||
@sio.event
|
@sio.event
|
||||||
def connect(sid, data):
|
def connect(sid, data):
|
||||||
global config;
|
global config;
|
||||||
|
config['version'] = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
|
||||||
if config['mode'] == 'clockio':
|
if config['mode'] == 'clockio':
|
||||||
global raw_prints;
|
global raw_prints;
|
||||||
stop_fprint_identify();
|
stop_fprint_identify();
|
||||||
@@ -241,7 +264,6 @@ def connect(sid, data):
|
|||||||
if responseJson['ok']:
|
if responseJson['ok']:
|
||||||
config['departments'] = responseJson['data'];
|
config['departments'] = responseJson['data'];
|
||||||
domain_fprint_file = '{}/fprint-sync/.{}-fprint-data.json'.format(os.getenv("HOME"), domain_code);
|
domain_fprint_file = '{}/fprint-sync/.{}-fprint-data.json'.format(os.getenv("HOME"), domain_code);
|
||||||
print(domain_fprint_file);
|
|
||||||
if os.path.exists(domain_fprint_file):
|
if os.path.exists(domain_fprint_file):
|
||||||
with open(domain_fprint_file) as f:
|
with open(domain_fprint_file) as f:
|
||||||
records = json.loads(f.read());
|
records = json.loads(f.read());
|
||||||
@@ -254,6 +276,8 @@ def connect(sid, data):
|
|||||||
'length': len(records['profiles']),
|
'length': len(records['profiles']),
|
||||||
'timestamp': records['timestamp']
|
'timestamp': records['timestamp']
|
||||||
};
|
};
|
||||||
|
else:
|
||||||
|
stop_fprint_enroll();
|
||||||
|
|
||||||
sio.emit('config', config);
|
sio.emit('config', config);
|
||||||
pass
|
pass
|
||||||
|
|||||||
+12
-11
@@ -6,9 +6,11 @@ var app = new Vue({
|
|||||||
phone: '',
|
phone: '',
|
||||||
domain: { code: 'uc', name: 'UNICAL' },
|
domain: { code: 'uc', name: 'UNICAL' },
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
|
version: '',
|
||||||
otp: '',
|
otp: '',
|
||||||
busy: {
|
busy: {
|
||||||
login: false
|
login: false,
|
||||||
|
capture: false,
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
phone: '',
|
phone: '',
|
||||||
@@ -37,12 +39,13 @@ var app = new Vue({
|
|||||||
|
|
||||||
this.socket.on("config", (data) => {
|
this.socket.on("config", (data) => {
|
||||||
this.domain = data.domain;
|
this.domain = data.domain;
|
||||||
|
this.version = data.version;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on("fprint-enroll-error", (data) => {
|
this.socket.on("fprint-enroll-error", (data) => {
|
||||||
console.log({ event: 'enroll-error', data });
|
console.log({ event: 'enroll-error', data });
|
||||||
swal("Oops!", `Operation failed. ${data}.`, "error");
|
swal("Oops!", `Operation failed. ${data}.`, "error");
|
||||||
this.busy.login = false;
|
this.busy.capture = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on("fprint-enroll-done", (data) => {
|
this.socket.on("fprint-enroll-done", (data) => {
|
||||||
@@ -52,8 +55,8 @@ var app = new Vue({
|
|||||||
this.step = 1.2;
|
this.step = 1.2;
|
||||||
this.fingerDetails[finger] = { id, fingerprint, finger }
|
this.fingerDetails[finger] = { id, fingerprint, finger }
|
||||||
}
|
}
|
||||||
this.busy.login = false;
|
this.busy.capture = false;
|
||||||
})
|
});
|
||||||
|
|
||||||
this.socket.on("fprint-verify-done", (data) => {
|
this.socket.on("fprint-verify-done", (data) => {
|
||||||
console.log({ event: 'verify-done', data});
|
console.log({ event: 'verify-done', data});
|
||||||
@@ -100,16 +103,13 @@ var app = new Vue({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
captureFingerPrint: async function (finger) {
|
captureFingerPrint: async function (finger) {
|
||||||
this.busy.login = true;
|
this.busy.capture = true;
|
||||||
this.step = 1.1;
|
this.step = 1.1;
|
||||||
// var { data: { success, message: { id, data, fingerprint } } } = await axios.post("http://localhost:9000/api/user", {
|
|
||||||
// name: this.staff.reference
|
|
||||||
// });
|
|
||||||
// this.fingerDetails = { id, fingerprint };
|
|
||||||
// var { data } = await axios.delete(`http://localhost:9000/api/user/${id}`);
|
|
||||||
// console.log(`${id} purged.`);
|
|
||||||
this.socket.emit("fprint-enroll", { finger });
|
this.socket.emit("fprint-enroll", { finger });
|
||||||
},
|
},
|
||||||
|
cancelCapture: async function () {
|
||||||
|
this.socket.emit("fprint-enroll-stop", { });
|
||||||
|
},
|
||||||
saveFingerPrint: async function () {
|
saveFingerPrint: async function () {
|
||||||
this.busy.login = true;
|
this.busy.login = true;
|
||||||
try {
|
try {
|
||||||
@@ -143,6 +143,7 @@ var app = new Vue({
|
|||||||
newEnrolment: function () {
|
newEnrolment: function () {
|
||||||
this.step = 1.0;
|
this.step = 1.0;
|
||||||
this.busy.login = false;
|
this.busy.login = false;
|
||||||
|
this.busy.capture = false;
|
||||||
this.staff.reference = "";
|
this.staff.reference = "";
|
||||||
this.fingerDetails = {
|
this.fingerDetails = {
|
||||||
'right-thumb': { },
|
'right-thumb': { },
|
||||||
|
|||||||
+12
-10
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<h1>
|
<h1>
|
||||||
{{domain.name}} Biometrics Enrolment Wizard
|
{{domain.name}} Biometrics Enrolment Wizard <span style="color: gainsboro">#{{version}}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<div v-if="step > 0" style="text-align: right">
|
<div v-if="step > 0" style="text-align: right">
|
||||||
@@ -114,16 +114,17 @@
|
|||||||
<label>Enrolment ID</label>
|
<label>Enrolment ID</label>
|
||||||
<input type="text" readonly v-model="fingerDetails['right-thumb'].id" class="form-control" />
|
<input type="text" readonly v-model="fingerDetails['right-thumb'].id" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
<div class="btn btn-success" style="display: inline" v-if="!fingerDetails['right-thumb'].id" v-bind:class="{ disabledbutton: busy.login }"
|
<div class="btn btn-success" style="display: inline" v-if="!fingerDetails['right-thumb'].id" v-bind:class="{ disabledbutton: busy.capture }"
|
||||||
v-on:click="() => { captureFingerPrint('right-thumb') }">
|
v-on:click="() => { captureFingerPrint('right-thumb') }">
|
||||||
<span v-if="!busy.login">Capture Fingerprint</span>
|
<span v-if="!busy.capture">Capture Fingerprint</span>
|
||||||
<span v-else>Please wait...</span>
|
<span v-else>Please wait...</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn btn-warning" style="display: inline" v-if="fingerDetails['right-thumb'].id" v-bind:class="{ disabledbutton: busy.login }"
|
<div class="btn btn-warning" style="display: inline" v-if="fingerDetails['right-thumb'].id" v-bind:class="{ disabledbutton: busy.capture }"
|
||||||
v-on:click="() => { captureFingerPrint('right-thumb') }">
|
v-on:click="() => { captureFingerPrint('right-thumb') }">
|
||||||
<span v-if="!busy.login">Recapture Fingerprint</span>
|
<span v-if="!busy.capture">Recapture Fingerprint</span>
|
||||||
<span v-else>Please wait...</span>
|
<span v-else>Please wait...</span>
|
||||||
</div>
|
</div>
|
||||||
|
<span style="cursor:pointer;" @click="cancelCapture" v-if="busy.capture"> Cancel</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -134,16 +135,17 @@
|
|||||||
<label>Enrolment ID</label>
|
<label>Enrolment ID</label>
|
||||||
<input type="text" readonly v-model="fingerDetails['right-index-finger'].id" class="form-control" />
|
<input type="text" readonly v-model="fingerDetails['right-index-finger'].id" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
<div class="btn btn-success" style="display: inline" v-if="!fingerDetails['right-index-finger'].id" v-bind:class="{ disabledbutton: busy.login }"
|
<div class="btn btn-success" style="display: inline" v-if="!fingerDetails['right-index-finger'].id" v-bind:class="{ disabledbutton: busy.capture }"
|
||||||
v-on:click="() => { captureFingerPrint('right-index-finger') }">
|
v-on:click="() => { captureFingerPrint('right-index-finger') }">
|
||||||
<span v-if="!busy.login">Capture Fingerprint</span>
|
<span v-if="!busy.capture">Capture Fingerprint</span>
|
||||||
<span v-else>Please wait...</span>
|
<span v-else>Please wait...</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn btn-warning" style="display: inline" v-if="fingerDetails['right-index-finger'].id" v-bind:class="{ disabledbutton: busy.login }"
|
<div class="btn btn-warning" style="display: inline" v-if="fingerDetails['right-index-finger'].id" v-bind:class="{ disabledbutton: busy.capture }"
|
||||||
v-on:click="() => { captureFingerPrint('right-index-finger') }">
|
v-on:click="() => { captureFingerPrint('right-index-finger') }">
|
||||||
<span v-if="!busy.login">Recapture Fingerprint</span>
|
<span v-if="!busy.capture">Recapture Fingerprint</span>
|
||||||
<span v-else>Please wait...</span>
|
<span v-else>Please wait...</span>
|
||||||
</div>
|
</div>
|
||||||
|
<span style="cursor:pointer;" @click="cancelCapture" v-if="busy.capture"> Cancel</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Your profile has <span style="color: red; font-weight: bold;" v-if="!staff.verified">NOT </span>been verified. -->
|
<!-- Your profile has <span style="color: red; font-weight: bold;" v-if="!staff.verified">NOT </span>been verified. -->
|
||||||
|
|||||||
Reference in New Issue
Block a user