diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index efc9e4a5..2bac6061 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -197,13 +197,19 @@ class TasksManager: for item in jobs: logger.info("JOB: {}".format(item)) + def remove_all_server_tasks(self, server_id): + schedules = management_helper.get_schedules_by_server(server_id) + for schedule in schedules: + self.remove_job(schedule.schedule_id) + def remove_job(self, sch_id): job = management_helper.get_scheduled_task_model(sch_id) management_helper.delete_scheduled_task(sch_id) if job.enabled: self.scheduler.remove_job(str(sch_id)) + logger.info("Job with ID {} was deleted.".format(sch_id)) else: - logger.info("Job with ID {} was deleted from DB, but was not enabled. Not going to try removing something that doesn't exist from active schedules.") + logger.info("Job with ID {} was deleted from DB, but was not enabled. Not going to try removing something that doesn't exist from active schedules.".format(sch_id)) def update_job(self, sch_id, job_data): management_helper.update_scheduled_task(sch_id, job_data) diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index f05bba3b..0686b9e0 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -407,6 +407,16 @@ class AjaxHandler(BaseHandler): server_id = self.get_argument('id', None) logger.info( "Removing server from panel for server: {}".format(self.controller.servers.get_server_friendly_name(server_id))) + + server_data = self.controller.get_server_data(server_id) + server_name = server_data['server_name'] + + self.controller.management.add_to_audit_log(exec_user_id, + "Deleted server {} named {}".format(server_id, server_name), + server_id, + self.get_remote_ip()) + + self.tasks_manager.remove_all_server_tasks(server_id) self.controller.remove_server(server_id, False) elif page == "delete_server_files": @@ -417,6 +427,16 @@ class AjaxHandler(BaseHandler): server_id = self.get_argument('id', None) logger.info( "Removing server and all associated files for server: {}".format(self.controller.servers.get_server_friendly_name(server_id))) + + server_data = self.controller.get_server_data(server_id) + server_name = server_data['server_name'] + + self.controller.management.add_to_audit_log(exec_user_id, + "Deleted server {} named {}".format(server_id, server_name), + server_id, + self.get_remote_ip()) + + self.tasks_manager.remove_all_server_tasks(server_id) self.controller.remove_server(server_id, True) @tornado.web.authenticated diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index c6b4daa3..3cd4150d 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -126,28 +126,6 @@ class PanelHandler(BaseHandler): elif page == 'contribute': template = "panel/contribute.html" - elif page == "remove_server": - server_id = self.get_argument('id', None) - - if not exec_user['superuser']: - self.redirect("/panel/error?error=Unauthorized access: not superuser") - return - elif server_id is None: - self.redirect("/panel/error?error=Invalid Server ID") - return - - server_data = self.controller.get_server_data(server_id) - server_name = server_data['server_name'] - - self.controller.management.add_to_audit_log(exec_user_data['user_id'], - "Deleted server {} named {}".format(server_id, server_name), - server_id, - self.get_remote_ip()) - - self.controller.remove_server(server_id) - self.redirect("/panel/dashboard") - return - elif page == 'dashboard': if exec_user['superuser'] == 1: try: diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html index cf1e7347..ab6d5656 100644 --- a/app/frontend/templates/base.html +++ b/app/frontend/templates/base.html @@ -21,6 +21,7 @@ + @@ -139,7 +140,6 @@ {% block js %} diff --git a/app/frontend/templates/notify.html b/app/frontend/templates/notify.html index 4bb76b6e..2431c40a 100644 --- a/app/frontend/templates/notify.html +++ b/app/frontend/templates/notify.html @@ -29,11 +29,11 @@ {% end %}

Email: {{ data['user_data']['email'] }}

- Support Logs + {{ translate('notify', 'supportLogs', data['lang']) }} {% if "Super User" in data['user_role'] %} - Activity + {{ translate('notify', 'activityLog', data['lang']) }} {% end %} - Sign Out + {{ translate('notify', 'logout', data['lang']) }} \ No newline at end of file diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 549097ec..0aa583bd 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -180,7 +180,14 @@ "cannotSee": "Not seeing everything?", "cannotSeeOnMobile": "Try clicking on a scheduled task for full details." }, - + "notify":{ + "supportLogs": "Support Logs", + "activityLog": "Activity Logs", + "logout": "Logout", + "preparingLogs": " Please wait while we prepare your logs... We`ll send a notification when they`re ready. This may take a while for large deployments.", + "downloadLogs": "Download Support Logs?", + "finishedPreparing": "We've finished preparing your support logs. Please click download to download" + }, "serverBackups": { "backupNow": "Backup Now!", "backupAtMidnight": "Auto-backup at midnight?", diff --git a/requirements.txt b/requirements.txt index 3466dd76..f21e1bb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,18 @@ -cryptography~=3.4 -argon2-cffi~=20.1 -bleach~=3.1 -colorama~=0.4 -cryptography~=3.4 -libgravatar~=1.0.0 -peewee~=3.13 -pexpect~=4.8 -psutil~=5.7 -pyOpenSSL~=19.1.0 +cryptography==3.4 +argon2-cffi==20.1 +bleach==3.1 +colorama==0.4 +cryptography==3.4 +libgravatar==1.0.0 +peewee==3.13 +pexpect==4.8 +psutil==5.7 +pyOpenSSL==19.1.0 PyYAML==5.3.1 -requests~=2.26 -termcolor~=1.1 -tornado~=6.0 +requests==2.26 +termcolor==1.1 +tornado==6.0 cached_property==1.5.2 -apscheduler~=3.8.1 -cron-validator~=1.0.3 -tzlocal==3.0 \ No newline at end of file +apscheduler==3.8.1 +cron-validator==1.0.3 +tzlocal==4.0 \ No newline at end of file