2018-04-09 23:33:42 -04:00
|
|
|
|
function hideLoader() {
|
|
|
|
|
$('.layout-loading-icon').fadeOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showLoader() {
|
|
|
|
|
$('.layout-loading-icon').attr('style', 'visibility:visible');
|
|
|
|
|
$('.layout-loading-icon').removeClass('text-danger');
|
2018-05-04 00:22:10 -04:00
|
|
|
|
$('.layout-loading-icon').removeClass('text-muted');
|
2018-04-09 23:33:42 -04:00
|
|
|
|
$('.layout-loading-icon').fadeIn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function errorLoader() {
|
|
|
|
|
$('.layout-loading-icon').addClass('text-danger');
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-04 00:22:10 -04:00
|
|
|
|
function staleLoader() {
|
|
|
|
|
$('.layout-loading-icon').addClass('text-muted');
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 23:33:42 -04:00
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
hideLoader();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* hide loader when clicking
|
|
|
|
|
*/
|
|
|
|
|
$(document).click(function (e) {
|
2018-09-02 17:59:27 -04:00
|
|
|
|
//hideLoader()
|
2018-04-09 23:33:42 -04:00
|
|
|
|
});
|
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
/*
|
|
|
|
|
* handle action modal
|
|
|
|
|
*/
|
|
|
|
|
$('.profile-action').click(function (e) {
|
|
|
|
|
const actionType = $(this).data('action');
|
2019-07-13 21:45:25 -04:00
|
|
|
|
const actionId = $(this).data('action-id');
|
2019-07-19 15:54:39 -04:00
|
|
|
|
const actionIdKey = actionId === undefined ? '' : '?id=' + actionId;
|
2019-07-13 21:45:25 -04:00
|
|
|
|
$.get('/Action/' + actionType + 'Form' + actionIdKey)
|
2018-04-04 15:38:34 -04:00
|
|
|
|
.done(function (response) {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeOut('fast');
|
|
|
|
|
$('#actionModal .modal-body-content').html(response);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$('#actionModal').modal();
|
2019-07-16 16:27:19 -04:00
|
|
|
|
$('#actionModal').trigger('action_form_received', actionType);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
2018-09-02 17:59:27 -04:00
|
|
|
|
$('#actionModal .modal-message').text('Error — ' + error);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$('#actionModal').modal();
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeIn('fast');
|
2018-04-04 15:38:34 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* handle action submit
|
|
|
|
|
*/
|
|
|
|
|
$(document).on('submit', '.action-form', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
$(this).append($('#target_id input'));
|
|
|
|
|
const data = $(this).serialize();
|
2018-04-09 23:33:42 -04:00
|
|
|
|
showLoader();
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$.get($(this).attr('action') + '/?' + data)
|
|
|
|
|
.done(function (response) {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
hideLoader();
|
2018-04-04 15:38:34 -04:00
|
|
|
|
// success without content
|
|
|
|
|
if (response.length === 0) {
|
|
|
|
|
location.reload();
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeOut('fast');
|
|
|
|
|
$('#actionModal .modal-body-content').html(response);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$('#actionModal').modal();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
errorLoader();
|
|
|
|
|
hideLoader();
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if ($('#actionModal .modal-message').text.length > 0) {
|
|
|
|
|
$('#actionModal .modal-message').fadeOut('fast');
|
|
|
|
|
}
|
|
|
|
|
if (jqxhr.status === 401) {
|
|
|
|
|
$('#actionModal .modal-message').text('Invalid login credentials');
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').text('Error — ' + error);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeIn('fast');
|
2018-04-04 15:38:34 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
2019-07-16 16:27:19 -04:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* handle loading of recent clients
|
|
|
|
|
*/
|
|
|
|
|
$('#actionModal').off('action_form_received');
|
|
|
|
|
$('#actionModal').on('action_form_received', function (e, actionType) {
|
2019-07-19 15:54:39 -04:00
|
|
|
|
if (actionType === 'RecentClients') {
|
2019-07-16 16:27:19 -04:00
|
|
|
|
const ipAddresses = $('.client-location-flag');
|
|
|
|
|
$.each(ipAddresses, function (index, address) {
|
|
|
|
|
$.get('https://ip2c.org/' + $(address).data('ip'), function (result) {
|
|
|
|
|
const countryCode = result.split(';')[1].toLowerCase();
|
2019-07-19 15:54:39 -04:00
|
|
|
|
if (countryCode !== 'zz') {
|
2019-07-19 11:33:00 -04:00
|
|
|
|
$(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`);
|
|
|
|
|
}
|
2019-07-16 16:27:19 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-04-04 15:38:34 -04:00
|
|
|
|
});
|