mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
10520 remove config, status - rebuild js
This commit is contained in:
parent
d885e1599d
commit
48f65fa84a
@ -2044,18 +2044,6 @@ class DeviceBulkRenameView(generic.BulkRenameView):
|
||||
table = tables.DeviceTable
|
||||
|
||||
|
||||
@register_model_view(Device, 'status')
|
||||
class DeviceStatusView(generic.ObjectView):
|
||||
queryset = Device.objects.all()
|
||||
template_name = 'dcim/device/status.html'
|
||||
|
||||
|
||||
@register_model_view(Device, 'config')
|
||||
class DeviceConfigView(generic.ObjectView):
|
||||
queryset = Device.objects.all()
|
||||
template_name = 'dcim/device/config.html'
|
||||
|
||||
|
||||
#
|
||||
# Modules
|
||||
#
|
||||
|
@ -40,8 +40,6 @@ async function bundleGraphIQL() {
|
||||
async function bundleNetBox() {
|
||||
const entryPoints = {
|
||||
netbox: 'src/index.ts',
|
||||
lldp: 'src/device/lldp.ts',
|
||||
config: 'src/device/config.ts',
|
||||
};
|
||||
try {
|
||||
const result = await esbuild.build({
|
||||
|
@ -1,50 +0,0 @@
|
||||
import { createToast } from '../bs';
|
||||
import { apiGetBase, getNetboxData, hasError, toggleLoader } from '../util';
|
||||
|
||||
/**
|
||||
* Initialize device config elements.
|
||||
*/
|
||||
function initConfig(): void {
|
||||
toggleLoader('show');
|
||||
const url = getNetboxData('data-object-url');
|
||||
|
||||
if (url !== null) {
|
||||
apiGetBase<DeviceConfig>(url)
|
||||
.then(data => {
|
||||
if (hasError(data)) {
|
||||
createToast('danger', 'Error Fetching Device Config', data.error).show();
|
||||
console.error(data.error);
|
||||
return;
|
||||
} else if (hasError<Required<DeviceConfig['get_config']>>(data.get_config)) {
|
||||
createToast('danger', 'Error Fetching Device Config', data.get_config.error).show();
|
||||
console.error(data.get_config.error);
|
||||
return;
|
||||
} else {
|
||||
const configTypes = ['running', 'startup', 'candidate'] as DeviceConfigType[];
|
||||
|
||||
for (const configType of configTypes) {
|
||||
const element = document.getElementById(`${configType}_config`);
|
||||
if (element !== null) {
|
||||
const config = data.get_config[configType];
|
||||
if (typeof config === 'string') {
|
||||
// If the returned config is a string, set the element innerHTML as-is.
|
||||
element.innerHTML = config;
|
||||
} else {
|
||||
// If the returned config is an object (dict), convert it to JSON.
|
||||
element.innerHTML = JSON.stringify(data.get_config[configType], null, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
toggleLoader('hide');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
initConfig();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', initConfig);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
{% extends 'dcim/device/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{ object }} - Config{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<script type="text/javascript" src="{% static 'config.js' %}" onerror="window.location='{% url 'media_failure' %}?filename=config.js'"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-overlay">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<h5 class="card-header">Device Configuration</h5>
|
||||
<div class="card-body">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation"><a class="nav-link active" href="#running" aria-controls="running" role="tab" data-bs-toggle="tab">Running</a></li>
|
||||
<li role="presentation"><a class="nav-link" href="#startup" aria-controls="startup" role="tab" data-bs-toggle="tab">Startup</a></li>
|
||||
<li role="presentation"><a class="nav-link" href="#candidate" aria-controls="candidate" role="tab" data-bs-toggle="tab">Candidate</a></li>
|
||||
</ul>
|
||||
<div class="tab-content p-3">
|
||||
<div role="tabpanel" class="tab-pane active" id="running">
|
||||
<pre id="running_config"></pre>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="startup">
|
||||
<pre id="startup_config"></pre>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="candidate">
|
||||
<pre id="candidate_config"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,87 +0,0 @@
|
||||
{% extends 'dcim/device/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{ object }} - Status{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<script type="text/javascript" src="{% static 'status.js' %}" onerror="window.location='{% url 'media_failure' %}?filename=status.js'"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-overlay">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<h5 class="card-header">Device Facts</h5>
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th scope="row">Hostname</th>
|
||||
<td id="hostname"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">FQDN</th>
|
||||
<td id="fqdn"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Vendor</th>
|
||||
<td id="vendor"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Model</th>
|
||||
<td id="model"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Serial Number</th>
|
||||
<td id="serial_number" class="text-monospace"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">OS Version</th>
|
||||
<td id="os_version"></td>
|
||||
</tr>
|
||||
<tr class="align-middle">
|
||||
<th scope="row">Uptime</th>
|
||||
<td>
|
||||
<div id="uptime-duration"></div>
|
||||
<div id="uptime" class="small text-muted"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-overlay">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<h5 class="card-header">Environment</h5>
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<tr id="status-cpu">
|
||||
<th colspan="2"><i class="mdi mdi-gauge"></i> CPU</th>
|
||||
</tr>
|
||||
<tr id="status-memory">
|
||||
<th colspan="2"><i class="mdi mdi-chip"></i> Memory</th>
|
||||
</tr>
|
||||
<tr id="status-temperature">
|
||||
<th colspan="2"><i class="mdi mdi-thermometer"></i> Temperature</th>
|
||||
</tr>
|
||||
<tr id="status-fans">
|
||||
<th colspan="2"><i class="mdi mdi-fan"></i> Fans</th>
|
||||
</tr>
|
||||
<tr id="status-power">
|
||||
<th colspan="2"><i class="mdi mdi-power"></i> Power</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user