Merge branch 'bugfix/fixing-motd-issue' into 'dev'

Fixing issue 322

See merge request crafty-controller/crafty-4!705
This commit is contained in:
Iain Powrie 2024-02-02 22:05:22 +00:00
commit a28dadaa0e
17 changed files with 86 additions and 94 deletions

View File

@ -21,6 +21,7 @@
- Improve display for `th-TH` characters ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/703))
- Improve display of white text on **wssErrors** ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/703))
- Improve display of white text on **Buttons** ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/703))
- Fix dashboard motd issue #322 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/705))
### Lang
- Update `zh_CN, pl_PL, nl_BE, lv_LV, he_IL, fr_FR, de_DE, lol_EN` translations for `4.2.3` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/696))
- New `uk_UA, tr_TR, th_TH` translations for `4.2.3` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/696))

View File

@ -96,7 +96,7 @@ function initParser(input, output) {
var input = document.getElementById(input),
output = document.getElementById(output);
if (input != null && output != null) {
var parsed = parseStyle(input.innerHTML);
var parsed = parseStyle(input.innerText);
output.innerHTML = '';
output.appendChild(parsed);
}

View File

@ -287,8 +287,7 @@
data['lang']) }} <br />
{% if server['stats']['desc'] != 'False' %}
<div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{
server['stats']['desc'] }}</div> <br />
<div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</div> <br />
{% end %}
{% if server['stats']['version'] != 'False' %}
@ -554,6 +553,7 @@
display: none;
/* for Chrome, Safari, and Opera */
}
.gray {
color: gray !important;
}
@ -736,11 +736,11 @@
try {
console.log(`#server_desc_${server.getAttribute("data-serverId")}`)
$(`#server_desc_${server.getAttribute("data-serverId")}`).toggleClass("gray", server.getAttribute('data-count') === 'false')
if (server.getAttribute('data-count') === 'true'){
if (server.getAttribute('data-count') === 'true') {
all_total_players += parseInt(server.getAttribute('data-players'));
all_total_max_players += parseInt(server.getAttribute('data-max'));
}
} catch {
} catch {
console.log("Player totals are not of type int");
}
})
@ -1006,24 +1006,24 @@
async function sendOrder(id_string) {
const token = getCookie("_xsrf")
let res = await fetch(`/api/v2/users/@me`, {
method: 'PATCH',
headers: {
'X-XSRFToken': token
},
body: JSON.stringify({
method: 'PATCH',
headers: {
'X-XSRFToken': token
},
body: JSON.stringify({
server_order: id_string,
}),
});
let responseData = await res.json();
if (responseData.status === "ok") {
return
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
let responseData = await res.json();
if (responseData.status === "ok") {
return
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
}
// Inits the sortable
$("table#servers_table tbody")

View File

@ -5,42 +5,27 @@
<div class="row">
<div class="col-sm-4 mr-2">
{% if data['server_stats']['running'] %}
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status"
class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started">{{
data['server_stats']['started'] }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime">{{
translate('serverStats', 'errorCalculatingUptime', data['lang']) }}</span>
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-success">{{ translate('serverStats', 'online', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started">{{ data['server_stats']['started'] }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime">{{ translate('serverStats', 'errorCalculatingUptime', data['lang']) }}</span>
{% elif data['server_stats']['crashed'] %}
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-danger">
<i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang'])
}}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started"
class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed',
data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-danger">
<i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) }}</span>
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started" class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed',data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-danger"> <i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang']) }}</span>
{% else %}
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status"
class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started"
class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime"
class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span>
<b>{{ translate('serverStats', 'serverStatus', data['lang']) }}:</b> <span id="status" class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverStarted', data['lang']) }}:</b> <span id="started" class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span><br />
<b>{{ translate('serverStats', 'serverUptime', data['lang']) }}:</b> <span id="uptime" class="text-warning">{{ translate('serverStats', 'offline', data['lang']) }}</span>
{% end %}
<br>
<b>{{ translate('serverStats', 'serverTimeZone', data['lang']) }}:</b> <span class="text-info">{{
data['serverTZ'] }}</span>
<b>{{ translate('serverStats', 'serverTimeZone', data['lang']) }}:</b> <span class="text-info">{{ data['serverTZ'] }}</span>
</div>
<div class="col-sm-3 mr-2">
<b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> <span id="cpu">{{
data['server_stats']['cpu'] }}%</span> <br />
<b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> <span id="mem">{{
data['server_stats']['mem'] }}</span> <br />
<b>{{ translate('serverStats', 'cpuUsage', data['lang']) }}:</b> <span id="cpu">{{ data['server_stats']['cpu'] }}%</span> <br />
<b>{{ translate('serverStats', 'memUsage', data['lang']) }}:</b> <span id="mem">{{ data['server_stats']['mem'] }}</span> <br />
{% if data['server_stats']['int_ping_results'] %}
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">{{
data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}</span><br />
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">{{ data['server_stats']['online'] }} / {{ data['server_stats']['max'] }}</span><br />
{% else %}
<b>{{ translate('serverStats', 'players', data['lang']) }}:</b> <span id="players">0/0</span><br />
{% end %}
@ -48,17 +33,12 @@
<div class="col-sm-3 mr-2">
{% if data['server_stats']['version'] != 'False' %}
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{
data['server_stats']['version'] }}</span><br />
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd"
style="max-width: 10px; max-height: 10px" class="input_motd">{{ data['server_stats']['desc'] }}</span>
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ data['server_stats']['version'] }}</span><br />
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span id="input_motd" style="max-width: 10px; max-height: 10px" class="input_motd">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</span>
<br />
{% else %}
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{
translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span
style="max-width: 10px; max-height: 10px" id="input_motd" class="input_motd">{{ translate('serverStats',
'unableToConnect', data['lang']) }}</span> <br />
<b>{{ translate('serverStats', 'version', data['lang']) }}:</b> <span id="version">{{ translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
<b>{{ translate('serverStats', 'description', data['lang']) }}:</b> <span style="max-width: 10px; max-height: 10px" id="input_motd" class="input_motd">{{ translate('serverStats', 'unableToConnect', data['lang']) }}</span> <br />
{% end %}
<b>Server Type: <span class="text-info">{{data['server_stats']['server_type']}}</span></b>
@ -229,23 +209,23 @@
initParser('input_motd', 'input_motd');
let text = ""
let players = server.players_cache;
for(let i=0; i < players.length; i++){
text += `<tr id="playerItem-${ players[i]["name"] }" class="playerItem--" style="text-align: center;">`;
text += `<td class="no-scroll" style="overflow: scroll;"><strong>${players[i]["name"]}</strong></td>`;
if(players[i]["status"] === "Online"){
text += `<td><span class="text-success"><i class="fas fa-signal"></i> ${ players[i]['status'] }</span></td>`
}else{
text += `<td><span class="text-warning"><i class="fa-regular fa-circle-xmark"></i><span class="offline-status">&nbsp;${ players[i]['status'] }</span><span class="conn-break"> Last connection :<br> ${ players[i]['last_seen'] }</span></td>`
}
if(server["running"]){
text += `<td><button onclick="send_command_to_server('ban ${ players[i]['name'] }')" type="button" class="btn btn-danger controls">Ban</button><br class="mobile-break"><button onclick="send_command_to_server('kick ${ players[i]['name'] }')" type="button" class="btn btn-outline-danger controls">Kick</button><br><button onclick="send_command_to_server('op ${ players[i]['name'] }')" type="button" class="btn btn-warning controls">OP</button><br class="mobile-break"><button onclick="send_command_to_server('deop ${ players[i]['name'] }')" type="button" class="btn btn-outline-warning controls">De-OP</button></td>`
}else{
text += `<td><span> Unavailable<br> (Server Offline)</span></td>`
}
let players = server.players_cache;
for (let i = 0; i < players.length; i++) {
text += `<tr id="playerItem-${players[i]["name"]}" class="playerItem--" style="text-align: center;">`;
text += `<td class="no-scroll" style="overflow: scroll;"><strong>${players[i]["name"]}</strong></td>`;
if (players[i]["status"] === "Online") {
text += `<td><span class="text-success"><i class="fas fa-signal"></i> ${players[i]['status']}</span></td>`
} else {
text += `<td><span class="text-warning"><i class="fa-regular fa-circle-xmark"></i><span class="offline-status">&nbsp;${players[i]['status']}</span><span class="conn-break"> Last connection :<br> ${players[i]['last_seen']}</span></td>`
}
if (server["running"]) {
text += `<td><button onclick="send_command_to_server('ban ${players[i]['name']}')" type="button" class="btn btn-danger controls">Ban</button><br class="mobile-break"><button onclick="send_command_to_server('kick ${players[i]['name']}')" type="button" class="btn btn-outline-danger controls">Kick</button><br><button onclick="send_command_to_server('op ${players[i]['name']}')" type="button" class="btn btn-warning controls">OP</button><br class="mobile-break"><button onclick="send_command_to_server('deop ${players[i]['name']}')" type="button" class="btn btn-outline-warning controls">De-OP</button></td>`
} else {
text += `<td><span> Unavailable<br> (Server Offline)</span></td>`
}
}
$("#player-body").html(text);
}
$("#player-body").html(text);
}
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
@ -262,24 +242,24 @@
add_server_name();
//}
});
async function add_server_name(){
async function add_server_name() {
let res = await fetch(`/api/v2/servers/${serverId}`, {
method: 'GET',
headers: {
'X-XSRFToken': token
},
});
let responseData = await res.json();
if (responseData.status === "ok") {
console.log(responseData)
$("#server-name-nav").html(`${responseData.data['server_name']}`)
$("#server-name-nav").show();
} else {
method: 'GET',
headers: {
'X-XSRFToken': token
},
});
let responseData = await res.json();
if (responseData.status === "ok") {
console.log(responseData)
$("#server-name-nav").html(`${responseData.data['server_name']}`)
$("#server-name-nav").show();
} else {
bootbox.alert({
title: responseData.error,
message: responseData.error_data
});
}
bootbox.alert({
title: responseData.error,
message: responseData.error_data
});
}
}
</script>

