Job Id
---
diff --git a/webinstall/cibuild.js b/webinstall/cibuild.js
index ce28750..3b9c3d4 100644
--- a/webinstall/cibuild.js
+++ b/webinstall/cibuild.js
@@ -1,4 +1,4 @@
-import { setButtons,fillValues, setValue, buildUrl, fetchJson, setVisible, enableEl, setValues } from "./helper";
+import { setButtons,fillValues, setValue, buildUrl, fetchJson, setVisible, enableEl, setValues, getParam, fillSelect, forEachEl } from "./helper.js";
(function(){
const STATUS_INTERVAL=2000;
const CURRENT_PIPELINE='pipeline';
@@ -6,6 +6,8 @@ import { setButtons,fillValues, setValue, buildUrl, fetchJson, setVisible, enabl
let currentPipeline=undefined;
let downloadUrl=undefined;
let timer=undefined;
+ let branch=getParam('branch');
+ if (! branch) branch='master';
const showError=(text)=>{
if (text === undefined){
setVisible('buildError',false,true);
@@ -14,12 +16,21 @@ import { setButtons,fillValues, setValue, buildUrl, fetchJson, setVisible, enabl
setValue('buildError',text);
setVisible('buildError',true,true);
}
+ const hideResults = () => {
+ downloadUrl = undefined;
+ currentPipeline = undefined;
+ setValue('pipeline', currentPipeline);
+ setValue('status','');
+ showError();
+ setVisible('download', false, true);
+ setVisible('status_url', false, true);
+ }
const setRunning=(active)=>{
if (active){
- downloadUrl=undefined;
showError();
- setVisible('download',false,true);
- setVisible('status_url',false,true);
+ downloadUrl=undefined;
+ setVisible('download', false, true);
+ setVisible('status_url', false, true);
}
enableEl('start',!active);
}
@@ -68,12 +79,13 @@ import { setButtons,fillValues, setValue, buildUrl, fetchJson, setVisible, enabl
window.localStorage.setItem(CURRENT_PIPELINE,pipeline);
};
const startBuild=()=>{
- let param={};
+ let param={'branch':branch};
currentPipeline=undefined;
if (timer) window.clearTimeout(timer);
timer=undefined;
fillValues(param,['environment','buildflags']);
setValue('status','requested');
+ setValue('pipeline','');
setRunning(true);
fetchJson(API,Object.assign({
api:'start'},param))
@@ -111,13 +123,21 @@ import { setButtons,fillValues, setValue, buildUrl, fetchJson, setVisible, enabl
download:runDownload,
webinstall:webInstall
};
+ const environments=[
+ 'm5stack-atom-generic',
+ 'm5stack-atoms3-generic',
+ 'nodemcu-generic'
+ ];
window.onload=()=>{
setButtons(btConfig);
+ forEachEl('#environment',(el)=>el.addEventListener('change',hideResults));
+ forEachEl('#buildflags',(el)=>el.addEventListener('change',hideResults));
+ fillSelect('environment',environments);
currentPipeline=window.localStorage.getItem(CURRENT_PIPELINE);
if (currentPipeline){
setValue('pipeline',currentPipeline);
- setRunning(true);
fetchStatus(true);
+ setRunning(true);
}
}
})();
\ No newline at end of file
diff --git a/webinstall/helper.js b/webinstall/helper.js
index d3c070e..3e51220 100644
--- a/webinstall/helper.js
+++ b/webinstall/helper.js
@@ -108,5 +108,16 @@ const enableEl=(id,en)=>{
if (en) el.disabled=false;
else el.disabled=true;
}
+const fillSelect=(el,values)=>{
+ if (typeof(el) !== 'object') el=document.getElementById(el);
+ if (! el) return;
+ el.textContent='';
+ let kf=(values instanceof Array)?(k)=>values[k]:(k)=>k;
+ for (let k in values){
+ let o=addEl('option','',el);
+ o.setAttribute('value',kf(k));
+ o.textContent=values[k];
+ }
+}
-export { getParam, addEl, forEachEl,setButtons,fillValues, setValue,setValues,buildUrl,fetchJson,setVisible, enableEl }
\ No newline at end of file
+export { getParam, addEl, forEachEl,setButtons,fillValues, setValue,setValues,buildUrl,fetchJson,setVisible, enableEl,fillSelect }
\ No newline at end of file
diff --git a/webinstall/install.js b/webinstall/install.js
index 059e431..3c7de3d 100644
--- a/webinstall/install.js
+++ b/webinstall/install.js
@@ -13,8 +13,8 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
const NAMEOFFSET = 48;
const CHIPOFFSET=NAMEOFFSET+64;
const MINSIZE = HDROFFSET + CHIPOFFSET + 32;
+ const imageMagic=0xe9; //at byte 0
const imageCheckBytes = {
- 0: 0xe9, //image magic
288: 0x32, //app header magic
289: 0x54,
290: 0xcd,
@@ -25,7 +25,6 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
length--;
}
if (length <= 0) return "";
- let decoder = new TextDecoder();
return buffer.substr(start,length);
}
/**
@@ -38,6 +37,9 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
if (content.length < (MINSIZE+startOffset)) {
throw new Error(prfx+"image to small, only " + content.length + " expected " + (MINSIZE+startOffset));
}
+ if (content.charCodeAt(0) != imageMagic){
+ throw new Error("no image magic "+imageMagic+" at start of "+prfx+"image");
+ }
for (let idx in imageCheckBytes) {
let cb=content.charCodeAt(parseInt(idx)+startOffset);
if (cb != imageCheckBytes[idx]) {