From fb32bb7113d978166394acc15936d1a0f3389568 Mon Sep 17 00:00:00 2001 From: Bryan Cerrati Date: Fri, 21 Mar 2025 11:46:03 -0400 Subject: [PATCH] Modify Added --- app/routes/clients.py | 39 +- app/templates/client_detail.html | 653 +++++++++++++++---------------- app/templates/edit_password.html | 36 ++ app/templates/edit_remote.html | 48 +++ 4 files changed, 446 insertions(+), 330 deletions(-) create mode 100644 app/templates/edit_password.html create mode 100644 app/templates/edit_remote.html diff --git a/app/routes/clients.py b/app/routes/clients.py index 71cc1be..08a4431 100644 --- a/app/routes/clients.py +++ b/app/routes/clients.py @@ -1,12 +1,12 @@ from flask import Blueprint, render_template, request, redirect, url_for, flash -from app.models import Client, ClientPassword, Domain, PasswordCategory, RemoteCategory +from app.models import Client, ClientPassword, Domain, PasswordCategory, RemoteCategory, ClientRemote from app import db clients_bp = Blueprint('clients', __name__) @clients_bp.route('/clients') def clients(): - clients_list = Client.query.all() + clients_list = Client.query.order_by(Client.name.asc()).all() return render_template('clients.html', clients=clients_list) @clients_bp.route('/clients/add', methods=['GET', 'POST']) @@ -209,3 +209,38 @@ def print_client(client_id): available_remote_categories=available_remote_categories, passwords_by_category=passwords_by_category, remotes_by_category=remotes_by_category) + +@clients_bp.route('/clients//edit_password/', methods=['GET', 'POST']) +def edit_password(client_id, password_id): + password_item = ClientPassword.query.get_or_404(password_id) + if request.method == 'POST': + password_item.item = request.form.get('item') + password_item.username = request.form.get('username') + password_item.password = request.form.get('password') + password_item.ip_address = request.form.get('ip_address') + category_id = request.form.get('category_id') + if category_id: + password_item.category_id = int(category_id) + else: + password_item.category_id = None + db.session.commit() + flash("Password updated successfully", "success") + return redirect(url_for('clients.client_detail', client_id=client_id)) + available_categories = PasswordCategory.query.all() + return render_template('edit_password.html', client_id=client_id, password=password_item, available_categories=available_categories) + +@clients_bp.route('/clients//edit_remote/', methods=['GET', 'POST']) +def edit_remote(client_id, remote_id): + remote = ClientRemote.query.get_or_404(remote_id) + if request.method == 'POST': + # For remote editing, update fields based on the remote category. + remote.name = request.form.get('remote_name') + remote.ip_address = request.form.get('ip_address') + remote.port = request.form.get('port') + remote.psk = request.form.get('psk') + remote.address = request.form.get('address') + remote.details = request.form.get('details') + db.session.commit() + flash("Remote updated successfully", "success") + return redirect(url_for('clients.client_detail', client_id=client_id)) + return render_template('edit_remote.html', client_id=client_id, remote=remote) diff --git a/app/templates/client_detail.html b/app/templates/client_detail.html index d419f2a..93db97a 100644 --- a/app/templates/client_detail.html +++ b/app/templates/client_detail.html @@ -1,165 +1,354 @@ {% extends "base.html" %} {% block title %}{{ client.name }}{% endblock %} {% block content %} -
-

{{ client.name }}

-
- - -
-
-
    - {% if client.phone %} -
  • Phone: {{ client.phone }}
  • - {% endif %} - {% if client.address %} -
  • Address: {{ client.address }}
  • - {% endif %} - {% if client.ip_address %} -
  • IP Address: {{ client.ip_address }}
  • - {% endif %} - {% if client.subnet_mask %} -
  • Subnet Mask: {{ client.subnet_mask }}
  • - {% endif %} - {% if client.gateway %} -
  • Gateway: {{ client.gateway }}
  • - {% endif %} -
- {% if client.phone is none and client.address is none and client.ip_address is none and client.subnet_mask is none and client.gateway is none %} -

No details available.

- {% endif %} - +
+ +
+

{{ client.name }}

-
-
-
+ + +
+

Details

+
+
    + {% if client.phone %}
  • Phone: {{ client.phone }}
  • {% endif %} + {% if client.address %}
  • Address: {{ client.address }}
  • {% endif %} + {% if client.ip_address %}
  • IP Address: {{ client.ip_address }}
  • {% endif %} + {% if client.subnet_mask %}
  • Subnet Mask: {{ client.subnet_mask }}
  • {% endif %} + {% if client.gateway %}
  • Gateway: {{ client.gateway }}
  • {% endif %} +
+ {% if not (client.phone or client.address or client.ip_address or client.subnet_mask or client.gateway) %} +

No details available.

+ {% endif %} + +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + + +
+
+
+ +
+ + +
+

Remote

+ {% for category, remotes in remotes_by_category.items() %} + {% if remotes|length > 0 %} +

{{ category }}

