From bce372a1d125ab51c2710454d99baf40a21689e2 Mon Sep 17 00:00:00 2001 From: Allan Eising Date: Sat, 14 Jun 2025 21:56:17 +0200 Subject: [PATCH] Refactor frontend views --- .../frontend/templates/audit/inner.html.j2 | 2 +- .../frontend/templates/clients/client.html.j2 | 126 ++++------ .../clients/drawer_client_create.html.j2 | 38 --- .../drawer_client_create_inner.html.j2 | 108 -------- .../clients/drawer_client_delete.html.j2 | 67 ----- .../templates/clients/dynamic.html.j2 | 3 - .../frontend/templates/clients/index.html.j2 | 28 +-- .../clients/partials/client_details.html.j2 | 180 ++++++++++++++ .../clients/partials/drawer_create.html.j2 | 164 +++++++++++++ .../drawer_edit.html.j2} | 39 +-- .../clients/partials/pagination.html.j2 | 73 ++++++ .../templates/clients/partials/tree.html.j2 | 80 ++++++ .../templates/clients/partials/tree_event.js | 34 +++ .../clients/partials/tree_items.html.j2 | 42 ++++ .../frontend/templates/dashboard/_base.html | 8 +- .../templates/dashboard/_scripts.html | 13 +- .../frontend/templates/secrets/index.html.j2 | 37 +-- .../secrets/partials/tree_detail.html.j2 | 2 +- .../templates/secrets/partials/tree_event.js | 36 +++ .../sshecret_admin/frontend/views/audit.py | 25 +- .../sshecret_admin/frontend/views/clients.py | 231 ++++++++++++++---- .../sshecret_admin/frontend/views/common.py | 41 ++++ .../sshecret_admin/services/admin_backend.py | 17 +- .../src/sshecret_admin/static/css/main.css | 157 ++++++++++++ .../src/sshecret_admin/static/css/style.css | 11 + .../src/sshecret_backend/api/audit/router.py | 5 +- .../api/clients/operations.py | 22 ++ .../sshecret_backend/api/clients/schemas.py | 4 + .../src/sshecret_backend/cli.py | 18 +- src/sshecret/backend/api.py | 36 ++- src/sshecret/backend/models.py | 22 +- tests/integration/test_backend.py | 19 ++ 32 files changed, 1230 insertions(+), 458 deletions(-) delete mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create.html.j2 delete mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create_inner.html.j2 delete mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_delete.html.j2 delete mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/dynamic.html.j2 create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/client_details.html.j2 create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_create.html.j2 rename packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/{drawer_client_update.html.j2 => partials/drawer_edit.html.j2} (78%) create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/pagination.html.j2 create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/tree.html.j2 create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/tree_event.js create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/tree_items.html.j2 create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/templates/secrets/partials/tree_event.js create mode 100644 packages/sshecret-admin/src/sshecret_admin/frontend/views/common.py diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/audit/inner.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/audit/inner.html.j2 index ca353b5..cfb41b8 100644 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/audit/inner.html.j2 +++ b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/audit/inner.html.j2 @@ -1,4 +1,4 @@ -
+
diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/client.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/client.html.j2 index 585a60f..a176f2a 100644 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/client.html.j2 +++ b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/client.html.j2 @@ -1,82 +1,46 @@ - - - {{-client.name -}} - - - {{- client.id -}} - - - {{- client.description -}} - - - {{- client.secrets|length -}} - - - {{- client.policies|join(', ') -}} - +{% extends "/dashboard/_base.html" %} {% block content %} +
+
+
+ - - - - - + +
+ +
+
+ {% include '/clients/partials/tree.html.j2' %} +
+
+
+ {% include '/clients/partials/client_details.html.j2' %} +
+
+
+
+ +
+{% include '/clients/partials/drawer_create.html.j2' %} + +{% endblock %} diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create.html.j2 deleted file mode 100644 index 1b1efea..0000000 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create.html.j2 +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create_inner.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create_inner.html.j2 deleted file mode 100644 index 48c5a06..0000000 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_create_inner.html.j2 +++ /dev/null @@ -1,108 +0,0 @@ -
-
- - -
- -
- - -
-
- -

- Separate multiple entries with comma. -

- - - -
- -
- - - -
-
- - -
-
diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_delete.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_delete.html.j2 deleted file mode 100644 index eea7411..0000000 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_delete.html.j2 +++ /dev/null @@ -1,67 +0,0 @@ - diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/dynamic.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/dynamic.html.j2 deleted file mode 100644 index fba24be..0000000 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/dynamic.html.j2 +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/index.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/index.html.j2 index c659292..6087d1d 100644 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/index.html.j2 +++ b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/index.html.j2 @@ -15,31 +15,27 @@
Clients -
-

Clients

+ +
-
-
- -
- +
+
+ {% include '/clients/partials/tree.html.j2' %} +
+
+
+

Click an item to view details

-
-
-
-
- {% include '/clients/inner.html.j2' %} -
-{% include '/clients/drawer_client_create.html.j2' %} +
+{% include '/clients/partials/drawer_create.html.j2' %} + {% endblock %} diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/client_details.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/client_details.html.j2 new file mode 100644 index 0000000..f2b4f90 --- /dev/null +++ b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/client_details.html.j2 @@ -0,0 +1,180 @@ + + +
+
+ + + +
+ + Client Data + Events + + + +
+
+
+

{{client.name}}

+ {% if client.description %} +

{{ client.description }}

+ {% endif %} +
+
+
+
+
Client ID
+
{{client.id}}
+
+ +
+
Client Description
+
{{client.description}}
+
+
+
Client Version
+
{{client.version}}
+
+
+
Public Key
+
{{client.public_key}}
+
+
+
Assigned Secrets
+
{{client.secrets|length}}
+
+
+
Allowed sources
+
{{client.policies|join(', ')}}
+
+
+
+
+
+
+ + + + + + + + + + + + + {% for entry in events.results | list %} + + + + + + + + + + {% endfor %} + +
TimestampSubsystemMessageOrigin
+

{{ entry.timestamp }}

+ + +
+ {{ entry.subsystem }} + + {{ entry.message }} + + {{ entry.origin }} +
+
+
+
+ +{% include '/clients/partials/drawer_edit.html.j2' %} diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_create.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_create.html.j2 new file mode 100644 index 0000000..89100b6 --- /dev/null +++ b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_create.html.j2 @@ -0,0 +1,164 @@ + diff --git a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_update.html.j2 b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_edit.html.j2 similarity index 78% rename from packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_update.html.j2 rename to packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_edit.html.j2 index c6fb099..7e474b5 100644 --- a/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/drawer_client_update.html.j2 +++ b/packages/sshecret-admin/src/sshecret_admin/frontend/templates/clients/partials/drawer_edit.html.j2 @@ -5,19 +5,15 @@ aria-labelledby="drawer-label-{{ client.id }}" aria-hidden="true" > +
-
- - Loading... -
Update Client
+ + +
+
+ + Loading... +
+
+
@@ -94,7 +99,7 @@ type="text" name="sources" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - placeholder="0.0.0.0/0" + placeholder="0.0.0.0/0, ::/0" id="sources-{{client.id}}" hx-post="/clients/validate/source" hx-target="#clientSourceValidation-{{ client.id }}" @@ -114,8 +119,7 @@ id="helper-text-explanation-{{ client.id }}" class="mt-2 text-sm text-gray-500 dark:text-gray-400" > - Note that updating the key will invalidate all secrets associated with - this client. + Note that this will create a new version of the client, and any existing secrets will no longer be accessible.