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

Initial work on config contexts

This commit is contained in:
Jeremy Stretch
2018-06-27 16:02:34 -04:00
parent ffcbc54522
commit c13e4858d7
26 changed files with 565 additions and 16 deletions

View File

@@ -69,6 +69,9 @@
{% include 'dcim/inc/device_napalm_tabs.html' %}
{% endif %}
{% endif %}
<li role="presentation"{% if active_tab == 'config-context' %} class="active"{% endif %}>
<a href="{% url 'dcim:device_configcontext' pk=device.pk %}">Config Context</a>
</li>
<li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
<a href="{% url 'dcim:device_changelog' pk=device.pk %}">Changelog</a>
</li>

View File

@@ -0,0 +1,18 @@
{% extends 'dcim/device.html' %}
{% block title %}{{ device }} - Config Context{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Config Context</strong>
</div>
<div class="panel-body">
<pre>{{ device.get_config_context }}</pre>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,154 @@
{% extends '_base.html' %}
{% load helpers %}
{% block header %}
<div class="row">
<div class="col-sm-8 col-md-9">
<ol class="breadcrumb">
<li><a href="{% url 'extras:configcontext_list' %}">Config Contexts</a></li>
<li>{{ configcontext }}</li>
</ol>
</div>
<div class="col-sm-4 col-md-3">
<form action="{% url 'extras:configcontext_list' %}" method="get">
<div class="input-group">
<input type="text" name="q" class="form-control" />
<span class="input-group-btn">
<button type="submit" class="btn btn-primary">
<span class="fa fa-search" aria-hidden="true"></span>
</button>
</span>
</div>
</form>
</div>
</div>
<div class="pull-right">
{% if perms.extras.change_configcontext %}
<a href="{% url 'extras:configcontext_edit' pk=configcontext.pk %}" class="btn btn-warning">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
Edit this config context
</a>
{% endif %}
</div>
<h1>{% block title %}{{ configcontext }}{% endblock %}</h1>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Config Context</strong>
</div>
<table class="table table-hover panel-body attr-table">
<tr>
<td>Name</td>
<td>
{{ configcontext.name }}
</td>
</tr>
<tr>
<td>Weight</td>
<td>
{{ configcontext.weight }}
</td>
</tr>
<tr>
<td>Active</td>
<td>
{% if configcontext.is_active %}
<span class="text-success">
<i class="fa fa-check"></i>
</span>
{% else %}
<span class="text-danger">
<i class="fa fa-close"></i>
</span>
{% endif %}
</td>
</tr>
<tr>
<td>Regions</td>
<td>
{% if configcontext.regions.all %}
<ul>
{% for region in configcontext.regions.all %}
<li><a href="{{ region.get_absolute_url }}">{{ region }}</a></li>
{% endfor %}
</ul>
{% else %}
<span class="text-muted">None</span>
{% endif %}
</td>
</tr>
<tr>
<td>Sites</td>
<td>
{% if configcontext.sites.all %}
<ul>
{% for site in configcontext.sites.all %}
<li><a href="{{ site.get_absolute_url }}">{{ site }}</a></li>
{% endfor %}
</ul>
{% else %}
<span class="text-muted">None</span>
{% endif %}
</td>
</tr>
<tr>
<td>Roles</td>
<td>
{% if configcontext.roles.all %}
<ul>
{% for role in configcontext.roles.all %}
<li><a href="{{ role.get_absolute_url }}">{{ role }}</a></li>
{% endfor %}
</ul>
{% else %}
<span class="text-muted">None</span>
{% endif %}
</td>
</tr>
<tr>
<td>Platforms</td>
<td>
{% if configcontext.platforms.all %}
<ul>
{% for platform in configcontext.platforms.all %}
<li><a href="{{ platform.get_absolute_url }}">{{ platform }}</a></li>
{% endfor %}
</ul>
{% else %}
<span class="text-muted">None</span>
{% endif %}
</td>
</tr>
<tr>
<td>Tenants</td>
<td>
{% if configcontext.tenants.all %}
<ul>
{% for tenant in configcontext.tenants.all %}
<li><a href="{{ tenant.get_absolute_url }}">{{ tenant }}</a></li>
{% endfor %}
</ul>
{% else %}
<span class="text-muted">None</span>
{% endif %}
</td>
</tr>
</table>
</div>
</div>
<div class="col-md-7">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Data</strong>
</div>
<div class="panel-body">
<pre>{{ configcontext.data }}</pre>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,24 @@
{% extends 'utilities/obj_edit.html' %}
{% load form_helpers %}
{% block form %}
<div class="panel panel-default">
<div class="panel-heading"><strong>Config Context</strong></div>
<div class="panel-body">
{% render_field form.name %}
{% render_field form.weight %}
{% render_field form.is_active %}
{% render_field form.regions %}
{% render_field form.sites %}
{% render_field form.roles %}
{% render_field form.platforms %}
{% render_field form.tenants %}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Data</strong></div>
<div class="panel-body">
{% render_field form.data %}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,16 @@
{% extends '_base.html' %}
{% load buttons %}
{% block content %}
<div class="pull-right">
{% if perms.extras.add_configcontext %}
{% add_button 'extras:configcontext_add' %}
{% endif %}
</div>
<h1>{% block title %}Config Contexts{% endblock %}</h1>
<div class="row">
<div class="col-md-12">
{% include 'utilities/obj_table.html' with bulk_delete_url='extras:configcontext_bulk_delete' %}
</div>
</div>
{% endblock %}

View File

@@ -63,6 +63,9 @@
<li>
<a href="{% url 'extras:tag_list' %}">Tags</a>
</li>
<li>
<a href="{% url 'extras:configcontext_list' %}">Config Contexts</a>
</li>
<li>
<a href="{% url 'extras:report_list' %}">Reports</a>
</li>

View File

@@ -44,6 +44,9 @@
<li role="presentation"{% if not active_tab %} class="active"{% endif %}>
<a href="{{ virtualmachine.get_absolute_url }}">Virtual Machine</a>
</li>
<li role="presentation"{% if active_tab == 'config-context' %} class="active"{% endif %}>
<a href="{% url 'virtualization:virtualmachine_configcontext' pk=virtualmachine.pk %}">Config Context</a>
</li>
<li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
<a href="{% url 'virtualization:virtualmachine_changelog' pk=virtualmachine.pk %}">Changelog</a>
</li>

View File

@@ -0,0 +1,18 @@
{% extends 'virtualization/virtualmachine.html' %}
{% block title %}{{ virtualmachine }} - Config Context{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Config Context</strong>
</div>
<div class="panel-body">
<pre>{{ virtualmachine.get_config_context }}</pre>
</div>
</div>
</div>
</div>
{% endblock %}