From eba7bff050d4bd4c85b1ffbb58fe830a4383ab55 Mon Sep 17 00:00:00 2001 From: LukasDoesDev Date: Fri, 15 Jan 2021 14:13:06 +0200 Subject: [PATCH] Now can see a tree view of the directory the server is in. Will do file editing now. --- app/classes/shared/helpers.py | 2 +- app/classes/web/panel_handler.py | 25 +- app/frontend/templates/panel/files.html | 173 ---------- .../templates/panel/server_files.html | 296 ++++++++++++++++++ 4 files changed, 303 insertions(+), 193 deletions(-) delete mode 100644 app/frontend/templates/panel/files.html create mode 100644 app/frontend/templates/panel/server_files.html diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index d415ae71..24256081 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -462,7 +462,7 @@ class Helpers: if os.path.isdir(rel): html += '
  • \n{}\n' + html += '\n
  • ' else: html += '
  • {}
  • '.format(filename) return html diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index d9ca5408..d284facc 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -62,24 +62,6 @@ class PanelHandler(BaseHandler): elif page == 'file_edit': template = "panel/file_edit.html" - elif page == 'files': - server_id = self.get_argument('id', None) - - if server_id is None: - self.redirect("/panel/error?error=Invalid Server ID") - return False - else: - server_id = bleach.clean(server_id) - - # does this server id exist? - if not db_helper.server_id_exists(server_id): - self.redirect("/panel/error?error=Invalid Server ID") - return False - - page_data['tree_html'] = helper.generate_tree(db_helper.get_server_data_by_id(server_id)['path']) - - template = "panel/files.html" - elif page == "remove_server": server_id = self.get_argument('id', None) server_data = controller.get_server_data(server_id) @@ -121,10 +103,15 @@ class PanelHandler(BaseHandler): self.redirect("/panel/error?error=Invalid Server ID") return False - valid_subpages = ['term', 'logs', 'config'] + valid_subpages = ['term', 'logs', 'config', 'files'] if subpage not in valid_subpages: + console.debug('not a valid subpage') subpage = 'term' + console.debug('Subpage: "{}"'.format(subpage)) + if subpage == 'files': + console.debug('Subpage is "files"') + page_data['tree_html'] = helper.generate_tree(db_helper.get_server_data_by_id(server_id)['path']) # server_data isn't needed since the server_stats also pulls server data # page_data['server_data'] = db_helper.get_server_data_by_id(server_id) diff --git a/app/frontend/templates/panel/files.html b/app/frontend/templates/panel/files.html deleted file mode 100644 index 1d8e18b8..00000000 --- a/app/frontend/templates/panel/files.html +++ /dev/null @@ -1,173 +0,0 @@ -{% extends ../base.html %} - -{% block meta %} - -{% end %} - -{% block title %}Crafty Controller - Looking at files in server -< server name >- (-< server path id >-){% end %} - -{% block content %} - -
    - - -
    -
    - -
    - -
    - - -
    - -
    - -
      -
    • - Files -
        - {{ data['tree_html'] }} - -
      -
    • -
    -
    - -
    -
    - - - - -
    - - -
    - - -{% end %} - -{% block js %} - - - -{% end %} \ No newline at end of file diff --git a/app/frontend/templates/panel/server_files.html b/app/frontend/templates/panel/server_files.html new file mode 100644 index 00000000..3d54a248 --- /dev/null +++ b/app/frontend/templates/panel/server_files.html @@ -0,0 +1,296 @@ +{% extends ../base.html %} + +{% block meta %} + +{% end %} + +{% block title %}Crafty Controller - Server Details{% end %} + +{% block content %} + +
    + + +
    +
    + +
    + +
    + + + {% include "parts/details_stats.html %} + +
    + +
    +
    +
    + + +
    +
    + +
      +
    • + Files +
        +
      • Error while getting files
      • + +
      +
    • +
    +
    + +
    + TODO: edit files

    + Editing file +
    file_contents
    +

    + +
    + + +
    + +
    +
    +
    +
    + + + +
    + + +{% end %} + +{% block js %} + + + + +{% end %} \ No newline at end of file