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