introduce a help button, show build command
This commit is contained in:
parent
80ab2224ce
commit
70345f0b79
|
@ -107,6 +107,7 @@ types:
|
||||||
type: select
|
type: select
|
||||||
key: m5groove
|
key: m5groove
|
||||||
label: 'M5 groove type'
|
label: 'M5 groove type'
|
||||||
|
help: 'Select the functionality that should be available at the M5 groove pins'
|
||||||
values:
|
values:
|
||||||
- key: 'CAN'
|
- key: 'CAN'
|
||||||
children:
|
children:
|
||||||
|
@ -120,6 +121,7 @@ types:
|
||||||
- &gpiopin
|
- &gpiopin
|
||||||
type: dropdown
|
type: dropdown
|
||||||
resource: "gpio:"
|
resource: "gpio:"
|
||||||
|
help: 'Select the number of the GPIO pin for this function'
|
||||||
values:
|
values:
|
||||||
- {label: unset,value:}
|
- {label: unset,value:}
|
||||||
- 0
|
- 0
|
||||||
|
@ -159,7 +161,18 @@ types:
|
||||||
- 38
|
- 38
|
||||||
- 39
|
- 39
|
||||||
|
|
||||||
|
- &serialRX
|
||||||
|
<<: *gpiopin
|
||||||
|
key: RX
|
||||||
|
help: 'number of the GPIO pin for the receive function'
|
||||||
|
target: "define:#serial#RX"
|
||||||
|
mandatory: true
|
||||||
|
- &serialTX
|
||||||
|
<<: *gpiopin
|
||||||
|
key: TX
|
||||||
|
help: 'number of the GPIO pin for the transmit function'
|
||||||
|
target: "define:#serial#TX"
|
||||||
|
mandatory: true
|
||||||
- &serialValues
|
- &serialValues
|
||||||
- key: true
|
- key: true
|
||||||
children:
|
children:
|
||||||
|
@ -172,46 +185,30 @@ types:
|
||||||
value: 1
|
value: 1
|
||||||
label: "UNI"
|
label: "UNI"
|
||||||
description: "Select direction at Config UI"
|
description: "Select direction at Config UI"
|
||||||
|
help: 'On the config UI you can select if the serial should be a transmitter or a receiver'
|
||||||
children:
|
children:
|
||||||
- <<: *gpiopin
|
- *serialRX
|
||||||
key: RX
|
- *serialTX
|
||||||
target: "define:#serial#RX"
|
|
||||||
mandatory: true
|
|
||||||
- <<: *gpiopin
|
|
||||||
key: TX
|
|
||||||
target: "define:#serial#TX"
|
|
||||||
mandatory: true
|
|
||||||
- key: bi
|
- key: bi
|
||||||
value: 2
|
value: 2
|
||||||
label: "BiDir"
|
label: "BiDir"
|
||||||
description: "Input and Output"
|
description: "Input and Output"
|
||||||
|
help: 'The serial device can run both receive and transmit. Typically for RS232.'
|
||||||
children:
|
children:
|
||||||
- <<: *gpiopin
|
- *serialRX
|
||||||
key: RX
|
- *serialTX
|
||||||
target: "define:#serial#RX"
|
|
||||||
mandatory: true
|
|
||||||
- <<: *gpiopin
|
|
||||||
key: TX
|
|
||||||
target: "define:#serial#TX"
|
|
||||||
mandatory: true
|
|
||||||
- key: rx
|
- key: rx
|
||||||
value: 3
|
value: 3
|
||||||
label: "RX"
|
label: "RX"
|
||||||
description: "Input only"
|
description: "Input only"
|
||||||
children:
|
children:
|
||||||
- <<: *gpiopin
|
- *serialRX
|
||||||
key: RX
|
|
||||||
target: "define:#serial#RX"
|
|
||||||
mandatory: true
|
|
||||||
- key: tx
|
- key: tx
|
||||||
value: 1
|
value: 1
|
||||||
label: "TX"
|
label: "TX"
|
||||||
description: "output only"
|
description: "output only"
|
||||||
children:
|
children:
|
||||||
- <<: *gpiopin
|
- *serialTX
|
||||||
key: TX
|
|
||||||
target: "define:#serial#TX"
|
|
||||||
mandatory: true
|
|
||||||
- &serial1
|
- &serial1
|
||||||
type: checkbox
|
type: checkbox
|
||||||
label: 'Serial 1'
|
label: 'Serial 1'
|
||||||
|
@ -230,7 +227,7 @@ types:
|
||||||
|
|
||||||
- &can
|
- &can
|
||||||
type: checkbox
|
type: checkbox
|
||||||
label: CAN
|
label: CAN(NMEA2000)
|
||||||
key: can
|
key: can
|
||||||
values:
|
values:
|
||||||
- key: true
|
- key: true
|
||||||
|
@ -239,11 +236,13 @@ types:
|
||||||
label: RX
|
label: RX
|
||||||
key: rx
|
key: rx
|
||||||
mandatory: true
|
mandatory: true
|
||||||
|
help: 'set the number of the GPIO pin for the CAN(NMEA2000) RX function'
|
||||||
target: "define:ESP32_CAN_RX_PIN"
|
target: "define:ESP32_CAN_RX_PIN"
|
||||||
- <<: *gpiopin
|
- <<: *gpiopin
|
||||||
label: TX
|
label: TX
|
||||||
key: tx
|
key: tx
|
||||||
mandatory: true
|
mandatory: true
|
||||||
|
help: 'set the number of the GPIO pin for the CAN(NMEA2000) TX function'
|
||||||
target: "define:ESP32_CAN_TX_PIN"
|
target: "define:ESP32_CAN_TX_PIN"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.configui .hidden{
|
.configui .hidden{
|
||||||
display: none;
|
display: none !important;
|
||||||
}
|
}
|
||||||
.configui .dialog{
|
.configui .dialog{
|
||||||
max-width: 35em;
|
max-width: 35em;
|
||||||
|
@ -106,6 +106,7 @@
|
||||||
.configui .radioFrame {
|
.configui .radioFrame {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
.configui input.radioCi {
|
.configui input.radioCi {
|
||||||
appearance: auto;
|
appearance: auto;
|
||||||
|
@ -152,6 +153,11 @@
|
||||||
width: 10em;
|
width: 10em;
|
||||||
font-weight: normal !important;
|
font-weight: normal !important;
|
||||||
}
|
}
|
||||||
|
.configui .titleFrame {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.configui form#upload {
|
.configui form#upload {
|
||||||
width: 0;
|
width: 0;
|
||||||
|
@ -166,3 +172,40 @@
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
width: initial;
|
width: initial;
|
||||||
}
|
}
|
||||||
|
.configui .overlayContainer {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: #80808070;
|
||||||
|
display: flex;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.configui .overlay {
|
||||||
|
margin: auto;
|
||||||
|
background-color: white;
|
||||||
|
padding: 0.5em;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.configui .overlayContent {
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
.configui div#overlayContent.text{
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
.configui .overlayButtons {
|
||||||
|
border-top: 1px solid grey;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
.configui button.help {
|
||||||
|
margin-left: 1em;
|
||||||
|
width: 2em;
|
||||||
|
height: 2em;
|
||||||
|
line-height: 1em;
|
||||||
|
}
|
|
@ -36,6 +36,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<span class="label">Build Flags</span>
|
<span class="label">Build Flags</span>
|
||||||
<div class="value" id="buildflags"></div>
|
<div class="value" id="buildflags"></div>
|
||||||
|
<button class="help" id="buildCommand">?</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row hidden error">
|
<div class="row hidden error">
|
||||||
<span class="label">Error</span>
|
<span class="label">Error</span>
|
||||||
|
@ -65,6 +66,16 @@
|
||||||
<button id="download">Download</button>
|
<button id="download">Download</button>
|
||||||
<button id="webinstall">Install</button>
|
<button id="webinstall">Install</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="overlayContainer hidden" id="overlayContainer">
|
||||||
|
<div id="overlay" class="overlay">
|
||||||
|
<div id="overlayContent" class="overlayContent">
|
||||||
|
AHA
|
||||||
|
</div>
|
||||||
|
<div class="overlayButtons">
|
||||||
|
<button id="hideOverlay">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<iframe id="dlframe" width="1" height="1"></iframe>
|
<iframe id="dlframe" width="1" height="1"></iframe>
|
||||||
<form id="upload">
|
<form id="upload">
|
||||||
<input type="file" id="fileSelect"/>
|
<input type="file" id="fileSelect"/>
|
||||||
|
|
|
@ -78,6 +78,7 @@ class PipelineInfo{
|
||||||
setVisible('error',currentPipeline.error!==undefined,true);
|
setVisible('error',currentPipeline.error!==undefined,true);
|
||||||
let values={};
|
let values={};
|
||||||
fillValues(values,['configError','environment']);
|
fillValues(values,['configError','environment']);
|
||||||
|
setVisible('buildCommand',values.environment !== "" && ! values.configError);
|
||||||
if (values.configError) {
|
if (values.configError) {
|
||||||
enableEl('start',false);
|
enableEl('start',false);
|
||||||
return;
|
return;
|
||||||
|
@ -233,13 +234,23 @@ class PipelineInfo{
|
||||||
let name="buildconfig.json";
|
let name="buildconfig.json";
|
||||||
fileDownload(JSON.stringify(config),name);
|
fileDownload(JSON.stringify(config),name);
|
||||||
}
|
}
|
||||||
const btConfig={
|
const showOverlay=(text, isHtml)=>{
|
||||||
start:startBuild,
|
let el = document.getElementById('overlayContent');
|
||||||
download:runDownload,
|
if (isHtml) {
|
||||||
webinstall:webInstall,
|
el.innerHTML = text;
|
||||||
uploadConfig: uploadConfig,
|
el.classList.remove("text");
|
||||||
downloadConfig: downloadConfig
|
}
|
||||||
};
|
else {
|
||||||
|
el.textContent = text;
|
||||||
|
el.classList.add("text");
|
||||||
|
}
|
||||||
|
let container = document.getElementById('overlayContainer');
|
||||||
|
container.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
const hideOverlay=()=> {
|
||||||
|
let container = document.getElementById('overlayContainer');
|
||||||
|
container.classList.add('hidden');
|
||||||
|
}
|
||||||
const loadConfig=async (url)=>{
|
const loadConfig=async (url)=>{
|
||||||
let config=await fetch(url).then((r)=>{
|
let config=await fetch(url).then((r)=>{
|
||||||
if (!r.ok) throw new Error("unable to fetch: "+r.statusText);
|
if (!r.ok) throw new Error("unable to fetch: "+r.statusText);
|
||||||
|
@ -248,6 +259,26 @@ class PipelineInfo{
|
||||||
let parsed=yamlLoad(config);
|
let parsed=yamlLoad(config);
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
const showBuildCommand=()=>{
|
||||||
|
let v={};
|
||||||
|
fillValues(v,['environment','buildflags']);
|
||||||
|
if (v.environment !== ""){
|
||||||
|
let help="Run the build from a command line:\nPLATFORMIO_BUILD_FLAGS=\"";
|
||||||
|
help+=v.buildflags;
|
||||||
|
help+="\" pio run -e "+v.environment;
|
||||||
|
showOverlay(help);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const btConfig={
|
||||||
|
start:startBuild,
|
||||||
|
download:runDownload,
|
||||||
|
webinstall:webInstall,
|
||||||
|
uploadConfig: uploadConfig,
|
||||||
|
downloadConfig: downloadConfig,
|
||||||
|
hideOverlay: hideOverlay,
|
||||||
|
buildCommand: showBuildCommand
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const PATH_ATTR='data-path';
|
const PATH_ATTR='data-path';
|
||||||
const SEPARATOR=':';
|
const SEPARATOR=':';
|
||||||
|
@ -289,6 +320,28 @@ class PipelineInfo{
|
||||||
lst.forEach((e)=>rt.push(expandObject(e,parent)));
|
lst.forEach((e)=>rt.push(expandObject(e,parent)));
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addDescription=(v,frame)=>{
|
||||||
|
if (frame === undefined) return;
|
||||||
|
if (v.description){
|
||||||
|
if(v.url) {
|
||||||
|
let lnk = addEl('a', 'radioDescription', frame, v.description);
|
||||||
|
lnk.setAttribute('href', v.url);
|
||||||
|
lnk.setAttribute('target', '_');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let de=addEl('span','radioDescription',frame,v.description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (v.help){
|
||||||
|
let bt=addEl('button','help',frame,'?');
|
||||||
|
bt.addEventListener('click',()=>showOverlay(v.help));
|
||||||
|
}
|
||||||
|
else if (v.helpHtml){
|
||||||
|
let bt=addEl('button','help',frame,'?');
|
||||||
|
bt.addEventListener('click',()=>showOverlay(v.helpHtml,true));
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {build a selector} parent
|
* @param {build a selector} parent
|
||||||
|
@ -305,8 +358,10 @@ class PipelineInfo{
|
||||||
let frame=addEl('div','selector level'+level.length+' t'+config.type,parent);
|
let frame=addEl('div','selector level'+level.length+' t'+config.type,parent);
|
||||||
frame.setAttribute(PATH_ATTR,name);
|
frame.setAttribute(PATH_ATTR,name);
|
||||||
let inputFrame=addEl('div','inputFrame',frame);
|
let inputFrame=addEl('div','inputFrame',frame);
|
||||||
|
let titleFrame=undefined;
|
||||||
if (config.label !== undefined){
|
if (config.label !== undefined){
|
||||||
addEl('div','title t'+config.type,inputFrame,config.label);
|
titleFrame=addEl('div','titleFrame t'+config.type,inputFrame);
|
||||||
|
addEl('div','title t'+config.type,titleFrame,config.label);
|
||||||
}
|
}
|
||||||
let initialConfig=undefined
|
let initialConfig=undefined
|
||||||
if (config.type === 'frame' || config.type === undefined){
|
if (config.type === 'frame' || config.type === undefined){
|
||||||
|
@ -321,6 +376,7 @@ class PipelineInfo{
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (config.type === 'select') {
|
if (config.type === 'select') {
|
||||||
|
addDescription(config,titleFrame);
|
||||||
for (let idx=0;idx<expandedValues.length;idx++){
|
for (let idx=0;idx<expandedValues.length;idx++){
|
||||||
let v=expandedValues[idx];
|
let v=expandedValues[idx];
|
||||||
if (v.key === undefined) continue;
|
if (v.key === undefined) continue;
|
||||||
|
@ -330,16 +386,7 @@ class PipelineInfo{
|
||||||
re.setAttribute('type', 'radio');
|
re.setAttribute('type', 'radio');
|
||||||
re.setAttribute('name', name);
|
re.setAttribute('name', name);
|
||||||
re.addEventListener('change', (ev) => callback(v,false));
|
re.addEventListener('change', (ev) => callback(v,false));
|
||||||
if (v.description){
|
addDescription(v,ef);
|
||||||
if(v.url) {
|
|
||||||
let lnk = addEl('a', 'radioDescription', ef, v.description);
|
|
||||||
lnk.setAttribute('href', v.url);
|
|
||||||
lnk.setAttribute('target', '_');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
let de=addEl('span','radioDescription',ef,v.description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (v.key == current) {
|
if (v.key == current) {
|
||||||
re.setAttribute('checked','checked');
|
re.setAttribute('checked','checked');
|
||||||
initialConfig=v;
|
initialConfig=v;
|
||||||
|
@ -358,6 +405,7 @@ class PipelineInfo{
|
||||||
initialConfig=v;
|
initialConfig=v;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
addDescription(config,inputFrame);
|
||||||
sel.addEventListener('change',(ev)=>{
|
sel.addEventListener('change',(ev)=>{
|
||||||
let v=expandedValues[ev.target.value];
|
let v=expandedValues[ev.target.value];
|
||||||
if (! v) return;
|
if (! v) return;
|
||||||
|
@ -386,6 +434,7 @@ class PipelineInfo{
|
||||||
else{
|
else{
|
||||||
initialConfig=inact;
|
initialConfig=inact;
|
||||||
}
|
}
|
||||||
|
addDescription(config,inputFrame);
|
||||||
cb.addEventListener('change',(ev)=>{
|
cb.addEventListener('change',(ev)=>{
|
||||||
if (ev.target.checked){
|
if (ev.target.checked){
|
||||||
callback(act,false);
|
callback(act,false);
|
||||||
|
|
Loading…
Reference in New Issue