Commit b4612ca5 authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Implementing refinements in the webui.

parent 10d66dbb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ INFLUXDB_DATABASE=$(kubectl --namespace $K8S_NAMESPACE get secrets influxdb-secr
# GRAFANA_HOSTNAME=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}')
# GRAFANA_HOSTNAME=`kubectl get service/webuiservice-public -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'`
GRAFANA_HOSTNAME=`kubectl get nodes --selector=node-role.kubernetes.io/master -o jsonpath='{$.items[*].status.addresses[?(@.type=="InternalIP")].address}'`
# GRAFANA_PORT=$(kubectl get service webuiservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}')
GRAFANA_PORT=`kubectl get service/webuiservice-public -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[1].nodePort}'`
GRAFANA_PORT=$(kubectl get service webuiservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}')
# GRAFANA_PORT=`kubectl get service/webuiservice-public -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[1].nodePort}'`
GRAFANA_USERNAME="admin"
GRAFANA_PASSWORD=${GRAFANA_PASSWORD:-"admin123+"}
GRAFANA_URL="http://${GRAFANA_USERNAME}:${GRAFANA_PASSWORD}@${GRAFANA_HOSTNAME}:${GRAFANA_PORT}"

manifests/expose_services.yaml

deleted100644 → 0
+0 −90
Original line number Diff line number Diff line
---
apiVersion: v1
kind: Service
metadata:
  name: contextservice-public
  labels:
    app: contextservice
spec:
  type: NodePort
  selector:
    app: contextservice
  ports:
  - name: grpc
    protocol: TCP
    port: 1010
    targetPort: 1010
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
    nodePort: 30808
---
apiVersion: v1
kind: Service
metadata:
  name: redis-tests
  labels:
    app: contextservice
spec:
  type: NodePort
  selector:
    app: contextservice
  ports:
  - name: redis
    protocol: TCP
    port: 6379
    targetPort: 6379
---
apiVersion: v1
kind: Service
metadata:
  name: influx-tests
  labels:
    app: monitoringservice
spec:
  type: NodePort
  selector:
    app: monitoringservice
  ports:
  - name: influx
    protocol: TCP
    port: 8086
    targetPort: 8086
---
apiVersion: v1
kind: Service
metadata:
  name: deviceservice-public
  labels:
    app: deviceservice
spec:
  type: NodePort
  selector:
    app: deviceservice
  ports:
  - name: grpc
    protocol: TCP
    port: 2020
    targetPort: 2020
---
apiVersion: v1
kind: Service
metadata:
  name: computeservice-public
  labels:
    app: computeservice
spec:
  type: NodePort
  selector:
    app: computeservice
  ports:
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
  - name: grpc
    protocol: TCP
    port: 9090
    targetPort: 9090
---
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
# limitations under the License.

import os
import json

from flask import Flask, session
from flask_healthz import healthz, HealthError

@@ -46,6 +48,10 @@ def readiness():
        raise HealthError('Can\'t connect with the service: ' + e.details())


def from_json(json_str):
    return json.loads(json_str)


def create_app(use_config=None):
    app = Flask(__name__)
    if use_config:
@@ -67,6 +73,11 @@ def create_app(use_config=None):
    from webui.service.device.routes import device
    app.register_blueprint(device)

    from webui.service.link.routes import link
    app.register_blueprint(link)

    app.jinja_env.filters['from_json'] = from_json
    
    app.jinja_env.globals.update(get_working_context=get_working_context)

    return app
+8 −6
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ def home():
        flash("Please select a context!", "warning")
        return redirect(url_for("main.home"))
    request: ContextId = ContextId()
    request.context_uuid.uuid = session.get('context_uuid', '-')
    request.context_uuid.uuid = context_uuid
    context_client.connect()
    response: DeviceList = context_client.ListDevices(request)
    context_client.close()
@@ -98,7 +98,7 @@ def add():
            device_client.close()

            flash(f'New device was created with ID "{response.device_uuid.uuid}".', 'success')
            return redirect('/device/')
            return redirect(url_for('device.home'))
        except Exception as e:
            flash(f'Problem adding the device. {e.details()}', 'danger')
        
@@ -106,16 +106,18 @@ def add():
                    submit_text='Add New Device',
                    device_driver_ids=device_driver_ids)

@device.route('detail/<device_uuid>', methods=['GET', 'POST'])
@device.route('detail/<path:device_uuid>', methods=['GET', 'POST'])
def detail(device_uuid: str):
    request: DeviceId = DeviceId()
    request.device_uuid.uuid = device_uuid
    context_client.connect()
    response: Device = context_client.GetDevice(request)
    context_client.close()
    return render_template('device/detail.html', device=response)
    return render_template('device/detail.html', device=response,
                                                 dde=DeviceDriverEnum,
                                                 dose=DeviceOperationalStatusEnum)

@device.get('<device_uuid>/delete')
@device.get('<path:device_uuid>/delete')
def delete(device_uuid):
    try:

@@ -136,4 +138,4 @@ def delete(device_uuid):
    except Exception as e:
        flash(f'Problem deleting the device. {e.details()}', 'danger')

    return redirect('/device/')
    return redirect(url_for('device.home'))
+0 −0

Empty file added.

Loading