Added JS and prepared view

This commit is contained in:
int2001
2025-06-24 15:31:37 +00:00
parent bf6ae4ec40
commit 5774bc621b
4 changed files with 148 additions and 8 deletions

View File

@@ -57,12 +57,10 @@ class Usermodes extends CI_Model {
function activate($id) {
// Clean ID
$clean_id = $this->security->xss_clean($id);
$data = array(
'active' => '1',
);
$this->db->where('id', $clean_id);
$this->db->update('adif_modes', $data);
return true;
$options_object = $this->user_options_model->get_options('usermodes', array('option_name' => 'enabled_usermodes', 'option_key' => 'json_modes'))->result();
$usermodes = json_decode($options_object[0]->option_value ?? '[]');
$mode2act=$this->mode($id)->result()->mode.'/'.($this->mode($id)->result()->submode ?? '');
return $mode2act;
}
function deactivate($id) {

View File

@@ -2348,6 +2348,10 @@ $('#sats').change(function(){
<?php } ?>
<?php if ($this->uri->segment(1) == "usermode") { ?>
<script src="<?php echo base_url(); ?>assets/js/sections/usermode.js"></script>
<?php } ?>
<?php if ($this->uri->segment(1) == "mode") { ?>
<script src="<?php echo base_url(); ?>assets/js/sections/mode.js"></script>
<?php } ?>

View File

@@ -62,8 +62,6 @@
</tbody>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th><---</th>

View File

@@ -0,0 +1,140 @@
$('.modetable').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "500px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
"language": {
url: getDataTablesLanguageUrl(),
},
initComplete: function () {
this.api()
.columns('.select-filter')
.every(function () {
var column = this;
var select = $('<select class="form-select"><option value=""></option></select>')
.appendTo($(column.footer()).empty())
.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex($(this).val());
column.search(val ? '^' + val + '$' : '', true, false).draw();
});
column
.data()
.unique()
.sort()
.each(function (d, j) {
select.append('<option value="' + d + '">' + d + '</option>');
});
});
},
});
function deactivateMode(modeid) {
$.ajax({
url: base_url + 'index.php/mode/deactivate',
type: 'post',
data: { 'id': modeid },
success: function (html) {
$(".mode_" + modeid).text(lang_mode_not_active);
$('.btn_' + modeid).html(lang_activate_mode);
$('.btn_' + modeid).removeClass('btn-secondary');
$('.btn_' + modeid).addClass('btn-primary');
$('.btn_' + modeid).attr('onclick', 'activateMode(' + modeid + ')')
}
});
}
function activateMode(modeid) {
$.ajax({
url: base_url + 'index.php/mode/activate',
type: 'post',
data: { 'id': modeid },
success: function (html) {
$('.mode_' + modeid).text(lang_mode_active);
$('.btn_' + modeid).html(lang_deactivate_mode);
$('.btn_' + modeid).removeClass('btn-primary');
$('.btn_' + modeid).addClass('btn-secondary');
$('.btn_' + modeid).attr('onclick', 'deactivateMode(' + modeid + ')')
}
});
}
function deleteMode(id, mode) {
BootstrapDialog.confirm({
title: lang_general_word_danger,
message: lang_mode_deletion_confirm + ' ' + mode,
type: BootstrapDialog.TYPE_DANGER,
closable: true,
draggable: true,
btnOKClass: 'btn-danger',
btnCancelLabel: lang_general_word_cancel,
btnOKLabel: lang_general_word_ok,
callback: function (result) {
if (result) {
$.ajax({
url: base_url + 'index.php/mode/delete',
type: 'post',
data: {
'id': id
},
success: function (data) {
$(".mode_" + id).parent("tr:first").remove(); // removes mode from table
}
});
}
}
});
}
function activateAllModes() {
BootstrapDialog.confirm({
title: lang_general_word_danger,
message: lang_active_all_confirm,
type: BootstrapDialog.TYPE_DANGER,
closable: true,
draggable: true,
btnOKClass: 'btn-danger',
btnCancelLabel: lang_general_word_cancel,
btnOKLabel: lang_general_word_ok,
callback: function (result) {
if (result) {
$.ajax({
url: base_url + 'index.php/mode/activateall',
type: 'post',
success: function (data) {
location.reload();
}
});
}
}
});
}
function deactivateAllModes() {
BootstrapDialog.confirm({
title: lang_general_word_danger,
message: lang_deactive_all_confirm,
type: BootstrapDialog.TYPE_DANGER,
closable: true,
draggable: true,
btnOKClass: 'btn-danger',
btnCancelLabel: lang_general_word_cancel,
btnOKLabel: lang_general_word_ok,
callback: function (result) {
if (result) {
$.ajax({
url: base_url + 'index.php/mode/deactivateall',
type: 'post',
success: function (data) {
location.reload();
}
});
}
}
});
}