[Advanced search] Adif export for search result.

这个提交包含在:
Andreas 2021-09-23 20:18:47 +02:00
父节点 4cfc4451e6
当前提交 915a470d8c
共有 3 个文件被更改,包括 305 次插入255 次删除

查看文件

@ -50,9 +50,25 @@ class Search extends CI_Controller {
}
function json_result() {
if(isset($_POST['search'])) {
$json = $_POST['search'];
$result = $this->fetchQueryResult($_POST['search']);
echo json_encode($result->result_array());
} else {
echo "Noooooooob";
}
}
function export_to_adif() {
if(isset($_POST['search'])) {
$data['qsos'] = $this->fetchQueryResult($_POST['search']);
$this->load->view('adif/data/exportall', $data);
} else {
echo "Noooooooob";
}
}
function fetchQueryResult($json) {
$search_items = json_decode($json, true);
@ -301,11 +317,8 @@ class Search extends CI_Controller {
}
}
$this->db->order_by('COL_TIME_ON', 'DESC');
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$query = $this->db->get($this->config->item('table_name'));
echo json_encode($query->result_array());
} else {
echo "Noooooooob";
}
return $query;
}
}

查看文件

@ -85,6 +85,41 @@ $(".search-results-box").hide();
]
});
$("#btn-export").on("click", function(){
var result = $('#builder').queryBuilder('getRules');
if (!$.isEmptyObject(result)) {
// Data to post
data = {
search: JSON.stringify(result, null, 2), temp: "testvar"
};
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
var a;
if (xhttp.readyState === 4 && xhttp.status === 200) {
// Trick for making downloadable link
a = document.createElement('a');
a.href = window.URL.createObjectURL(xhttp.response);
// Give filename you wish to download
a.download = "advanced_search_export.adi";
a.style.display = 'none';
document.body.appendChild(a);
a.click();
}
};
// Post data to URL which handles post request
xhttp.open("POST", "<?php echo site_url('search/export_to_adif');?>", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// You should set responseType as blob for binary responses
xhttp.responseType = 'blob';
xhttp.send("search=" + JSON.stringify(result, null, 2));
}
});
$('#btn-get').on('click', function() {
var result = $('#builder').queryBuilder('getRules');
if (!$.isEmptyObject(result)) {

查看文件

@ -32,6 +32,8 @@
<button class="btn btn-primary" id="btn-get">Search</button>
<button class="btn btn-warning" id="btn-reset">Reset</button>
<button class="btn btn-primary" id="btn-export">Export to ADIF</button>
</p>
<span class="badge badge-info">Info</span> You can find out how to use the <a href="https://github.com/magicbug/Cloudlog/wiki/Search----Filter" target="_blank">search filter functions</a> in the wiki.</a>