Skip to content

Commit 386e87d

Browse files
feat: Enhance RconServerStatus to support onUpdated callback and improve map highlighting functionality
1 parent fbd0045 commit 386e87d

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/XtremeIdiots.Portal.Web/Views/ServerAdmin/ServerDetail.cshtml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@
467467
antiForgeryToken: antiForgeryToken,
468468
mapNameSelector: '#sd-currentMapName',
469469
mapImageSelector: '#sd-currentMapImage',
470-
playerCountSelector: '#sd-playerCount'
470+
playerCountSelector: '#sd-playerCount',
471+
onUpdated: highlightCurrentMap
471472
});
472473
RconPlayers.init({ serverId: serverId, antiForgeryToken: antiForgeryToken, tableSelector: '#sd-playersTable' });
473474
RconMapControl.init({
@@ -541,7 +542,12 @@
541542
// Highlight current map in the rotation carousel
542543
function highlightCurrentMap() {
543544
var mapName = $('#sd-currentMapName').text().trim();
544-
if (!mapName) return;
545+
546+
// Clear existing highlights
547+
$('#sd-mapRotationCarousel .map-card').removeClass('border border-success border-2 rounded');
548+
$('#sd-mapRotationCarousel .map-card .map-card-title .badge.bg-success').remove();
549+
550+
if (!mapName || mapName === 'Loading...' || mapName === 'Unknown') return;
545551
546552
$('#sd-mapRotationCarousel .map-card').each(function() {
547553
var btn = $(this).find('.load-map-btn');

src/XtremeIdiots.Portal.Web/wwwroot/js/rcon-server-status.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ var RconServerStatus = (function () {
1111
var _refreshEnabled = true;
1212
var _lastRefreshTime = new Date();
1313
var _selectors = {};
14+
var _onUpdated = null;
1415

1516
function init(options) {
1617
_serverId = options.serverId;
1718
_antiForgeryToken = options.antiForgeryToken;
19+
_onUpdated = options.onUpdated || null;
1820
_selectors = {
1921
mapName: options.mapNameSelector || '#currentMapName',
2022
mapImage: options.mapImageSelector || '#currentMapImage',
@@ -27,7 +29,7 @@ var RconServerStatus = (function () {
2729
};
2830
}
2931

30-
function load() {
32+
function load(callback) {
3133
if (!_refreshEnabled || !_serverId) return;
3234

3335
$(_selectors.loadingIndicator).show();
@@ -45,11 +47,14 @@ var RconServerStatus = (function () {
4547
}
4648
$(_selectors.loadingIndicator).hide();
4749
$(_selectors.contentContainer).css('opacity', '1');
50+
if (typeof _onUpdated === 'function') _onUpdated();
51+
if (typeof callback === 'function') callback();
4852
},
4953
error: function () {
5054
$(_selectors.statusIndicator).removeClass('bg-success').addClass('bg-danger').text('Error');
5155
$(_selectors.loadingIndicator).hide();
5256
$(_selectors.contentContainer).css('opacity', '1');
57+
if (typeof callback === 'function') callback();
5358
}
5459
});
5560
}

0 commit comments

Comments
 (0)