diff --git a/src/webui/service/link/routes.py b/src/webui/service/link/routes.py index 0fda8958e2ab2609969d2c1f68aaae61b7360b68..3ab320d8b13d037e195f00ced9eb63bd14ecc0dd 100644 --- a/src/webui/service/link/routes.py +++ b/src/webui/service/link/routes.py @@ -13,8 +13,8 @@ # limitations under the License. -from flask import render_template, Blueprint, flash, session, redirect, url_for -from common.proto.context_pb2 import Empty, Link, LinkList +from flask import current_app, render_template, Blueprint, flash, session, redirect, url_for +from common.proto.context_pb2 import Empty, Link, LinkId, LinkList from common.tools.context_queries.EndPoint import get_endpoint_names from common.tools.context_queries.Link import get_link from common.tools.context_queries.Topology import get_topology @@ -65,3 +65,25 @@ def detail(link_uuid: str): device_names, endpoints_data = get_endpoint_names(context_client, link_obj.link_endpoint_ids) context_client.close() return render_template('link/detail.html',link=link_obj, device_names=device_names, endpoints_data=endpoints_data) + +@link.get('/delete') +def delete(link_uuid): + try: + + # first, check if link exists! + # request: LinkId = LinkId() + # request.link_uuid.uuid = link_uuid + # response: Link = client.GetLink(request) + # TODO: finalize implementation + + request = LinkId() + request.link_uuid.uuid = link_uuid # pylint: disable=no-member + context_client.connect() + context_client.RemoveLink(request) + context_client.close() + + flash(f'Link "{link_uuid}" deleted successfully!', 'success') + except Exception as e: # pylint: disable=broad-except + flash(f'Problem deleting link "{link_uuid}": {e.details()}', 'danger') + current_app.logger.exception(e) + return redirect(url_for('link.home')) diff --git a/src/webui/service/templates/link/detail.html b/src/webui/service/templates/link/detail.html index 916abafde05b3ec990346ff7966f207b1dafc10a..8ca7faee3e1871d11b819c6ca95668e654041f8c 100644 --- a/src/webui/service/templates/link/detail.html +++ b/src/webui/service/templates/link/detail.html @@ -13,62 +13,92 @@ See the License for the specific language governing permissions and limitations under the License. --> - {% extends 'base.html' %} - - {% block content %} -

Link {{ link.name }} ({{ link.link_id.link_uuid.uuid }})

-
-
- -
-
-
-
-
- UUID: {{ link.link_id.link_uuid.uuid }}
- Name: {{ link.name }}
-
-
- - - - - - - - - - - {% for endpoint in link.link_endpoint_ids %} - - - - - - - {% endfor %} - -
Endpoint UUIDNameDeviceEndpoint Type
- {{ endpoint.endpoint_uuid.uuid }} - - {{ endpoints_data.get(endpoint.endpoint_uuid.uuid, (endpoint.endpoint_uuid.uuid, ''))[0] }} - - - {{ device_names.get(endpoint.device_id.device_uuid.uuid, endpoint.device_id.device_uuid.uuid) }} - - - - - - - {{ endpoints_data.get(endpoint.endpoint_uuid.uuid, ('', '-'))[1] }} -
+{% extends 'base.html' %} + +{% block content %} +

Link {{ link.name }} ({{ link.link_id.link_uuid.uuid }})

+
+
+ +
+
+ + +
+
+ +
+
+
+ UUID: {{ link.link_id.link_uuid.uuid }}
+ Name: {{ link.name }}
+
+
+ + + + + + + + + + + {% for endpoint in link.link_endpoint_ids %} + + + + + + + {% endfor %} + +
Endpoint UUIDNameDeviceEndpoint Type
+ {{ endpoint.endpoint_uuid.uuid }} + + {{ endpoints_data.get(endpoint.endpoint_uuid.uuid, (endpoint.endpoint_uuid.uuid, ''))[0] }} + + + {{ device_names.get(endpoint.device_id.device_uuid.uuid, endpoint.device_id.device_uuid.uuid) }} + + + + + + + {{ endpoints_data.get(endpoint.endpoint_uuid.uuid, ('', '-'))[1] }} +
+
+
+ + + + - {% endblock %} - \ No newline at end of file +{% endblock %}