Simplified defaults data for maintainability
This commit is contained in:
@@ -5,10 +5,11 @@
|
|||||||
"repository": "https://github.com/OneFinityCNC/onefinity",
|
"repository": "https://github.com/OneFinityCNC/onefinity",
|
||||||
"license": "GPL-3.0+",
|
"license": "GPL-3.0+",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jshint": "",
|
|
||||||
"browserify": "",
|
"browserify": "",
|
||||||
"jstransformer-stylus": "",
|
"jshint": "",
|
||||||
"jstransformer-escape-html": "",
|
"jstransformer-escape-html": "",
|
||||||
|
"jstransformer-stylus": "",
|
||||||
|
"lodash.merge": "4.6.2",
|
||||||
"pug-cli": ""
|
"pug-cli": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,14 +27,19 @@
|
|||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const merge = require("lodash.merge");
|
||||||
|
|
||||||
|
const config_defaults = require("../resources/onefinity_defaults.json");
|
||||||
|
|
||||||
|
const variant_defaults = {
|
||||||
|
machinist_x35: require("../resources/onefinity_machinist_x35_defaults.json"),
|
||||||
|
woodworker_x35: require("../resources/onefinity_woodworker_x35_defaults.json"),
|
||||||
|
woodworker_x50: require("../resources/onefinity_woodworker_x50_defaults.json"),
|
||||||
|
journeyman_x50: require("../resources/onefinity_journeyman_x50_defaults.json")
|
||||||
|
};
|
||||||
|
|
||||||
const api = require('./api');
|
const api = require('./api');
|
||||||
|
|
||||||
async function fetchJSON(url, options) {
|
|
||||||
const response = await fetch(url, options);
|
|
||||||
|
|
||||||
return response.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
template: '#admin-general-view-template',
|
template: '#admin-general-view-template',
|
||||||
props: ['config', 'state'],
|
props: ['config', 'state'],
|
||||||
@@ -99,17 +104,11 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset: async function () {
|
reset: async function () {
|
||||||
const fetchConfig = async () => {
|
const config = merge(
|
||||||
try {
|
{},
|
||||||
return await fetchJSON(`/api/config/${this.reset_variant}`);
|
config_defaults,
|
||||||
} catch (err) {
|
variant_defaults[this.reset_variant]
|
||||||
api.alert("Invalid default config file");
|
);
|
||||||
console.error('Invalid default config file', err);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = await fetchConfig();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.put('config/save', config)
|
await api.put('config/save', config)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import subprocess
|
|||||||
import socket
|
import socket
|
||||||
from tornado.web import HTTPError
|
from tornado.web import HTTPError
|
||||||
from tornado import gen
|
from tornado import gen
|
||||||
from pkg_resources import Requirement, resource_filename
|
|
||||||
|
|
||||||
import bbctrl
|
import bbctrl
|
||||||
|
|
||||||
@@ -225,13 +224,6 @@ class PasswordHandler(bbctrl.APIHandler):
|
|||||||
raise HTTPError(401, 'Failed to set password')
|
raise HTTPError(401, 'Failed to set password')
|
||||||
|
|
||||||
|
|
||||||
class ConfigDefaultsHandler(bbctrl.APIHandler):
|
|
||||||
def get(self):
|
|
||||||
# defaults_path = bbctrl.get_resource("")
|
|
||||||
# defaults_path = resource_filename(Requirement.parse('bbctrl'), 'bbctrl/' + path)
|
|
||||||
# self.write_json(self.get_ctrl().config.load())
|
|
||||||
pass
|
|
||||||
|
|
||||||
class ConfigLoadHandler(bbctrl.APIHandler):
|
class ConfigLoadHandler(bbctrl.APIHandler):
|
||||||
def get(self): self.write_json(self.get_ctrl().config.load())
|
def get(self): self.write_json(self.get_ctrl().config.load())
|
||||||
|
|
||||||
@@ -529,7 +521,6 @@ class Web(tornado.web.Application):
|
|||||||
(r'/api/wifi', WifiHandler),
|
(r'/api/wifi', WifiHandler),
|
||||||
(r'/api/remote/username', UsernameHandler),
|
(r'/api/remote/username', UsernameHandler),
|
||||||
(r'/api/remote/password', PasswordHandler),
|
(r'/api/remote/password', PasswordHandler),
|
||||||
(r'/api/config/defaults/(.*)', ConfigDefaultsHandler),
|
|
||||||
(r'/api/config/load', ConfigLoadHandler),
|
(r'/api/config/load', ConfigLoadHandler),
|
||||||
(r'/api/config/download', ConfigDownloadHandler),
|
(r'/api/config/download', ConfigDownloadHandler),
|
||||||
(r'/api/config/save', ConfigSaveHandler),
|
(r'/api/config/save', ConfigSaveHandler),
|
||||||
|
|||||||
@@ -14,13 +14,14 @@
|
|||||||
"probe": "normally-open"
|
"probe": "normally-open"
|
||||||
},
|
},
|
||||||
"probe": {
|
"probe": {
|
||||||
|
"probe-diameter": 6.35,
|
||||||
"probe-ydim": 53.975,
|
"probe-ydim": 53.975,
|
||||||
"probe-slow-seek": 25,
|
"probe-slow-seek": 25,
|
||||||
"probe-fast-seek": 75,
|
"probe-fast-seek": 75,
|
||||||
"probe-zdim": 15.4,
|
"probe-zdim": 15.4,
|
||||||
"probe-xdim": 53.975
|
"probe-xdim": 53.975
|
||||||
},
|
},
|
||||||
"version": "1.0.4",
|
"version": "1.0.9",
|
||||||
"outputs": {
|
"outputs": {
|
||||||
"load-1": "disabled",
|
"load-1": "disabled",
|
||||||
"fault": "disabled",
|
"fault": "disabled",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"motors": [
|
"motors": [
|
||||||
{
|
{
|
||||||
"travel-per-rev": 16,
|
"travel-per-rev": 16,
|
||||||
|
|||||||
@@ -995,12 +995,12 @@ tt.save
|
|||||||
width 98%
|
width 98%
|
||||||
|
|
||||||
.reset-variants
|
.reset-variants
|
||||||
padding-left 40px
|
padding-left 40px
|
||||||
padding-bottom 20px
|
padding-bottom 20px
|
||||||
display grid
|
display grid
|
||||||
grid-template-rows repeat(4, auto)
|
grid-template-rows repeat(4, auto)
|
||||||
grid-template-columns min-content auto
|
grid-template-columns min-content auto
|
||||||
grid-gap 20px 10px
|
grid-gap 20px 10px
|
||||||
|
|
||||||
input[type="radio"]
|
input[type="radio"]
|
||||||
width 30px
|
width 30px
|
||||||
|
|||||||
Reference in New Issue
Block a user