mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'feature/proxy-stats' into 'dev'
Allow omission of player stats from total See merge request crafty-controller/crafty-4!692
This commit is contained in:
commit
5ffe8718c5
@ -2,6 +2,7 @@
|
||||
## --- [4.2.3] - 2023/TBD
|
||||
### New features
|
||||
- Use Papermc Group's API for `paper` & `folia` builds in server builder ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/688))
|
||||
- Allow omission of player count from Dashboard (e.g. for proxy servers) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/692))
|
||||
### Bug fixes
|
||||
- Fix bukkit and downstream fork MOTD crash ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/686))
|
||||
- Fix bug where invalid server Id leads to stack ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/690))
|
||||
|
@ -42,6 +42,7 @@ class Servers(BaseModel):
|
||||
created_by = IntegerField(default=-100)
|
||||
shutdown_timeout = IntegerField(default=60)
|
||||
ignored_exits = CharField(default="0")
|
||||
count_players = BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
table_name = "servers"
|
||||
|
@ -1593,6 +1593,7 @@ class ServerInstance:
|
||||
"version": raw_ping_result.get("version"),
|
||||
"icon": raw_ping_result.get("icon"),
|
||||
"crashed": self.is_crashed,
|
||||
"count_players": self.server_object.count_players,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -29,6 +29,7 @@ server_patch_schema = {
|
||||
"logs_delete_after": {"type": "integer", "minimum": 0},
|
||||
"ignored_exits": {"type": "string"},
|
||||
"show_status": {"type": "boolean"},
|
||||
"count_players": {"type": "boolean"},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"minProperties": 1,
|
||||
@ -46,6 +47,7 @@ basic_server_patch_schema = {
|
||||
"shutdown_timeout": {"type": "integer"},
|
||||
"logs_delete_after": {"type": "integer", "minimum": 0},
|
||||
"ignored_exits": {"type": "string"},
|
||||
"count_players": {"type": "boolean"},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"minProperties": 1,
|
||||
|
@ -315,7 +315,7 @@
|
||||
<br />
|
||||
<br />
|
||||
</td>
|
||||
<span class="server-player-totals" id="server_players_{{server['server_data']['server_id']}}" data-players="{{ server['stats']['online']}}" data-max="{{ server['stats']['max'] }}"></span>
|
||||
<span class="server-player-totals" id="server_players_{{server['server_data']['server_id']}}" data-serverId="{{server['server_data']['server_id']}}" data-players="{{ server['stats']['online']}}" data-max="{{ server['stats']['max'] }}" data-count="{{server['server_data']['count_players']}}"></span>
|
||||
</tr>
|
||||
{% end %}
|
||||
</div>
|
||||
@ -554,6 +554,9 @@
|
||||
display: none;
|
||||
/* for Chrome, Safari, and Opera */
|
||||
}
|
||||
.gray {
|
||||
color: gray !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@ -724,15 +727,20 @@
|
||||
|
||||
server_players.setAttribute('data-players', server.online);
|
||||
server_players.setAttribute('data-max', server.max);
|
||||
server_players.setAttribute('data-count', server.count_players)
|
||||
let servers = Array.from(document.getElementsByClassName("server-player-totals"));
|
||||
let all_total_players = 0;
|
||||
let all_total_max_players = 0;
|
||||
|
||||
servers.forEach(server => {
|
||||
try {
|
||||
all_total_players += parseInt(server.getAttribute('data-players'));
|
||||
all_total_max_players += parseInt(server.getAttribute('data-max'));
|
||||
} catch {
|
||||
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'){
|
||||
all_total_players += parseInt(server.getAttribute('data-players'));
|
||||
all_total_max_players += parseInt(server.getAttribute('data-max'));
|
||||
}
|
||||
} catch {
|
||||
console.log("Player totals are not of type int");
|
||||
}
|
||||
})
|
||||
|
@ -188,6 +188,17 @@
|
||||
{% end %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
{% if data['server_stats']['server_id']['count_players'] %}
|
||||
<input type="checkbox" class="custom-control-input" id="count_players" name="count_players" checked="" value="1">
|
||||
<label class="custom-control-label" for="count_players"> {{ translate('serverConfig', 'countPlayers', data['lang']) }}</label>
|
||||
{% else %}
|
||||
<input type="checkbox" class="custom-control-input" id="count_players" name="count_players" value="1">
|
||||
<label class="custom-control-label" for="count_players"> {{ translate('serverConfig', 'countPlayers', data['lang']) }}</label>
|
||||
{% end %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
{% if data['super_user'] %}
|
||||
@ -559,6 +570,7 @@
|
||||
formDataObject.show_status = $("#show_status").prop('checked');
|
||||
formDataObject.crash_detection = $("#crash_detection").prop('checked');
|
||||
formDataObject.auto_start = $("#auto_start").prop('checked');
|
||||
formDataObject.count_players = $("#count_players").prop('checked');
|
||||
console.log(formDataObject);
|
||||
// Format the plain form data as JSON
|
||||
let formDataJsonString = JSON.stringify(formDataObject, replacer);
|
||||
|
16
app/migrations/20231229_player_count.py
Normal file
16
app/migrations/20231229_player_count.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Generated by database migrator
|
||||
import peewee
|
||||
|
||||
|
||||
def migrate(migrator, database, **kwargs):
|
||||
migrator.add_columns("servers", count_players=peewee.BooleanField(default=True))
|
||||
"""
|
||||
Write your migrations here.
|
||||
"""
|
||||
|
||||
|
||||
def rollback(migrator, database, **kwargs):
|
||||
migrator.drop_columns("servers", ["count_players"])
|
||||
"""
|
||||
Write your rollback migrations here.
|
||||
"""
|
@ -377,7 +377,8 @@
|
||||
"timeoutExplain2": "command before it forces the process down.",
|
||||
"update": "Update Executable",
|
||||
"yesDelete": "Yes, delete",
|
||||
"yesDeleteFiles": "Yes, delete files"
|
||||
"yesDeleteFiles": "Yes, delete files",
|
||||
"countPlayers": "Include server in total player count"
|
||||
},
|
||||
"serverConfigHelp": {
|
||||
"desc": "Here is where you can change the configuration of your server",
|
||||
@ -665,4 +666,4 @@
|
||||
"webhook_body": "Webhook Body",
|
||||
"webhooks": "Webhooks"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user