mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'enhancement/metrics-range' into 'dev'
Add ability to change metrics scale See merge request crafty-controller/crafty-4!448
This commit is contained in:
commit
2e5f239c84
@ -4,7 +4,7 @@
|
||||
- Win Portable Updater will now be included in Windows Package ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/446))
|
||||
- Bedrock Server Creator ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/443))
|
||||
### Bug fixes
|
||||
- Fix performance issues on server metrics panels (Temporarily setting to 24hr query) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/440))
|
||||
- Fix performance issues on server metrics panels 'with metrics range' ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/440)) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/448))
|
||||
- Fix no id on import3 servers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/442))
|
||||
- Fix functionality of bedrock update ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/441))
|
||||
### Tweaks
|
||||
|
@ -105,10 +105,9 @@ class ServersController(metaclass=Singleton):
|
||||
server_instance.update_server_instance()
|
||||
return ret
|
||||
|
||||
def get_history_stats(self, server_id):
|
||||
now = datetime.datetime.now()
|
||||
def get_history_stats(self, server_id, days):
|
||||
srv = ServersController().get_server_instance_by_id(server_id)
|
||||
return srv.stats_helper.get_history_stats(server_id)
|
||||
return srv.stats_helper.get_history_stats(server_id, days)
|
||||
|
||||
@staticmethod
|
||||
def update_unloaded_server(server_obj):
|
||||
|
@ -138,8 +138,8 @@ class HelperServerStats:
|
||||
)
|
||||
return server_data
|
||||
|
||||
def get_history_stats(self, server_id):
|
||||
max_age = datetime.datetime.now() - timedelta(days=1)
|
||||
def get_history_stats(self, server_id, num_days):
|
||||
max_age = datetime.datetime.now() - timedelta(days=num_days)
|
||||
return (
|
||||
ServerStats.select()
|
||||
.where(ServerStats.created > max_age)
|
||||
|
@ -756,8 +756,21 @@ class PanelHandler(BaseHandler):
|
||||
page_data["backup_path"] = Helpers.wtol_path(server_info["backup_path"])
|
||||
|
||||
if subpage == "metrics":
|
||||
try:
|
||||
days = int(self.get_argument("days", "1"))
|
||||
except ValueError as e:
|
||||
self.redirect(
|
||||
f"/panel/error?error=Type error: Argument must be an int {e}"
|
||||
)
|
||||
page_data["options"] = [1, 2, 3]
|
||||
if not days in page_data["options"]:
|
||||
page_data["options"].insert(0, days)
|
||||
else:
|
||||
page_data["options"].insert(
|
||||
0, page_data["options"].pop(page_data["options"].index(days))
|
||||
)
|
||||
page_data["history_stats"] = self.controller.servers.get_history_stats(
|
||||
server_id
|
||||
server_id, days
|
||||
)
|
||||
|
||||
def get_banned_players_html():
|
||||
|
@ -38,6 +38,16 @@
|
||||
<span class="d-block d-sm-none">
|
||||
{% include "parts/m_server_controls_list.html %}
|
||||
</span>
|
||||
<div class="col-2">
|
||||
<div class="form-group">
|
||||
<label for="days">Metric Period</label>
|
||||
<select required class="form-control form-control-lg select-css" id="days" name="days">
|
||||
{% for value in data['options'] %}
|
||||
<option value="{{value}}">{{value}} Day(s)</option>
|
||||
{% end %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button style="float: right; visibility: hidden;" class="btn btn-outline-success reset-button"
|
||||
id="reset-button"><i class="fas fa-undo"></i> {{ translate('serverMetrics', 'resetZoom', data['lang'])
|
||||
}}</button>
|
||||
@ -69,6 +79,7 @@
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
const serverId = new URLSearchParams(document.location.search).get('id')
|
||||
var zoomed = false;
|
||||
//line
|
||||
var ctxL = document.getElementById("lineChart").getContext('2d');
|
||||
@ -162,6 +173,10 @@
|
||||
}
|
||||
});
|
||||
$(window).ready(function () {
|
||||
$('#days').on("change", function () {
|
||||
let days = $('#days').find(":selected").val();
|
||||
window.location.href = "/panel/server_detail?id=" + serverId + "&days=" + days + "&subpage=metrics"
|
||||
});
|
||||
$('body').click(function () {
|
||||
$('.hints').popover("hide");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user