1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

92 lines
3.3 KiB
HTML
Raw Normal View History

{% extends 'generic/object.html' %}
2019-08-09 12:33:33 -04:00
{% load helpers %}
{% load form_helpers %}
{% load log_levels %}
{% block title %}{{ script }}{% endblock %}
{% block object_identifier %}
{{ script.full_name }}
2022-01-05 09:09:39 -05:00
{% endblock object_identifier %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'extras:script_list' %}">Scripts</a></li>
<li class="breadcrumb-item"><a href="{% url 'extras:script_list' %}#module{{ module.pk }}">{{ module|bettertitle }}</a></li>
2022-01-05 09:09:39 -05:00
{% endblock breadcrumbs %}
2021-04-16 14:58:44 -07:00
2021-08-13 09:43:23 -04:00
{% block subtitle %}
<div class="object-subtitle">
<div class="text-muted">{{ script.Meta.description|markdown }}</div>
2021-08-13 09:43:23 -04:00
</div>
2022-01-05 09:09:39 -05:00
{% endblock subtitle %}
2021-08-13 09:43:23 -04:00
{% block controls %}{% endblock %}
2021-08-13 09:43:23 -04:00
{% block tabs %}
2022-01-05 09:09:39 -05:00
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
<a href="#run" role="tab" data-bs-toggle="tab" class="nav-link active">Run</a>
</li>
<li class="nav-item" role="presentation">
<a href="#source" role="tab" data-bs-toggle="tab" class="nav-link">Source</a>
</li>
</ul>
{% endblock tabs %}
2021-08-13 09:43:23 -04:00
2022-01-05 09:09:39 -05:00
{% block content %}
<div role="tabpanel" class="tab-pane active" id="run">
<div class="row">
<div class="col">
{% if not perms.extras.run_script %}
<div class="alert alert-warning">
<i class="mdi mdi-alert"></i>
You do not have permission to run scripts.
</div>
{% endif %}
2022-09-18 15:06:28 +02:00
<form action="" method="post" enctype="multipart/form-data" class="form form-object-edit">
2022-01-05 09:09:39 -05:00
{% csrf_token %}
<div class="field-group my-4">
{% if form.requires_input %}
{% if script.Meta.fieldsets %}
{# Render grouped fields according to declared fieldsets #}
{% for group, fields in script.Meta.fieldsets %}
<div class="field-group mb-5">
<div class="row mb-2">
<h5 class="offset-sm-3">{{ group }}</h5>
</div>
{% for name in fields %}
{% with field=form|getfield:name %}
{% render_field field %}
{% endwith %}
{% endfor %}
</div>
{% endfor %}
{% else %}
{# Render all fields as a single group #}
<div class="row mb-2">
<h5 class="offset-sm-3">Script Data</h5>
</div>
{% render_form form %}
{% endif %}
2022-01-05 09:09:39 -05:00
{% else %}
<div class="alert alert-info">
<i class="mdi mdi-information"></i>
This script does not require any input to run.
</div>
{% render_form form %}
2022-01-05 09:09:39 -05:00
{% endif %}
</div>
<div class="float-end">
<a href="{% url 'extras:script_list' %}" class="btn btn-outline-danger">Cancel</a>
<button type="submit" name="_run" class="btn btn-primary"{% if not perms.extras.run_script %} disabled="disabled"{% endif %}><i class="mdi mdi-play"></i> Run Script</button>
</div>
</form>
2021-08-13 09:43:23 -04:00
</div>
2019-08-09 12:33:33 -04:00
</div>
2021-08-13 09:43:23 -04:00
</div>
2022-01-05 09:09:39 -05:00
<div role="tabpanel" class="tab-pane" id="source">
<code class="h6 my-3 d-block">{{ script.filename }}</code>
<pre class="block">{{ script.source }}</pre>
</div>
{% endblock content %}