feat(fpagent): show scanner availability and gate capture
Consume fpagent's fprint-device-status {available, device, captureAgentId}
in the /fingerprint wizard. Availability is tracked tri-state so an agent
that does not report it leaves capture working as before; the header tag
shows offline / no-scanner / ready, the capture panel warns, and capture is
disabled until a supported reader is attached.
Adds a vm-sandbox test for the wizard logic and the OpenSpec change
fpagent-device-availability, archived with the fingerprint-wizard spec.
This commit is contained in:
@@ -20,7 +20,9 @@ Vue.config.ignoredElements = [/^cds-/];
|
||||
session: null,
|
||||
tick: Date.now(),
|
||||
socket: null,
|
||||
agent: { connected: false, version: '', captureAgentId: '' },
|
||||
// available is tri-state: null = not yet reported (old agent), true/false
|
||||
// = the last fprint-device-status. Unknown is not blocked.
|
||||
agent: { connected: false, version: '', captureAgentId: '', available: null, device: '' },
|
||||
domain: '',
|
||||
reference: '',
|
||||
otpLookup: '',
|
||||
@@ -68,6 +70,27 @@ Vue.config.ignoredElements = [/^cds-/];
|
||||
if (!this.session || !this.session.domainsCheckedAt) return '';
|
||||
return new Date(this.session.domainsCheckedAt).toLocaleTimeString();
|
||||
},
|
||||
// Warning shown in the capture panel when the agent cannot capture.
|
||||
scannerNotice: function () {
|
||||
if (!this.agent.connected) {
|
||||
return {
|
||||
title: 'Capture agent offline',
|
||||
subtitle: 'The fpagent service is not reachable on this machine. Captures are disabled until it reconnects.',
|
||||
};
|
||||
}
|
||||
if (this.agent.available === false) {
|
||||
return {
|
||||
title: 'Scanner not connected',
|
||||
subtitle: 'Attach the fingerprint reader. Captures are disabled until the agent detects it.',
|
||||
};
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Capture is allowed when the agent is connected and no status has said
|
||||
// the scanner is missing. Unknown availability (old agent) stays allowed.
|
||||
captureReady: function () {
|
||||
return this.agent.connected && this.agent.available !== false;
|
||||
},
|
||||
},
|
||||
|
||||
created: function () {
|
||||
@@ -139,18 +162,38 @@ Vue.config.ignoredElements = [/^cds-/];
|
||||
renderAgentTag: function () {
|
||||
var el = document.getElementById('agent-status');
|
||||
if (!el) return;
|
||||
el.textContent = this.agent.connected ? 'Agent connected' : 'Agent offline';
|
||||
el.setAttribute('type', this.agent.connected ? 'green' : 'red');
|
||||
el.setAttribute('title', this.agent.version ? 'fpagent ' + this.agent.version : '');
|
||||
var label, type, title = this.agent.version ? 'fpagent ' + this.agent.version : '';
|
||||
if (!this.agent.connected) {
|
||||
label = 'Agent offline'; type = 'red';
|
||||
} else if (this.agent.available === false) {
|
||||
label = 'Scanner not connected'; type = 'red';
|
||||
} else if (this.agent.available === true) {
|
||||
label = 'Agent ready'; type = 'green';
|
||||
} else {
|
||||
// Connected but no status yet (or an agent that does not report it).
|
||||
label = 'Agent connected'; type = 'green';
|
||||
}
|
||||
if (this.agent.available === true && this.agent.device) {
|
||||
title += ' · ' + this.agent.device;
|
||||
}
|
||||
el.textContent = label;
|
||||
el.setAttribute('type', type);
|
||||
el.setAttribute('title', title);
|
||||
},
|
||||
|
||||
connectAgent: function () {
|
||||
var self = this;
|
||||
this.socket = io(this.session.agentUrl, { reconnectionDelayMax: 5000 });
|
||||
|
||||
var offline = function () {
|
||||
self.agent.connected = false;
|
||||
self.agent.available = null;
|
||||
self.agent.device = '';
|
||||
self.renderAgentTag();
|
||||
};
|
||||
this.socket.on('connect', function () { self.agent.connected = true; self.renderAgentTag(); });
|
||||
this.socket.on('disconnect', function () { self.agent.connected = false; self.renderAgentTag(); });
|
||||
this.socket.on('connect_error', function () { self.agent.connected = false; self.renderAgentTag(); });
|
||||
this.socket.on('disconnect', offline);
|
||||
this.socket.on('connect_error', offline);
|
||||
|
||||
this.socket.on('agent-hello', function (data) {
|
||||
self.agent.version = (data && data.version) || '';
|
||||
@@ -158,6 +201,12 @@ Vue.config.ignoredElements = [/^cds-/];
|
||||
self.renderAgentTag();
|
||||
});
|
||||
|
||||
this.socket.on('fprint-device-status', function (data) {
|
||||
self.agent.available = !!(data && data.available);
|
||||
self.agent.device = (data && data.device) || '';
|
||||
self.renderAgentTag();
|
||||
});
|
||||
|
||||
this.socket.on('fprint-enroll-status', function (data) {
|
||||
if (!self.capturing) return;
|
||||
self.fingers[self.capturing].stage = (data && data.stage) || 0;
|
||||
@@ -213,6 +262,11 @@ Vue.config.ignoredElements = [/^cds-/];
|
||||
|
||||
capture: function (finger) {
|
||||
if (this.capturing || !this.socket || !this.domain || !this.reference) return;
|
||||
if (!this.captureReady) {
|
||||
var notice = this.scannerNotice;
|
||||
if (notice) this.showNotif('warning', notice.title, notice.subtitle);
|
||||
return;
|
||||
}
|
||||
// Preserve a previous good capture so a cancelled/failed recapture
|
||||
// can restore it instead of destroying it.
|
||||
var old = this.fingers[finger];
|
||||
|
||||
@@ -84,6 +84,10 @@
|
||||
<span class="hint">Two fingers are required · place the finger on the scanner each scan</span>
|
||||
</div>
|
||||
|
||||
<cds-inline-notification v-if="scannerNotice" kind="warning" hide-close-button class="mt-1"
|
||||
v-bind:title="scannerNotice.title" v-bind:subtitle="scannerNotice.subtitle">
|
||||
</cds-inline-notification>
|
||||
|
||||
<dl class="details">
|
||||
<div><dt>Name</dt><dd>{{ staff.name }}</dd></div>
|
||||
<div><dt>Reference</dt><dd>{{ staff.reference }}</dd></div>
|
||||
@@ -107,11 +111,11 @@
|
||||
<p class="meta" v-if="fingers[finger].status === 'failed'">The last attempt failed. You can try again.</p>
|
||||
|
||||
<div class="row-gap mt-1">
|
||||
<cds-button v-if="fingers[finger].status !== 'done'" v-bind:disabled="capturing !== null" v-on:click="capture(finger)">
|
||||
<cds-button v-if="fingers[finger].status !== 'done'" v-bind:disabled="capturing !== null || !captureReady" v-on:click="capture(finger)">
|
||||
<svg slot="icon" width="16" height="16" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M7,5.21a.77.77,0,0,1-.46-1.38A15.46,15.46,0,0,1,16,1c2.66,0,6.48.45,9.5,2.62a.77.77,0,0,1,.18,1.07.78.78,0,0,1-1.08.17A15,15,0,0,0,16,2.53,14,14,0,0,0,7.5,5.05.74.74,0,0,1,7,5.21Z"/><path d="M28.23,12.26a.78.78,0,0,1-.63-.33C25.87,9.49,22.78,6.24,16,6.24a14,14,0,0,0-11.63,5.7.77.77,0,0,1-1.07.17A.76.76,0,0,1,3.15,11,15.54,15.54,0,0,1,16,4.71c5.61,0,9.81,2.08,12.84,6.34a.77.77,0,0,1-.19,1.07A.79.79,0,0,1,28.23,12.26Z"/><path d="M12.28,31a.78.78,0,0,1-.72-.49.75.75,0,0,1,.44-1c4.37-1.68,7-5.12,7-9.21a2.8,2.8,0,0,0-3-3c-1.86,0-2.76,1-3,3.35a4.27,4.27,0,0,1-4.52,3.83,4.27,4.27,0,0,1-4.32-4.59A11.71,11.71,0,0,1,16,8.39a12,12,0,0,1,12,11.93,18.66,18.66,0,0,1-1.39,6.5.78.78,0,0,1-1,.41.76.76,0,0,1-.41-1,17.25,17.25,0,0,0,1.27-5.91A10.45,10.45,0,0,0,16,9.92a10.18,10.18,0,0,0-10.38,10,2.77,2.77,0,0,0,2.79,3.06,2.74,2.74,0,0,0,3-2.48c.36-3.11,1.89-4.69,4.56-4.69a4.31,4.31,0,0,1,4.52,4.56c0,4.74-3,8.72-8,10.63A.92.92,0,0,1,12.28,31Z"/><path d="M19.77,30.28a.81.81,0,0,1-.52-.2.76.76,0,0,1,0-1.08,12.63,12.63,0,0,0,3.54-8.68c0-1.56-.48-6.65-6.7-6.65a6.83,6.83,0,0,0-4.94,1.87A6.17,6.17,0,0,0,9.32,20a.77.77,0,0,1-.77.76h0A.76.76,0,0,1,7.78,20,7.73,7.73,0,0,1,10,14.46a8.34,8.34,0,0,1,6-2.32c6.08,0,8.24,4.4,8.24,8.18A14.09,14.09,0,0,1,20.34,30,.75.75,0,0,1,19.77,30.28Z"/><path d="M8.66,27.74a14.14,14.14,0,0,1-1.56-.09.76.76,0,1,1,.17-1.52c2.49.28,4.45-.16,5.84-1.32a6.37,6.37,0,0,0,2.12-4.53.75.75,0,0,1,.82-.71.78.78,0,0,1,.72.81A7.89,7.89,0,0,1,14.09,26,8.2,8.2,0,0,1,8.66,27.74Z"/></svg>
|
||||
{{ fingers[finger].status === 'failed' ? 'Retry capture' : 'Capture fingerprint' }}
|
||||
</cds-button>
|
||||
<cds-button kind="secondary" v-if="fingers[finger].status === 'done'" v-bind:disabled="capturing !== null" v-on:click="capture(finger)">
|
||||
<cds-button kind="secondary" v-if="fingers[finger].status === 'done'" v-bind:disabled="capturing !== null || !captureReady" v-on:click="capture(finger)">
|
||||
<svg slot="icon" width="16" height="16" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M12 10H6.78A11 11 0 0127 16h2A13 13 0 006 7.68V4H4v8h8zM20 22h5.22A11 11 0 015 16H3a13 13 0 0023 8.32V28h2V20H20z"/></svg>
|
||||
Recapture
|
||||
</cds-button>
|
||||
|
||||
Reference in New Issue
Block a user