header in both plans, add title mapping to columns

This commit is contained in:
Wolfgang 2024-05-24 19:55:54 +02:00
parent 603bd72bbb
commit c142be9e4a
3 changed files with 74 additions and 41 deletions

View file

@ -1,3 +1,10 @@
- header: true
columns: [power]
titles: {
power_a: Power A,
power_e: Power E,
power_n: Power N
}
- start: 135.7
end: 137.8
power: {a: 1 W ERP}

View file

@ -1,5 +1,13 @@
- band: header
- header: true
columns: [band, frequency, mode, bandwidth, description]
part_columns: [description]
titles: {
band: Band,
frequency: Frequency / kHz,
mode: Mode,
bandwidth: Bandwidth / Hz,
description: Description
}
- band: 2.2 km
mode: CW
bandwidth: 200

View file

@ -84,30 +84,41 @@ div#togglebuttons>button {
function update_table(bands, additions) {
var tdata = [];
var header = {};
var base_header = {};
var add_header = {};
// first, fill header
// first, fill base_header
bands.forEach((band) => {
if (band.band === "header") {
header = structuredClone(band);
if ((typeof band.header !== "undefined") && band.header) {
base_header = structuredClone(band);
}
});
// then fill tdata
bands.forEach((band) => {
if (band.band !== "header") {
if ((typeof band.header === "undefined") || (band.header == false)) {
band.parts.forEach((part) => {
let p = {};
header.columns.forEach((col) => {
p[col] = band[col];
if (col == "description") {
base_header.columns.forEach((col) => {
if (base_header.part_columns.includes(col)) {
p[col] = part[col];
} else {
p[col] = band[col];
}
});
p["frequency"] = typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end;
// first, fill add_header
additions.forEach((add) => {
if ((typeof add.header !== "undefined") && add.header) {
add_header = structuredClone(add);
}
});
// then fill tdata
let parts_already_added = false;
additions.forEach((add) => {
if ((typeof add.header === "undefined") || (add.header == false)) {
if (typeof part.at !== "undefined") {
if (isInRange(part.at, add.start, add.end)) {
// at single frequency
@ -144,6 +155,7 @@ div#togglebuttons>button {
}
}
}
}
});
if (!parts_already_added) {
tdata.push(p);
@ -179,6 +191,12 @@ div#togglebuttons>button {
column.headerFilter = "input";
column.headerFilterFunc = filter_with_not;
if (typeof base_header.titles[column.field] !== "undefined") {
column.title = base_header.titles[column.field];
}
if (typeof add_header.titles[column.field] !== "undefined") {
column.title = add_header.titles[column.field];
}
});
return definitions;