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(
|
page_data["server_data"] = self.controller.servers.get_server_data_by_id(
|
||||||
server_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(
|
page_data["server_stats"] = self.controller.servers.get_server_stats_by_id(
|
||||||
server_id
|
server_id
|
||||||
)
|
)
|
||||||
@ -1136,6 +1139,7 @@ class PanelHandler(BaseHandler):
|
|||||||
page_data["schedule"]["delay"] = 0
|
page_data["schedule"]["delay"] = 0
|
||||||
page_data["schedule"]["time"] = ""
|
page_data["schedule"]["time"] = ""
|
||||||
page_data["schedule"]["interval"] = 1
|
page_data["schedule"]["interval"] = 1
|
||||||
|
page_data["schedule"]["action_id"] = ""
|
||||||
# we don't need to check difficulty here.
|
# we don't need to check difficulty here.
|
||||||
# We'll just default to basic for new schedules
|
# We'll just default to basic for new schedules
|
||||||
page_data["schedule"]["difficulty"] = "basic"
|
page_data["schedule"]["difficulty"] = "basic"
|
||||||
@ -1181,6 +1185,9 @@ class PanelHandler(BaseHandler):
|
|||||||
exec_user["user_id"], server_id
|
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(
|
page_data["server_data"] = self.controller.servers.get_server_data_by_id(
|
||||||
server_id
|
server_id
|
||||||
)
|
)
|
||||||
@ -1195,6 +1202,7 @@ class PanelHandler(BaseHandler):
|
|||||||
page_data["schedule"]["server_id"] = server_id
|
page_data["schedule"]["server_id"] = server_id
|
||||||
page_data["schedule"]["schedule_id"] = schedule.schedule_id
|
page_data["schedule"]["schedule_id"] = schedule.schedule_id
|
||||||
page_data["schedule"]["action"] = schedule.action
|
page_data["schedule"]["action"] = schedule.action
|
||||||
|
page_data["schedule"]["action_id"] = schedule.action_id
|
||||||
if schedule.name:
|
if schedule.name:
|
||||||
page_data["schedule"]["name"] = schedule.name
|
page_data["schedule"]["name"] = schedule.name
|
||||||
else:
|
else:
|
||||||
|
@ -21,6 +21,9 @@ new_task_schema = {
|
|||||||
"action": {
|
"action": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
|
"action_id": {
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"interval": {"type": "integer"},
|
"interval": {"type": "integer"},
|
||||||
"interval_type": {
|
"interval_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -22,6 +22,9 @@ task_patch_schema = {
|
|||||||
"action": {
|
"action": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
|
"action_id": {
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"interval": {"type": "integer"},
|
"interval": {"type": "integer"},
|
||||||
"interval_type": {
|
"interval_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -79,6 +79,24 @@
|
|||||||
<option id="command" value="command">{{ translate('serverScheduleConfig', 'custom' , data['lang'])
|
<option id="command" value="command">{{ translate('serverScheduleConfig', 'custom' , data['lang'])
|
||||||
}}</option>
|
}}</option>
|
||||||
</select>
|
</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>
|
||||||
<div id="ifBasic">
|
<div id="ifBasic">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -232,7 +250,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function replacer(key, value) {
|
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") {
|
if (typeof value == "boolean") {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
@ -247,7 +265,7 @@
|
|||||||
}
|
}
|
||||||
} else if (value === "" && key == "start_time"){
|
} else if (value === "" && key == "start_time"){
|
||||||
return "00:00";
|
return "00:00";
|
||||||
}else{
|
}else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,6 +299,11 @@
|
|||||||
// Format the plain form data as JSON
|
// Format the plain form data as JSON
|
||||||
let formDataJsonString = JSON.stringify(formDataObject, replacer);
|
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/`, {
|
let res = await fetch(`/api/v2/servers/${serverId}/tasks/`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -358,6 +381,14 @@
|
|||||||
document.getElementById("ifYes").style.display = "none";
|
document.getElementById("ifYes").style.display = "none";
|
||||||
document.getElementById("command_input").required = false;
|
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() {
|
function basicAdvanced() {
|
||||||
if (document.getElementById('difficulty').value == "advanced") {
|
if (document.getElementById('difficulty').value == "advanced") {
|
||||||
|
@ -503,6 +503,7 @@
|
|||||||
},
|
},
|
||||||
"serverSchedules": {
|
"serverSchedules": {
|
||||||
"action": "Action",
|
"action": "Action",
|
||||||
|
"actionId": "Select Action Child",
|
||||||
"areYouSure": "Delete Scheduled Task?",
|
"areYouSure": "Delete Scheduled Task?",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"cannotSee": "Not seeing everything?",
|
"cannotSee": "Not seeing everything?",
|
||||||
|
Loading…
Reference in New Issue
Block a user