From 0adc129462ca680a644ab3676f9f3ddaba67d370 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 3 Jun 2023 13:36:38 -0400 Subject: [PATCH] Inital commit for webhooks on frontend --- app/classes/web/panel_handler.py | 43 +++ .../templates/panel/server_webhook_edit.html | 261 ++++++++++++++++++ .../templates/panel/server_webhooks.html | 2 +- 3 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 app/frontend/templates/panel/server_webhook_edit.html diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 692bcff4..454cbd4d 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -25,6 +25,7 @@ from app.classes.controllers.roles_controller import RolesController from app.classes.shared.helpers import Helpers from app.classes.shared.main_models import DatabaseShortcuts from app.classes.web.base_handler import BaseHandler +from app.classes.web.webhook_handler import WebhookHandler logger = logging.getLogger(__name__) @@ -1039,6 +1040,48 @@ class PanelHandler(BaseHandler): template = "panel/panel_edit_user.html" + elif page == "add_webhook": + server_id = self.get_argument("id", None) + if server_id is None: + return self.redirect("/panel/error?error=Invalid Server ID") + server_obj = self.controller.servers.get_server_instance_by_id(server_id) + page_data["backup_failed"] = server_obj.last_backup_status() + server_obj = None + page_data["active_link"] = "webhooks" + page_data["server_data"] = self.controller.servers.get_server_data_by_id( + server_id + ) + page_data[ + "user_permissions" + ] = self.controller.server_perms.get_user_id_permissions_list( + exec_user["user_id"], server_id + ) + page_data["permissions"] = { + "Commands": EnumPermissionsServer.COMMANDS, + "Terminal": EnumPermissionsServer.TERMINAL, + "Logs": EnumPermissionsServer.LOGS, + "Schedule": EnumPermissionsServer.SCHEDULE, + "Backup": EnumPermissionsServer.BACKUP, + "Files": EnumPermissionsServer.FILES, + "Config": EnumPermissionsServer.CONFIG, + "Players": EnumPermissionsServer.PLAYERS, + } + page_data["server_stats"] = self.controller.servers.get_server_stats_by_id( + server_id + ) + page_data["server_stats"][ + "server_type" + ] = self.controller.servers.get_server_type_by_id(server_id) + page_data["new_webhook"] = True + page_data["providers"] = WebhookHandler.get_providers() + + if not EnumPermissionsServer.CONFIG in page_data["user_permissions"]: + if not superuser: + self.redirect("/panel/error?error=Unauthorized access To Webhooks") + return + + template = "panel/server_webhook_edit.html" + elif page == "add_schedule": server_id = self.get_argument("id", None) if server_id is None: diff --git a/app/frontend/templates/panel/server_webhook_edit.html b/app/frontend/templates/panel/server_webhook_edit.html new file mode 100644 index 00000000..8baed81f --- /dev/null +++ b/app/frontend/templates/panel/server_webhook_edit.html @@ -0,0 +1,261 @@ +{% extends ../base.html %} + +{% block meta %} +{% end %} + +{% block title %}Crafty Controller - {{ translate('serverDetails', 'serverDetails', data['lang']) }}{% end %} + +{% block content %} + +
+ + +
+
+ +
+ +
+ + + {% include "parts/details_stats.html" %} + +
+ +
+
+
+ {% include "parts/server_controls_list.html" %} + +
+
+ {% if data['new_webhook'] == True %} +
+ {% else %} + + {% end %} + +
+
+ + +
+
+ +
+
+
+
+ + + +
+ + + {% end %} + + {% block js %} + + + {% end %} \ No newline at end of file diff --git a/app/frontend/templates/panel/server_webhooks.html b/app/frontend/templates/panel/server_webhooks.html index b8552401..e0342c4b 100644 --- a/app/frontend/templates/panel/server_webhooks.html +++ b/app/frontend/templates/panel/server_webhooks.html @@ -52,7 +52,7 @@ data-placement="bottom"> {% end %}