mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Set backup schedules
This commit is contained in:
parent
ab83b846d6
commit
772910dc6f
@ -1116,6 +1116,9 @@ class PanelHandler(BaseHandler):
|
||||
page_data["server_data"] = self.controller.servers.get_server_data_by_id(
|
||||
server_id
|
||||
)
|
||||
page_data["backups"] = self.controller.management.get_backups_by_server(
|
||||
server_id, True
|
||||
)
|
||||
page_data["server_stats"] = self.controller.servers.get_server_stats_by_id(
|
||||
server_id
|
||||
)
|
||||
@ -1136,6 +1139,7 @@ class PanelHandler(BaseHandler):
|
||||
page_data["schedule"]["delay"] = 0
|
||||
page_data["schedule"]["time"] = ""
|
||||
page_data["schedule"]["interval"] = 1
|
||||
page_data["schedule"]["action_id"] = ""
|
||||
# we don't need to check difficulty here.
|
||||
# We'll just default to basic for new schedules
|
||||
page_data["schedule"]["difficulty"] = "basic"
|
||||
@ -1181,6 +1185,9 @@ class PanelHandler(BaseHandler):
|
||||
exec_user["user_id"], server_id
|
||||
)
|
||||
)
|
||||
page_data["backups"] = self.controller.management.get_backups_by_server(
|
||||
server_id, True
|
||||
)
|
||||
page_data["server_data"] = self.controller.servers.get_server_data_by_id(
|
||||
server_id
|
||||
)
|
||||
@ -1195,6 +1202,7 @@ class PanelHandler(BaseHandler):
|
||||
page_data["schedule"]["server_id"] = server_id
|
||||
page_data["schedule"]["schedule_id"] = schedule.schedule_id
|
||||
page_data["schedule"]["action"] = schedule.action
|
||||
page_data["schedule"]["action_id"] = schedule.action_id
|
||||
if schedule.name:
|
||||
page_data["schedule"]["name"] = schedule.name
|
||||
else:
|
||||
|
@ -21,6 +21,9 @@ new_task_schema = {
|
||||
"action": {
|
||||
"type": "string",
|
||||
},
|
||||
"action_id": {
|
||||
"type": "string",
|
||||
},
|
||||
"interval": {"type": "integer"},
|
||||
"interval_type": {
|
||||
"type": "string",
|
||||
|
@ -22,6 +22,9 @@ task_patch_schema = {
|
||||
"action": {
|
||||
"type": "string",
|
||||
},
|
||||
"action_id": {
|
||||
"type": "string",
|
||||
},
|
||||
"interval": {"type": "integer"},
|
||||
"interval_type": {
|
||||
"type": "string",
|
||||
|
@ -79,6 +79,24 @@
|
||||
<option id="command" value="command">{{ translate('serverScheduleConfig', 'custom' , data['lang'])
|
||||
}}</option>
|
||||
</select>
|
||||
<div id="ifBackup" style="display: none;">
|
||||
<br>
|
||||
<label for="action_id">{{ translate('serverSchedules', 'actionId' , data['lang']) }}<small
|
||||
class="text-muted ml-1"></small> </label><br>
|
||||
<select id="action_id" name="action_id"
|
||||
class="form-control form-control-lg select-css" value="{{ data['schedule']['action_id'] }}">
|
||||
{% for backup in data["backups"] %}
|
||||
{% if backup.backup_id == data["schedule"]["action_id"] %}
|
||||
<option id="{{backup.backup_id}}" value="{{backup.backup_id}}">{{backup.backup_name}}</option>
|
||||
{% end %}
|
||||
{% end %}
|
||||
{% for backup in data["backups"] %}
|
||||
{% if backup.backup_id != data["schedule"]["action_id"] %}
|
||||
<option id="{{backup.backup_id}}" value="{{backup.backup_id}}">{{backup.backup_name}}</option>
|
||||
{% end %}
|
||||
{% end %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ifBasic">
|
||||
<div class="form-group">
|
||||
@ -232,7 +250,7 @@
|
||||
}
|
||||
|
||||
function replacer(key, value) {
|
||||
if (key != "start_time" && key != "cron_string" && key != "interval_type") {
|
||||
if (key != "start_time" && key != "cron_string" && key != "interval_type" && key != "action_id") {
|
||||
if (typeof value == "boolean") {
|
||||
return value
|
||||
}
|
||||
@ -247,7 +265,7 @@
|
||||
}
|
||||
} else if (value === "" && key == "start_time"){
|
||||
return "00:00";
|
||||
}else{
|
||||
}else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -281,6 +299,11 @@
|
||||
// Format the plain form data as JSON
|
||||
let formDataJsonString = JSON.stringify(formDataObject, replacer);
|
||||
|
||||
let data = JSON.parse(formDataJsonString)
|
||||
if (data["action"] === "backup" && !data["action_id"]){
|
||||
return bootbox.alert("Validation Failed")
|
||||
}
|
||||
|
||||
let res = await fetch(`/api/v2/servers/${serverId}/tasks/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -358,6 +381,14 @@
|
||||
document.getElementById("ifYes").style.display = "none";
|
||||
document.getElementById("command_input").required = false;
|
||||
}
|
||||
if (document.getElementById('action').value == "backup"){
|
||||
document.getElementById("ifBackup").style.display = "block";
|
||||
document.getElementById("action_id").required = true;
|
||||
} else {
|
||||
document.getElementById("ifBackup").style.display = "none";
|
||||
document.getElementById("action_id").required = false;
|
||||
$("#action_id").val(null);
|
||||
}
|
||||
}
|
||||
function basicAdvanced() {
|
||||
if (document.getElementById('difficulty').value == "advanced") {
|
||||
|
@ -503,6 +503,7 @@
|
||||
},
|
||||
"serverSchedules": {
|
||||
"action": "Action",
|
||||
"actionId": "Select Action Child",
|
||||
"areYouSure": "Delete Scheduled Task?",
|
||||
"cancel": "Cancel",
|
||||
"cannotSee": "Not seeing everything?",
|
||||
|
Loading…
Reference in New Issue
Block a user