shop: add crateless items and options #143
@ -16,6 +16,36 @@ const ipv6 = (params) => {
|
||||
}
|
||||
}
|
||||
|
||||
const hostname = (params) => {
|
||||
const maxHostnameLength = 253;
|
||||
const maxLabelLength = 63;
|
||||
const labelRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
|
||||
|
||||
return (text) => {
|
||||
if (text.length > maxHostnameLength) {
|
||||
return false;
|
||||
}
|
||||
const labels = text.split('.');
|
||||
for (const label of labels) {
|
||||
if (label.length < 1 || label.length > maxLabelLength) {
|
||||
return false;
|
||||
}
|
||||
if (!labelRegex.test(label)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const ipv4OrHost = (params) => {
|
||||
const hostnameLocal = hostname(params);
|
||||
const ipv4Local = ipv4(params);
|
||||
return (text) => {
|
||||
return ipv4Local(text) || hostnameLocal(text);
|
||||
}
|
||||
}
|
||||
|
||||
const ipv4or6 = (params) => {
|
||||
const ipv4Local = ipv4(params);
|
||||
const ipv6Local = ipv6(params);
|
||||
@ -47,5 +77,7 @@ export const Validation = {
|
||||
ipv4: ipv4,
|
||||
ipv6: ipv6,
|
||||
ipv4or6: ipv4or6,
|
||||
hostname: hostname,
|
||||
ipv4OrHost: ipv4OrHost,
|
||||
frequency: frequency
|
||||
};
|
@ -1106,10 +1106,24 @@ const shop_data = {
|
||||
validator: {name: "ipv4or6"},
|
||||
fallback: {text: "DHCP", checked: false},
|
||||
tip: "Set up IP address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
{type: "Switch", args: {title: "Ext power", outvar: "ext_pwr", "tip": "Use external power supply in order to reduce number of used EEM connectors"}},
|
||||
{type: "Switch", args: {title: "Term #0", outvar: "term_0", tip: "Enable termination on ADC channel #0"}},
|
||||
{type: "Switch", args: {title: "Term #1", outvar: "term_1", tip: "Enable termination on ADC channel #1"}}
|
||||
],
|
||||
crateless_options: [
|
||||
{type: "SwitchLine", args: {title: "IP", outvar: "ip",
|
||||
validator: {name: "ipv4or6"},
|
||||
fallback: {text: "DHCP", checked: false},
|
||||
tip: "Set up IP address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
],
|
||||
options_class: "stabilizer",
|
||||
size: 'small',
|
||||
warnings: [
|
||||
@ -1140,10 +1154,24 @@ const shop_data = {
|
||||
validator: {name: "ipv4or6"},
|
||||
fallback: {text: "DHCP", checked: false},
|
||||
tip: "Set up IP address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
{type: "Switch", args: {title: "Ext power", outvar: "ext_pwr", "tip": "Use external power supply in order to reduce number of used EEM connectors"}},
|
||||
{type: "Switch", args: {title: "Term #0", outvar: "term_0", tip: "Enable termination on ADC channel #0"}},
|
||||
{type: "Switch", args: {title: "Term #1", outvar: "term_1", tip: "Enable termination on ADC channel #1"}}
|
||||
],
|
||||
crateless_options: [
|
||||
{type: "SwitchLine", args: {title: "IP", outvar: "ip",
|
||||
validator: {name: "ipv4or6"},
|
||||
fallback: {text: "DHCP", checked: false},
|
||||
tip: "Set up IP address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
],
|
||||
options_class: "stabilizer",
|
||||
size: 'small',
|
||||
warnings: [
|
||||
@ -1229,7 +1257,25 @@ const shop_data = {
|
||||
'100Base-T Ethernet with PoE.'
|
||||
],
|
||||
options: [
|
||||
{type: "Switch", args: {title: "Ext power", outvar: "ext_pwr", "tip": "Use external power supply in order to reduce number of used EEM connectors"}}
|
||||
{type: "Switch", args: {title: "Ext power", outvar: "ext_pwr", "tip": "Use external power supply in order to reduce number of used EEM connectors"}},
|
||||
{type: "SwitchLine", args: {title: "Static IPv4", outvar: "ip",
|
||||
validator: {name: "ipv4"},
|
||||
fallback: {text: "0.0.0.0", checked: false},
|
||||
tip: "Set up static IPv4 address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
],
|
||||
crateless_options: [
|
||||
{type: "SwitchLine", args: {title: "Static IPv4", outvar: "ip",
|
||||
validator: {name: "ipv4"},
|
||||
fallback: {text: "0.0.0.0", checked: false},
|
||||
tip: "Set up static IPv4 address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
],
|
||||
size: 'small',
|
||||
warnings: [
|
||||
@ -1254,6 +1300,12 @@ const shop_data = {
|
||||
'100Base-T Ethernet with PoE.',
|
||||
'Can stabilize temperature of Sinara 5432 DAC or external devices containing TEC and thermistor.'
|
||||
],
|
||||
crateless_options: [
|
||||
{type: "SwitchLine", args: {title: "IPv4", outvar: "ip",
|
||||
validator: {name: "ipv4"},
|
||||
fallback: {text: "192.168.1.26/24", checked: false},
|
||||
tip: "Set up IP address used by the device"}},
|
||||
],
|
||||
size: 'small',
|
||||
consumes: {
|
||||
hp: 4
|
||||
@ -1305,12 +1357,26 @@ const shop_data = {
|
||||
validator: {name: "ipv4or6"},
|
||||
fallback: {text: "DHCP", checked: false},
|
||||
tip: "Set up IP address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
{type: "Switch", args: {title: "Ext power", outvar: "ext_pwr", "tip": "Use external power supply in order to reduce number of used EEM connectors"}},
|
||||
{type: "SwitchLine", args: {title: "Ext CLK", outvar: "ext_clk",
|
||||
fallback: {text: "125 MHz", checked: false}, validator: {name: "frequency", params: {min: 10e6, max: 1e9}}}},
|
||||
{type: "Switch", args: {title: "Termination #0", outvar: "term_0", tip: "Enable termination on ADC channel #0"}},
|
||||
{type: "Switch", args: {title: "Termination #1", outvar: "term_1", tip: "Enable termination on ADC channel #1"}}
|
||||
],
|
||||
crateless_options: [
|
||||
{type: "SwitchLine", args: {title: "Static IPv4", outvar: "ip",
|
||||
validator: {name: "ipv4"},
|
||||
fallback: {text: "0.0.0.0", checked: false},
|
||||
tip: "Set up static IPv4 address used by the device"}},
|
||||
{type: "SwitchLine", args: {title: "MQTT broker address", outvar: "broker",
|
||||
validator: {name: "ipv4OrHost"},
|
||||
fallback: {text: "mqtt", checked: false},
|
||||
tip: "Set up domain name or IPv4 of the MQTT broker"}},
|
||||
],
|
||||
size: 'big',
|
||||
warnings: [
|
||||
"no_eem_source",
|
||||
|
Loading…
Reference in New Issue
Block a user