mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
76a499f5a4
Fix update notifs
533 lines
24 KiB
HTML
533 lines
24 KiB
HTML
{% extends ../base.html %}
|
|
|
|
{% block meta %}
|
|
{% end %}
|
|
|
|
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
|
|
|
{% block content %}
|
|
|
|
<div class="content-wrapper">
|
|
|
|
<!-- Page Title Header Starts-->
|
|
<div class="row page-title-header">
|
|
<div class="col-12">
|
|
<div class="page-header">
|
|
<h4 class="page-title">
|
|
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
|
|
data['server_stats']['server_id']['server_name'] }}
|
|
<br />
|
|
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
|
|
</h4>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<!-- Page Title Header Ends-->
|
|
|
|
{% include "parts/details_stats.html" %}
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12 grid-margin">
|
|
<div class="card">
|
|
<div class="card-body pt-0">
|
|
{% if not data['failed'] %}
|
|
<span class="d-none d-sm-block">
|
|
{% include "parts/server_controls_list.html %}
|
|
</span>
|
|
<span class="d-block d-sm-none">
|
|
{% include "parts/m_server_controls_list.html %}
|
|
</span>
|
|
{% end %}
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 col-sm-12">
|
|
<form class="forms-sample" method="post" id="config_form" action="/panel/server_detail">
|
|
{% raw xsrf_form_html() %}
|
|
<input type="hidden" name="id" value="{{ data['server_stats']['server_id']['server_id'] }}">
|
|
<input type="hidden" name="subpage" value="config">
|
|
|
|
<div class="form-group">
|
|
<label for="server_name">{{ translate('serverConfig', 'serverName', data['lang']) }} <small
|
|
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverNameDesc', data['lang']) }}</small>
|
|
</label>
|
|
<input type="text" class="form-control" name="server_name" id="server_name"
|
|
value="{{ data['server_stats']['server_id']['server_name'] }}"
|
|
placeholder="{{ translate('serverConfig', 'serverName', data['lang']) }}" required>
|
|
</div>
|
|
|
|
{% if data['super_user'] %}
|
|
<div class="form-group">
|
|
<label for="server_path">{{ translate('serverConfig', 'serverPath', data['lang']) }} <small
|
|
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverPathDesc', data['lang']) }}</small>
|
|
</label>
|
|
<input type="text" class="form-control" name="server_path" id="server_path"
|
|
value="{{ data['server_stats']['server_id']['path'] }}"
|
|
placeholder="{{ translate('serverConfig', 'serverPath', data['lang']) }}" required>
|
|
|
|
</div>
|
|
{% if data['server_stats']['server_type'] != "minecraft-bedrock" %}
|
|
<div class="form-group">
|
|
<label for="log_path">{{ translate('serverConfig', 'serverLogLocation', data['lang']) }} <small
|
|
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverLogLocationDesc', data['lang'])
|
|
}}</small> </label>
|
|
<input type="text" class="form-control" name="log_path" id="log_path"
|
|
value="{{ data['server_stats']['server_id']['log_path'] }}"
|
|
placeholder="{{ translate('serverConfig', 'serverLogLocation', data['lang']) }}" required>
|
|
</div>
|
|
{% end %}
|
|
|
|
<div class="form-group">
|
|
<label for="executable">{{ translate('serverConfig', 'serverExecutable', data['lang']) }} <small
|
|
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverExecutableDesc', data['lang'])
|
|
}}</small> </label>
|
|
<input type="text" class="form-control" name="executable" id="executable"
|
|
value="{{ data['server_stats']['server_id']['executable'] }}"
|
|
placeholder="{{ translate('serverConfig', 'serverExecutable', data['lang']) }}" required>
|
|
</div>
|
|
{% end %}
|
|
{% if data['server_stats']['server_type'] == "minecraft-java" %}
|
|
<div class="form-group">
|
|
<label for="java_selection">{{ translate('serverConfig', 'javaVersion', data['lang']) }}
|
|
<small class="text-muted ml-1">{{ translate('serverConfig', 'javaVersionDesc', data['lang'])
|
|
}}</small>
|
|
</label>
|
|
<select class="form-select form-control form-control-lg select-css" id="java_selection"
|
|
name="java_selection" form="config_form">
|
|
<option value="">{{ translate('serverConfig',
|
|
'javaNoChange', data['lang'])}}</option>
|
|
{% for path in data['java_versions'] %}
|
|
<option value="{{path}}">{{path}}</option>
|
|
{% end %}
|
|
</select>
|
|
</div>
|
|
{% end %}
|
|
|
|
{% if data['super_user'] %}
|
|
<div class="form-group">
|
|
<label for="execution_command">{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }}
|
|
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverExecutionCommandDesc',
|
|
data['lang']) }}</small> </label>
|
|
<input type="text" class="form-control" name="execution_command" id="execution_command"
|
|
value="{{ data['server_stats']['server_id']['execution_command'] }}"
|
|
placeholder="{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }}" required>
|
|
</div>
|
|
{% else %}
|
|
<label for="execution_command">{{ translate('serverConfig', 'serverExecutionCommand', data['lang']) }}
|
|
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
|
<span style="color: gray;">{{ data['server_stats']['server_id']['execution_command'] }}</span> 🔒
|
|
</div>
|
|
<br>
|
|
{% end %}
|
|
<div class="form-group">
|
|
<label for="stop_command">{{ translate('serverConfig', 'serverStopCommand', data['lang']) }} <small
|
|
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverStopCommandDesc', data['lang'])
|
|
}}</small> </label>
|
|
<input type="text" class="form-control" name="stop_command" id="stop_command"
|
|
value="{{ data['server_stats']['server_id']['stop_command'] }}"
|
|
placeholder="{{ translate('serverConfig', 'serverStopCommand', data['lang']) }}" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="auto_start_delay">{{ translate('serverConfig', 'serverAutostartDelay', data['lang']) }}
|
|
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'serverAutostartDelayDesc',
|
|
data['lang']) }}</small> </label>
|
|
<input type="number" class="form-control" name="auto_start_delay" id="auto_start_delay"
|
|
value="{{ data['server_stats']['server_id']['auto_start_delay'] }}" step="1" max="999" min="10"
|
|
required>
|
|
</div>
|
|
|
|
{% if data['super_user'] %}
|
|
{% if data['server_stats']['server_type'] != "minecraft-bedrock" %}
|
|
<div class="form-group">
|
|
<label for="executable_update_url">{{ translate('serverConfig', 'exeUpdateURL', data['lang']) }}
|
|
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'exeUpdateURLDesc', data['lang'])
|
|
}}</small> </label>
|
|
<input type="text" class="form-control" name="executable_update_url" id="executable_update_url"
|
|
value="{{ data['server_stats']['server_id']['executable_update_url'] }}"
|
|
placeholder="{{ translate('serverConfig', 'exeUpdateURL', data['lang']) }}">
|
|
</div>
|
|
{% end %}
|
|
|
|
<div class="form-group">
|
|
<label for="server_ip">{{ translate('serverConfig', 'serverIP', data['lang']) }} <small
|
|
class="text-muted ml-1">- {{ translate('serverConfig', 'serverIPDesc', data['lang']) }}</small>
|
|
</label>
|
|
<input type="text" class="form-control" name="server_ip" id="server_ip"
|
|
value="{{ data['server_stats']['server_id']['server_ip'] }}" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="server_port">{{ translate('serverConfig', 'serverPort', data['lang']) }} <small
|
|
class="text-muted ml-1"> - {{ translate('serverConfig', 'serverPortDesc', data['lang']) }}
|
|
</small> </label>
|
|
<input type="number" class="form-control" name="server_port" id="server_port"
|
|
value="{{ data['server_stats']['server_id']['server_port'] }}" step="1" max="65566" min="1"
|
|
required>
|
|
</div>
|
|
{% end %}
|
|
|
|
<div class="form-group">
|
|
<label for="shutdown_timeout">{{ translate('serverConfig', 'shutdownTimeout', data['lang']) }}
|
|
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'timeoutExplain1', data['lang'])
|
|
}}
|
|
{{ data['server_stats']['server_id']['stop_command'] }} {{ translate('serverConfig',
|
|
'timeoutExplain2', data['lang']) }}
|
|
</small> </label>
|
|
<input type="number" class="form-control" name="shutdown_timeout" id="shutdown_timeout"
|
|
value="{{ data['server_stats']['server_id']['shutdown_timeout'] }}" step="2" max="300" min="60"
|
|
required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="logs_delete_after">{{ translate('serverConfig', 'removeOldLogsAfter', data['lang']) }}
|
|
<small class="text-muted ml-1"> - {{ translate('serverConfig', 'removeOldLogsAfterDesc',
|
|
data['lang']) }}</small> </label>
|
|
<input type="number" class="form-control" name="logs_delete_after" id="logs_delete_after"
|
|
value="{{ data['server_stats']['server_id']['logs_delete_after'] }}" step="1" max="365" min="0"
|
|
required>
|
|
</div>
|
|
|
|
<div class="form-check-flat">
|
|
<label for="auto_start" class="form-check-label ml-4 mb-4">
|
|
{% if data['server_stats']['server_id']['auto_start'] %}
|
|
<input type="checkbox" class="form-check-input" id="auto_start" name="auto_start" checked=""
|
|
data-toggle="toggle" value="1"> {{ translate('serverConfig', 'serverAutoStart',
|
|
data['lang']) }}
|
|
{% else %}
|
|
<input type="checkbox" class="form-check-input" id="auto_start" name="auto_start" value="1"
|
|
data-toggle="toggle"> {{
|
|
translate('serverConfig', 'serverAutoStart', data['lang']) }}
|
|
{% end %}
|
|
</label>
|
|
|
|
<label for="crash_detection" class="form-check-label ml-4 mb-4">
|
|
{% if data['server_stats']['server_id']['crash_detection'] %}
|
|
<input type="checkbox" class="form-check-input" id="crash_detection" name="crash_detection"
|
|
data-toggle="toggle" checked="" value="1"> {{ translate('serverConfig',
|
|
'serverCrashDetection', data['lang']) }}
|
|
{% else %}
|
|
<input type="checkbox" class="form-check-input" id="crash_detection" name="crash_detection"
|
|
data-toggle="toggle" value="1"> {{ translate('serverConfig', 'serverCrashDetection',
|
|
data['lang']) }}
|
|
{% end %}
|
|
</label>
|
|
|
|
{% if data['super_user'] %}
|
|
<label for="show_status" class="form-check-label ml-4 mb-4">
|
|
{% if data['server_stats']['server_id']['show_status'] %}
|
|
<input type="checkbox" class="form-check-input" id="show_status" name="show_status"
|
|
data-toggle="toggle" checked="" value="1"> {{ translate('serverConfig', 'showStatus',
|
|
data['lang']) }}
|
|
{% else %}
|
|
<input type="checkbox" class="form-check-input" id="show_status" name="show_status"
|
|
data-toggle="toggle" value="1"> {{ translate('serverConfig', 'showStatus',
|
|
data['lang']) }}
|
|
{% end %}
|
|
</label>
|
|
{% end %}
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{
|
|
translate('serverConfig', 'save', data['lang']) }}</button>
|
|
<button type="reset" class="btn btn-light"><i class="fas fa-times"></i> {{ translate('serverConfig',
|
|
'cancel', data['lang']) }}</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="col-md-6 col-sm-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="card-title">{{ translate('serverConfigHelp', 'title', data['lang']) }}</h4>
|
|
<p class="card-description"> {{ translate('serverConfigHelp', 'desc', data['lang']) }}</p>
|
|
<blockquote class="blockquote">
|
|
<p class="mb-0">
|
|
{% raw translate('serverConfigHelp', 'perms', data['lang']) %}
|
|
</p>
|
|
</blockquote>
|
|
</div>
|
|
</div>
|
|
<div class="text-center">
|
|
{% if data['server_stats']['running'] %}
|
|
{% if data['server_stats']['updating'] %}
|
|
<i id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
|
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
|
class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
|
'update', data['lang']) }}</button>
|
|
{% else %}
|
|
<i style="visibility: hidden;" id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
|
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
|
class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
|
'update', data['lang']) }}</button>
|
|
{% end %}
|
|
<a class="btn btn-sm btn-danger disabled">{{ translate('serverConfig', 'deleteServer', data['lang'])
|
|
}}</a><br />
|
|
<small>{{ translate('serverConfig', 'stopBeforeDeleting', data['lang']) }}</small>
|
|
{% else %}
|
|
{% if not data['failed'] %}
|
|
{% if data['server_stats']['updating'] %}
|
|
<i id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
|
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
|
class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
|
'update', data['lang']) }}</button>
|
|
{% else %}
|
|
<i style="visibility: hidden;" id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
|
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
|
class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
|
'update', data['lang']) }}</button>
|
|
{% end %}
|
|
{% end %}
|
|
{% if not data['failed'] %}
|
|
<button onclick="deleteConfirm()" class="btn btn-sm btn-danger">{{ translate('serverConfig',
|
|
'deleteServer', data['lang']) }}</button>
|
|
{% else %}
|
|
<button onclick="deleteUnloadedConfirm()" class="btn btn-sm btn-danger">{{ translate('serverConfig',
|
|
'deleteServer', data['lang']) }}</button>
|
|
{% end %}
|
|
{% end %}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
<style>
|
|
.toggle-handle {
|
|
background-color: white !important;
|
|
}
|
|
|
|
.toggle-on {
|
|
color: black !important;
|
|
background-color: blueviolet !important;
|
|
}
|
|
|
|
.toggle {
|
|
height: 0px !important;
|
|
background-color: grey !important;
|
|
}
|
|
</style>
|
|
<!-- content-wrapper ends -->
|
|
|
|
{% end %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(function () {
|
|
$('.form-check-input').bootstrapToggle({
|
|
on: '',
|
|
off: ''
|
|
});
|
|
})
|
|
const serverId = new URLSearchParams(document.location.search).get('id')
|
|
|
|
|
|
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
|
|
function getCookie(name) {
|
|
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
|
|
return r ? r[1] : undefined;
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
console.log("ready!");
|
|
|
|
});
|
|
|
|
function deleteServerE(callback) {
|
|
var token = getCookie("_xsrf")
|
|
$.ajax({
|
|
type: "DELETE",
|
|
headers: { 'X-XSRFToken': token },
|
|
url: '/ajax/delete_server?id=' + serverId,
|
|
data: {
|
|
},
|
|
success: function (data) {
|
|
console.log("got response:");
|
|
console.log(data);
|
|
},
|
|
});
|
|
}
|
|
function deleteServerFilesE(path, callback) {
|
|
var token = getCookie("_xsrf")
|
|
$.ajax({
|
|
type: "DELETE",
|
|
headers: { 'X-XSRFToken': token },
|
|
url: '/ajax/delete_server_files?id=' + serverId,
|
|
data: {
|
|
},
|
|
success: function (data) {
|
|
console.log("got response:");
|
|
console.log(data);
|
|
},
|
|
});
|
|
}
|
|
|
|
function send_command(serverId, command) {
|
|
//<!-- this getCookie function is in base.html-->
|
|
var token = getCookie("_xsrf");
|
|
if (command == "update_executable") {
|
|
document.getElementById("update-spinner").style.visibility = "visible";
|
|
}
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
headers: { 'X-XSRFToken': token },
|
|
url: '/server/command?command=' + command + '&id=' + serverId,
|
|
success: function (data) {
|
|
console.log("got response:");
|
|
console.log(data);
|
|
if (command != "update_executable") {
|
|
setTimeout(function () { location.reload(); }, 10000);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function deleteServer() {
|
|
path = "{{data['server_stats']['server_id']['path']}}";
|
|
name = "{{data['server_stats']['server_id']['server_name']}}";
|
|
bootbox.dialog({
|
|
size: "",
|
|
title: "{% raw translate('serverConfig', 'deleteFilesQuestion', data['lang']) %}",
|
|
closeButton: false,
|
|
message: "{% raw translate('serverConfig', 'deleteFilesQuestionMessage', data['lang']) %}",
|
|
buttons: {
|
|
files: {
|
|
label: "{{ translate('serverConfig', 'yesDeleteFiles', data['lang']) }}",
|
|
className: 'btn-danger',
|
|
callback: function () {
|
|
deleteServerFilesE();
|
|
setTimeout(function () { window.location = '/panel/dashboard'; }, 5000);
|
|
bootbox.dialog({
|
|
backdrop: true,
|
|
title: '{% raw translate("serverConfig", "sendingDelete", data['lang']) %}',
|
|
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> {% raw translate("serverConfig", "bePatientDeleteFiles", data['lang']) %} </div>',
|
|
closeButton: false
|
|
})
|
|
|
|
return;
|
|
}
|
|
},
|
|
noFiles: {
|
|
label: "{{ translate('serverConfig', 'noDeleteFiles', data['lang']) }}",
|
|
className: 'btn-outline-danger',
|
|
callback: function () {
|
|
deleteServerE()
|
|
setTimeout(function () { window.location = '/panel/dashboard'; }, 5000);
|
|
bootbox.dialog({
|
|
backdrop: true,
|
|
title: '{% raw translate("serverConfig", "sendingDelete", data['lang']) %}',
|
|
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> {% raw translate("serverConfig", "bePatientDelete", data['lang']) %} </div>',
|
|
closeButton: false
|
|
})
|
|
return;
|
|
}
|
|
},
|
|
cancel: {
|
|
label: "{{ translate('serverConfig', 'cancel', data['lang']) }}",
|
|
className: 'btn-secondary',
|
|
callback: function () {
|
|
return;
|
|
}
|
|
}
|
|
},
|
|
callback: function (result) {
|
|
|
|
}
|
|
});
|
|
}
|
|
function deleteConfirm() {
|
|
path = "{{data['server_stats']['server_id']['path']}}";
|
|
name = "{{data['server_stats']['server_id']['server_name']}}";
|
|
bootbox.confirm({
|
|
size: "",
|
|
title: "{% raw translate('serverConfig', 'deleteServerQuestion', data['lang']) %}",
|
|
closeButton: false,
|
|
message: "{% raw translate('serverConfig', 'deleteServerQuestionMessage', data['lang']) %}",
|
|
buttons: {
|
|
confirm: {
|
|
label: "{{ translate('serverConfig', 'yesDelete', data['lang']) }}",
|
|
className: 'btn-danger',
|
|
},
|
|
cancel: {
|
|
label: "{{ translate('serverConfig', 'noDelete', data['lang']) }}",
|
|
className: 'btn-link',
|
|
}
|
|
},
|
|
callback: function (result) {
|
|
if (!result) {
|
|
return;
|
|
return;
|
|
}
|
|
else {
|
|
deleteServer();
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
function deleteUnloadedConfirm() {
|
|
path = "{{data['server_stats']['server_id']['path']}}";
|
|
name = "{{data['server_stats']['server_id']['server_name']}}";
|
|
bootbox.confirm({
|
|
size: "",
|
|
title: "{% raw translate('serverConfig', 'deleteServerQuestion', data['lang']) %}",
|
|
closeButton: false,
|
|
message: "{% raw translate('serverConfig', 'deleteServerQuestionMessage', data['lang']) %}",
|
|
buttons: {
|
|
confirm: {
|
|
label: "{{ translate('serverConfig', 'yesDelete', data['lang']) }}",
|
|
className: 'btn-danger',
|
|
},
|
|
cancel: {
|
|
label: "{{ translate('serverConfig', 'noDelete', data['lang']) }}",
|
|
className: 'btn-link',
|
|
}
|
|
},
|
|
callback: function (result) {
|
|
if (!result) {
|
|
return;
|
|
return;
|
|
}
|
|
else {
|
|
var token = getCookie("_xsrf")
|
|
setTimeout(function () { window.location = '/panel/dashboard'; }, 5000);
|
|
bootbox.dialog({
|
|
backdrop: true,
|
|
title: '{% raw translate("serverConfig", "sendingDelete", data['lang']) %}',
|
|
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> {% raw translate("serverConfig", "bePatientDelete", data['lang']) %} </div>',
|
|
closeButton: false
|
|
})
|
|
$.ajax({
|
|
type: "DELETE",
|
|
headers: { 'X-XSRFToken': token },
|
|
url: '/ajax/delete_unloaded_server?id=' + serverId,
|
|
data: {
|
|
},
|
|
success: function (data) {
|
|
console.log("got response:");
|
|
console.log(data);
|
|
},
|
|
});
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
webSocket.on('remove_spinner', function () {
|
|
document.getElementById("update-spinner").style.visibility = "hidden";
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
{% end %} |