+ + + {% if category == 'RDP' %} + + + + + + + {% elif category == 'SSL-VPN' %} + + + + + + {% elif category == 'VPN' %} + + + + + + {% elif category == 'MGMT' %} + + + + + + {% else %} + + + + + {% endif %} + + + {% for remote in remotes %} + + {% if category == 'RDP' %} + + + + {% elif category == 'SSL-VPN' %} + + + {% elif category == 'VPN' %} + + + {% elif category == 'MGMT' %} + + + {% else %} + + {% endif %} + + + {% endfor %} + +
NameIP AddressPortAction
IP AddressPortAction
IP AddressPSKAction
NameAddressAction
DetailsAction
+ {% if remote.name %} + {{ remote.name }} + {% else %} + Edit + {% endif %} + {{ remote.ip_address }}{{ remote.port }}{{ remote.ip_address }}{{ remote.port }}{{ remote.ip_address }}{{ remote.psk }} + {% if remote.name %} + {{ remote.name }} + {% else %} + Edit + {% endif %} + {{ remote.address }}{{ remote.details }} +
+ +
+
+ {% endif %} + {% endfor %} + + + + + + -
- - -
- - -
-

Remote

- {% for category, remotes in remotes_by_category.items() %} - {% if remotes|length > 0 %} -

{{ category }}

+ +
+ + +
+

Passwords

+ {% for category, passwords in passwords_by_category.items() %} + {% if passwords|length > 0 %} +

{{ category }}

+ + + + + + + + + + + + {% for p in passwords %} + + + + + + + + {% endfor %} + +
ItemUsernamePasswordIP AddressAction
+ {{ p.item }} + {{ p.username }}{{ p.password }}{{ p.ip_address }} +
+ +
+
+ {% endif %} + {% endfor %} + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+
+
+
+ +
+ + +
+

Domains

+ {% if client.domains|length > 0 %} - {% if category == 'RDP' %} - - - - - - - {% elif category == 'SSL-VPN' %} - - - - - - {% elif category == 'VPN' %} - - - - - - {% elif category == 'MGMT' %} - - - - - - {% else %} - - - - - {% endif %} + + + + + - {% for remote in remotes %} - - {% if category == 'RDP' %} - - - - {% elif category == 'SSL-VPN' %} - - - {% elif category == 'VPN' %} - - - {% elif category == 'MGMT' %} - - - {% else %} - - {% endif %} - - + {% for d in client.domains %} + + + + + {% endfor %}
NameIP AddressPortAction
IP AddressPortAction
IP AddressPSKAction
NameAddressAction
DetailsAction
DomainWHOIS ExpirationAction
{{ remote.name }}{{ remote.ip_address }}{{ remote.port }}{{ remote.ip_address }}{{ remote.port }}{{ remote.ip_address }}{{ remote.psk }}{{ remote.name }}{{ remote.address }}{{ remote.details }} -
- -
-
{{ d.domain }}{{ d.expiration_date }} +
+ +
+
+ {% else %} +

No domain associations.

{% endif %} - {% endfor %} - - - - - - + +
+ + +
+

SSL

+ {% if client.ssl_domains|length > 0 %} + + + + + + + + + + {% for d in client.ssl_domains %} + + + + + + {% endfor %} + +
DomainSSL ExpirationAction
{{ d.domain }}{{ d.ssl_expiration_date }} +
+ +
+
+ {% else %} +

No SSL associations.

+ {% endif %} +
+
+ + +
+ +
+
+ +
+ + +
+
+ +
+ Print +
- - -
- - -
-

Passwords

- {% for category, passwords in passwords_by_category.items() %} - {% if passwords|length > 0 %} -

{{ category }}

- - - - - - - - - - - - {% for p in passwords %} - - - - - - - - {% endfor %} - -
ItemUsernamePasswordIP AddressAction
{{ p.item }}{{ p.username }}{{ p.password }}{{ p.ip_address }} -
- -
-
- {% endif %} - {% endfor %} - - - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- - -
- - -
-

Domains

- {% if client.domains|length > 0 %} - - - - - - - - - - {% for d in client.domains %} - - - - - - {% endfor %} - -
DomainWHOIS ExpirationAction
{{ d.domain }}{{ d.expiration_date }} -
- -
-
- {% else %} -

No domain associations.

- {% endif %} -
-
- - -
- -
-
- - -
- - -
-

SSL

- {% if client.ssl_domains|length > 0 %} - - - - - - - - - - {% for d in client.ssl_domains %} - - - - - - {% endfor %} - -
DomainSSL ExpirationAction
{{ d.domain }}{{ d.ssl_expiration_date }} -
- -
-
- {% else %} -

No SSL associations.

- {% endif %} -
-
- - -
- -
-
- - -
- - -
-
- -
- Print -
- {% endblock %} diff --git a/app/templates/edit_password.html b/app/templates/edit_password.html new file mode 100644 index 0000000..ab7f263 --- /dev/null +++ b/app/templates/edit_password.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} +{% block title %}Edit Password{% endblock %} +{% block content %} +
+

Edit Password

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + Cancel +
+
+{% endblock %} diff --git a/app/templates/edit_remote.html b/app/templates/edit_remote.html new file mode 100644 index 0000000..00b69f1 --- /dev/null +++ b/app/templates/edit_remote.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} +{% block title %}Edit Remote{% endblock %} +{% block content %} +
+

Edit Remote

+
+ {% set category = remote.remote_category.name %} + {% if category in ['RDP', 'MGMT'] %} +
+ + +
+ {% endif %} + {% if category in ['RDP', 'SSL-VPN', 'VPN'] %} +
+ + +
+ {% endif %} + {% if category in ['RDP', 'SSL-VPN'] %} +
+ + +
+ {% endif %} + {% if category == 'VPN' %} +
+ + +
+ {% endif %} + {% if category == 'MGMT' %} +
+ + +
+ {% endif %} + {% if category not in ['RDP', 'SSL-VPN', 'VPN', 'MGMT'] %} +
+ + +
+ {% endif %} + + Cancel +
+
+{% endblock %}