diff --git a/app/core/views/common.py b/app/core/views/common.py index f1baac20..a1350afa 100644 --- a/app/core/views/common.py +++ b/app/core/views/common.py @@ -75,6 +75,13 @@ class ChangeView(View, generic.UpdateView): external_links_query = None + if 'tab' in self.request.GET: + + context['open_tab'] = str(self.request.GET.get("tab")).lower() + + else: + context['open_tab'] = None + if self.model._meta.model_name == 'device': diff --git a/app/itim/forms/services.py b/app/itim/forms/services.py index a88dc277..e591afb4 100644 --- a/app/itim/forms/services.py +++ b/app/itim/forms/services.py @@ -1,8 +1,11 @@ from django import forms from django.forms import ValidationError +from django.urls import reverse from itim.models.services import Service +from app import settings + from core.forms.common import CommonModelForm @@ -79,3 +82,81 @@ class ServiceForm(CommonModelForm): return cleaned_data + + + +class DetailForm(ServiceForm): + + + tabs: dict = { + "details": { + "name": "Details", + "slug": "details", + "sections": [ + { + "layout": "double", + "left": [ + 'name', + 'config_key_variable', + 'template', + 'organization', + 'c_created', + 'c_modified' + ], + "right": [ + 'model_notes', + ] + } + ] + }, + "rendered_config": { + "name": "Rendered Config", + "slug": "rendered_config", + "sections": [ + { + "layout": "single", + "fields": [ + 'config_variables', + ], + "json": [ + 'config_variables' + ] + } + ] + } + } + + + def __init__(self, *args, **kwargs): + + super().__init__(*args, **kwargs) + + + self.fields['config_variables'] = forms.fields.JSONField( + widget = forms.Textarea( + attrs = { + "cols": "80", + "rows": "100" + } + ), + label = 'Rendered Configuration', + initial = self.instance.config_variables, + ) + + self.fields['c_created'] = forms.DateTimeField( + label = 'Created', + input_formats=settings.DATETIME_FORMAT, + disabled = True, + initial = self.instance.created, + ) + + self.fields['c_modified'] = forms.DateTimeField( + label = 'Modified', + input_formats=settings.DATETIME_FORMAT, + disabled = True, + initial = self.instance.modified, + ) + + self.tabs['details'].update({ + "edit_url": reverse('ITIM:_service_change', args=(self.instance.pk,)) + }) diff --git a/app/itim/templates/itim/service.html.j2 b/app/itim/templates/itim/service.html.j2 index 14bbe245..c6b48466 100644 --- a/app/itim/templates/itim/service.html.j2 +++ b/app/itim/templates/itim/service.html.j2 @@ -1,273 +1,75 @@ -{% extends 'base.html.j2' %} +{% extends 'detail.html.j2' %} {% load json %} {% load markdown %} -{% block content %} - +
+

Dependent Services

+ + + + + + {% if item.dependent_service.all %} + {% for service in item.dependent_service.all %} + + + + + {% endfor%} + {% else %} + + + + {% endif %} +
NameOrganization
{{ service }}{{ service.organization }}
Nothing Found
+
- -
- - - - - {% if perms.assistance.change_service %} - - {% endif %}
-
-
-

Details

- {% csrf_token %} +
-
+ {% include 'content/section.html.j2' with tab=form.tabs.rendered_config %} -
- -
- - {{ form.name.value }} -
- -
- - {{ form.config_key_variable.value }} -
- - {% if form.template.value or form.is_template.value %} -
- - - {% if form.is_template.value %} - {{ form.is_template.value }} - {% else %} - {{ item.template }} - {% endif %} - -
- {% endif %} - -
- - - {% if form.organization.value %} - {{ item.organization }} - {% else %} -   - {% endif %} - -
- -
- - {{ item.created }} -
- -
- - - {% if item.cluster %} - {{ item.cluster }} - {% else %} - {% if item.device.id %} - {{ item.device }} - {% endif %} - {% endif %} - -
- -
- - {{ item.modified }} -
- -
- - -
-
- - -
- {% if form.model_notes.value %} - {{ form.model_notes.value | markdown | safe }} - {% else %} -   - {% endif %} -
-
-
- -
- - - -
- -
-

Ports

- - - - - - {% if item.port.all and not item.template %} - {% for port in item.port.all %} - - - - - {% endfor %} - {% elif not item.port.all and item.template %} - {% for port in item.template.port.all %} - - - - - {% endfor%} - {% else %} - - - - {% endif %} -
NameDescription
{{ port }}{{ port.description }}
{{ port }}{{ port.description }}
Nothing Found
-
- - -
-

Dependent Services

- - - - - - {% if item.dependent_service.all %} - {% for service in item.dependent_service.all %} - - - - - {% endfor%} - {% else %} - - - - {% endif %} -
NameOrganization
{{ service }}{{ service.organization }}
Nothing Found
-
- - -
-

Service Config

-
- -
- -
- - - -
- -
-

- Rendered Config -

- -
- -
- -
- - {% if perms.assistance.change_knowledgebase %} -
-

- Notes -

- {{ notes_form }} - -
- {% if notes %} - {% for note in notes %} - {% include 'note.html.j2' %} - {% endfor %} - {% endif %} -
- -
- {% endif %} - - +
{% endblock %} \ No newline at end of file diff --git a/app/itim/views/services.py b/app/itim/views/services.py index 42c97fb4..0068416c 100644 --- a/app/itim/views/services.py +++ b/app/itim/views/services.py @@ -6,7 +6,7 @@ from core.forms.comment import AddNoteForm from core.models.notes import Notes from core.views.common import AddView, ChangeView, DeleteView, IndexView -from itim.forms.services import ServiceForm +from itim.forms.services import ServiceForm, DetailForm from itim.models.services import Service from settings.models.user_settings import UserSettings @@ -136,7 +136,7 @@ class View(ChangeView): context_object_name = "item" - form_class = ServiceForm + form_class = DetailForm model = Service diff --git a/app/templates/detail.html.j2 b/app/templates/detail.html.j2 index 35d54ee2..4b893626 100644 --- a/app/templates/detail.html.j2 +++ b/app/templates/detail.html.j2 @@ -20,7 +20,7 @@ {% else %} - + {% endif %} @@ -30,4 +30,18 @@ {% block tabs %}{% endblock %} +{% if open_tab %} + + + +{% else %} + + + +{% endif %} + {% endblock %} \ No newline at end of file