copy build cmd to clipboard

This commit is contained in:
andreas 2023-11-03 20:30:43 +01:00
parent e815cd19da
commit 362a26635a
2 changed files with 28 additions and 6 deletions

View File

@ -72,6 +72,7 @@
AHA AHA
</div> </div>
<div class="overlayButtons"> <div class="overlayButtons">
<button id="secondDialogButton"></button>
<button id="hideOverlay">Close</button> <button id="hideOverlay">Close</button>
</div> </div>
</div> </div>

View File

@ -238,7 +238,7 @@ class PipelineInfo{
name+=".json"; name+=".json";
fileDownload(JSON.stringify(config),name); fileDownload(JSON.stringify(config),name);
} }
const showOverlay=(text, isHtml)=>{ const showOverlay=(text, isHtml, secondButton)=>{
let el = document.getElementById('overlayContent'); let el = document.getElementById('overlayContent');
if (isHtml) { if (isHtml) {
el.innerHTML = text; el.innerHTML = text;
@ -250,6 +250,17 @@ class PipelineInfo{
} }
let container = document.getElementById('overlayContainer'); let container = document.getElementById('overlayContainer');
container.classList.remove('hidden'); container.classList.remove('hidden');
let db=document.getElementById("secondDialogButton");
if (db) {
if (secondButton && secondButton.callback) {
db.classList.remove("hidden");
if (secondButton.title){db.textContent=secondButton.title}
db.onclick=secondButton.callback;
}
else {
db.classList.add("hidden");
}
}
} }
const hideOverlay=()=> { const hideOverlay=()=> {
let container = document.getElementById('overlayContainer'); let container = document.getElementById('overlayContainer');
@ -263,14 +274,24 @@ class PipelineInfo{
let parsed=yamlLoad(config); let parsed=yamlLoad(config);
return parsed; return parsed;
} }
const showBuildCommand=()=>{ const showBuildCommand= async ()=>{
let v={}; let v={};
fillValues(v,['environment','buildflags']); fillValues(v,['environment','buildflags']);
if (v.environment !== ""){ if (v.environment !== ""){
let help="Run the build from a command line:\nPLATFORMIO_BUILD_FLAGS=\""; let help="Run the build from a command line:\n";
help+=v.buildflags; let cmd="PLATFORMIO_BUILD_FLAGS=\"";
help+="\" pio run -e "+v.environment; cmd+=v.buildflags;
showOverlay(help); cmd+="\" pio run -e "+v.environment;
help+=cmd;
showOverlay(help,false,{title:"Copy",callback:(ev)=>{
try{
navigator.clipboard.writeText(cmd);
//alert("copied:"+cmd);
}
catch (e){
alert("Unable to copy:"+e);
}
}});
} }
} }
const btConfig={ const btConfig={