new admin structure

This commit is contained in:
Josh Harvey 2017-05-09 00:37:38 +03:00
parent 7d82874916
commit c2282e61b4
17 changed files with 5768 additions and 1204 deletions

View file

@ -1,9 +1,8 @@
const _ = require('lodash/fp')
const db = require('./db')
const configManager = require('./config-manager')
const machines = require('./admin/machines')
const schema = require('../lamassu-schema.json')
const logger = require('./logger')
function allScopes (cryptoScopes, machineScopes) {
const scopes = []
@ -91,8 +90,16 @@ function getGroupField (group, fieldCode) {
return _.merge(_.pick(['cryptoScope', 'machineScope'], group), field)
}
const fetchMachines = () => machines.getMachines()
.then(machineList => machineList.map(r => r.deviceId))
// Note: We can't use machine-loader because it relies on settings-loader,
// which relies on this
function getMachines () {
return db.any('select device_id from devices')
}
function fetchMachines () {
return getMachines()
.then(machineList => machineList.map(r => r.device_id))
}
function validateFieldParameter (value, validator) {
switch (validator.code) {
@ -115,6 +122,8 @@ function ensureConstraints (config) {
config.every(fieldInstance => {
const fieldCode = fieldInstance.fieldLocator.code
const field = pickField(fieldCode)
if (!field) throw new Error('No such field: ' + fieldCode)
const fieldValue = fieldInstance.fieldValue
const isValid = field.fieldValidation