diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml index 9cd630e7..0f5863b2 100644 --- a/.github/workflows/semantic-release.yml +++ b/.github/workflows/semantic-release.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: Python Semantic Release - uses: relekang/python-semantic-release@v8.0.8 + uses: relekang/python-semantic-release@v9.4.2 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dba5c485..c02bb08f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ exclude: '^static/[bootstrap|htmx]/' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v4.5.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.1.1 hooks: - id: black diff --git a/app/Entirety/.env.EXAMPLE b/app/Entirety/.env.EXAMPLE index e75be9d6..6e97b30e 100644 --- a/app/Entirety/.env.EXAMPLE +++ b/app/Entirety/.env.EXAMPLE @@ -2,6 +2,7 @@ ENTITIES_LOAD=True DEVICES_LOAD=True NOTIFICATIONS_LOAD=True +SEMANTICS_LOAD=True # Database DATABASE_PORT=5432 @@ -26,6 +27,7 @@ LOKI_PROTOCOL=http LOKI_SRC_HOST=entirety LOKI_TIMEZONE=Europe/Berlin +LOCAL_AUTH=True # OIDC OIDC_OP_AUTHORIZATION_ENDPOINT= OIDC_OP_JWKS_ENDPOINT= diff --git a/app/Entirety/devices/forms/servicegroups.py b/app/Entirety/devices/forms/servicegroups.py index 314fa47e..071e7f65 100644 --- a/app/Entirety/devices/forms/servicegroups.py +++ b/app/Entirety/devices/forms/servicegroups.py @@ -1,5 +1,7 @@ from crispy_forms.helper import FormHelper from django import forms +from smartdatamodels.models import SmartDataModel +import json class ServiceGroupBasic(forms.Form): @@ -10,7 +12,7 @@ class ServiceGroupBasic(forms.Form): attrs={ "data-bs-toggle": "tooltip", "title": "A string representing the southbound resource " - "that will be used to provision a device, e.g. /iot/json", + "that will be used to provision a device, e.g. /iot/json", } ), ) @@ -35,10 +37,36 @@ class ServiceGroupBasic(forms.Form): } ), ) - explicit_attrs = forms.BooleanField(label="Explicit Attributes", required=False, initial=False) - autoprovision = forms.BooleanField(label="Auto Provision", required=False, initial=True) + explicit_attrs = forms.BooleanField( + label="Explicit Attributes", required=False, initial=False + ) + autoprovision = forms.BooleanField( + label="Auto Provision", required=False, initial=True + ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_tag = False + + +class SmartDataModelServicesForm(forms.Form): + select_data_model = forms.ChoiceField(label="Select a Data Model", required=True) + only_required_attrs = forms.BooleanField( + label="Only use required attributes", required=False, initial=False + ) + + def __init__(self, *args, **kwargs): + super(SmartDataModelServicesForm, self).__init__(*args, **kwargs) + qs = SmartDataModel.objects.all() + list_of_schemas = [] + for set in qs: + list_of_schemas.append( + {"name": set.name, "value": json.dumps(set.jsonschema)} + ) + list_of_schemas.append({"name": "..", "value": ".."}) + self.fields["select_data_model"] = forms.ChoiceField( + choices=[(x.get("value"), x.get("name")) for x in list_of_schemas] + ) + self.helper = FormHelper(self) + self.helper.form_tag = False diff --git a/app/Entirety/devices/templates/devices/batch.html b/app/Entirety/devices/templates/devices/batch.html index 928ee3d8..9b2402d7 100644 --- a/app/Entirety/devices/templates/devices/batch.html +++ b/app/Entirety/devices/templates/devices/batch.html @@ -3,11 +3,10 @@ {% load compress %} {% load crispy_forms_tags %} - -{% block title %}Create Batch Devices {% endblock %} +{% block title %}Create Batch Devices{% endblock %} {% block content %} - Create Batch Devices + Create Batch Devices
{% compress js %} {% endcompress %} - - {% endblock %} diff --git a/app/Entirety/devices/templates/devices/datamodels.html b/app/Entirety/devices/templates/devices/datamodels.html new file mode 100644 index 00000000..4100287f --- /dev/null +++ b/app/Entirety/devices/templates/devices/datamodels.html @@ -0,0 +1,29 @@ +{% extends '_base.html' %} +{% load static %} +{% load compress %} +{% load crispy_forms_tags %} + + +{% block title %}Create device or service group from data model {% endblock %} + +{% block content %} +{# Create Device#} + +{# #} + +{# {% compress js %}#} +{# #} +{# {% endcompress %}#} + + +{% endblock %} diff --git a/app/Entirety/devices/templates/devices/detail.html b/app/Entirety/devices/templates/devices/detail.html index 99ea626d..3f245142 100644 --- a/app/Entirety/devices/templates/devices/detail.html +++ b/app/Entirety/devices/templates/devices/detail.html @@ -1,4 +1,6 @@ {% extends '_base.html' %} +{% load crispy_forms_tags %} + {% block title %} {% if action == "Create" %} @@ -14,27 +16,31 @@ {% block content %} {% if action == "Create" %} -