2021-11-30 17:29:53 +00:00
|
|
|
{% extends ../base.html %}
|
|
|
|
|
|
|
|
{% block meta %}
|
|
|
|
{% end %}
|
|
|
|
|
2021-11-30 20:46:30 +00:00
|
|
|
{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %}
|
2021-11-30 17:29:53 +00:00
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
|
|
<div class="content-wrapper">
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
<!-- Page Title Header Starts-->
|
2021-11-30 17:29:53 +00:00
|
|
|
<div class="row page-title-header">
|
|
|
|
<div class="col-12">
|
|
|
|
<div class="page-header">
|
2021-11-30 20:46:30 +00:00
|
|
|
<h4 class="page-title">
|
2022-08-04 22:15:59 +00:00
|
|
|
{{ translate('serverDetails', 'serverDetails', data['lang']) }} - {{
|
|
|
|
data['server_stats']['server_id']['server_name'] }}
|
2022-03-26 22:37:08 +00:00
|
|
|
<br />
|
|
|
|
<small>UUID: {{ data['server_stats']['server_id']['server_uuid'] }}</small>
|
2021-11-30 20:46:30 +00:00
|
|
|
</h4>
|
2021-11-30 17:29:53 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- Page Title Header Ends-->
|
|
|
|
|
2022-06-22 22:58:06 +00:00
|
|
|
{% include "parts/details_stats.html" %}
|
2021-11-30 20:46:30 +00:00
|
|
|
|
2021-11-30 17:29:53 +00:00
|
|
|
<div class="row">
|
|
|
|
|
|
|
|
<div class="col-sm-12 grid-margin">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-body pt-0">
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
<span class="d-none d-sm-block">
|
2022-06-22 22:58:06 +00:00
|
|
|
{% include "parts/server_controls_list.html" %}
|
2022-03-26 22:37:08 +00:00
|
|
|
</span>
|
|
|
|
<span class="d-block d-sm-none">
|
2022-06-22 22:58:06 +00:00
|
|
|
{% include "parts/m_server_controls_list.html" %}
|
2022-03-26 22:37:08 +00:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12 col-sm-12" style="overflow-x:auto;">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-header header-sm d-flex justify-content-between align-items-center">
|
2022-08-05 15:56:41 +00:00
|
|
|
<h4 class="card-title"><i class="fas fa-calendar"></i> {{ translate('serverSchedules',
|
|
|
|
'scheduledTasks', data['lang']) }} </h4>
|
2022-04-03 01:25:26 +00:00
|
|
|
{% if data['user_data']['hints'] %}
|
2023-10-21 15:32:48 +00:00
|
|
|
<span class="too_small" title="{{ translate('serverSchedules', 'cannotSee', data['lang']) }}" , data-content="{{ translate('serverSchedules', 'cannotSeeOnMobile', data['lang']) }}" , data-placement="bottom"></span>
|
2022-04-03 01:25:26 +00:00
|
|
|
{% end %}
|
2023-10-21 15:32:48 +00:00
|
|
|
<div><a class="btn btn-info" href="/panel/add_schedule?id={{ data['server_stats']['server_id']['server_id'] }}"><i class="fas fa-plus-circle"></i> {{ translate('serverSchedules', 'create', data['lang']) }}</a></div>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
2023-10-21 15:32:48 +00:00
|
|
|
{% if len(data['schedules']) == 0 %}
|
|
|
|
<div style="text-align: center; color: grey;">
|
2023-10-22 21:33:18 +00:00
|
|
|
<h7>{{ translate('serverSchedules', 'no-schedule', data['lang']) }} <strong>{{ translate('serverSchedules', 'newSchedule',data['lang']) }}</strong>.</h7>
|
2023-10-21 15:32:48 +00:00
|
|
|
</div>
|
|
|
|
{% end %}
|
|
|
|
{% if len(data['schedules']) > 0 %}
|
|
|
|
<div class="d-none d-lg-block">
|
|
|
|
<table class="table table-hover table-responsive" id="schedule_table" style="table-layout:fixed;" aria-describedby="Schedule List">
|
|
|
|
<thead>
|
|
|
|
<tr class="rounded">
|
|
|
|
<th style="width: 5%; min-width: 64px;">{{ translate('serverSchedules', 'enabled',
|
|
|
|
data['lang']) }}</th>
|
|
|
|
<th style="width: 7%; min-width: 10px;">{{ translate('serverSchedules', 'name', data['lang']) }}
|
|
|
|
</th>
|
|
|
|
<th style="width: 23%; min-width: 50px;">{{ translate('serverSchedules', 'action', data['lang'])
|
|
|
|
}}</th>
|
|
|
|
<th style="width: 40%; min-width: 50px;">{{ translate('serverSchedules', 'command',
|
|
|
|
data['lang']) }}</th>
|
|
|
|
<th style="width: 10%; min-width: 50px;">{{ translate('serverSchedules', 'interval',
|
|
|
|
data['lang']) }}</th>
|
|
|
|
<th style="width: 10%; min-width: 50px;">{{ translate('serverSchedules', 'nextRun',
|
|
|
|
data['lang']) }}</th>
|
|
|
|
<th style="width: 10%; min-width: 50px;">{{ translate('serverSchedules', 'edit', data['lang'])
|
|
|
|
}}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for schedule in data['schedules'] %}
|
|
|
|
<tr>
|
|
|
|
<td id="{{schedule.enabled}}" class="enabled">
|
|
|
|
<button type="button" class="btn btn-sm btn-info btn-toggle schedule-custom-toggle" id="schedule{{schedule.id}}" name="schedule{{schedule.id}}" data-schedule-id="{{schedule.schedule_id}}" data-schedule-enabled="{{ 'true' if schedule.enabled else 'false' }}" data-toggle="button" aria-pressed="true" autocomplete="off">
|
|
|
|
<div class="handle"></div>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.schedule_id}}" class="id">
|
|
|
|
<p>{{schedule.name}}</p>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.action}}">
|
|
|
|
<p>{{schedule.action}}</p>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.command}}" style="overflow: scroll; max-width: 30px;">
|
|
|
|
<p style="overflow: scroll;" class="no-scroll">{{schedule.command}}</p>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.interval}}">
|
|
|
|
{% if schedule.interval_type != '' and schedule.interval_type != 'reaction' %}
|
|
|
|
<p>{{ translate('serverSchedules', 'every', data['lang']) }}</p>
|
|
|
|
<p>{{schedule.interval}} {{schedule.interval_type}}</p>
|
|
|
|
{% elif schedule.interval_type == 'reaction' %}
|
|
|
|
<p>{{schedule.interval_type}}<br><br>{{ translate('serverSchedules', 'child', data['lang'])}}:
|
|
|
|
{{ schedule.parent }}</p>
|
|
|
|
{% else %}
|
|
|
|
<p>Cron String:</p>
|
|
|
|
<p>{{schedule.cron_string}}</p>
|
|
|
|
{% end %}
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.start_time}}">
|
|
|
|
<p>{{schedule.next_run}}</p>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.action}}" class="action">
|
|
|
|
<button onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'" class="btn btn-info">
|
|
|
|
<i class="fas fa-pencil-alt"></i>
|
|
|
|
</button>
|
|
|
|
<button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button">
|
|
|
|
<i class="fas fa-trash" aria-hidden="true"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% end %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
<div class=" d-block d-lg-none">
|
|
|
|
<table class="table table-hover" id="mini_schedule_table" style="table-layout:fixed;" aria-describedby="Schedule List Mobile">
|
|
|
|
<thead>
|
|
|
|
<tr class="rounded">
|
|
|
|
<th style="width: 25%; min-width: 50px;">{{ translate('serverSchedules', 'action', data['lang'])
|
|
|
|
}}</th>
|
|
|
|
<th style="max-width: 40%; min-width: 50px;">{{ translate('serverSchedules', 'command',
|
|
|
|
data['lang']) }}</th>
|
|
|
|
<th style="width: 10%; min-width: 50px;">{{ translate('serverSchedules', 'enabled',
|
|
|
|
data['lang']) }}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for schedule in data['schedules'] %}
|
|
|
|
<tr data-toggle="modal" data-target="#task_details_{{schedule.schedule_id}}">
|
|
|
|
<td id="{{schedule.action}}" class="action">
|
|
|
|
<p>{{schedule.action}}</p>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.command}}" class="action" style="overflow: scroll; max-width: 30px;">
|
|
|
|
<p style="overflow: scroll;">{{schedule.command}}</p>
|
|
|
|
</td>
|
|
|
|
<td id="{{schedule.enabled}}" class="enabled">
|
|
|
|
<button type="button" class="btn btn-sm btn-info btn-toggle schedule-custom-toggle" id="schedule{{schedule.id}}" name="schedule{{schedule.id}}" data-schedule-id="{{schedule.schedule_id}}" data-schedule-enabled="{{ 'true' if schedule.enabled else 'false' }}" data-toggle="button" aria-pressed="true" autocomplete="off">
|
|
|
|
<div class="handle"></div>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<!-- Modal -->
|
|
|
|
<div class="modal fade" id="task_details_{{schedule.schedule_id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title" id="exampleModalLabel">{{ translate('serverSchedules', 'details',
|
|
|
|
data['lang']) }}</h5>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<ul style="list-style: none;">
|
|
|
|
<li id="{{schedule.schedule_id}}" class="id" style="border-top: .1em solid gray;">
|
|
|
|
<h4>{{ translate('serverSchedules', 'name', data['lang']) }}</h4>
|
|
|
|
<p>{{schedule.schedule_id}}</p>
|
|
|
|
</li>
|
|
|
|
<li id="{{schedule.action}}" class="action" style="border-top: .1em solid gray;">
|
|
|
|
<h4>{{ translate('serverSchedules', 'action', data['lang']) }}</h4>
|
|
|
|
<p>{{schedule.action}}</p>
|
|
|
|
</li>
|
|
|
|
<li id="{{schedule.command}}" class="action" style="border-top: .1em solid gray;">
|
|
|
|
<h4>{{ translate('serverSchedules', 'command', data['lang']) }}</h4>
|
|
|
|
<p>{{schedule.command}}</p>
|
|
|
|
</li>
|
|
|
|
<li id="{{schedule.interval}}" class="action" style="border-top: .1em solid gray;">
|
|
|
|
{% if schedule.interval != '' %}
|
|
|
|
<h4>{{ translate('serverSchedules', 'interval', data['lang']) }}</h4>
|
|
|
|
<p>{{ translate('serverSchedules', 'every', data['lang']) }} {{schedule.interval}}
|
|
|
|
{{schedule.interval_type}}</p>
|
|
|
|
{% elif schedule.interval_type == 'reaction' %}
|
|
|
|
<h4>{{ translate('serverSchedules', 'interval', data['lang']) }}</h4>
|
|
|
|
<p>{{schedule.interval_type}}<br><br>{{ translate('serverSchedules', 'child',
|
|
|
|
data['lang']) }}: {{ schedule.parent }}</p>
|
|
|
|
{% else %}
|
|
|
|
<h4>{{ translate('serverSchedules', 'interval', data['lang']) }}</h4>
|
|
|
|
<p>{{ translate('serverSchedules', 'cron', data['lang']) }}: {{schedule.cron_string}}
|
|
|
|
</p>
|
|
|
|
{% end %}
|
|
|
|
</li>
|
|
|
|
<li id="{{schedule.start_time}}" class="action" style="border-top: .1em solid gray;">
|
|
|
|
<h4>{{ translate('serverSchedules', 'nextRun', data['lang']) }}</h4>
|
|
|
|
{% if schedule.next_run %}
|
|
|
|
<p>{{schedule.next_run}}</p>
|
|
|
|
{% else %}
|
|
|
|
<p>zzzzzzz</p>
|
|
|
|
{% end %}
|
|
|
|
</li>
|
|
|
|
<li id="{{schedule.enabled}}" class="action" style="border-top: .1em solid gray; border-bottom: .1em solid gray">
|
|
|
|
<h4>{{ translate('serverSchedules', 'enabled', data['lang']) }}</h4>
|
|
|
|
<input type="checkbox" class="schedule-enabled-toggle" data-schedule-id="{{schedule.schedule_id}}" data-schedule-enabled="{{ 'true' if schedule.enabled else 'false' }}">
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button onclick="window.location.href='/panel/edit_schedule?id={{ data['server_stats']['server_id']['server_id'] }}&sch_id={{schedule.schedule_id}}'" class="btn btn-info">
|
|
|
|
<i class="fas fa-pencil-alt"></i> {{ translate('serverSchedules', 'edit', data['lang'])
|
|
|
|
}}
|
|
|
|
</button>
|
|
|
|
<button data-sch={{ schedule.schedule_id }} class="btn btn-danger del_button">
|
|
|
|
<i class="fas fa-trash" aria-hidden="true"></i> {{ translate('serverSchedules',
|
|
|
|
'delete', data['lang']) }}
|
|
|
|
</button>
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{
|
|
|
|
translate('serverSchedules', 'close', data['lang']) }}</button>
|
|
|
|
</div>
|
2022-01-12 18:48:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2023-10-21 15:32:48 +00:00
|
|
|
{% end %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{% end %}
|
2021-11-30 17:29:53 +00:00
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2021-11-30 17:29:53 +00:00
|
|
|
</div>
|
2022-03-26 22:37:08 +00:00
|
|
|
</div>
|
2021-11-30 17:29:53 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-12 23:52:44 +00:00
|
|
|
<style>
|
2022-03-26 22:37:08 +00:00
|
|
|
.popover-body {
|
|
|
|
color: white !important;
|
|
|
|
;
|
|
|
|
}
|
2022-08-04 22:15:59 +00:00
|
|
|
|
2022-07-14 18:46:23 +00:00
|
|
|
.toggle-handle {
|
|
|
|
background-color: white !important;
|
|
|
|
}
|
2022-08-04 22:15:59 +00:00
|
|
|
|
2022-07-14 18:46:23 +00:00
|
|
|
.toggle-on {
|
|
|
|
color: black !important;
|
|
|
|
}
|
2022-08-04 22:15:59 +00:00
|
|
|
|
2022-07-14 18:46:23 +00:00
|
|
|
.toggle {
|
|
|
|
height: 0px !important;
|
|
|
|
}
|
2023-10-21 15:32:48 +00:00
|
|
|
|
|
|
|
td.enabled {
|
|
|
|
vertical-align: middle;
|
|
|
|
border-collapse: collapse !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.enabled .toggle-group .btn {
|
|
|
|
vertical-align: middle;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2022-01-12 23:52:44 +00:00
|
|
|
</style>
|
2021-11-30 17:29:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2022-01-12 01:26:39 +00:00
|
|
|
<style>
|
|
|
|
/* Hide scrollbar for Chrome, Safari and Opera */
|
2022-03-26 22:37:08 +00:00
|
|
|
td::-webkit-scrollbar {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hide scrollbar for IE, Edge and Firefox */
|
|
|
|
td {
|
|
|
|
-ms-overflow-style: none;
|
|
|
|
/* IE and Edge */
|
|
|
|
scrollbar-width: none;
|
|
|
|
/* Firefox */
|
|
|
|
}
|
2022-01-12 01:26:39 +00:00
|
|
|
</style>
|
2021-11-30 17:29:53 +00:00
|
|
|
<!-- content-wrapper ends -->
|
|
|
|
|
|
|
|
{% end %}
|
|
|
|
|
|
|
|
{% block js %}
|
|
|
|
<script>
|
2022-02-27 17:26:54 +00:00
|
|
|
|
2022-08-04 22:15:59 +00:00
|
|
|
function debounce(func, timeout = 300) {
|
2022-06-22 22:58:06 +00:00
|
|
|
let timer;
|
|
|
|
return (...args) => {
|
|
|
|
clearTimeout(timer);
|
|
|
|
timer = setTimeout(() => { func.apply(this, args); }, timeout);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-10-21 15:32:48 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
$('.schedule-custom-toggle').each(function () {
|
2022-06-22 22:58:06 +00:00
|
|
|
const enabled = JSON.parse(this.getAttribute('data-schedule-enabled'));
|
2023-10-21 15:32:48 +00:00
|
|
|
if (enabled) {
|
|
|
|
this.classList.add("active");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.classList.remove("active");
|
|
|
|
}
|
2022-06-22 22:58:06 +00:00
|
|
|
})
|
2023-10-21 15:32:48 +00:00
|
|
|
});
|
|
|
|
$(() => {
|
|
|
|
$('.schedule-custom-toggle').click(function () {
|
2022-06-22 22:58:06 +00:00
|
|
|
const id = this.getAttribute('data-schedule-id');
|
2023-10-21 15:32:48 +00:00
|
|
|
const enabled = !JSON.parse(this.getAttribute('data-schedule-enabled'));
|
2022-06-22 22:58:06 +00:00
|
|
|
|
|
|
|
fetch(`/api/v2/servers/{{data['server_id']}}/tasks/${id}`, {
|
|
|
|
method: 'PATCH',
|
2022-08-04 22:15:59 +00:00
|
|
|
body: JSON.stringify({ enabled }),
|
2022-06-22 22:58:06 +00:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2022-02-27 17:26:54 +00:00
|
|
|
const serverId = new URLSearchParams(document.location.search).get('id')
|
2022-03-26 22:37:08 +00:00
|
|
|
|
|
|
|
$(document).ready(function () {
|
2023-07-12 16:23:09 +00:00
|
|
|
console.log('ready for JS!');
|
2022-01-13 04:58:16 +00:00
|
|
|
$('#schedule_table').DataTable({
|
2022-08-05 17:52:50 +00:00
|
|
|
'order': [4, 'asc'],
|
2022-01-13 04:58:16 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
|
|
console.log('ready for JS!')
|
|
|
|
$('#mini_schedule_table').DataTable({
|
2022-08-05 17:52:50 +00:00
|
|
|
'order': [2, 'asc']
|
2022-03-26 22:37:08 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
document.getElementById('mini_schedule_table_wrapper').hidden = true;
|
|
|
|
});
|
|
|
|
$(document).ready(function () {
|
2022-01-12 23:52:44 +00:00
|
|
|
$('[data-toggle="popover"]').popover();
|
2022-03-26 22:37:08 +00:00
|
|
|
if ($(window).width() < 1000) {
|
2022-01-12 23:52:44 +00:00
|
|
|
$('.too_small').popover("show");
|
2022-01-13 05:30:35 +00:00
|
|
|
document.getElementById('schedule_table_wrapper').hidden = true;
|
2022-01-14 07:35:26 +00:00
|
|
|
document.getElementById('mini_schedule_table_wrapper').hidden = false;
|
2022-01-12 23:52:44 +00:00
|
|
|
}
|
2022-01-21 22:50:04 +00:00
|
|
|
|
2022-01-12 23:52:44 +00:00
|
|
|
});
|
2022-03-26 22:37:08 +00:00
|
|
|
$(window).ready(function () {
|
|
|
|
$('body').click(function () {
|
|
|
|
$('.too_small').popover("hide");
|
|
|
|
});
|
2022-01-12 23:52:44 +00:00
|
|
|
});
|
2022-03-26 22:37:08 +00:00
|
|
|
$(window).resize(function () {
|
2022-01-12 23:52:44 +00:00
|
|
|
// This will execute whenever the window is resized
|
2022-03-26 22:37:08 +00:00
|
|
|
if ($(window).width() < 1000) {
|
2022-01-12 23:52:44 +00:00
|
|
|
$('.too_small').popover("show");
|
2022-01-13 05:30:35 +00:00
|
|
|
document.getElementById('schedule_table_wrapper').hidden = true;
|
2022-01-14 07:35:26 +00:00
|
|
|
document.getElementById('mini_schedule_table_wrapper').hidden = false;
|
2022-01-12 23:52:44 +00:00
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
else {
|
2022-01-12 23:52:44 +00:00
|
|
|
$('.too_small').popover("hide");
|
2022-01-13 05:30:35 +00:00
|
|
|
document.getElementById('schedule_table_wrapper').hidden = false;
|
2022-01-14 07:35:26 +00:00
|
|
|
document.getElementById('mini_schedule_table_wrapper').hidden = true;
|
2022-01-12 23:52:44 +00:00
|
|
|
} // New width
|
|
|
|
});
|
2022-03-26 22:37:08 +00:00
|
|
|
</script>
|
2022-01-12 23:52:44 +00:00
|
|
|
<script>
|
2021-11-30 17:29:53 +00:00
|
|
|
|
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
//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;
|
|
|
|
}
|
2021-11-30 17:29:53 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
console.log("ready!");
|
2021-11-30 17:29:53 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
});
|
|
|
|
$(".del_button").click(function () {
|
|
|
|
var sch_id = $(this).data('sch');
|
2022-01-11 05:26:33 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
console.log(sch_id)
|
2022-01-11 05:26:33 +00:00
|
|
|
|
2022-03-26 22:37:08 +00:00
|
|
|
bootbox.confirm({
|
2022-01-11 23:51:07 +00:00
|
|
|
title: "{{ translate('serverSchedules', 'areYouSure', data['lang']) }}",
|
|
|
|
message: "{{ translate('serverSchedules', 'confirmDelete', data['lang']) }}",
|
2022-01-11 05:26:33 +00:00
|
|
|
buttons: {
|
2022-03-26 22:37:08 +00:00
|
|
|
cancel: {
|
|
|
|
label: '<i class="fas fa-times"></i> {{ translate("serverSchedules", "cancel", data['lang']) }}'
|
2022-01-11 05:26:33 +00:00
|
|
|
},
|
2022-03-26 22:37:08 +00:00
|
|
|
confirm: {
|
|
|
|
className: 'btn-outline-danger',
|
|
|
|
label: '<i class="fas fa-check"></i> {{ translate("serverSchedules", "confirm", data['lang']) }}'
|
2022-01-11 05:26:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
callback: function (result) {
|
2022-03-26 22:37:08 +00:00
|
|
|
console.log(result);
|
|
|
|
if (result == true) {
|
|
|
|
del_task(sch_id, serverId);
|
|
|
|
}
|
2022-01-11 05:26:33 +00:00
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
});
|
2022-01-11 05:26:33 +00:00
|
|
|
});
|
2022-03-26 22:37:08 +00:00
|
|
|
|
2023-03-04 23:18:39 +00:00
|
|
|
async function del_task(sch_id, id) {
|
2023-09-04 23:22:11 +00:00
|
|
|
const token = getCookie("_xsrf")
|
2022-03-26 22:37:08 +00:00
|
|
|
|
2023-03-04 23:18:39 +00:00
|
|
|
let res = await fetch(`/api/v2/servers/${id}/tasks/${sch_id}`, {
|
|
|
|
method: 'DELETE',
|
|
|
|
headers: {
|
|
|
|
'token': token,
|
2022-03-26 22:37:08 +00:00
|
|
|
},
|
|
|
|
});
|
2023-03-04 23:18:39 +00:00
|
|
|
let responseData = await res;
|
|
|
|
if (responseData.statusText === "OK") {
|
|
|
|
window.location.reload();
|
|
|
|
}
|
2022-03-26 22:37:08 +00:00
|
|
|
}
|
2022-01-11 05:26:33 +00:00
|
|
|
|
2021-11-30 17:29:53 +00:00
|
|
|
</script>
|
|
|
|
|
2023-10-22 21:33:18 +00:00
|
|
|
{% end %}
|