user-login-log.page.js 1.06 KB
require('admin/user-login-log.page.css');
require('bootstrap-daterangepicker');
require('bootpag/lib/jquery.bootpag.min');
const moment = require('moment');

function bind_date_picker() {
    if (typeof ($.fn.daterangepicker) === 'undefined') {
        return;
    }

    $('#time').daterangepicker({
        timePicker: true,
        timePickerIncrement: 30,
        startDate: moment().add(-30, 'day'),
        endDate: moment(),
        locale: {
            format: 'YYYY-MM-DD HH:mm:ss'
        }
    });
}
function bind_button_event() {
    $('.btn-export').click(() => {
        const url = $('#url').val();
        const time = $('#time').val();
        const timeArray = time.split(' - ');
        let startTime, endTime;

        if (timeArray.length === 2) {
            startTime = moment(timeArray[0]).valueOf();
            endTime = moment(timeArray[1]).valueOf();
        }

        window.open(`/admin/user/exportUserLoginLog?startTime=${startTime}&endTime=${endTime}&url=${url}`, '_blank');
    });
}

(() => {
    bind_date_picker();
    bind_button_event();
})();