show login token for longer period

This commit is contained in:
RaidMax 2022-04-22 16:56:29 -05:00
parent 0a8e415af8
commit 5b7f5160b2
5 changed files with 24 additions and 26 deletions

View File

@ -61,6 +61,6 @@
} }
<div class="ml-auto"> <div class="ml-auto">
<button type="submit" class="btn btn-primary">@Model.ActionButtonLabel</button> <button type="submit" class="btn btn-primary">@Model.ActionButtonLabel</button>
<a href="#" class="btn mr-5" role="button">Close</a> <a href="#" class="btn mr-5" role="button" onclick="halfmoon.toggleModal('actionModal');">Close</a>
</div> </div>
</form> </form>

View File

@ -298,6 +298,17 @@
}); });
} }
if (Model.LevelInt < (int)ViewBag.User.Level && Model.Online)
{
menuItems.Items.Add(new SideContextMenuItem
{
Title = "Kick",
IsButton = true,
Reference = "kick",
Icon = "oi-circle-x",
});
}
if ((Model.LevelInt < (int)ViewBag.User.Level && !Model.HasActivePenalty || isTempBanned) && ViewBag.Authorized) if ((Model.LevelInt < (int)ViewBag.User.Level && !Model.HasActivePenalty || isTempBanned) && ViewBag.Authorized)
{ {
menuItems.Items.Add(new SideContextMenuItem menuItems.Items.Add(new SideContextMenuItem

View File

@ -139,12 +139,10 @@
<partial name="_LeftNavBar"/> <partial name="_LeftNavBar"/>
<!-- End Main Modal -->
<div id="target_id"> <div id="target_id">
@await RenderSectionAsync("targetid", required: false) @await RenderSectionAsync("targetid", required: false)
</div> </div>
<!-- End Action Modal -->
<div class="container-fluid content-wrapper"> <div class="container-fluid content-wrapper">
<div id="mainLoadingBar" class="progress-bar position-absolute flex-fill position-fixed z-30" style="display: none"> <div id="mainLoadingBar" class="progress-bar position-absolute flex-fill position-fixed z-30" style="display: none">
<div class="progress-bar-value"></div> <div class="progress-bar-value"></div>

View File

@ -134,7 +134,7 @@
<span class="name">@ViewBag.Localization["WEBFRONT_ACTION_RECENT_CLIENTS"]</span> <span class="name">@ViewBag.Localization["WEBFRONT_ACTION_RECENT_CLIENTS"]</span>
</a> </a>
</has-permission> </has-permission>
<a class="sidebar-link profile-action" href="#actionModal" data-action="GenerateLoginToken" title="@ViewBag.Localization["WEBFRONT_ACTION_TOKEN"]"> <a class="sidebar-link profile-action" href="#actionModal" data-action="GenerateLoginToken" data-response-duration="30000" title="@ViewBag.Localization["WEBFRONT_ACTION_TOKEN"]">
<i class="oi oi-key mr-5"></i> <i class="oi oi-key mr-5"></i>
<span class="name">@ViewBag.Localization["WEBFRONT_ACTION_TOKEN"]</span> <span class="name">@ViewBag.Localization["WEBFRONT_ACTION_TOKEN"]</span>
</a> </a>

View File

@ -60,6 +60,7 @@ function escapeHtml (string) {
$(document).ready(function () { $(document).ready(function () {
let toastMessage = getUrlParameter('toastMessage'); let toastMessage = getUrlParameter('toastMessage');
const duration = parseInt(getUrlParameter('duration'));
if (toastMessage) { if (toastMessage) {
toastMessage = unescape(toastMessage); toastMessage = unescape(toastMessage);
@ -71,23 +72,28 @@ $(document).ready(function () {
content: toastMessage, content: toastMessage,
title: 'Success', title: 'Success',
alertType: 'alert-success', alertType: 'alert-success',
fillType: 'filled' fillType: 'filled',
timeShown: duration
}); });
} }
hideLoader(); hideLoader();
$(document).off('click', '.profile-action'); $(document).off('click', '.profile-action');
$(document).on('click', '.profile-action', function () { $(document).on('click', '.profile-action', function (e) {
e.preventDefault();
const actionType = $(this).data('action'); const actionType = $(this).data('action');
const actionId = $(this).data('action-id'); const actionId = $(this).data('action-id');
const responseDuration = $(this).data('response-duration') || 5000;
const actionIdKey = actionId === undefined ? '' : `?id=${actionId}`; const actionIdKey = actionId === undefined ? '' : `?id=${actionId}`;
showLoader(); showLoader();
$.get(`/Action/${actionType}Form/${actionIdKey}`) $.get(`/Action/${actionType}Form/${actionIdKey}`)
.done(function (response) { .done(function (response) {
$('#actionModal .modal-message').fadeOut('fast'); $('#actionModal .modal-message').fadeOut('fast')
$('#actionModal').attr('data-response-duration', responseDuration);
$('#actionModalContent').html(response); $('#actionModalContent').html(response);
hideLoader(); hideLoader();
halfmoon.toggleModal('actionModal');
}) })
.fail(function (jqxhr, textStatus, error) { .fail(function (jqxhr, textStatus, error) {
halfmoon.initStickyAlert({ halfmoon.initStickyAlert({
@ -108,6 +114,7 @@ $(document).ready(function () {
const modal = $('#actionModal'); const modal = $('#actionModal');
const shouldRefresh = modal.data('should-refresh', modal.find('.refreshable').length !== 0); const shouldRefresh = modal.data('should-refresh', modal.find('.refreshable').length !== 0);
const data = $(this).serialize(); const data = $(this).serialize();
const duration = modal.data('response-duration');
showLoader(); showLoader();
$.get($(this).attr('action') + '/?' + data) $.get($(this).attr('action') + '/?' + data)
@ -123,7 +130,7 @@ $(document).ready(function () {
} }
catch{} catch{}
if (shouldRefresh) { if (shouldRefresh) {
window.location = `${window.location.href.replace('#actionModal', '')}?toastMessage=${escape(message)}`; window.location = `${window.location.href.replace('#', '')}?toastMessage=${escape(message)}${duration ? `&duration=${duration}` : ''}`;
} }
else { else {
modal.modal(); modal.modal();
@ -164,22 +171,4 @@ $(document).ready(function () {
}); });
}); });
}); });
/*
* handle loading of recent clients
*/
$('#actionModal').off('action_form_received');
$('#actionModal').on('action_form_received', function (e, actionType) {
if (actionType === 'RecentClients') {
const ipAddresses = $('.client-location-flag');
$.each(ipAddresses, function (index, address) {
$.get(`https://get.geojs.io/v1/ip/country/${(address).data('ip')}.json`, function (result) {
const countryCode = result['country'].toLowerCase();
if (countryCode !== 'zz') {
$(address).css('background-image', `url('https://flagcdn.com/w80/${countryCode}.png')`);
}
});
});
}
});
}); });