Skip to content

Commit b598821

Browse files
feat: Update Connected Players table columns and improve user profile link rendering
1 parent e84aab8 commit b598821

2 files changed

Lines changed: 32 additions & 18 deletions

File tree

src/XtremeIdiots.Portal.Web/Views/ConnectedPlayers/Index.cshtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
<tr>
4646
<th scope="col">Game</th>
4747
<th scope="col">Username</th>
48-
<th scope="col">Player Id</th>
49-
<th scope="col">Profile Id</th>
48+
<th scope="col">Website Profile</th>
5049
<th scope="col">Method</th>
5150
<th scope="col">Status</th>
5251
<th scope="col" class="table-date-col">Linked At</th>

src/XtremeIdiots.Portal.Web/wwwroot/js/connected-players-index.js

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,25 @@ $(document).ready(function () {
1313
}
1414

1515
function renderUserProfileLink(userProfileId) {
16-
const encoded = htmlEncode(userProfileId);
17-
return '<a href="/User/ManageProfile/' + encoded + '">' + encoded + '</a>';
16+
const routeValue = encodeURIComponent(userProfileId ?? '');
17+
return '<a href="/User/ManageProfile/' + routeValue + '">Link</a>';
18+
}
19+
20+
function renderGameIcon(gameType) {
21+
return gameTypeIcon(htmlEncode(gameType));
22+
}
23+
24+
function renderUsernameLink(username, playerId) {
25+
const routeValue = encodeURIComponent(playerId ?? '');
26+
const coloredName = typeof CodColors !== 'undefined' && CodColors && typeof CodColors.renderSafe === 'function'
27+
? CodColors.renderSafe(username)
28+
: htmlEncode(username);
29+
30+
if (!playerId) {
31+
return coloredName;
32+
}
33+
34+
return '<a href="/Players/Details/' + routeValue + '">' + coloredName + '</a>';
1835
}
1936

2037
function renderStatusBadge(isActive) {
@@ -59,12 +76,12 @@ $(document).ready(function () {
5976
autoWidth: false,
6077
stateSave: true,
6178
stateSaveParams: function (settings, data) {
62-
data._connectedPlayersStructureVersion = 1;
79+
data._connectedPlayersStructureVersion = 2;
6380
data.filterGameType = gameSel?.value || '';
6481
data.filterStatus = statusSel?.value || '';
6582
},
6683
stateLoadParams: function (settings, data) {
67-
if (data._connectedPlayersStructureVersion !== 1) {
84+
if (data._connectedPlayersStructureVersion !== 2) {
6885
return false;
6986
}
7087

@@ -77,7 +94,7 @@ $(document).ready(function () {
7794
}
7895
},
7996
pageLength: 25,
80-
order: [[6, 'desc']],
97+
order: [[5, 'desc']],
8198
ajax: {
8299
url: '/ConnectedPlayers/GetConnectedPlayersAjax',
83100
dataSrc: 'data',
@@ -105,18 +122,16 @@ $(document).ready(function () {
105122
columnDefs: [
106123
{ targets: 0, responsivePriority: 3 },
107124
{ targets: 1, responsivePriority: 1 },
108-
{ targets: 2, responsivePriority: 5 },
109-
{ targets: 3, responsivePriority: 4 },
110-
{ targets: 4, responsivePriority: 8 },
111-
{ targets: 5, responsivePriority: 2 },
112-
{ targets: 6, responsivePriority: 6 },
113-
{ targets: 7, responsivePriority: 9 },
114-
{ targets: 8, responsivePriority: 7, orderable: false, searchable: false }
125+
{ targets: 2, responsivePriority: 4 },
126+
{ targets: 3, responsivePriority: 8 },
127+
{ targets: 4, responsivePriority: 2 },
128+
{ targets: 5, responsivePriority: 6 },
129+
{ targets: 6, responsivePriority: 9 },
130+
{ targets: 7, responsivePriority: 7, orderable: false, searchable: false }
115131
],
116132
columns: [
117-
{ data: 'gameType', name: 'gameType', orderable: true },
118-
{ data: 'username', name: 'username', orderable: true, render: function (data) { return htmlEncode(data); } },
119-
{ data: 'playerId', name: 'playerId', orderable: false, render: function (data) { return '<code>' + htmlEncode(data) + '</code>'; } },
133+
{ data: 'gameType', name: 'gameType', orderable: true, render: function (data) { return renderGameIcon(data); } },
134+
{ data: 'username', name: 'username', orderable: true, render: function (data, type, row) { return renderUsernameLink(data, row.playerId); } },
120135
{ data: 'userProfileId', name: 'userProfileId', orderable: false, render: function (data) { return renderUserProfileLink(data); } },
121136
{ data: 'linkMethod', name: 'linkMethod', orderable: true, render: function (data) { return htmlEncode(data); } },
122137
{ data: 'isActive', name: 'isActive', orderable: true, render: function (data, type, row) { return renderStatusBadge(row.isActive); } },
@@ -210,7 +225,7 @@ $(document).ready(function () {
210225

211226
if (changed) {
212227
table.column(0).search('', true, false);
213-
table.column(5).search('', true, false);
228+
table.column(4).search('', true, false);
214229
table.page('first');
215230
table.draw(false);
216231
}

0 commit comments

Comments
 (0)