1
mirror of https://github.com/rvdbreemen/OTGW-firmware synced 2024-11-16 04:33:49 +01:00

rollback changes index.js

This commit is contained in:
Robert van den Breemen 2024-04-02 18:32:39 +02:00
parent 6752fdfc8e
commit 3f0320f41f
2 changed files with 64 additions and 58 deletions

View File

@ -8,11 +8,11 @@
** TERMS OF USE: MIT License. See bottom of file.
***************************************************************************
*/
"use strict";
const localURL=window.location.protocol+'//'+window.location.host;
const APIGW=localURL+'/api/';
const APIGW=window.location.protocol+'//'+window.location.host+'/api/';
"use strict";
let needReload = true;
refreshDevTime();
@ -161,20 +161,21 @@
}
//============================================================================
function refreshDevTime() {
fetch(APIGW + "v0/devtime")
function refreshDevTime()
{
//console.log("Refresh api/v0/devtime ..");
fetch(APIGW+"v0/devtime")
.then(response => response.json())
.then(json => {
const dateTime = json.devtime.find(item => item.name === "dateTime");
const message = json.devtime.find(item => item.name === "message");
if (dateTime) {
document.getElementById('theTime').innerHTML = dateTime.value;
}
if (message) {
document.getElementById('message').innerHTML = message.value;
}
//console.log("parsed .., data is ["+ JSON.stringify(json)+"]");
for( let i in json.devtime ){
if (json.devtime[i].name == "dateTime")
{
//console.log("Got new time ["+json.devtime[i].value+"]");
document.getElementById('theTime').innerHTML = json.devtime[i].value;
}
if (json.devtime[i].name == "message") document.getElementById('message').innerHTML = json.devtime[i].value;
}
})
.catch(function(error) {
var p = document.createElement('p');
@ -182,22 +183,23 @@
document.createTextNode('Error: ' + error.message)
);
});
} // refreshDevTime()
//============================================================================
function refreshFirmware() {
console.log("refreshFirmware() .. " + APIGW + "firmwarefilelist");
fetch(APIGW + "firmwarefilelist")
function refreshFirmware(){
console.log("refreshFirmware() .. "+APIGW+"firmwarefilelist");
fetch(APIGW+"firmwarefilelist")
.then(response => response.json())
.then(files => {
console.log("parsed ... data is [" + JSON.stringify(files) + "]");
console.log("parsed ... data is ["+ JSON.stringify(files)+"]");
let displayPICpage = document.getElementById('displayPICpage');
while (displayPICpage.lastChild) {
displayPICpage.lastChild.remove();
}
let tableDiv = document.createElement("div");
tableDiv.setAttribute("class", "pictable");
var rowDiv = document.createElement("div");
rowDiv.setAttribute("class", "picrow");
rowDiv.setAttribute("id", "firmwarename");
@ -210,29 +212,31 @@
rowDiv.appendChild(fldDiv);
//--- version on screen ---
var valDiv = document.createElement("div");
valDiv.setAttribute("class", "piccolumn2");
valDiv.textContent = "Version"
valDiv.setAttribute("class", "piccolumn2");
valDiv.textContent = "Version"
rowDiv.appendChild(valDiv);
//--- size on screen ---
var sizDiv = document.createElement("div");
sizDiv.setAttribute("class", "piccolumn3");
sizDiv.textContent = "Size"
sizDiv.setAttribute("class", "piccolumn3");
sizDiv.textContent = "Size"
rowDiv.appendChild(sizDiv);
//--- refresh icon ---
var btn = document.createElement("div");
btn.setAttribute("class", "piccolumn4");
rowDiv.appendChild(btn);
rowDiv.appendChild(btn);
//--- flash to pic icon---
var btn = document.createElement("div");
rowDiv.appendChild(btn);
rowDiv.appendChild(btn);
tableDiv.appendChild(rowDiv);
for (let i in files) {
console.log("[" + files[i].name + "]=>[" + files[i].version + "]=>[" + files[i].size + "]");
for( let i in files )
{
console.log("["+files[i].name+"]=>["+files[i].version+"]=>["+files[i].size+"]");
// var displayPICflash = document.getElementById('displayPICflash');
var rowDiv = document.createElement("div");
rowDiv.setAttribute("class", "picrow");
rowDiv.setAttribute("id", "firmware_" + files[i].name);
rowDiv.setAttribute("id", "firmware_"+files[i].name);
rowDiv.style.background = "lightblue";
//--- field Name ---
var fldDiv = document.createElement("div");
@ -241,54 +245,56 @@
rowDiv.appendChild(fldDiv);
//--- version on screen ---
var valDiv = document.createElement("div");
valDiv.setAttribute("class", "piccolumn2");
valDiv.textContent = files[i].version;
valDiv.setAttribute("class", "piccolumn2");
valDiv.textContent = files[i].version;
rowDiv.appendChild(valDiv);
//--- size on screen ---
var sizDiv = document.createElement("div");
sizDiv.setAttribute("class", "piccolumn3");
sizDiv.textContent = files[i].size;
sizDiv.setAttribute("class", "piccolumn3");
sizDiv.textContent = files[i].size;
rowDiv.appendChild(sizDiv);
//--- refresh icon ---
var btn = document.createElement("div");
btn.setAttribute("class", "piccolumn4");
var a = document.createElement('a');
// a.title = "Update";
a.href = localURL + '/pic?action=refresh&name=' + files[i].name + '&version=' + files[i].version;
var img = document.createElement('img');
img.src = localURL + '/update.png';
a.href = localURL+'/pic?action=refresh&name='+files[i].name+'&version='+files[i].version;
var img = document.createElement('img');
img.src = localURL+'/update.png';
img.title = "Update firmware from web";
img.style.width = '16px';
img.style.height = 'auto';
img.setAttribute = ("alt", "Update");
img.setAttribute=("alt", "Update");
a.appendChild(img);
btn.appendChild(a);
rowDiv.appendChild(btn);
btn.appendChild(a);
rowDiv.appendChild(btn);
//--- flash to pic icon---
var btn = document.createElement("div");
btn.setAttribute("class", "piccolumn5");
var a = document.createElement('a');
a.href = localURL + '/pic?action=upgrade&name=' + files[i].name + '&version=' + files[i].version;
var img = document.createElement('img');
img.src = localURL + '/system_update.png'
a.href = localURL+'/pic?action=upgrade&name='+files[i].name+'&version='+files[i].version;
var img = document.createElement('img');
img.src = localURL+'/system_update.png'
img.title = "Install firmware onto pic";
img.style.width = '16px';
img.style.height = 'auto';
img.setAttribute = ("alt", "Install");
img.setAttribute=("alt", "Install");
a.appendChild(img);
btn.appendChild(a);
rowDiv.appendChild(btn);
btn.appendChild(a);
rowDiv.appendChild(btn);
tableDiv.appendChild(rowDiv);
}
displayPICpage.appendChild(tableDiv);
})
.catch(function (error) {
.catch(function(error) {
var p = document.createElement('p');
p.appendChild(
document.createTextNode('Error: ' + error.message)
);
});
});
}

View File

@ -2,15 +2,15 @@
#define _VERSION_MAJOR 0
#define _VERSION_MINOR 10
#define _VERSION_PATCH 3
#define _VERSION_BUILD 2105
#define _VERSION_GITHASH "1214611"
#define _VERSION_BUILD 2106
#define _VERSION_GITHASH "6752fdf"
#define _VERSION_PRERELEASE beta
#define _VERSION_DATE "01-04-2024"
#define _VERSION_TIME "09:17:10"
#define _VERSION_DATE "02-04-2024"
#define _VERSION_TIME "18:29:36"
#define _SEMVER_CORE "0.10.3"
#define _SEMVER_BUILD "0.10.3+2105"
#define _SEMVER_GITHASH "0.10.3+1214611"
#define _SEMVER_FULL "0.10.3-beta+1214611"
#define _SEMVER_NOBUILD "0.10.3-beta (01-04-2024)"
#define _VERSION "0.10.3-beta+1214611 (01-04-2024)"
#define _SEMVER_BUILD "0.10.3+2106"
#define _SEMVER_GITHASH "0.10.3+6752fdf"
#define _SEMVER_FULL "0.10.3-beta+6752fdf"
#define _SEMVER_NOBUILD "0.10.3-beta (02-04-2024)"
#define _VERSION "0.10.3-beta+6752fdf (02-04-2024)"
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver