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,63 +84,75 @@ 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 part.at !== "undefined") {
if (isInRange(part.at, add.start, add.end)) {
// at single frequency
add_power(add, p);
}
} else {
// frequeny range
if ((add.start == part.start) && (add.end == part.end)) {
// ranges are the same
add_power(add, p);
} else if (isInRange(part.start, add.start, add.end) && isInRange(part.end, add.start, add.end)) {
// range of part is inside of range of add
add_power(add, p);
if ((typeof add.header === "undefined") || (add.header == false)) {
if (typeof part.at !== "undefined") {
if (isInRange(part.at, add.start, add.end)) {
// at single frequency
add_power(add, p);
}
} else {
// part range is split by add range
if (isInRange(add.start, part.start, part.end)) {
// part range starts below add range
let p_clone = structuredClone(p);
let start = add.start;
let end = part.end < add.end ? part.end : add.end;
p_clone["frequency"] = start + '\u2013' + end;
add_power(add, p_clone);
tdata.push(p_clone);
parts_already_added = true;
} else if (isInRange(add.end, part.start, part.end)) {
// add range starts below part range
let p_clone = structuredClone(p);
let start = part.start;
let end = add.end;
p_clone["frequency"] = start + '\u2013' + end;
add_power(add, p_clone);
tdata.push(p_clone);
parts_already_added = true;
// frequeny range
if ((add.start == part.start) && (add.end == part.end)) {
// ranges are the same
add_power(add, p);
} else if (isInRange(part.start, add.start, add.end) && isInRange(part.end, add.start, add.end)) {
// range of part is inside of range of add
add_power(add, p);
} else {
// part range is split by add range
if (isInRange(add.start, part.start, part.end)) {
// part range starts below add range
let p_clone = structuredClone(p);
let start = add.start;
let end = part.end < add.end ? part.end : add.end;
p_clone["frequency"] = start + '\u2013' + end;
add_power(add, p_clone);
tdata.push(p_clone);
parts_already_added = true;
} else if (isInRange(add.end, part.start, part.end)) {
// add range starts below part range
let p_clone = structuredClone(p);
let start = part.start;
let end = add.end;
p_clone["frequency"] = start + '\u2013' + end;
add_power(add, p_clone);
tdata.push(p_clone);
parts_already_added = true;
}
}
}
}
@ -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;