* Upgrade service to integrate with new FPrint OS.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
import socketio
|
import socketio
|
||||||
import uuid
|
import uuid
|
||||||
@@ -19,11 +20,18 @@ config = {
|
|||||||
},
|
},
|
||||||
'mode': 'capture'
|
'mode': 'capture'
|
||||||
}
|
}
|
||||||
|
config_default = config;
|
||||||
|
|
||||||
|
os.chdir(os.path.dirname(__file__));
|
||||||
|
|
||||||
configFileExists = os.path.exists('.config.json');
|
configFileExists = os.path.exists('.config.json');
|
||||||
if configFileExists:
|
if configFileExists:
|
||||||
with open('.config.json') as reader:
|
with open('.config.json') as reader:
|
||||||
config = json.loads(reader.read());
|
try:
|
||||||
|
|
||||||
|
config = json.loads(reader.read());
|
||||||
|
except:
|
||||||
|
config = config_default
|
||||||
|
|
||||||
sio = socketio.Server(async_mode="threading")
|
sio = socketio.Server(async_mode="threading")
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -260,18 +268,26 @@ def connect(sid, data):
|
|||||||
config['started'] = is_identify_active
|
config['started'] = is_identify_active
|
||||||
domain_code = config['domain']['code'];
|
domain_code = config['domain']['code'];
|
||||||
response = requests.get("https://apis.a2loft.net/identity/{}/units".format(domain_code))
|
response = requests.get("https://apis.a2loft.net/identity/{}/units".format(domain_code))
|
||||||
responseJson = json.loads(response.text)
|
config['departments'] = [];
|
||||||
if responseJson['ok']:
|
if response.ok:
|
||||||
config['departments'] = responseJson['data'];
|
responseJson = json.loads(response.text)
|
||||||
|
if responseJson['ok']:
|
||||||
|
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);
|
||||||
|
config['records'] = {
|
||||||
|
'length': 0,
|
||||||
|
'timestamp': 0
|
||||||
|
};
|
||||||
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());
|
||||||
raw_prints = records['profiles'];
|
raw_prints = records['profiles'];
|
||||||
prints_dict = {};
|
prints_dict = {};
|
||||||
for profile in raw_prints:
|
for profile in raw_prints:
|
||||||
for fp in profile['fingerprints']:
|
for index, fp in enumerate(profile['fingerprints']):
|
||||||
prints_dict[fp] = profile
|
reference = profile['reference'];
|
||||||
|
finger = fp['finger']
|
||||||
|
prints_dict['{}-{}-{}'.format(reference, finger, index+1)] = profile
|
||||||
config['records'] = {
|
config['records'] = {
|
||||||
'length': len(records['profiles']),
|
'length': len(records['profiles']),
|
||||||
'timestamp': records['timestamp']
|
'timestamp': records['timestamp']
|
||||||
|
|||||||
+11
-7
@@ -2,7 +2,7 @@
|
|||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
domain: { },
|
domain: { name: '', code: '' },
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
staff: { reference: '' },
|
staff: { reference: '' },
|
||||||
department: '-',
|
department: '-',
|
||||||
@@ -23,12 +23,16 @@ var app = new Vue({
|
|||||||
this.socket.on("config", (data) => {
|
this.socket.on("config", (data) => {
|
||||||
let deptStr = localStorage.getItem("idid-departments");
|
let deptStr = localStorage.getItem("idid-departments");
|
||||||
if (deptStr) this.savedDepartments = JSON.parse(deptStr);
|
if (deptStr) this.savedDepartments = JSON.parse(deptStr);
|
||||||
data.departments.forEach(d => {
|
if (data.departments)
|
||||||
d.name = d.name.replace('*', '');
|
data.departments.forEach(d => {
|
||||||
d.checked = this.savedDepartments.includes(d.id);
|
d.name = d.name.replace('*', '');
|
||||||
return d;
|
d.checked = this.savedDepartments.includes(d.id);
|
||||||
});
|
return d;
|
||||||
this.domain = data;
|
});
|
||||||
|
else
|
||||||
|
data.departments = [];
|
||||||
|
|
||||||
|
this.domain = data.domain;
|
||||||
this.started = data.started;
|
this.started = data.started;
|
||||||
this.today = new Date().toDateString();
|
this.today = new Date().toDateString();
|
||||||
this.records = data.records;
|
this.records = data.records;
|
||||||
|
|||||||
Reference in New Issue
Block a user