Loading open_webui.sh +4 −2 Original line number Diff line number Diff line Loading @@ -19,8 +19,10 @@ K8S_NAMESPACE=${K8S_NAMESPACE:-'tf-dev'} WEBUI_SERVICE_NAME="webuiservice-public" WEBUI_PROTO=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[0].name}'` WEBUI_IP=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'` WEBUI_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8004)].nodePort}') GRAFANA_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}') # WEBUI_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8004)].nodePort}') WEBUI_PORT=8004 # GRAFANA_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}') GRAFANA_PORT=3000 # Open WebUI URL=${WEBUI_PROTO}://${WEBUI_IP}:${WEBUI_PORT} Loading src/webui/service/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import os import json from flask import Flask, session from flask import Flask, request, session from flask_healthz import healthz, HealthError from webui.proto.context_pb2 import Empty Loading src/webui/service/main/forms.py +8 −3 Original line number Diff line number Diff line Loading @@ -16,16 +16,21 @@ from flask_wtf import FlaskForm from flask_wtf.file import FileAllowed from wtforms import SelectField, FileField, SubmitField #from wtforms.validators import DataRequired, Length from wtforms.validators import DataRequired, Length class ContextForm(FlaskForm): context = SelectField( 'Context', choices=[], validators=[ #DataRequired(), #Length(min=1) DataRequired(), Length(min=1) ]) submit = SubmitField('Submit') class DescriptorForm(FlaskForm): descriptors = FileField('Descriptors', validators=[ FileAllowed(['json'], 'JSON Descriptors only!') Loading src/webui/service/main/routes.py +17 −15 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ from webui.Config import (CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT, from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from webui.proto.context_pb2 import Context, Device, Empty, Link, Topology from webui.service.main.forms import ContextForm from webui.service.main.forms import ContextForm, DescriptorForm main = Blueprint('main', __name__) Loading Loading @@ -66,27 +66,29 @@ def process_descriptors(descriptors): def home(): context_client.connect() device_client.connect() try: response = context_client.ListContextIds(Empty()) context_form: ContextForm = ContextForm() context_form.context.choices.append(('', 'Select...')) for context in response.context_ids: context_form.context.choices.append((context.context_uuid.uuid, context.context_uuid)) if context_form.validate_on_submit(): if context_form.context.data: session['context_uuid'] = context_form.context.data flash(f'The context was successfully set to `{context_form.context.data}`.', 'success') if context_form.descriptors.data: process_descriptors(context_form.descriptors) return redirect(url_for("main.home")) if 'context_uuid' in session: context_form.context.data = session['context_uuid'] return render_template('main/home.html', context_form=context_form) descriptor_form: DescriptorForm = DescriptorForm() try: if descriptor_form.validate_on_submit(): process_descriptors(descriptor_form.descriptors) return redirect(url_for("main.home")) except Exception as e: logger.exception('Descriptor load failed') flash(f'Descriptor load failed: `{str(e)}`', 'danger') finally: context_client.close() device_client.close() return render_template('main/home.html', context_form=context_form, descriptor_form=descriptor_form) @main.route('/topology', methods=['GET']) def topology(): Loading src/webui/service/service/routes.py +6 −1 Original line number Diff line number Diff line Loading @@ -75,8 +75,13 @@ def detail(service_uuid: str): context_client.connect() response: Service = context_client.GetService(request) context_client.close() return render_template('service/detail.html', service=response) except Exception as e: flash('The system encountered an error and cannot show the details of this service.', 'warning') current_app.logger.exception(e) return redirect(url_for('service.home')) return render_template('service/detail.html', service=response) @service.get('delete/<path:service_uuid>') def delete(service_uuid: str): pass Loading
open_webui.sh +4 −2 Original line number Diff line number Diff line Loading @@ -19,8 +19,10 @@ K8S_NAMESPACE=${K8S_NAMESPACE:-'tf-dev'} WEBUI_SERVICE_NAME="webuiservice-public" WEBUI_PROTO=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[0].name}'` WEBUI_IP=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'` WEBUI_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8004)].nodePort}') GRAFANA_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}') # WEBUI_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8004)].nodePort}') WEBUI_PORT=8004 # GRAFANA_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}') GRAFANA_PORT=3000 # Open WebUI URL=${WEBUI_PROTO}://${WEBUI_IP}:${WEBUI_PORT} Loading
src/webui/service/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import os import json from flask import Flask, session from flask import Flask, request, session from flask_healthz import healthz, HealthError from webui.proto.context_pb2 import Empty Loading
src/webui/service/main/forms.py +8 −3 Original line number Diff line number Diff line Loading @@ -16,16 +16,21 @@ from flask_wtf import FlaskForm from flask_wtf.file import FileAllowed from wtforms import SelectField, FileField, SubmitField #from wtforms.validators import DataRequired, Length from wtforms.validators import DataRequired, Length class ContextForm(FlaskForm): context = SelectField( 'Context', choices=[], validators=[ #DataRequired(), #Length(min=1) DataRequired(), Length(min=1) ]) submit = SubmitField('Submit') class DescriptorForm(FlaskForm): descriptors = FileField('Descriptors', validators=[ FileAllowed(['json'], 'JSON Descriptors only!') Loading
src/webui/service/main/routes.py +17 −15 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ from webui.Config import (CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT, from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from webui.proto.context_pb2 import Context, Device, Empty, Link, Topology from webui.service.main.forms import ContextForm from webui.service.main.forms import ContextForm, DescriptorForm main = Blueprint('main', __name__) Loading Loading @@ -66,27 +66,29 @@ def process_descriptors(descriptors): def home(): context_client.connect() device_client.connect() try: response = context_client.ListContextIds(Empty()) context_form: ContextForm = ContextForm() context_form.context.choices.append(('', 'Select...')) for context in response.context_ids: context_form.context.choices.append((context.context_uuid.uuid, context.context_uuid)) if context_form.validate_on_submit(): if context_form.context.data: session['context_uuid'] = context_form.context.data flash(f'The context was successfully set to `{context_form.context.data}`.', 'success') if context_form.descriptors.data: process_descriptors(context_form.descriptors) return redirect(url_for("main.home")) if 'context_uuid' in session: context_form.context.data = session['context_uuid'] return render_template('main/home.html', context_form=context_form) descriptor_form: DescriptorForm = DescriptorForm() try: if descriptor_form.validate_on_submit(): process_descriptors(descriptor_form.descriptors) return redirect(url_for("main.home")) except Exception as e: logger.exception('Descriptor load failed') flash(f'Descriptor load failed: `{str(e)}`', 'danger') finally: context_client.close() device_client.close() return render_template('main/home.html', context_form=context_form, descriptor_form=descriptor_form) @main.route('/topology', methods=['GET']) def topology(): Loading
src/webui/service/service/routes.py +6 −1 Original line number Diff line number Diff line Loading @@ -75,8 +75,13 @@ def detail(service_uuid: str): context_client.connect() response: Service = context_client.GetService(request) context_client.close() return render_template('service/detail.html', service=response) except Exception as e: flash('The system encountered an error and cannot show the details of this service.', 'warning') current_app.logger.exception(e) return redirect(url_for('service.home')) return render_template('service/detail.html', service=response) @service.get('delete/<path:service_uuid>') def delete(service_uuid: str): pass