mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Started working on ajax call for download
This commit is contained in:
@@ -111,25 +111,39 @@ class Clublog extends CI_Controller
|
||||
$data['next_run_up'] = $this->cron_model->get_next_run("clublog_upload");
|
||||
$data['next_run_down'] = $this->cron_model->get_next_run("clublog_download");
|
||||
|
||||
$footerData = [];
|
||||
$footerData['scripts'] = [
|
||||
'assets/js/sections/clublog.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/clublog.js")),
|
||||
];
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('clublog/export');
|
||||
$this->load->view('interface_assets/footer');
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
|
||||
public function uploadlog($station_id) {
|
||||
public function uploadlog() {
|
||||
$this->load->model('clublog_model');
|
||||
|
||||
$clean_station_id = $this->security->xss_clean($this->input->post('station_id'));
|
||||
|
||||
$users = $this->clublog_model->get_clublog_users($this->session->userdata('user_id'));
|
||||
|
||||
if (!empty($users)) {
|
||||
$stationinfo = $this->clublog_model->stations_with_clublog_enabled();
|
||||
$info = $stationinfo->result();
|
||||
$data['info'] = $info;
|
||||
foreach ($users as $user) {
|
||||
$r = $this->clublog_model->uploadUser($user->user_id, $user->user_clublog_name, $user->user_clublog_password, $station_id);
|
||||
$data['status'] = 'OK';
|
||||
$data['infomessage'] = $this->clublog_model->uploadUser($user->user_id, $user->user_clublog_name, $user->user_clublog_password, $clean_station_id);
|
||||
}
|
||||
} else {
|
||||
$r = __("No user has configured Clublog.");
|
||||
$data['status'] = 'Error';
|
||||
$data['errormessages']= __("No user has configured Clublog.");
|
||||
$data['info'] = '';
|
||||
}
|
||||
|
||||
echo $r;
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public function importlog() {
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
echo '<td id ="modcount'.$station->station_id.'">' . $station->modcount . '</td>';
|
||||
echo '<td id ="notcount'.$station->station_id.'">' . $station->notcount . '</td>';
|
||||
echo '<td id ="totcount'.$station->station_id.'">' . $station->totcount . '</td>';
|
||||
if (!($this->config->item('disable_manual_clublog'))) {
|
||||
echo '<td><a href="' . site_url('clublog/uploadlog') . '/' . $station->station_id . '" class="btn btn-sm btn-primary"><i class="fas fa-cloud-upload-alt"></i> ' . __("Upload") .'</a></td>';
|
||||
} else {
|
||||
echo '<td> </td>';
|
||||
}
|
||||
if (!($this->config->item('disable_manual_clublog'))) {
|
||||
echo '<td><button id="clublogUpload" type="button" name="clublogUpload" class="btn btn-primary btn-sm ld-ext-right ld-ext-right-'.$station->station_id.'" onclick="ExportClublog('. $station->station_id .')"><i class="fas fa-cloud-upload-alt"></i> ' . __("Upload") . '<div class="ld ld-ring ld-spin"></div></button></td>';
|
||||
} else {
|
||||
echo '<td> </td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></table>';
|
||||
|
||||
31
assets/js/sections/clublog.js
Normal file
31
assets/js/sections/clublog.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function ExportClublog(station_id) {
|
||||
if ($(".alert").length > 0) {
|
||||
$(".alert").remove();
|
||||
}
|
||||
if ($(".errormessages").length > 0) {
|
||||
$(".errormessages").remove();
|
||||
}
|
||||
$(".ld-ext-right-"+station_id).addClass('running');
|
||||
$(".ld-ext-right-"+station_id).prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/clublog/uploadlog',
|
||||
type: 'post',
|
||||
data: {'station_id': station_id},
|
||||
success: function (data) {
|
||||
$(".ld-ext-right-"+station_id).removeClass('running');
|
||||
$(".ld-ext-right-"+station_id).prop('disabled', false);
|
||||
if (data.status == 'OK') {
|
||||
$.each(data.info, function(index, value){
|
||||
$('#modcount'+value.station_id).html(value.modcount);
|
||||
$('#notcount'+value.station_id).html(value.notcount);
|
||||
$('#totcount'+value.station_id).html(value.totcount);
|
||||
});
|
||||
$(".card-body").append('<div class="alert alert-success" role="alert">' + data.infomessage + '</div>');
|
||||
}
|
||||
else {
|
||||
$(".card-body").append('<div class="alert alert-danger" role="alert">' + data.info + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user