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 - start: 135.7
end: 137.8 end: 137.8
power: {a: 1 W ERP} power: {a: 1 W ERP}

View file

@ -1,5 +1,13 @@
- band: header - header: true
columns: [band, frequency, mode, bandwidth, description] 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 - band: 2.2 km
mode: CW mode: CW
bandwidth: 200 bandwidth: 200

View file

@ -84,63 +84,75 @@ div#togglebuttons>button {
function update_table(bands, additions) { function update_table(bands, additions) {
var tdata = []; var tdata = [];
var header = {}; var base_header = {};
var add_header = {};
// first, fill header // first, fill base_header
bands.forEach((band) => { bands.forEach((band) => {
if (band.band === "header") { if ((typeof band.header !== "undefined") && band.header) {
header = structuredClone(band); base_header = structuredClone(band);
} }
}); });
// then fill tdata // then fill tdata
bands.forEach((band) => { bands.forEach((band) => {
if (band.band !== "header") { if ((typeof band.header === "undefined") || (band.header == false)) {
band.parts.forEach((part) => { band.parts.forEach((part) => {
let p = {}; let p = {};
header.columns.forEach((col) => { base_header.columns.forEach((col) => {
p[col] = band[col]; if (base_header.part_columns.includes(col)) {
if (col == "description") {
p[col] = part[col]; p[col] = part[col];
} else {
p[col] = band[col];
} }
}); });
p["frequency"] = typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end; 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; let parts_already_added = false;
additions.forEach((add) => { additions.forEach((add) => {
if (typeof part.at !== "undefined") { if ((typeof add.header === "undefined") || (add.header == false)) {
if (isInRange(part.at, add.start, add.end)) { if (typeof part.at !== "undefined") {
// at single frequency if (isInRange(part.at, add.start, add.end)) {
add_power(add, p); // 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);
} else { } else {
// part range is split by add range // frequeny range
if (isInRange(add.start, part.start, part.end)) { if ((add.start == part.start) && (add.end == part.end)) {
// part range starts below add range // ranges are the same
let p_clone = structuredClone(p); add_power(add, p);
let start = add.start; } else if (isInRange(part.start, add.start, add.end) && isInRange(part.end, add.start, add.end)) {
let end = part.end < add.end ? part.end : add.end; // range of part is inside of range of add
p_clone["frequency"] = start + '\u2013' + end; add_power(add, p);
add_power(add, p_clone); } else {
tdata.push(p_clone); // part range is split by add range
parts_already_added = true; if (isInRange(add.start, part.start, part.end)) {
} else if (isInRange(add.end, part.start, part.end)) { // part range starts below add range
// add range starts below part range let p_clone = structuredClone(p);
let p_clone = structuredClone(p); let start = add.start;
let start = part.start; let end = part.end < add.end ? part.end : add.end;
let end = add.end; p_clone["frequency"] = start + '\u2013' + end;
p_clone["frequency"] = start + '\u2013' + end; add_power(add, p_clone);
add_power(add, p_clone); tdata.push(p_clone);
tdata.push(p_clone); parts_already_added = true;
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.headerFilter = "input";
column.headerFilterFunc = filter_with_not; 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; return definitions;