crafty-4/app/frontend/templates/panel/dashboard.html

1068 lines
49 KiB
HTML
Raw Normal View History

2020-08-13 14:38:36 +00:00
{% extends ../base.html %}
2020-08-27 22:35:08 +00:00
{% block meta %}
{% end %}
{% block title %}Crafty Controller - {{ translate('dashboard', 'dashboard', data['lang']) }}{% end %}
2020-08-13 14:38:36 +00:00
{% block content %}
<div class="content-wrapper">
2022-01-19 21:45:52 +00:00
<!-- Page Title Header Starts-->
2020-08-13 14:38:36 +00:00
<div class="row page-title-header">
<div class="col-12">
<div class="page-header">
2022-03-19 01:48:24 +00:00
<h4 class="page-title">{{ translate('dashboard', 'dashboard', data['lang']) }}
{% if data['server_stats']['running'] != 0 %}
2022-05-18 20:00:20 +00:00
<span id="sync" style="margin-left: 5px;"><i class="fas fa-sync fa-spin"></i></span>
</h4>
{% end %}
2020-08-13 14:38:36 +00:00
</div>
</div>
</div>
<!-- Page Title Header Ends-->
2022-06-12 21:03:42 +00:00
{% if data['first_log'] %}
<script>
2022-06-20 20:39:03 +00:00
$(document).ready(function () {
2022-06-12 21:03:42 +00:00
bootbox.alert({
2022-06-20 20:39:03 +00:00
backdrop: true,
title: 'Your Feedback Is Appreciated...',
message: '<p>We will only request this information from the admin user once... 😊</p>'
+ '<p><strong>All data collected is completely anonymous</strong> and is only used to improve Crafty 4.0 and allow us to more accurately report the number of Crafty 4 users.</p><iframe width="640px" height="480px"'
+ 'src="https://forms.office.com/Pages/ResponsePage.aspx?id=LwLajNkpXU2CKc95G1oO3MN0Hu3oEUNLr-EtLx31TS5UNUNVQlFNVUVYMEc'
+ '1V1BKS0FQUUlERUtWQy4u&embed=true" frameborder="0" marginwidth="0" marginheight="0" style="border: none; max-width:100%;'
+ ' max-height:100vh" allowfullscreen webkitallowfullscreen mozallowfullscreen msallowfullscreen> </iframe>',
buttons: {
ok: {
2022-06-12 21:03:42 +00:00
label: 'Skip Survey/Done',
className: 'btn-secondary'
2022-06-20 20:39:03 +00:00
},
2022-06-12 21:03:42 +00:00
},
});
});
</script>
{% end %}
2020-08-13 14:38:36 +00:00
<div class="row">
<div class="col-md-12 grid-margin">
<div class="card">
<div class="card-body">
<div class="row">
2023-02-07 18:56:13 +00:00
<div class="col-xl-4 col-md-5">
2020-08-13 14:38:36 +00:00
<div class="d-flex">
<div class="wrapper">
2022-01-19 21:45:52 +00:00
<h5 class="mb-1 font-weight-medium text-primary"> {{ translate('dashboard', 'host', data['lang']) }}
</h5>
<h3 class="mb-0 font-weight-semibold"> <i class="fas fa-chart-line"></i></h3>
2020-08-13 14:38:36 +00:00
</div>
<div class="wrapper my-auto ml-auto ml-lg-4">
2023-09-02 19:51:28 +00:00
<p id="cpu_data" class="mb-0 text-success" data-toggle="tooltip" data-placement="top" data-html="true" title="{% raw translate('dashboard', 'cpuCores', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cores') }} <br /> {% raw translate('dashboard', 'cpuCurFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_cur_freq') }} <br /> {% raw translate('dashboard', 'cpuMaxFreq', data['lang']) %}: {{ data.get('hosts_data').get('cpu_max_freq') }}">
2022-01-19 21:45:52 +00:00
{{ translate('dashboard', 'cpuUsage', data['lang']) }}: <span id="cpu_usage">{{
data.get('hosts_data').get('cpu_usage') }}</span>
</p>
2023-09-02 19:51:28 +00:00
<p id="mem_usage" class="mb-0 text-danger" data-toggle="tooltip" data-placement="top" title="{{ translate('dashboard', 'memUsage', data['lang']) }}: {{ data.get('hosts_data').get('mem_usage') }}">
2022-01-19 21:45:52 +00:00
{{ translate('dashboard', 'memUsage', data['lang']) }}: <span id="mem_percent">{{
data.get('hosts_data').get('mem_percent') }}%</span>
</p>
2020-08-13 14:38:36 +00:00
</div>
</div>
</div>
2023-02-07 18:56:13 +00:00
<div class="col-xl-4 col-md-4 mt-md-0 mt-4">
2020-08-13 14:38:36 +00:00
<div class="d-flex">
<div class="wrapper">
2022-01-19 21:45:52 +00:00
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'servers', data['lang']) }}
</h5>
<h3 class="mb-0 font-weight-semibold">{{ data['server_stats']['total'] }}</h3>
2020-08-13 14:38:36 +00:00
</div>
<div class="wrapper my-auto ml-auto ml-lg-4">
2022-01-19 21:45:52 +00:00
<p class="mb-0 text-success">{{ data['server_stats']['running'] }} {{ translate('dashboard', 'online',
data['lang']).lower() }}</p>
<p class="mb-0 text-warning"> {{ data['server_stats']['stopped'] }} {{ translate('dashboard',
'offline', data['lang']).lower() }}</p>
2020-08-13 14:38:36 +00:00
</div>
</div>
</div>
2023-02-07 18:56:13 +00:00
<div class="col-xl-4 col-md-3 mt-md-0 mt-4">
2020-08-13 14:38:36 +00:00
<div class="d-flex">
<div class="wrapper">
2022-01-19 21:45:52 +00:00
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'players', data['lang']) }}
</h5>
<h3 class="mb-0 font-weight-semibold" id="total_players">{{ data['num_players'] }}</h3>
2020-08-13 14:38:36 +00:00
</div>
<div class="wrapper my-auto ml-auto ml-lg-4">
2022-04-03 01:25:26 +00:00
<p class="mb-0 text-warning"><span id="max_players">0</span> {{ translate('dashboard', 'max',
data['lang']) }}</p>
2020-08-13 14:38:36 +00:00
</div>
</div>
</div>
2023-03-12 20:46:50 +00:00
{% if len(data['hosts_data']['disk_json']) > 0 %}
2023-02-07 18:56:13 +00:00
<div class="col-12 mt-4">
2023-02-05 21:47:12 +00:00
<div class="d-flex">
<div class="wrapper" style="width: 100%;">
{% if len(data["monitored"]) > 0 %}
<h5 class="mb-1 font-weight-medium text-primary">{{ translate('dashboard', 'storage',
data['lang']) }}
2023-02-05 21:47:12 +00:00
</h5>
{% end %}
<div id="storage_data">
2023-02-07 18:56:13 +00:00
<div class="row">
2023-03-12 20:46:50 +00:00
{% for item in data['hosts_data']['disk_json'] %}
2023-02-07 18:56:13 +00:00
{% if item["mount"] in data["monitored"] %}
<div id="{{item['device']}}" class="col-xl-3 col-lg-3 col-md-4 col-12">
2023-09-02 19:51:28 +00:00
<h4 class="mb-0 font-weight-semibold d-inline-block text-truncate storage-heading" id="title_{{item['device']}}" data-toggle="tooltip" data-placement="bottom" title="{{item['mount']}}" style="max-width: 100%;"><i class="fas fa-hdd"></i>
2023-02-07 22:51:13 +00:00
{{item["mount"]}}</h4>
2023-09-02 19:51:28 +00:00
<div class="progress d-inline-block" style="height: 20px; width: 100%; background-color: rgb(139, 139, 139) !important;">
2023-02-07 18:56:13 +00:00
<div class="progress-bar
2023-02-07 22:51:13 +00:00
{% if item['percent_used'] <= 58 %}
2023-02-07 18:56:13 +00:00
bg-success
2023-02-07 22:51:13 +00:00
{% elif 59 <= item['percent_used'] <= 75 %}
2023-02-07 18:56:13 +00:00
bg-warning
{% else %}
bg-danger
{% end %}
2023-09-02 19:51:28 +00:00
" role="progressbar" style="color: black; height: 100%; width: {{item['percent_used']}}%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">{{item["used"]}} /
2023-02-07 18:56:13 +00:00
{{item["total"]}}
</div>
</div>
</div>
{% end %}
{% end %}
</div>
</div>
2023-02-05 21:47:12 +00:00
</div>
</div>
</div>
2023-03-12 20:46:50 +00:00
{% end %}
2020-08-13 14:38:36 +00:00
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 grid-margin stretch-card">
<div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center">
2022-01-19 21:45:52 +00:00
<h4 class="card-title"><i class="fas fa-server"></i> &nbsp;{{ translate('dashboard', 'allServers',
data['lang']) }}</h4>
{% if len(data['servers']) > 0 %}
2022-04-03 01:25:26 +00:00
{% if data['user_data']['hints'] %}
2023-09-02 19:51:28 +00:00
<span class="too_small" title="{{ translate('dashboard', 'cannotSeeOnMobile', data['lang']) }}" , data-content="{{ translate('dashboard', 'cannotSeeOnMobile2', data['lang']) }}" , data-placement="top"></span>
{% end %}
2022-04-03 01:25:26 +00:00
{% end %}
2022-01-19 21:45:52 +00:00
<div><a class="nav-link" href="/server/step1"><i class="fas fa-plus-circle"></i> &nbsp; {{
translate('dashboard', 'newServer', data['lang']) }}</a></div>
2020-08-13 14:38:36 +00:00
</div>
<div class="card-body">
{% if len(data['servers']) == 0 and len(data['failed_servers']) == 0 %}
2022-06-20 20:39:03 +00:00
<div style="text-align: center; color: grey;">
<h1>{{ translate('dashboard', 'welcome', data['lang']) }}</h1>
<br>
<h7>{{ translate('dashboard', 'no-servers', data['lang']) }} {{ translate('dashboard', 'newServer',
data['lang']) }}.</h7>
</div>
2022-01-19 21:45:52 +00:00
2022-06-20 20:39:03 +00:00
{% end %}
{% if len(data['servers']) > 0 or len(data['failed_servers']) > 0 %}
2022-06-20 20:39:03 +00:00
<!-- View for Large screen -->
<div class="table-responsive d-none d-sm-block">
<table id="servers_table" class="table table-hover">
2020-08-13 14:38:36 +00:00
<thead>
<tr class="rounded" id="first" draggable="false">
<th draggable="false">{{ translate('dashboard', 'server', data['lang']) }}</th>
<th draggable="false">{{ translate('dashboard', 'actions', data['lang']) }}</th>
<th draggable="false">{{ translate('dashboard', 'cpuUsage', data['lang']) }}</th>
<th draggable="false">{{ translate('dashboard', 'memUsage', data['lang']) }}</th>
<th draggable="false">{{ translate('dashboard', 'size', data['lang']) }}</th>
<th draggable="false">{{ translate('dashboard', 'players', data['lang']) }}</th>
<th draggable="false">{{ translate('dashboard', 'status', data['lang']) }}</th>
2020-08-13 14:38:36 +00:00
</tr>
</thead>
<tbody>
2020-08-24 17:08:17 +00:00
{% for server in data['servers'] %}
2022-03-19 01:48:24 +00:00
<tr id="{{server['server_data']['server_id']}}" draggable="true">
<td draggable="false">
2020-08-24 17:08:17 +00:00
<i class="fas fa-server"></i>
2022-06-21 19:59:08 +00:00
{% if server['alert'] %}
2023-09-02 19:51:28 +00:00
<a style="color: red !important;" draggable="false" href="/panel/server_detail?id={{server['server_data']['server_id']}}">
2022-06-21 19:59:08 +00:00
{{ server['server_data']['server_name'] }}&nbsp; <i class="fas fa-exclamation-triangle"></i>
</a>
{% else %}
<a draggable="false" href="/panel/server_detail?id={{server['server_data']['server_id']}}">
{{ server['server_data']['server_name'] }}
2020-08-24 17:08:17 +00:00
</a>
2022-06-21 19:59:08 +00:00
{% end %}
2020-08-24 17:08:17 +00:00
</td>
<td draggable="false" id="controls{{server['server_data']['server_id']}}" class="actions_serverlist">
{% if server['user_command_permission'] %}
2022-11-19 20:45:29 +00:00
{% if server['stats']['importing'] and server['stats']['running'] %}
<!-- WHAT HAPPENED HERE -->
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class=""><i class="fa fa-spinner fa-spin"></i>&nbsp;{{ translate('serverTerm', 'installing',
2022-11-19 20:45:29 +00:00
data['lang']) }}</i></a>
2022-01-19 21:45:52 +00:00
{% elif server['stats']['updating']%}
<!-- WHAT HAPPENED HERE -->
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class=""><i class="fa fa-spinner fa-spin"></i>&nbsp;{{ translate('serverTerm', 'updating',
2022-01-19 21:45:52 +00:00
data['lang']) }}</i></a>
{% elif server['stats']['waiting_start']%}
<!-- WHAT HAPPENED HERE -->
<a data-id="{{server['server_data']['server_id']}}" class="" title="{{
translate('dashboard', 'delay-explained' , data['lang'])}}">{{ translate('dashboard', 'starting',
2022-01-19 21:45:52 +00:00
data['lang']) }}</i></a>
{% elif server['stats']['importing']%}
2022-06-02 17:27:38 +00:00
<a data-id="{{server['server_data']['server_id']}}" class=""><i class="fa fa-spinner fa-spin"></i>
{{ translate('serverTerm', 'importing',
2022-05-18 20:00:20 +00:00
data['lang']) }}</a>
{% elif server['stats']['running'] %}
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="stop_button" data-toggle="tooltip" title="{{ translate('dashboard', 'stop' , data['lang']) }}">
<i class="fas fa-stop"></i>
</a> &nbsp;
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="restart_button" data-toggle="tooltip" title="{{ translate('dashboard', 'restart' , data['lang']) }}">
<i class="fas fa-sync"></i>
</a> &nbsp;
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip" title="{{ translate('dashboard', 'kill' , data['lang']) }}">
<i class="fas fa-skull"></i>
</a> &nbsp;
2022-01-19 21:45:52 +00:00
{% else %}
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="play_button" data-toggle="tooltip" title="{{ translate('dashboard', 'start' , data['lang']) }}">
<i class="fas fa-play"></i>
</a> &nbsp;
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="clone_button" data-toggle="tooltip" title="{{ translate('dashboard', 'clone' , data['lang']) }}">
<i class="fas fa-clone"></i>
</a> &nbsp;
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="kill_button" data-toggle="tooltip" title="{{ translate('dashboard', 'kill' , data['lang']) }}">
<i class="fas fa-skull"></i>
</a> &nbsp;
2022-01-19 21:45:52 +00:00
{% end %}
2020-08-24 17:08:17 +00:00
{% end %}
2020-08-13 14:38:36 +00:00
</td>
2020-08-24 17:08:17 +00:00
<td draggable="false" id="server_cpu_{{server['server_data']['server_id']}}">
2023-09-02 19:51:28 +00:00
<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="{{server['stats']['cpu']}}">
<div class="progress-bar
{% if server['stats']['cpu'] <= 33 %}
bg-success
{% elif 34 <= server['stats']['cpu'] <= 66 %}
bg-warning
{% else %}
bg-danger
{% end %}
2023-09-02 19:51:28 +00:00
" role="progressbar" style="width: {{server['stats']['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
2020-08-13 14:38:36 +00:00
</div>
{{server['stats']['cpu']}}%
2020-08-13 14:38:36 +00:00
</td>
2020-08-24 17:08:17 +00:00
<td draggable="false" id="server_mem_{{server['server_data']['server_id']}}">
2023-09-02 19:51:28 +00:00
<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="{{server['stats']['mem']}}">
<div class="progress-bar
{% if server['stats']['mem_percent'] <= 33 %}
bg-success
{% elif 34 <= server['stats']['mem_percent'] <= 66 %}
bg-warning
{% else %}
bg-danger
{% end %}
2023-09-02 19:51:28 +00:00
" role="progressbar" style="width: {{server['stats']['mem_percent']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
2020-08-13 14:38:36 +00:00
</div>
{{server['stats']['mem_percent']}}% -
{% if server['stats']['mem'] == 0 %}
2022-01-19 21:45:52 +00:00
0 MB
{% else %}
2022-01-19 21:45:52 +00:00
{{server['stats']['mem']}}
{% end %}
2020-08-13 14:38:36 +00:00
</td>
<td draggable="false" id="server_world_{{server['server_data']['server_id']}}">
2022-03-02 02:56:12 +00:00
{{ server['stats']['world_size'] }}
2020-08-13 14:38:36 +00:00
</td>
<td draggable="false" id="server_desc_{{server['server_data']['server_id']}}">
{% if server['stats']['int_ping_results'] %}
2022-01-19 21:45:52 +00:00
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max',
data['lang']) }} <br />
2022-01-19 21:45:52 +00:00
{% if server['stats']['desc'] != 'False' %}
2024-01-31 22:04:22 +00:00
<div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">{{ translate('serverStats', 'loadingMotd', data['lang']) }}</div> <br />
2022-01-19 21:45:52 +00:00
{% end %}
2022-01-19 21:45:52 +00:00
{% if server['stats']['version'] != 'False' %}
{{ server['stats']['version'] }}
{% end %}
{% end %}
2020-08-24 17:08:17 +00:00
</td>
<td draggable="false">
2022-11-29 00:45:53 +00:00
<span class="port" data-toggle="tooltip" title="{{
server['server_data']['server_port'] }}">
<div id="server_running_status_{{server['server_data']['server_id']}}">
{% if server['stats']['running'] %}
<span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online',
data['lang']) }}</span>
{% elif server['stats']['crashed'] %}
<span class="text-danger"><i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard',
'crashed',
data['lang']) }}</span>
{% else %}
<span class="text-warning"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline',
data['lang']) }}</span>
{% end %}
<br />
<br />
2020-08-13 14:38:36 +00:00
</td>
<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 %}
2022-06-20 20:39:03 +00:00
</div>
</span>
{% for server in data['failed_servers'] %}
<tr id="{{server['server_id']}}" draggable="false">
2023-09-02 19:51:28 +00:00
<td class="text-warning"><i class="fas fa-server"></i>&nbsp;<a class="text-warning" href="/panel/server_detail?id={{server['server_id']}}&subpage=config">{{server['server_name']}}</a>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><i class="fas fa-cloud"></i>&nbsp;Unloaded</td>
</tr>
2022-06-20 20:39:03 +00:00
{% end %}
</tbody>
</table>
</div>
{% end %}
{% if len(data['servers']) > 0 %}
<!-- View for Small screen -->
<div class="d-sm-none d-block">
<div class="accordion" id="accordionServers">
{% for server in data['servers'] %}
<div class="card">
<div class="card-header" id="heading-{{server['server_data']['server_id']}}">
<h2 class="mb-0 container overflow-hidden">
<div class="row">
<div class="col-10 col-lg-3 mx-0 px-0">
{% if server['alert'] %}
2023-09-02 19:51:28 +00:00
<a style="color: red !important" class="btn btn-link d-flex justify-content-start" type="button" href="/panel/server_detail?id={{server['server_data']['server_id']}}">
<i class="fas fa-server"></i> {{ server['server_data']['server_name'] }}&nbsp; <i class="fas fa-exclamation-triangle"></i>
</a>
{% else %}
2023-09-02 19:51:28 +00:00
<a class="btn btn-link d-flex justify-content-start" type="button" href="/panel/server_detail?id={{server['server_data']['server_id']}}">
<i class="fas fa-server"></i> {{ server['server_data']['server_name'] }}
</a>
{% end %}
</div>
<div class="col-2 col-lg-3 mx-0 px-0">
2023-09-02 19:51:28 +00:00
<a class="btn btn-link d-flex justify-content-center" type="button" data-toggle="collapse" data-target="#collapse-{{server['server_data']['server_id']}}" aria-expanded="false" aria-controls="collapse-{{server['server_data']['server_id']}}">
<i class="fas fa-chart-bar"></i>
</a>
</div>
<div class="col-4 col-lg-3 mx-0 px-0">
2023-09-02 19:51:28 +00:00
<a id="m_server_running_status_{{server['server_data']['server_id']}}" class="btn btn-link d-flex justify-content-start" type="button">
{% if server['stats']['running'] %}
<span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online',
data['lang']) }}</span>
{% elif server['stats']['crashed'] %}
<span class="text-danger"><i class="fas fa-exclamation-triangle"></i> {{
translate('dashboard',
'crashed',
data['lang']) }}</span>
2022-06-21 19:59:08 +00:00
{% else %}
<span class="text-warning"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline',
data['lang']) }}</span>
2022-06-21 19:59:08 +00:00
{% end %}
</a>
</div>
<div class="col-8 col-lg-3 mx-0 px-0">
<div id="controls{{server['server_data']['server_id']}}" class="container overflow-hidden">
{% if server['user_command_permission'] %}
{% if server['stats']['running'] %}
<div class="row">
<div class="col-4 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn btn-link stop_button actions_serveritem" data-toggle="tooltip" title="{{ translate('dashboard', 'stop' , data['lang']) }}">
<i class="fas fa-stop"></i>
</a>
</div>
<div class="col-4 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn btn-link restart_button actions_serveritem" data-toggle="tooltip" title="{{ translate('dashboard', 'restart' , data['lang']) }}">
<i class="fas fa-sync"></i>
</a>
2022-06-20 21:41:52 +00:00
</div>
<div class="col-4 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn btn-link kill_button actions_serveritem" data-toggle="tooltip" title="{{ translate('dashboard', 'kill' , data['lang']) }}">
<i class="fas fa-skull"></i>
</a>
</div>
</div>
{% elif server['stats']['updating']%}
<!-- WHAT HAPPENED HERE -->
<div class="row">
<div class="col-12 px-0">
<a data-id="{{server['server_data']['server_id']}}" class="btn btn-link">{{
translate('serverTerm', 'updating',
data['lang']) }}</i></a>
2022-06-20 21:41:52 +00:00
</div>
</div>
{% elif server['stats']['waiting_start']%}
<!-- WHAT HAPPENED HERE -->
<div class="row">
<div class="col-12 px-0">
<a data-id="{{server['server_data']['server_id']}}" class="btn btn-link" title="{{
2022-06-20 21:41:52 +00:00
translate('dashboard', 'delay-explained' , data['lang'])}}">{{ translate('dashboard', 'starting',
data['lang']) }}</i></a>
2022-06-20 21:41:52 +00:00
</div>
</div>
{% elif server['stats']['importing']%}
<div class="row">
<div class="col-12 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn btn-link"><i class="fa fa-spinner fa-spin"></i>
{{ translate('serverTerm', 'importing', data['lang']) }}</a>
2022-06-20 21:41:52 +00:00
</div>
</div>
{% else %}
<div class="row">
<div class="col-4 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn play_button actions_serveritem" data-toggle="tooltip" title="{{ translate('dashboard', 'start' , data['lang']) }}">
<i class="fas fa-play"></i>
</a>
</div>
<div class="col-4 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn clone_button actions_serveritem" data-toggle="tooltip" title="{{ translate('dashboard', 'clone' , data['lang']) }}">
<i class="fas fa-clone"></i>
</a>
</div>
<div class="col-4 px-0">
2023-09-02 19:51:28 +00:00
<a data-id="{{server['server_data']['server_id']}}" class="btn kill_button actions_serveritem" data-toggle="tooltip" title="{{ translate('dashboard', 'kill' , data['lang']) }}">
<i class="fas fa-skull"></i></a>
2022-06-20 21:41:52 +00:00
</div>
</div>
{% end %}
{% end %}
2022-06-20 21:41:52 +00:00
</div>
</div>
</div>
</h2>
</div>
2023-09-02 19:51:28 +00:00
<div id="collapse-{{server['server_data']['server_id']}}" class="collapse" aria-labelledby="heading-{{server['server_data']['server_id']}}" data-parent="#accordionServers">
<div class="card-body">
<div class="row">
<div class="col-6">
<h6>{{ translate('dashboard', 'cpuUsage', data['lang']) }}</h6>
<div id="m_server_cpu_{{server['server_data']['server_id']}}">
2023-09-02 19:51:28 +00:00
<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="{{server['stats']['cpu']}}">
<div class="progress-bar
2022-06-20 21:41:52 +00:00
{% if server['stats']['cpu'] <= 33 %}
bg-success
{% elif 34 <= server['stats']['cpu'] <= 66 %}
bg-warning
{% else %}
2022-06-20 21:41:52 +00:00
bg-danger
{% end %}
2023-09-02 19:51:28 +00:00
" role="progressbar" style="width: {{server['stats']['cpu']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
2022-06-20 21:41:52 +00:00
</div>
{{server['stats']['cpu']}}%
2022-06-20 21:41:52 +00:00
</div>
</div>
<div class="col-6">
<h6>{{ translate('dashboard', 'memUsage', data['lang']) }}</h6>
<div draggable="false" id="m_server_mem_{{server['server_data']['server_id']}}">
2023-09-02 19:51:28 +00:00
<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="{{server['stats']['mem']}}">
<div class="progress-bar
2022-06-20 21:41:52 +00:00
{% if server['stats']['mem_percent'] <= 33 %}
bg-success
{% elif 34 <= server['stats']['mem_percent'] <= 66 %}
bg-warning
{% else %}
2022-06-20 21:41:52 +00:00
bg-danger
{% end %}
2023-09-02 19:51:28 +00:00
" role="progressbar" style="width: {{server['stats']['mem_percent']}}%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{{server['stats']['mem_percent']}}% -
{% if server['stats']['mem'] == 0 %}
0 MB
{% else %}
{{server['stats']['mem']}}
{% end %}
</div>
2022-06-20 21:41:52 +00:00
</div>
</div>
<br />
<div class="row">
<div class="col-6">
<h6>{{ translate('dashboard', 'size', data['lang']) }}</h6>
<div draggable="false" id="m_server_world_{{server['server_data']['server_id']}}">
{{ server['stats']['world_size'] }}
2022-06-20 21:41:52 +00:00
</div>
</div>
<div class="col-6" style="width: auto;">
<h6>{{ translate('dashboard', 'players', data['lang']) }}</h6>
<div draggable="false" id="m_server_desc_{{server['server_data']['server_id']}}">
{% if server['stats']['int_ping_results'] %}
{{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard',
'max',
data['lang']) }} <br />
{% if server['stats']['desc'] != 'False' %}
2023-09-02 19:51:28 +00:00
<div id="desc_id" style="overflow-wrap: break-word !important; max-width: 85px !important; overflow: scroll;">
{{ server['stats']['desc'] }}</div> <br />
{% end %}
{% if server['stats']['version'] != 'False' %}
{{ server['stats']['version'] }}
{% end %}
{% end %}
</div>
</div>
2022-06-20 21:41:52 +00:00
</div>
</div>
</div>
</div>
{% end %}
2022-06-20 20:39:03 +00:00
</div>
2020-08-13 14:38:36 +00:00
</div>
{% end %}
2020-08-13 14:38:36 +00:00
</div>
</div>
</div>
</div>
2020-08-13 14:38:36 +00:00
2020-08-24 17:08:17 +00:00
2020-08-13 14:38:36 +00:00
</div>
<!-- content-wrapper ends -->
<div id="mobile"></div>
<style>
2022-01-19 21:45:52 +00:00
.popover-body {
color: white !important;
;
}
2022-05-18 20:00:20 +00:00
2022-03-14 23:48:53 +00:00
#desc_id {
2022-05-18 20:00:20 +00:00
-ms-overflow-style: none;
/* for Internet Explorer, Edge */
scrollbar-width: none;
/* for Firefox */
overflow-y: scroll;
2022-05-18 20:00:20 +00:00
}
2022-03-14 23:48:53 +00:00
2022-05-18 20:00:20 +00:00
#desc_id::-webkit-scrollbar {
display: none;
/* for Chrome, Safari, and Opera */
}
2024-01-31 22:04:22 +00:00
.gray {
color: gray !important;
}
</style>
2020-08-13 14:38:36 +00:00
{% end %}
{% block js %}
2022-01-19 21:45:52 +00:00
<script src="/static/assets/js/motd.js"></script>
<script>
function display_motd() {
2022-03-19 01:48:24 +00:00
let all_motds = Array.from(document.getElementsByClassName('input_motd'));
for (element of all_motds) {
initParser(element.id, element.id);
};
}
2022-05-18 20:00:20 +00:00
$(document).ready(function () {
2022-01-19 21:45:52 +00:00
$('[data-toggle="popover"]').popover();
if ($(window).width() < 1000) {
$('.too_small').popover("show");
}
});
2022-03-19 01:48:24 +00:00
2022-05-18 20:00:20 +00:00
$(window).ready(function () {
$('body').click(function () {
2022-01-19 21:45:52 +00:00
$('.too_small').popover("hide");
});
2022-01-19 21:45:52 +00:00
});
2022-03-19 01:48:24 +00:00
2022-05-18 20:00:20 +00:00
$(window).resize(function () {
2022-01-19 21:45:52 +00:00
// This will execute whenever the window is resized
if ($(window).width() < 1000) {
$('.too_small').popover("show");
}
else {
$('.too_small').popover("hide");
} // New width
});
</script>
<script>
async function send_command(server_id, command) {
2022-01-19 21:45:52 +00:00
/* this getCookie function is in base.html */
2022-03-19 01:48:24 +00:00
const token = getCookie("_xsrf");
let res = await fetch(`/api/v2/servers/${server_id}/action/${command}`, {
method: 'POST',
headers: {
'token': token,
},
2022-01-19 21:45:52 +00:00
});
let responseData = await res.json();
if (responseData.status === "ok") {
if (command === "clone_server"){
window.location.reload()
}
console.log("Command received successfully")
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
2022-01-19 21:45:52 +00:00
}
function warnServer(message, link = null, className = null) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');
var msgEl = document.createElement('div');
closeEl.innerHTML = '&times;';
strongEL.textContent = 'Warning: ';
msgEl.append(strongEL, message);
closeEl.style.marginLeft = '15px';
closeEl.style.fontWeight = 'bold';
closeEl.style.float = 'right';
closeEl.style.fontSize = '22px';
closeEl.style.lineHeight = '20px';
closeEl.style.cursor = 'pointer';
closeEl.addEventListener('click', function () { this.parentElement.style.display = 'none'; });
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
parentEl.style.backgroundColor = '#f7970f';
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
if (link) {
let linkEl = document.createElement('a')
linkEl.href = link;
linkEl.innerHTML = "See our documentation for details.";
linkEl.style.color = 'white';
linkEl.style.textDecoration = 'underline';
linkEl.target = "_blank";
parentEl.appendChild(linkEl);
}
if (className) {
parentEl.classList.add(className);
}
2022-12-28 05:20:06 +00:00
document.querySelector('.dynamicMsg').appendChild(parentEl);
}
2022-01-19 21:45:52 +00:00
function update_one_server_status(server) {
/* Mobile view update */
2022-01-19 21:45:52 +00:00
server_cpu = document.getElementById('server_cpu_' + server.id);
server_mem = document.getElementById('server_mem_' + server.id);
server_world = document.getElementById('server_world_' + server.id);
server_desc = document.getElementById('server_desc_' + server.id);
server_online_status = document.getElementById('server_running_status_' + server.id);
server_players = document.getElementById('server_players_' + server.id);
total_players = document.getElementById('total_players');
2022-01-19 21:45:52 +00:00
/* Mobile view update */
m_server_cpu = document.getElementById('m_server_cpu_' + server.id);
m_server_mem = document.getElementById('m_server_mem_' + server.id);
m_server_world = document.getElementById('m_server_world_' + server.id);
m_server_desc = document.getElementById('m_server_desc_' + server.id);
m_server_online_status = document.getElementById('m_server_running_status_' + server.id);
2022-01-19 21:45:52 +00:00
console.log("Received Data : " + server.id + ": " + server);
/* TODO Update each element */
/* Update CPU */
2022-03-19 01:48:24 +00:00
cpu_status = "bg-danger";
if (server.cpu <= 33) {
2022-01-19 21:45:52 +00:00
cpu_status = "bg-success";
2022-03-19 01:48:24 +00:00
} else if (server.cpu > 33 && server.cpu <= 66) {
2022-01-19 21:45:52 +00:00
cpu_status = "bg-warning";
}
2022-03-19 01:48:24 +00:00
2022-05-18 20:00:20 +00:00
server_cpu.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="` + server.cpu + `"><div class="progress-bar ` + cpu_status + `" role="progressbar" style="width: ` + server.cpu + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>` + server.cpu + `%`;
m_server_cpu.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="` + server.cpu + `"><div class="progress-bar ` + cpu_status + `" role="progressbar" style="width: ` + server.cpu + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>` + server.cpu + `%`;
2022-01-19 21:45:52 +00:00
/* Update Memory */
2022-03-19 01:48:24 +00:00
mem_status = "bg-danger";
total_mem = "0 MB";
if (server.mem_percent <= 33) {
2022-01-19 21:45:52 +00:00
mem_status = "bg-success";
2022-03-19 01:48:24 +00:00
} else if (server.mem_percent > 33 && server.mem_percent <= 66) {
2022-01-19 21:45:52 +00:00
mem_status = "bg-warning";
}
2021-09-13 19:03:47 +00:00
2022-03-19 01:48:24 +00:00
if (server.mem !== 0) {
2022-01-19 21:45:52 +00:00
total_mem = server.mem;
}
2022-05-18 20:00:20 +00:00
server_mem.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="` + server_mem + `"><div class="progress-bar ` + mem_status + `" role="progressbar" style="width: ` + server.mem_percent + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>` + server.mem_percent + `% - ` + total_mem;
m_server_mem.innerHTML = `<div class="progress mb-1" data-toggle="tooltip" data-placement="top" title="` + server_mem + `"><div class="progress-bar ` + mem_status + `" role="progressbar" style="width: ` + server.mem_percent + `%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div></div>` + server.mem_percent + `% - ` + total_mem;
2022-01-19 21:45:52 +00:00
/* Update World Infos */
2022-03-02 02:56:12 +00:00
server_world.innerHTML = server.world_size
m_server_world.innerHTML = server.world_size
2022-01-19 21:45:52 +00:00
/* Update Server Infos */
if (server.int_ping_results) {
/* Update Players */
if (server.players) {
server_desc.innerHTML = server.online + ` / ` + server.max + ` {{ translate('dashboard', 'max', data['lang']) }}<br />`
m_server_desc.innerHTML = server.online + ` / ` + server.max + ` {{ translate('dashboard', 'max', data['lang']) }}<br />`
2022-01-19 21:45:52 +00:00
server_players.setAttribute('data-players', server.online);
server_players.setAttribute('data-max', server.max);
server_players.setAttribute('data-count', server.count_players)
2022-06-03 19:21:57 +00:00
let servers = Array.from(document.getElementsByClassName("server-player-totals"));
let all_total_players = 0;
let all_total_max_players = 0;
servers.forEach(server => {
2022-03-19 01:48:24 +00:00
try {
console.log(`#server_desc_${server.getAttribute("data-serverId")}`)
$(`#server_desc_${server.getAttribute("data-serverId")}`).toggleClass("gray", server.getAttribute('data-count') === 'false')
2024-01-31 22:04:22 +00:00
if (server.getAttribute('data-count') === 'true') {
all_total_players += parseInt(server.getAttribute('data-players'));
all_total_max_players += parseInt(server.getAttribute('data-max'));
}
2024-01-31 22:04:22 +00:00
} catch {
console.log("Player totals are not of type int");
}
})
total_players.innerHTML = all_total_players;
document.getElementById('max_players').innerHTML = all_total_max_players;
document.getElementById('sync').innerHTML = '';
2022-01-19 21:45:52 +00:00
server_infos = "";
m_server_infos = "";
server_infos = server.online + " / " + server.max + " {{ translate('dashboard', 'max', data['lang']) }}<br />"
2022-01-19 21:45:52 +00:00
}
/* Update Motd */
2022-03-19 01:48:24 +00:00
let motd = "";
2022-01-19 21:45:52 +00:00
if (server.desc) {
2023-09-02 19:51:28 +00:00
m_motd = `<span id="m_input_motd_` + server.id + `" class="input_motd">` + server.desc + `</span>`;
2022-01-19 21:45:52 +00:00
motd = `<span id="input_motd_` + server.id + `" class="input_motd">` + server.desc + `</span>`;
m_server_infos = server_infos + '<div id="desc_id" style="word-wrap: break-word; overflow: auto;">' + motd + '</div>' + "<br />";
2022-03-14 23:48:53 +00:00
server_infos = server_infos + '<div id="desc_id" style="word-wrap: break-word; max-width: 85px !important; overflow: auto;">' + motd + '</div>' + "<br />";
2022-01-19 21:45:52 +00:00
}
/* Version */
if (server.version) {
server_infos = server_infos + server.version
m_server_infos = m_server_infos + server.version
2022-01-19 21:45:52 +00:00
}
server_desc.innerHTML = server_infos;
m_server_desc.innerHTML = m_server_infos;
2022-01-19 21:45:52 +00:00
}
/* Update Online Status */
2022-03-19 01:48:24 +00:00
let online_status = `<span class="text-warning"><i class="fas fa-ban"></i> {{ translate('dashboard', 'offline', data['lang'])}}</span>`;
2022-01-19 21:45:52 +00:00
if (server.running) {
online_status = `<span class="text-success"><i class="fas fa-signal"></i> {{ translate('dashboard', 'online', data['lang'])}}</span>`;
}
2022-03-19 01:48:24 +00:00
if (server.crashed) {
online_status = `<span class="text-danger"><i class="fas fa-exclamation-triangle"></i> {{ translate('dashboard', 'crashed', data['lang'])}}</span>`
2022-01-19 21:45:52 +00:00
}
2022-03-19 01:48:24 +00:00
2022-01-19 21:45:52 +00:00
server_online_status.innerHTML = online_status;
}
function update_servers_status(data) {
2022-03-19 01:48:24 +00:00
try {
2022-05-18 20:00:20 +00:00
update_one_server_status(data[0]);
2022-03-19 01:48:24 +00:00
} catch (e) {
2022-05-18 20:00:20 +00:00
console.log('Failed to update server stats', e)
2022-03-19 01:48:24 +00:00
}
2022-01-19 21:45:52 +00:00
display_motd();
}
2022-05-18 20:00:20 +00:00
$(document).ready(function () {
2022-01-19 21:45:52 +00:00
console.log('ready for JS!')
2022-05-18 20:00:20 +00:00
$(".play_button").click(function () {
2022-01-19 21:45:52 +00:00
server_id = $(this).attr("data-id");
send_command(server_id, 'start_server');
bootbox.alert({
backdrop: true,
2022-12-28 05:20:06 +00:00
title: '<span class="dynamicMsg">{% raw translate("dashboard", "sendingCommand", data["lang"]) %}</span>',
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> &nbsp; {% raw translate("dashboard", "bePatientStart", data["lang"]) %} </div>'
});
2022-12-28 05:20:06 +00:00
setTimeout(finishTimeout, 60000);
});
2022-12-28 05:20:06 +00:00
function finishTimeout() {
warnServer("It seems this is taking a while...it's possible you're using UBlock or a similar ad blocker and it's causing some of our connections to not make it to the server. Try disabling your ad blocker.",
2022-12-28 05:20:06 +00:00
null, 'wssError');
}
2022-05-18 20:00:20 +00:00
$(".stop_button").click(function () {
2022-01-19 21:45:52 +00:00
console.log("stopping server");
server_id = $(this).attr("data-id");
send_command(server_id, 'stop_server');
bootbox.alert({
backdrop: true,
title: '{% raw translate("dashboard", "sendingCommand", data["lang"]) %}',
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> &nbsp; {% raw translate("dashboard", "bePatientStop", data["lang"]) %} </div>'
});
});
2022-05-18 20:00:20 +00:00
$(".restart_button").click(function () {
2022-01-19 21:45:52 +00:00
server_id = $(this).attr("data-id");
send_command(server_id, 'restart_server');
bootbox.alert({
backdrop: true,
title: '{% raw translate("dashboard", "sendingCommand", data["lang"]) %}',
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> &nbsp; {% raw translate("dashboard", "bePatientRestart", data["lang"]) %} </div>'
});
2022-01-19 21:45:52 +00:00
});
2022-05-18 20:00:20 +00:00
$(".kill_button").click(function () {
2021-09-13 19:03:47 +00:00
server_id = $(this).attr("data-id");
bootbox.confirm({
2022-01-19 21:45:52 +00:00
message: "This will kill the server process and all it's subprocesses. Killing a process can potentially corrupt files. Only do this in extreme circumstances. Are you sure you would like to continue?",
buttons: {
confirm: {
label: '{% raw translate("dashboard", "kill", data["lang"]) %}',
2021-09-13 19:03:47 +00:00
className: 'btn-danger'
2022-01-19 21:45:52 +00:00
},
cancel: {
label: '{% raw translate("panelConfig", "cancel", data["lang"]) %}',
2021-09-13 19:03:47 +00:00
className: 'btn-secondary'
2022-01-19 21:45:52 +00:00
}
},
2022-05-18 20:00:20 +00:00
callback: function (result) {
2022-01-19 21:45:52 +00:00
if (result) {
send_command(server_id, "kill_server");
2022-03-19 01:48:24 +00:00
let dialog = bootbox.dialog({
title: '{% raw translate("dashboard", "killing", data["lang"]) %}',
2022-01-19 21:45:52 +00:00
message: '<p><i class="fa fa-spin fa-spinner"></i> Loading...</p>'
});
}
2021-09-13 19:03:47 +00:00
}
2022-01-19 21:45:52 +00:00
});
2021-02-27 12:05:04 +00:00
});
2022-01-19 21:45:52 +00:00
if (webSocket) {
cpu_data = document.getElementById('cpu_data');
cpu_usage = document.getElementById('cpu_usage');
mem_usage = document.getElementById('mem_usage');
mem_percent = document.getElementById('mem_percent');
2022-03-19 01:48:24 +00:00
2022-05-18 20:00:20 +00:00
webSocket.on('update_host_stats', function (hostStats) {
2022-03-19 01:48:24 +00:00
let cpuDataTitle = `{% raw translate('dashboard', 'cpuCores', data['lang']) %}: ${hostStats.cpu_cores} <br /> {% raw translate("dashboard", "cpuCurFreq", data['lang']) %}: ${hostStats.cpu_cur_freq} <br /> {% raw translate("dashboard", "cpuMaxFreq", data['lang']) %}: ${hostStats.cpu_max_freq}`;
2022-01-19 21:45:52 +00:00
cpu_data.setAttribute('data-original-title', cpuDataTitle);
cpu_usage.textContent = hostStats.cpu_usage;
mem_usage.setAttribute('data-original-title', `{% raw translate("dashboard", "memUsage", data['lang']) %}: ${hostStats.mem_usage}`);
mem_percent.textContent = hostStats.mem_percent + '%';
2023-02-07 18:56:13 +00:00
var storage_html = '<div class="row">';
for (i = 0; i < hostStats.disk_usage.length; i++) {
if (hostStats.mounts.includes(hostStats.disk_usage[i].mount)) {
2023-03-12 20:46:50 +00:00
storage_html += `<div id="host_storage" class="col-xl-3 col-lg-3 col-md-4 col-12">
<h4 class="mb-0 font-weight-semibold d-inline-block text-truncate storage-heading" id="title_host_storage" data-toggle="tooltip" data-placement="bottom" title="${hostStats.disk_usage[i].mount}" style="max-width: 100%;"><i class="fas fa-hdd"></i> ${hostStats.disk_usage[i].mount}</h4>
2023-02-07 18:56:13 +00:00
<div class="progress" style="display: inline-block; height: 20px; width: 100%; background-color: rgb(139, 139, 139) !important;">
<div class="progress-bar`;
2023-02-07 22:51:13 +00:00
if (hostStats.disk_usage[i].percent_used <= 58) {
storage_html += ` bg-success`;
2023-02-07 22:51:13 +00:00
} else if (hostStats.disk_usage[i].percent_used <= 75 && hostStats.disk_usage[i].percent_used >= 59) {
storage_html += ` bg-warning`;
} else {
storage_html += ` bg-danger`;
}
storage_html += `" role="progressbar" style="color: black; height: 100%; width: ${hostStats.disk_usage[i].percent_used}%;"
2023-02-07 18:56:13 +00:00
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">${hostStats.disk_usage[i].used} / ${hostStats.disk_usage[i].total}
</div>
</div>
</div>`;
}
}
2023-02-07 18:56:13 +00:00
storage_html += `</div>`;
2023-02-07 22:51:13 +00:00
$(".storage-heading").tooltip('hide');
$("#storage_data").html(storage_html);
2023-02-07 22:51:13 +00:00
$("#storage_data").tooltip({ selector: '.storage-heading' });
2022-01-19 21:45:52 +00:00
});
}
if (webSocket) {
2022-05-18 20:00:20 +00:00
webSocket.on('send_start_reload', function () {
2022-01-19 21:45:52 +00:00
location.reload()
});
}
2022-01-19 21:45:52 +00:00
if (webSocket) {
2022-05-18 20:00:20 +00:00
webSocket.on('update_button_status', function (updateButton) {
let serverId = updateButton.server_id;
let message = updateButton.string;
let updating = updateButton.isUpdating;
let id = 'controls' + serverId;
if (updating) {
console.log(updating)
document.getElementById(id).innerHTML = message;
}
2022-01-19 21:45:52 +00:00
else {
window.location.reload()
}
});
}
if (webSocket) {
webSocket.on('update_server_status', update_servers_status);
}
2022-05-18 20:00:20 +00:00
$(".clone_button").click(function () {
2022-01-19 21:45:52 +00:00
server_id = $(this).attr("data-id");
2022-06-22 18:51:10 +00:00
bootbox.confirm({
message: "{{ translate('dashboard', 'cloneConfirm' , data['lang']) }}",
buttons: {
confirm: {
label: "{{ translate('dashboard', 'clone' , data['lang']) }}",
className: 'btn-outline-warning'
},
cancel: {
label: '{% raw translate("panelConfig", "cancel", data["lang"]) %}',
className: 'btn-secondary'
}
},
callback: function (result) {
if (result) {
send_command(server_id, 'clone_server');
bootbox.dialog({
backdrop: true,
title: '{% raw translate("dashboard", "sendingCommand", data["lang"]) %}',
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> &nbsp; {% raw translate("dashboard", "bePatientClone", data["lang"]) %} </div>',
closeButton: false,
});
2022-06-22 18:51:10 +00:00
}
}
});
});
2022-01-19 21:45:52 +00:00
});
</script>
2022-06-02 17:27:38 +00:00
<script src="/static/assets/vendors/js/jquery-ui.js"></script>
<link rel="stylesheet" href="/static/assets/vendors/css/jquery-ui.css">
<link rel="stylesheet" href="/static/assets/vendors/css/jquery-ui.structure.css">
<style>
@media only screen and (max-width: 760px) {
2022-05-18 20:00:20 +00:00
#mobile {
display: none;
}
}
2022-05-18 20:00:20 +00:00
.ui-sortable-handle {
cursor: default;
2022-05-18 20:00:20 +00:00
padding: 2px;
}
2022-05-18 20:00:20 +00:00
.ui-sortable-handle:hover {
cursor: grab !important;
2022-05-18 20:00:20 +00:00
padding: 2px;
}
</style>
<script>
2022-03-19 01:48:24 +00:00
/* Search Bar */
2022-05-18 20:00:20 +00:00
$(document).ready(function () {
2022-03-19 01:48:24 +00:00
let servers_table = $('#servers_table').DataTable({
"ordering": false, // false to disable sorting (or any other option)
"paging": false
});
2022-06-15 21:19:48 +00:00
const first = document.querySelector('#first')
first !== null && first.setAttribute('draggable', false);
2022-03-19 01:48:24 +00:00
$('.dataTables_length').addClass('bs-select');
});
/* Search Bar End */
2022-05-18 20:00:20 +00:00
$(document).on("mousedown keyup click", function (event) {
2022-03-19 01:48:24 +00:00
const value = $('.dataTables_filter input').val();
2022-04-03 01:47:32 +00:00
const is_mobile = $('#mobile').css('display') === 'none';
if ($("table#servers_table tbody").sortable("toArray").length > 1 && value === '' && !is_mobile) {
2022-03-19 01:48:24 +00:00
$("table#servers_table tbody").sortable("enable");
} else {
$("table#servers_table tbody").sortable("disable");
}
2022-03-19 01:48:24 +00:00
});
2022-05-18 20:00:20 +00:00
$(document).ready(function () {
2023-10-08 02:10:24 +00:00
async function sendOrder(id_string) {
2022-05-18 20:00:20 +00:00
const token = getCookie("_xsrf")
2023-10-08 02:10:24 +00:00
let res = await fetch(`/api/v2/users/@me`, {
2024-01-31 22:04:22 +00:00
method: 'PATCH',
headers: {
'X-XSRFToken': token
},
body: JSON.stringify({
2023-03-01 20:25:28 +00:00
server_order: id_string,
}),
2022-05-18 20:00:20 +00:00
});
2024-01-31 22:04:22 +00:00
let responseData = await res.json();
if (responseData.status === "ok") {
return
} else {
bootbox.alert({
title: responseData.status,
message: responseData.error
});
}
2023-10-08 02:10:24 +00:00
}
2022-05-18 20:00:20 +00:00
// Inits the sortable
$("table#servers_table tbody")
.sortable({
items: '> tr',
cursor: "grabbing",
axis: "y",
revert: true,
handle: "i.fas.fa-server,a",
forcePlaceholderSize: true,
placeholder: 'table-placeholder',
deactivate: function (event, ui) {
// Gets the list of ids in the server list as an array,
// and joins the elements with an [,] and sends to the server.
const ids = $("table#servers_table tbody").sortable("toArray").join();
try {
sendOrder(ids);
} catch {
console.log("Search is actively supressing order change")
}
},
});
2022-03-19 01:48:24 +00:00
2022-05-18 20:00:20 +00:00
// Give the table an actual width so the draggable does't collapse when dragged
$("table#servers_table")
2022-03-19 01:48:24 +00:00
.children()
.find("td")
.each(function () {
$(this).css("width", "").css("width", $(this).outerWidth());
2022-05-18 20:00:20 +00:00
});
2022-03-19 01:48:24 +00:00
2022-05-18 20:00:20 +00:00
// Fixes the appearance of a scrollbar when a user tries to drag an item too low
// Disabled on mobile since sorting is disabled on mobile
2022-04-03 01:47:32 +00:00
if ($('#mobile').css('display') !== 'none') {
2022-05-18 20:00:20 +00:00
$("div#servers_table_wrapper").css({ overflow: "hidden" });
}
});
2022-03-19 01:48:24 +00:00
</script>
2022-06-20 20:39:03 +00:00
{% end %}