mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Added bandedge deletion
This commit is contained in:
@@ -34,11 +34,16 @@ class Band extends CI_Controller {
|
||||
|
||||
$data['bands'] = $this->bands->get_all_bandedges_for_user();
|
||||
|
||||
$footerData = [];
|
||||
$footerData['scripts'] = [
|
||||
'assets/js/sections/bandedges.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/bandedges.js")),
|
||||
];
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = __("Bands");
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('bands/bandedges');
|
||||
$this->load->view('interface_assets/footer');
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
|
||||
public function create()
|
||||
@@ -184,4 +189,13 @@ class Band extends CI_Controller {
|
||||
$this->user_options_model->set_option('frequency', 'unit', array($band => $unit));
|
||||
$this->session->set_userdata('qrgunit_'.$band, $unit);
|
||||
}
|
||||
|
||||
public function deletebandedge() {
|
||||
$id = $this->input->post('id');
|
||||
$this->load->model('bands');
|
||||
$this->bands->deletebandedge($id);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('message' => 'OK'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,12 +109,34 @@ class Bands extends CI_Model {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$this->insert_band_edges_for_user();
|
||||
|
||||
$this->db->from('bandedges');
|
||||
$this->db->where('bandedges.userid', -1);
|
||||
|
||||
return $this->db->get()->result();
|
||||
}
|
||||
|
||||
function insert_band_edges_for_user() {
|
||||
// Get band edges from default user
|
||||
$this->db->from('bandedges');
|
||||
$this->db->where('bandedges.userid', -1);
|
||||
$result = $this->db->get()->result();
|
||||
|
||||
if ($result) {
|
||||
foreach($result as $edge) {
|
||||
$data = array(
|
||||
'frequencyfrom' => $edge->frequencyfrom,
|
||||
'frequencyto' => $edge->frequencyto,
|
||||
'mode' => $edge->mode,
|
||||
'userid' => $this->session->userdata('user_id')
|
||||
);
|
||||
$this->db->insert('bandedges', $data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function all() {
|
||||
return $this->bandslots;
|
||||
}
|
||||
@@ -426,6 +448,14 @@ class Bands extends CI_Model {
|
||||
|
||||
return $worked_slots;
|
||||
}
|
||||
|
||||
function deletebandedge($id) {
|
||||
// Clean ID
|
||||
$clean_id = $this->security->xss_clean($id);
|
||||
|
||||
// Delete Bandedge
|
||||
$this->db->delete('bandedges', array('id' => $clean_id, 'userid' => $this->session->userdata('user_id')));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
<tbody>
|
||||
<?php foreach ($bands as $band) { ?>
|
||||
<tr>
|
||||
<td style="text-align: center; vertical-align: middle;" ><?php echo $band->frequencyfrom;?></td>
|
||||
<td class="bandedge_<?php echo $band->id ?>" style="text-align: center; vertical-align: middle;" ><?php echo $band->frequencyfrom;?></td>
|
||||
<td style="text-align: center; vertical-align: middle;" ><?php echo $band->frequencyto;?></td>
|
||||
<td style="text-align: center; vertical-align: middle;" ><?php echo $band->mode;?></td>
|
||||
<td id="editButton" style="text-align: center; vertical-align: middle;"><button id="<?php echo $band->id ?>" class="btn btn-sm btn-success editBandEdge"><i class="fas fa-edit"></i></button></td>
|
||||
<td id="deleteButton" style="text-align: center; vertical-align: middle;"><button id="<?php echo $band->id; ?>'" class="deleteBandEdge btn btn-sm btn-danger"><i class="fas fa-trash-alt"></i></button></td>
|
||||
<td id="editButton" style="text-align: center; vertical-align: middle;"><button onclick="editBandEdgeDialog(<?php echo $band->id ?>)" id="<?php echo $band->id ?>" class="btn btn-sm btn-success"><i class="fas fa-edit"></i></button></td>
|
||||
<td id="deleteButton" style="text-align: center; vertical-align: middle;"><button id="<?php echo $band->id; ?>" class="deleteBandEdge btn btn-sm btn-danger" onclick="deleteBandEdge(<?php echo $band->id ?>)"><i class="fas fa-trash-alt"></i></button></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
86
assets/js/sections/bandedges.js
Normal file
86
assets/js/sections/bandedges.js
Normal file
@@ -0,0 +1,86 @@
|
||||
function editBandEdgeDialog(id) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/band/bandedgedit',
|
||||
type: 'post',
|
||||
data: {
|
||||
'id': id
|
||||
},
|
||||
success: function (html) {
|
||||
BootstrapDialog.show({
|
||||
title: lang_options_bands_edit,
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'edit-band-dialog',
|
||||
nl2br: false,
|
||||
message: html,
|
||||
buttons: [{
|
||||
label: lang_admin_close,
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveUpdatedBandEdge(form) {
|
||||
$(".alert").remove();
|
||||
if (form.band.value == "") {
|
||||
$('#edit_band_dialog').prepend('<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Please enter a band!</div>');
|
||||
}
|
||||
else {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/band/saveupdatedbandedge',
|
||||
type: 'post',
|
||||
data: {'id': form.id.value,
|
||||
'band': form.band.value,
|
||||
'bandgroup': form.bandgroup.value,
|
||||
'ssbqrg': form.ssbqrg.value,
|
||||
'dataqrg': form.dataqrg.value,
|
||||
'cwqrg': form.cwqrg.value
|
||||
},
|
||||
success: function (html) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteBandEdge(id) {
|
||||
BootstrapDialog.confirm({
|
||||
title: lang_general_word_danger,
|
||||
message: 'Are you sure you want to delete this band edge?',
|
||||
type: BootstrapDialog.TYPE_DANGER,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-danger',
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/band/deletebandedge',
|
||||
type: 'post',
|
||||
data: {
|
||||
'id': id
|
||||
},
|
||||
success: function (data) {
|
||||
$(".bandedge_" + id).parent("tr:first").remove(); // removes band from table
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveBandEdge(id) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/band/saveBandEdge',
|
||||
type: 'post',
|
||||
data: {'id': id,
|
||||
'frequencyfrom': $('#frequencyfrom').val(),
|
||||
'frequencyto': $('#frequencyto').val(),
|
||||
'mode': $('#mode').val()
|
||||
},
|
||||
success: function (html) {
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user