View File

@ -49,7 +49,7 @@
<img src="/static/assets/images/pack.png" alt="icon" style="-webkit-filter:grayscale(100%); filter:grayscale(100%)" />
</div>
<div class="col-auto">
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ server['stats']['desc'] }}</span>
<span id="input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</span>
</div>
</div>
{% end %}
@ -133,8 +133,7 @@
<div class="media-body">
{% if server['stats']['desc'] != 'False' %}
<div id="m_server_motd_{{ server['stats']['server_id']['server_id'] }}">
<span id="m_input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{
server['stats']['desc'] }}</span> <br />
<span id="m_input_motd_{{ server['stats']['server_id']['server_id'] }}" class="input_motd">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</span> <br />
</div>
{% end %}
</div>

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU-Nutzung",
"description": "Beschreibung",
"errorCalculatingUptime": "Fehler bei der Berechnung der Betriebszeit",
"loadingMotd": "Nachricht des Tages lädt (MOTD)",
"memUsage": "RAM/Speicherverbrauch",
"offline": "Offline",
"online": "Online",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU Usage",
"description": "Description",
"errorCalculatingUptime": "Error Calculating Uptime",
"loadingMotd": "Loading MOTD",
"memUsage": "Memory Usage",
"offline": "Offline",
"online": "Online",

