[QSO] Adds Select Radio under the map
这个提交包含在:
父节点
446b9654e6
当前提交
83dd417539
共有 2 个文件被更改,包括 786 次插入 和 661 次删除
|
|
@ -807,8 +807,7 @@ if ($this->session->userdata('user_id') != null) {
|
||||||
document.getElementById('from').value = data;
|
document.getElementById('from').value = data;
|
||||||
document.getElementById('to').value = new Date().toISOString().split('T')[0];
|
document.getElementById('to').value = new Date().toISOString().split('T')[0];
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {},
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -916,8 +915,8 @@ if ($this->session->userdata('user_id') != null) {
|
||||||
var icon = L.divIcon({
|
var icon = L.divIcon({
|
||||||
className: 'custom-icon',
|
className: 'custom-icon',
|
||||||
html: `<i class="${iconsList.qso.icon}" style="color:${iconsList.qso.color}"></i>`
|
html: `<i class="${iconsList.qso.icon}" style="color:${iconsList.qso.color}"></i>`
|
||||||
});
|
});
|
||||||
|
|
||||||
L.marker([marker.lat, marker.lng], {
|
L.marker([marker.lat, marker.lng], {
|
||||||
icon: icon
|
icon: icon
|
||||||
})
|
})
|
||||||
|
|
@ -931,9 +930,9 @@ if ($this->session->userdata('user_id') != null) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
markers = newMarkers;
|
markers = newMarkers;
|
||||||
} else {
|
} else {
|
||||||
console.log("No QSOs found to populate dashboard map.");
|
console.log("No QSOs found to populate dashboard map.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1502,129 +1501,159 @@ if ($this->session->userdata('user_id') != null) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Javascript for controlling rig frequency.
|
// Helper function to update a UI element with CAT data
|
||||||
var updateFromCAT = function() {
|
const cat2UI = (ui, cat, allowEmpty = true, allowZero = true, callbackOnUpdate) => {
|
||||||
var cat2UI = function(ui, cat, allow_empty, allow_zero, callback_on_update) {
|
if (
|
||||||
// Check, if cat-data is available
|
cat == null ||
|
||||||
if (cat == null) {
|
(!allowEmpty && cat === '') ||
|
||||||
return;
|
(!allowZero && cat === '0')
|
||||||
} else if (typeof allow_empty !== 'undefined' && !allow_empty && cat == '') {
|
) return;
|
||||||
return;
|
|
||||||
} else if (typeof allow_zero !== 'undefined' && !allow_zero && cat == '0') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Only update the ui-element, if cat-data has changed
|
|
||||||
if (ui.data('catValue') != cat) {
|
|
||||||
ui.val(cat);
|
|
||||||
ui.data('catValue', cat);
|
|
||||||
if (typeof callback_on_update === 'function') {
|
|
||||||
callback_on_update(cat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('select.radios option:selected').val() != '0') {
|
if (ui.data('catValue') != cat) {
|
||||||
radioID = $('select.radios option:selected').val();
|
ui.val(cat).data('catValue', cat);
|
||||||
$.getJSON("radio/json/" + radioID, function(data) {
|
if (typeof callbackOnUpdate === 'function') callbackOnUpdate(cat);
|
||||||
/* {
|
|
||||||
"frequency": "2400210000",
|
|
||||||
"frequency_rx": "10489710000",
|
|
||||||
"mode": "SSB",
|
|
||||||
"satmode": "S/X",
|
|
||||||
"satname": "QO-100"
|
|
||||||
"power": "20"
|
|
||||||
"prop_mode": "SAT",
|
|
||||||
"error": "not_logged_id" // optional, reserved for errors
|
|
||||||
} */
|
|
||||||
if (data.error) {
|
|
||||||
if (data.error == 'not_logged_in') {
|
|
||||||
$(".radio_cat_state").remove();
|
|
||||||
if ($('.radio_login_error').length == 0) {
|
|
||||||
$('.qso_panel').prepend('<div class="alert alert-danger radio_login_error" role="alert"><i class="fas fa-broadcast-tower"></i> You\'re not logged it. Please <a href="<?php echo base_url(); ?>">login</a></div>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Put future Errorhandling here
|
|
||||||
} else {
|
|
||||||
if ($('.radio_login_error').length != 0) {
|
|
||||||
$(".radio_login_error").remove();
|
|
||||||
}
|
|
||||||
cat2UI($('#frequency'), data.frequency, false, true, function(d) {
|
|
||||||
$("#band").val(frequencyToBand(d))
|
|
||||||
});
|
|
||||||
cat2UI($('#frequency_rx'), data.frequency_rx, false, true, function(d) {
|
|
||||||
$("#band_rx").val(frequencyToBand(d))
|
|
||||||
});
|
|
||||||
cat2UI($('.mode'), data.mode, false, false, function(d) {
|
|
||||||
setRst($(".mode").val())
|
|
||||||
});
|
|
||||||
cat2UI($('#sat_name'), data.satname, false, false);
|
|
||||||
cat2UI($('#sat_mode'), data.satmode, false, false);
|
|
||||||
cat2UI($('#transmit_power'), data.power, false, false);
|
|
||||||
cat2UI($('#selectPropagation'), data.prop_mode, false, false);
|
|
||||||
|
|
||||||
// Display CAT Timeout warning based on the figure given in the config file
|
|
||||||
var minutes = Math.floor(<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?> / 60);
|
|
||||||
|
|
||||||
if (data.updated_minutes_ago > minutes) {
|
|
||||||
$(".radio_cat_state").remove();
|
|
||||||
if ($('.radio_timeout_error').length == 0) {
|
|
||||||
$('#radio_status').prepend('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
|
|
||||||
} else {
|
|
||||||
$('.radio_timeout_error').html('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$(".radio_timeout_error").remove();
|
|
||||||
text = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> ' + (Math.round(parseInt(data.frequency) / 100) / 10000).toFixed(4) + ' MHz';
|
|
||||||
if (data.mode != null) {
|
|
||||||
text = text + '<span style="margin-left:10px"></span>' + data.mode;
|
|
||||||
}
|
|
||||||
if (data.power != null && data.power != 0) {
|
|
||||||
text = text + '<span style="margin-left:10px"></span>' + data.power + ' W';
|
|
||||||
}
|
|
||||||
ptext = '';
|
|
||||||
if (data.prop_mode != null && data.prop_mode != '') {
|
|
||||||
ptext = ptext + data.prop_mode;
|
|
||||||
if (data.prop_mode == 'SAT') {
|
|
||||||
ptext = ptext + ' ' + data.satname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (data.frequency_rx != null && data.frequency_rx != 0) {
|
|
||||||
ptext = ptext + '<span style="margin-left:10px"></span><b>RX:</b> ' + (Math.round(parseInt(data.frequency_rx) / 1000) / 1000).toFixed(3) + ' MHz';
|
|
||||||
}
|
|
||||||
if (ptext != '') {
|
|
||||||
text = text + '<span style="margin-left:10px"></span>(' + ptext + ')';
|
|
||||||
}
|
|
||||||
if (!$('#radio_cat_state').length) {
|
|
||||||
$('#radio_status').prepend('<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">' + text + '</div></div>');
|
|
||||||
} else {
|
|
||||||
$('#radio_cat_state').html(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update frequency every three second
|
// Update UI from CAT data
|
||||||
setInterval(updateFromCAT, 3000);
|
const updateFromCAT = (radioID) => {
|
||||||
|
if (radioID === '0') return;
|
||||||
|
|
||||||
// If a radios selected from drop down select radio update.
|
$.getJSON(`radio/json/${radioID}`, (data) => {
|
||||||
$('.radios').change(updateFromCAT);
|
if (data.error) {
|
||||||
|
if (data.error === 'not_logged_in') {
|
||||||
|
handleLoginError();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If no radio is selected clear data
|
clearLoginError();
|
||||||
$(".radios").change(function() {
|
updateUIWithCATData(data);
|
||||||
if ($(".radios option:selected").val() == 0) {
|
});
|
||||||
$("#sat_name").val("");
|
};
|
||||||
$("#sat_mode").val("");
|
|
||||||
$("#frequency").val("");
|
// Handle login error display
|
||||||
$("#frequency_rx").val("");
|
const handleLoginError = () => {
|
||||||
$("#band_rx").val("");
|
$(".radio_cat_state").remove();
|
||||||
$("#selectPropagation").val($("#selectPropagation option:first").val());
|
if ($('.radio_login_error').length === 0) {
|
||||||
$(".radio_timeout_error").remove();
|
$('.qso_panel').prepend(
|
||||||
|
'<div class="alert alert-danger radio_login_error" role="alert">' +
|
||||||
|
'<i class="fas fa-broadcast-tower"></i> You\'re not logged in. ' +
|
||||||
|
'Please <a href="<?php echo base_url(); ?>">login</a></div>'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clear login error
|
||||||
|
const clearLoginError = () => {
|
||||||
|
$(".radio_login_error").remove();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Update UI elements with CAT data
|
||||||
|
const updateUIWithCATData = (data) => {
|
||||||
|
cat2UI($('#frequency'), data.frequency, false, true, (d) => {
|
||||||
|
$("#band").val(frequencyToBand(d));
|
||||||
|
});
|
||||||
|
cat2UI($('#frequency_rx'), data.frequency_rx, false, true, (d) => {
|
||||||
|
$("#band_rx").val(frequencyToBand(d));
|
||||||
|
});
|
||||||
|
cat2UI($('.mode'), data.mode, false, false, () => {
|
||||||
|
setRst($(".mode").val());
|
||||||
|
});
|
||||||
|
cat2UI($('#sat_name'), data.satname, false, false);
|
||||||
|
cat2UI($('#sat_mode'), data.satmode, false, false);
|
||||||
|
cat2UI($('#transmit_power'), data.power, false, false);
|
||||||
|
cat2UI($('#selectPropagation'), data.prop_mode, false, false);
|
||||||
|
|
||||||
|
handleCATTimeout(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle CAT timeout
|
||||||
|
const handleCATTimeout = (data) => {
|
||||||
|
const minutes = Math.floor(<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?> / 60);
|
||||||
|
|
||||||
|
if (data.updated_minutes_ago > minutes) {
|
||||||
|
$(".radio_cat_state").remove();
|
||||||
|
const errorText = `Radio connection timed-out: ${$('select.radios option:selected').text()} data is ${data.updated_minutes_ago} minutes old.`;
|
||||||
|
if ($('.radio_timeout_error').length === 0) {
|
||||||
|
$('#radio_status').prepend(
|
||||||
|
`<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> ${errorText}</div>`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$('.radio_timeout_error').html(errorText);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$(".radio_timeout_error").remove();
|
||||||
|
updateCATStatusDisplay(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Update the status display
|
||||||
|
const updateCATStatusDisplay = (data) => {
|
||||||
|
let text = `<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> ${(Math.round(parseInt(data.frequency) / 100) / 10000).toFixed(4)} MHz`;
|
||||||
|
if (data.mode) text += `<span style="margin-left:10px"></span>${data.mode}`;
|
||||||
|
if (data.power && data.power !== 0) text += `<span style="margin-left:10px"></span>${data.power} W`;
|
||||||
|
|
||||||
|
let ptext = '';
|
||||||
|
if (data.prop_mode) {
|
||||||
|
ptext = data.prop_mode;
|
||||||
|
if (data.prop_mode === 'SAT') ptext += ` ${data.satname}`;
|
||||||
|
}
|
||||||
|
if (data.frequency_rx && data.frequency_rx !== 0) {
|
||||||
|
ptext += `<span style="margin-left:10px"></span><b>RX:</b> ${(Math.round(parseInt(data.frequency_rx) / 1000) / 1000).toFixed(3)} MHz`;
|
||||||
|
}
|
||||||
|
if (ptext) text += `<span style="margin-left:10px"></span>(${ptext})`;
|
||||||
|
|
||||||
|
if (!$('#radio_cat_state').length) {
|
||||||
|
$('#radio_status').prepend(
|
||||||
|
`<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">${text}</div></div>`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$('#radio_cat_state').html(text);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reset UI when no radio is selected
|
||||||
|
const resetUI = () => {
|
||||||
|
$("#sat_name, #sat_mode, #frequency, #frequency_rx, #band_rx").val("");
|
||||||
|
$("#selectPropagation").val($("#selectPropagation option:first").val());
|
||||||
|
$(".radio_timeout_error").remove();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Event listeners
|
||||||
|
$(document).ready(() => {
|
||||||
|
// Update frequency every three seconds for the selected radio
|
||||||
|
setInterval(() => {
|
||||||
|
const selectedRadioID = $('select.radios option:selected').val();
|
||||||
|
if (selectedRadioID !== '0') {
|
||||||
|
updateFromCAT(selectedRadioID);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
// Trigger updateFromCAT when any <select> with class 'radios' changes
|
||||||
|
$('.radios').on('change', function() {
|
||||||
|
const selectedRadioID = $(this).val();
|
||||||
|
if (selectedRadioID === '0') {
|
||||||
|
resetUI();
|
||||||
|
} else {
|
||||||
|
updateFromCAT(selectedRadioID);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
// Synchronize the two selects
|
||||||
|
$('.radios').on('change', function () {
|
||||||
|
const selectedValue = $(this).val(); // Get the selected value
|
||||||
|
$('.radios').not(this).val(selectedValue); // Update other selects to match
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if ($this->uri->segment(1) == "logbook" && $this->uri->segment(2) == "view") { ?>
|
<?php if ($this->uri->segment(1) == "logbook" && $this->uri->segment(2) == "view") { ?>
|
||||||
|
|
|
||||||
文件差异内容过多而无法显示
加载差异
正在加载…
在新工单中引用