View File

@ -512,6 +512,7 @@
"cpuUsage": "Utilisation CPU",
"description": "Description",
"errorCalculatingUptime": "Erreur de Calcul du Temps de Disponibilité",
"loadingMotd": "Chargement MOTD",
"memUsage": "Utilisation Mémoire",
"offline": "Hors Ligne",
"online": "En Ligne",

View File

@ -512,6 +512,7 @@
"cpuUsage": "שימוש במעבד",
"description": "תיאור",
"errorCalculatingUptime": "שגיאה בחישוב זמן פעולה",
"loadingMotd": "טוען MOTD",
"memUsage": "שימוש בזיכרון",
"offline": "לא מקוון",
"online": "פועל",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU USAGE",
"description": "DESCRIPSHUN",
"errorCalculatingUptime": "I DUN GOOF'D WEN CALCULATIN TEH TEIM AWAEK!",
"loadingMotd": "LOADIN' MEOWSSAGE OF DA DAY",
"memUsage": "HOW HARD IZ THINKIN RN",
"offline": "TURND OFF",
"online": "TURND OAN",

View File

@ -513,6 +513,7 @@
"cpuUsage": "CPU Lietojums",
"description": "Apraksts",
"errorCalculatingUptime": "Kļūda aprēķinot darbības laiku",
"loadingMotd": "Ielādē MOTD",
"memUsage": "Atmiņas Lietojums",
"offline": "Offlinā",
"online": "Onlinā",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU gebruik",
"description": "Beschrijving",
"errorCalculatingUptime": "Fout bij berekenen van uptime",
"loadingMotd": "MOTD laden",
"memUsage": "Geheugengebruik",
"offline": "Offline",
"online": "Online",

View File

@ -512,6 +512,7 @@
"cpuUsage": "Użycie procesora",
"description": "Opis",
"errorCalculatingUptime": "Błąd obliczania czasu pracy",
"loadingMotd": "Wczytywanie MOTD",
"memUsage": "Użycie RAMu",
"offline": "Wyłączony",
"online": "Włączony",

View File

@ -512,6 +512,7 @@
"cpuUsage": "การใช้งานซีพียู",
"description": "คำอธิบาย",
"errorCalculatingUptime": "เกิดข้อผิดพลาดในการคำนวณสถานะการออนไลน์",
"loadingMotd": "กำลังโหลด MOTD",
"memUsage": "การใช้งานหน่วยความจำ",
"offline": "ออฟไลน์",
"online": "ออนไลน์",

View File

@ -512,6 +512,7 @@
"cpuUsage": "CPU Kullanımı",
"description": "Açıklama",
"errorCalculatingUptime": "Çalışma Süresi Hesaplanırken Hata",
"loadingMotd": "MOTD yükleniyor",
"memUsage": "Bellek Kullanımı",
"offline": "Çevrimdışı",
"online": "Çevrimiçi",

View File

@ -512,6 +512,7 @@
"cpuUsage": "Використання Процесора",
"description": "Опис",
"errorCalculatingUptime": "Підрахунок помилок аптайму",
"loadingMotd": "Завантаження MOTD",
"memUsage": "Використання ОПЗ",
"offline": "Оффлайн",
"online": "Онлайн",

View File

@ -95,7 +95,7 @@
"lastBackup": "上次:",
"max": "最大",
"memUsage": "内存使用率",
"motd": "今日消息MOTD",
"motd": "服务器描述MOTD",
"newServer": "创建新服务器",
"nextBackup": "下次:",
"no-servers": "当前没有服务器。要开始,请点击",
@ -512,6 +512,7 @@
"cpuUsage": "CPU 使用率",
"description": "简介",
"errorCalculatingUptime": "计算正常运行时间时发生错误",
"loadingMotd": "正在加载服务器描述MOTD",
"memUsage": "内存使用率",
"offline": "已停止",
"online": "运行中",