mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
remove old files
This commit is contained in:
parent
fe4a9bff2d
commit
ce98957be0
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
@ -1,24 +0,0 @@
|
||||
$('#cabletrace_modal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var obj = button.data('obj');
|
||||
var url = button.data('url');
|
||||
var modal_title = $(this).find('.modal-title');
|
||||
var modal_body = $(this).find('.modal-body');
|
||||
modal_title.text(obj);
|
||||
modal_body.empty();
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
$.each(json, function(i, segment) {
|
||||
modal_body.append(
|
||||
'<div class="row">' +
|
||||
'<div class="col-md-4 text-center">' + segment[0].device.name + '<br />' + segment[0].name + '</div>' +
|
||||
'<div class="col-md-4 text-center">Cable #' + segment[1].id + '</div>' +
|
||||
'<div class="col-md-4 text-center">' + segment[2].device.name + '<br />' + segment[2].name + '</div>' +
|
||||
'</div><hr />'
|
||||
);
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
@ -1,46 +0,0 @@
|
||||
function toggleConnection(elem) {
|
||||
var url = netbox_api_path + "dcim/cables/" + elem.attr('data') + "/";
|
||||
if (elem.hasClass('connected')) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
beforeSend: function(xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", netbox_csrf_token);
|
||||
},
|
||||
data: {
|
||||
'status': 'planned'
|
||||
},
|
||||
context: this,
|
||||
success: function() {
|
||||
elem.parents('tr').removeClass('success').addClass('info');
|
||||
elem.removeClass('connected btn-warning').addClass('btn-success');
|
||||
elem.attr('title', 'Mark installed');
|
||||
elem.children('i').removeClass('mdi mdi-lan-disconnect').addClass('mdi mdi-lan-connect')
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
beforeSend: function(xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", netbox_csrf_token);
|
||||
},
|
||||
data: {
|
||||
'status': 'connected'
|
||||
},
|
||||
context: this,
|
||||
success: function() {
|
||||
elem.parents('tr').removeClass('info').addClass('success');
|
||||
elem.removeClass('btn-success').addClass('connected btn-warning');
|
||||
elem.attr('title', 'Mark planned');
|
||||
elem.children('i').removeClass('mdi mdi-lan-connect').addClass('mdi mdi-lan-disconnect')
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$(".cable-toggle").click(function() {
|
||||
return toggleConnection($(this));
|
||||
});
|
@ -1,445 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// Pagination
|
||||
$('select#per_page').change(function() {
|
||||
this.form.submit();
|
||||
});
|
||||
|
||||
// "Toggle" checkbox for object lists (PK column)
|
||||
$('input:checkbox.toggle').click(function() {
|
||||
$(this).closest('table').find('input:checkbox[name=pk]:visible').prop('checked', $(this).prop('checked'));
|
||||
|
||||
// Show the "select all" box if present
|
||||
if ($(this).is(':checked')) {
|
||||
$('#select_all_box').removeClass('hidden');
|
||||
} else {
|
||||
$('#select_all').prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
// Uncheck the "toggle" and "select all" checkboxes if an item is unchecked
|
||||
$('input:checkbox[name=pk]').click(function (event) {
|
||||
if (!$(this).attr('checked')) {
|
||||
$('input:checkbox.toggle, #select_all').prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
// Enable hidden buttons when "select all" is checked
|
||||
$('#select_all').click(function() {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#select_all_box').find('button').prop('disabled', '');
|
||||
} else {
|
||||
$('#select_all_box').find('button').prop('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
|
||||
// Slugify
|
||||
function slugify(s, num_chars) {
|
||||
s = s.replace(/[^\-\.\w\s]/g, ''); // Remove unneeded chars
|
||||
s = s.replace(/^[\s\.]+|[\s\.]+$/g, ''); // Trim leading/trailing spaces
|
||||
s = s.replace(/[\-\.\s]+/g, '-'); // Convert spaces and decimals to hyphens
|
||||
s = s.toLowerCase(); // Convert to lowercase
|
||||
return s.substring(0, num_chars); // Trim to first num_chars chars
|
||||
}
|
||||
var slug_field = $('#id_slug');
|
||||
if (slug_field) {
|
||||
var slug_source = $('#id_' + slug_field.attr('slug-source'));
|
||||
var slug_length = slug_field.attr('maxlength');
|
||||
if (slug_field.val()) {
|
||||
slug_field.attr('_changed', true);
|
||||
}
|
||||
slug_field.change(function() {
|
||||
$(this).attr('_changed', true);
|
||||
});
|
||||
slug_source.on('keyup change', function() {
|
||||
if (slug_field && !slug_field.attr('_changed')) {
|
||||
slug_field.val(slugify($(this).val(), (slug_length ? slug_length : 50)));
|
||||
}
|
||||
});
|
||||
$('button.reslugify').click(function() {
|
||||
slug_field.val(slugify(slug_source.val(), (slug_length ? slug_length : 50)));
|
||||
});
|
||||
}
|
||||
|
||||
// Bulk edit nullification
|
||||
$('input:checkbox[name=_nullify]').click(function() {
|
||||
$('#id_' + this.value).toggle('disabled');
|
||||
});
|
||||
|
||||
// Set formaction and submit using a link
|
||||
$('a.formaction').click(function(event) {
|
||||
event.preventDefault();
|
||||
var form = $(this).closest('form');
|
||||
form.attr('action', $(this).attr('href'));
|
||||
form.submit();
|
||||
});
|
||||
|
||||
// Parse URLs which may contain variable references to other field values
|
||||
function parseURL(url) {
|
||||
var filter_regex = /\{\{([a-z_]+)\}\}/g;
|
||||
var match;
|
||||
var rendered_url = url;
|
||||
var filter_field;
|
||||
while (match = filter_regex.exec(url)) {
|
||||
filter_field = $('#id_' + match[1]);
|
||||
var custom_attr = $('option:selected', filter_field).attr('api-value');
|
||||
if (custom_attr) {
|
||||
rendered_url = rendered_url.replace(match[0], custom_attr);
|
||||
} else if (filter_field.val()) {
|
||||
rendered_url = rendered_url.replace(match[0], filter_field.val());
|
||||
} else if (filter_field.attr('data-null-option')) {
|
||||
rendered_url = rendered_url.replace(match[0], 'null');
|
||||
}
|
||||
}
|
||||
return rendered_url
|
||||
}
|
||||
|
||||
// Assign color picker selection classes
|
||||
function colorPickerClassCopy(data, container) {
|
||||
if (data.element) {
|
||||
// Swap the style
|
||||
$(container).attr('style', $(data.element).attr("style"));
|
||||
}
|
||||
return data.text;
|
||||
}
|
||||
|
||||
// Speed selector
|
||||
$("a.set_speed").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#id_" + $(this).attr("target")).val($(this).attr("data"));
|
||||
});
|
||||
|
||||
// Color Picker
|
||||
$('.netbox-select2-color-picker').select2({
|
||||
allowClear: true,
|
||||
placeholder: "---------",
|
||||
theme: "bootstrap",
|
||||
templateResult: colorPickerClassCopy,
|
||||
templateSelection: colorPickerClassCopy,
|
||||
width: "off"
|
||||
});
|
||||
|
||||
// Static choice selection
|
||||
$('.netbox-select2-static').select2({
|
||||
allowClear: true,
|
||||
placeholder: "---------",
|
||||
theme: "bootstrap",
|
||||
width: "off"
|
||||
});
|
||||
|
||||
// API backed selection
|
||||
// Includes live search and chained fields
|
||||
// The `multiple` setting may be controlled via a data-* attribute
|
||||
$('.netbox-select2-api').select2({
|
||||
allowClear: true,
|
||||
placeholder: "---------",
|
||||
theme: "bootstrap",
|
||||
width: "off",
|
||||
ajax: {
|
||||
delay: 500,
|
||||
|
||||
url: function(params) {
|
||||
var element = this[0];
|
||||
var url = parseURL(element.getAttribute("data-url"));
|
||||
|
||||
if (url.includes("{{")) {
|
||||
// URL is not fully rendered yet, abort the request
|
||||
return false;
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
data: function(params) {
|
||||
var element = this[0];
|
||||
// Paging. Note that `params.page` indexes at 1
|
||||
var offset = (params.page - 1) * 50 || 0;
|
||||
// Base query params
|
||||
var parameters = {
|
||||
q: params.term,
|
||||
limit: 50,
|
||||
offset: offset,
|
||||
brief: true,
|
||||
};
|
||||
|
||||
// Attach any extra query parameters
|
||||
$.each(element.attributes, function(index, attr){
|
||||
if (attr.name.includes("data-query-param-")){
|
||||
var param_name = attr.name.split("data-query-param-")[1];
|
||||
|
||||
$.each($.parseJSON(attr.value), function(index, value) {
|
||||
// Referencing the value of another form field
|
||||
if (value.startsWith('$')) {
|
||||
let ref_field = $('#id_' + value.slice(1));
|
||||
if (ref_field.val() && ref_field.is(":visible")) {
|
||||
value = ref_field.val();
|
||||
} else if (ref_field.attr("required") && ref_field.attr("data-null-option")) {
|
||||
value = "null";
|
||||
} else {
|
||||
return true; // Skip if ref_field has no value
|
||||
}
|
||||
}
|
||||
if (param_name in parameters) {
|
||||
if (Array.isArray(parameters[param_name])) {
|
||||
parameters[param_name].push(value);
|
||||
} else {
|
||||
parameters[param_name] = [parameters[param_name], value];
|
||||
}
|
||||
} else {
|
||||
parameters[param_name] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// This will handle params with multiple values (i.e. for list filter forms)
|
||||
return $.param(parameters, true);
|
||||
},
|
||||
|
||||
processResults: function (data) {
|
||||
var element = this.$element[0];
|
||||
$(element).children('option').attr('disabled', false);
|
||||
var results = data.results;
|
||||
|
||||
results = results.reduce((results,record,idx) => {
|
||||
record.text = record[element.getAttribute('display-field')] || record.name;
|
||||
if (record._depth) {
|
||||
// Annotate hierarchical depth for MPTT objects
|
||||
record.text = '--'.repeat(record._depth) + ' ' + record.text;
|
||||
}
|
||||
record.id = record[element.getAttribute('value-field')] || record.id;
|
||||
if(element.getAttribute('disabled-indicator') && record[element.getAttribute('disabled-indicator')]) {
|
||||
// The disabled-indicator equated to true, so we disable this option
|
||||
record.disabled = true;
|
||||
}
|
||||
results[idx] = record;
|
||||
|
||||
return results;
|
||||
},Object.create(null));
|
||||
|
||||
results = Object.values(results);
|
||||
|
||||
// Handle the null option, but only add it once
|
||||
if (element.getAttribute('data-null-option') && data.previous === null) {
|
||||
results.unshift({
|
||||
id: 'null',
|
||||
text: element.getAttribute('data-null-option')
|
||||
});
|
||||
}
|
||||
|
||||
// Check if there are more results to page
|
||||
var page = data.next !== null;
|
||||
return {
|
||||
results: results,
|
||||
pagination: {
|
||||
more: page
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Flatpickr selectors
|
||||
$('.date-picker').flatpickr({
|
||||
allowInput: true
|
||||
});
|
||||
$('.datetime-picker').flatpickr({
|
||||
allowInput: true,
|
||||
enableSeconds: true,
|
||||
enableTime: true,
|
||||
time_24hr: true
|
||||
});
|
||||
$('.time-picker').flatpickr({
|
||||
allowInput: true,
|
||||
enableSeconds: true,
|
||||
enableTime: true,
|
||||
noCalendar: true,
|
||||
time_24hr: true
|
||||
});
|
||||
|
||||
// API backed tags
|
||||
var tags = $('#id_tags.tagfield');
|
||||
if (tags.length > 0 && tags.val().length > 0){
|
||||
tags = $('#id_tags.tagfield').val().split(/,\s*/);
|
||||
} else {
|
||||
tags = [];
|
||||
}
|
||||
tag_objs = $.map(tags, function (tag) {
|
||||
return {
|
||||
id: tag,
|
||||
text: tag,
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
// Replace the django issued text input with a select element
|
||||
$('#id_tags.tagfield').replaceWith('<select name="tags" id="id_tags" class="form-control tagfield"></select>');
|
||||
$('#id_tags.tagfield').select2({
|
||||
tags: true,
|
||||
data: tag_objs,
|
||||
multiple: true,
|
||||
allowClear: true,
|
||||
placeholder: "Tags",
|
||||
theme: "bootstrap",
|
||||
width: "off",
|
||||
ajax: {
|
||||
delay: 250,
|
||||
url: netbox_api_path + "extras/tags/",
|
||||
|
||||
data: function(params) {
|
||||
// Paging. Note that `params.page` indexes at 1
|
||||
var offset = (params.page - 1) * 50 || 0;
|
||||
var parameters = {
|
||||
q: params.term,
|
||||
brief: 1,
|
||||
limit: 50,
|
||||
offset: offset,
|
||||
};
|
||||
return parameters;
|
||||
},
|
||||
|
||||
processResults: function (data) {
|
||||
var results = $.map(data.results, function (obj) {
|
||||
// If tag contains space add double quotes
|
||||
if (/\s/.test(obj.name))
|
||||
obj.name = '"' + obj.name + '"'
|
||||
|
||||
return {
|
||||
id: obj.name,
|
||||
text: obj.name
|
||||
}
|
||||
});
|
||||
|
||||
// Check if there are more results to page
|
||||
var page = data.next !== null;
|
||||
return {
|
||||
results: results,
|
||||
pagination: {
|
||||
more: page
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#id_tags.tagfield').closest('form').submit(function(event){
|
||||
// django-taggit can only accept a single comma seperated string value
|
||||
var value = $('#id_tags.tagfield').val();
|
||||
if (value.length > 0){
|
||||
var final_tags = value.join(', ');
|
||||
$('#id_tags.tagfield').val(null).trigger('change');
|
||||
var option = new Option(final_tags, final_tags, true, true);
|
||||
$('#id_tags.tagfield').append(option).trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
if( $('select#id_mode').length > 0 ) {
|
||||
$('select#id_mode').on('change', function () {
|
||||
if ($(this).val() == '') {
|
||||
$('select#id_untagged_vlan').val();
|
||||
$('select#id_untagged_vlan').trigger('change');
|
||||
$('select#id_tagged_vlans').val([]);
|
||||
$('select#id_tagged_vlans').trigger('change');
|
||||
$('select#id_untagged_vlan').parent().parent().hide();
|
||||
$('select#id_tagged_vlans').parent().parent().hide();
|
||||
}
|
||||
else if ($(this).val() == 'access') {
|
||||
$('select#id_tagged_vlans').val([]);
|
||||
$('select#id_tagged_vlans').trigger('change');
|
||||
$('select#id_untagged_vlan').parent().parent().show();
|
||||
$('select#id_tagged_vlans').parent().parent().hide();
|
||||
}
|
||||
else if ($(this).val() == 'tagged') {
|
||||
$('select#id_untagged_vlan').parent().parent().show();
|
||||
$('select#id_tagged_vlans').parent().parent().show();
|
||||
}
|
||||
else if ($(this).val() == 'tagged-all') {
|
||||
$('select#id_tagged_vlans').val([]);
|
||||
$('select#id_tagged_vlans').trigger('change');
|
||||
$('select#id_untagged_vlan').parent().parent().show();
|
||||
$('select#id_tagged_vlans').parent().parent().hide();
|
||||
}
|
||||
});
|
||||
$('select#id_mode').trigger('change');
|
||||
}
|
||||
|
||||
// Scroll up an offset equal to the first nav element if a hash is present
|
||||
// Cannot use '#navbar' because it is not always visible, like in small windows
|
||||
function headerOffsetScroll() {
|
||||
if (window.location.hash) {
|
||||
// Short wait needed to allow the page to scroll to the element
|
||||
setTimeout(function() {
|
||||
window.scrollBy(0, -$('nav').height())
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
// Account for the header height when hash-scrolling
|
||||
window.addEventListener('load', headerOffsetScroll);
|
||||
window.addEventListener('hashchange', headerOffsetScroll);
|
||||
|
||||
// Offset between the preview window and the window edges
|
||||
const IMAGE_PREVIEW_OFFSET_X = 20;
|
||||
const IMAGE_PREVIEW_OFFSET_Y = 10;
|
||||
|
||||
// Preview an image attachment when the link is hovered over
|
||||
$('a.image-preview').on('mouseover', function(e) {
|
||||
// Twice the offset to account for all sides of the picture
|
||||
var maxWidth = window.innerWidth - (e.clientX + (IMAGE_PREVIEW_OFFSET_X * 2));
|
||||
var maxHeight = window.innerHeight - (e.clientY + (IMAGE_PREVIEW_OFFSET_Y * 2));
|
||||
var img = $('<img>').attr('id', 'image-preview-window').css({
|
||||
display: 'none',
|
||||
position: 'absolute',
|
||||
maxWidth: maxWidth + 'px',
|
||||
maxHeight: maxHeight + 'px',
|
||||
left: e.pageX + IMAGE_PREVIEW_OFFSET_X + 'px',
|
||||
top: e.pageY + IMAGE_PREVIEW_OFFSET_Y + 'px',
|
||||
boxShadow: '0 0px 12px 3px rgba(0, 0, 0, 0.4)',
|
||||
});
|
||||
|
||||
// Remove any existing preview windows and add the current one
|
||||
$('#image-preview-window').remove();
|
||||
$('body').append(img);
|
||||
|
||||
// Once loaded, show the preview if the image is indeed an image
|
||||
img.on('load', function(e) {
|
||||
if (e.target.complete && e.target.naturalWidth) {
|
||||
$('#image-preview-window').fadeIn('fast');
|
||||
}
|
||||
});
|
||||
|
||||
// Begin loading
|
||||
img.attr('src', e.target.href);
|
||||
});
|
||||
|
||||
// Fade the image out; it will be deleted when another one is previewed
|
||||
$('a.image-preview').on('mouseout', function() {
|
||||
$('#image-preview-window').fadeOut('fast');
|
||||
});
|
||||
|
||||
// Rearrange options within a <select> list
|
||||
$('#move-option-up').bind('click', function() {
|
||||
var select_id = '#' + $(this).attr('data-target');
|
||||
$(select_id + ' option:selected').each(function () {
|
||||
var newPos = $(select_id + ' option').index(this) - 1;
|
||||
if (newPos > -1) {
|
||||
$(select_id + ' option').eq(newPos).before("<option value='" + $(this).val() + "' selected='selected'>" + $(this).text() + "</option>");
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#move-option-down').bind('click', function() {
|
||||
var select_id = '#' + $(this).attr('data-target');
|
||||
var countOptions = $(select_id + ' option').length;
|
||||
var countSelectedOptions = $(select_id + ' option:selected').length;
|
||||
$(select_id + ' option:selected').each(function () {
|
||||
var newPos = $(select_id + ' option').index(this) + countSelectedOptions;
|
||||
if (newPos < countOptions) {
|
||||
$(select_id + ' option').eq(newPos).after("<option value='" + $(this).val() + "' selected='selected'>" + $(this).text() + "</option>");
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#select-all-options').bind('click', function() {
|
||||
var select_id = '#' + $(this).attr('data-target');
|
||||
$(select_id + ' option').prop('selected',true);
|
||||
});
|
||||
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
// Inteface filtering
|
||||
$('input.interface-filter').on('input', function() {
|
||||
let filter = new RegExp(this.value);
|
||||
let interface;
|
||||
|
||||
for (interface of $('table > tbody > tr')) {
|
||||
if (filter.test(interface.getAttribute('data-name'))) {
|
||||
// Match the toggle in case the filter now matches the interface
|
||||
$(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
|
||||
$(interface).show();
|
||||
} else {
|
||||
// Uncheck to prevent actions from including it when it doesn't match
|
||||
$(interface).find('input:checkbox[name=pk]').prop('checked', false);
|
||||
$(interface).hide();
|
||||
}
|
||||
}
|
||||
});
|
@ -1,47 +0,0 @@
|
||||
var url = netbox_api_path + "extras/job-results/";
|
||||
var timeout = 1000;
|
||||
|
||||
function updatePendingStatusLabel(status){
|
||||
var labelClass;
|
||||
if (status.value === 'failed' || status.value === 'errored'){
|
||||
labelClass = 'danger';
|
||||
} else if (status.value === 'running'){
|
||||
labelClass = 'warning';
|
||||
} else if (status.value === 'completed'){
|
||||
labelClass = 'success';
|
||||
} else {
|
||||
labelClass = 'default';
|
||||
}
|
||||
var elem = $('#pending-result-label > label');
|
||||
elem.attr('class', 'label label-' + labelClass);
|
||||
elem.text(status.label);
|
||||
}
|
||||
|
||||
function refreshWindow(){
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
if (pending_result_id !== null){
|
||||
(function checkPendingResult(){
|
||||
$.ajax({
|
||||
url: url + pending_result_id + '/',
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
context: this,
|
||||
success: function(data) {
|
||||
updatePendingStatusLabel(data.status);
|
||||
if (data.status.value === 'completed' || data.status.value === 'failed' || data.status.value === 'errored'){
|
||||
jobTerminatedAction()
|
||||
} else {
|
||||
setTimeout(checkPendingResult, timeout);
|
||||
if (timeout < 10000) {
|
||||
// back off each iteration, until we reach a 10s interval
|
||||
timeout += 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
}
|
||||
})
|
@ -1,133 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
// Instantiate ClipboardJS on all copy buttons
|
||||
new ClipboardJS('button.copy-secret');
|
||||
|
||||
// Unlocking a secret
|
||||
$('button.unlock-secret').click(function(event) {
|
||||
var secret_id = $(this).attr('secret-id');
|
||||
unlock_secret(secret_id);
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Locking a secret
|
||||
$('button.lock-secret').click(function(event) {
|
||||
var secret_id = $(this).attr('secret-id');
|
||||
lock_secret(secret_id);
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Adding/editing a secret
|
||||
$('form').submit(function(event) {
|
||||
$(this).find('.requires-session-key').each(function() {
|
||||
if (this.value && document.cookie.indexOf('session_key') == -1) {
|
||||
console.log('Field ' + this.name + ' requires a session key');
|
||||
$('#privkey_modal').modal('show');
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Retrieve a session key
|
||||
$('#request_session_key').click(function() {
|
||||
var private_key_field = $('#user_privkey');
|
||||
var private_key = private_key_field.val();
|
||||
get_session_key(private_key);
|
||||
private_key_field.val("");
|
||||
});
|
||||
|
||||
// Retrieve a secret via the API
|
||||
function unlock_secret(secret_id) {
|
||||
$.ajax({
|
||||
url: netbox_api_path + 'secrets/secrets/' + secret_id + '/',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (response, status) {
|
||||
if (response.plaintext) {
|
||||
console.log("Secret retrieved successfully");
|
||||
$('#secret_' + secret_id).text(response.plaintext);
|
||||
$('button.unlock-secret[secret-id=' + secret_id + ']').hide();
|
||||
$('button.copy-secret[secret-id=' + secret_id + ']').show();
|
||||
$('button.lock-secret[secret-id=' + secret_id + ']').show();
|
||||
} else {
|
||||
console.log("Secret was not decrypted. Prompt user for private key.");
|
||||
$('#privkey_modal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log("Error: " + xhr.responseText);
|
||||
if (xhr.status == 403) {
|
||||
alert("Permission denied");
|
||||
} else {
|
||||
alert(xhr.responseText);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Remove secret data from the DOM
|
||||
function lock_secret(secret_id) {
|
||||
var secret_div = $('#secret_' + secret_id);
|
||||
secret_div.html('********');
|
||||
$('button.lock-secret[secret-id=' + secret_id + ']').hide();
|
||||
$('button.copy-secret[secret-id=' + secret_id + ']').hide();
|
||||
$('button.unlock-secret[secret-id=' + secret_id + ']').show();
|
||||
}
|
||||
|
||||
// Request a session key via the API
|
||||
function get_session_key(private_key) {
|
||||
var csrf_token = $('input[name=csrfmiddlewaretoken]').val();
|
||||
$.ajax({
|
||||
url: netbox_api_path + 'secrets/get-session-key/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
private_key: private_key
|
||||
},
|
||||
dataType: 'json',
|
||||
beforeSend: function(xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrf_token);
|
||||
},
|
||||
success: function (response, status) {
|
||||
console.log("Received a new session key");
|
||||
alert('Session key received! You may now unlock secrets.');
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
if (xhr.status == 403) {
|
||||
alert("Permission denied");
|
||||
} else {
|
||||
var json = jQuery.parseJSON(xhr.responseText);
|
||||
alert("Failed to retrieve a session key: " + json['error']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Generate a new public/private key pair via the API
|
||||
$('#generate_keypair').click(function() {
|
||||
$('#new_keypair_modal').modal('show');
|
||||
$.ajax({
|
||||
url: netbox_api_path + 'secrets/generate-rsa-key-pair/',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (response, status) {
|
||||
var public_key = response.public_key;
|
||||
var private_key = response.private_key;
|
||||
$('#new_pubkey').val(public_key);
|
||||
$('#new_privkey').val(private_key);
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
alert("There was an error generating a new key pair.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Accept a new RSA key pair generated via the API
|
||||
$('#use_new_pubkey').click(function() {
|
||||
var new_pubkey = $('#new_pubkey');
|
||||
|
||||
if (new_pubkey.val()) {
|
||||
$('#id_public_key').val(new_pubkey.val());
|
||||
}
|
||||
});
|
||||
|
||||
});
|
@ -1,65 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// Select or reset table columns
|
||||
$('#save_tableconfig').click(function(event) {
|
||||
$('select[name="columns"] option').attr("selected", "selected");
|
||||
});
|
||||
$('#reset_tableconfig').click(function(event) {
|
||||
$('select[name="columns"]').val([]);
|
||||
});
|
||||
|
||||
// Swap columns between available and selected lists
|
||||
$('#add_columns').click(function(e) {
|
||||
let selected_columns = $('#id_available_columns option:selected');
|
||||
$('#id_columns').append($(selected_columns).clone());
|
||||
$(selected_columns).remove();
|
||||
e.preventDefault();
|
||||
});
|
||||
$('#remove_columns').click(function(e) {
|
||||
let selected_columns = $('#id_columns option:selected');
|
||||
$('#id_available_columns').append($(selected_columns).clone());
|
||||
$(selected_columns).remove();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('form.userconfigform').submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Derive an array from the dotted path to the config root
|
||||
let path = this.getAttribute('data-config-root').split('.');
|
||||
let data = {};
|
||||
let pointer = data;
|
||||
|
||||
// Construct a nested JSON object from the path
|
||||
let node;
|
||||
for (node of path) {
|
||||
pointer[node] = {};
|
||||
pointer = pointer[node];
|
||||
}
|
||||
|
||||
// Assign the form data to the child node
|
||||
let field;
|
||||
$.each($(this).find('[id^="id_"]:input'), function(index, value) {
|
||||
field = $(value);
|
||||
pointer[field.attr("name")] = field.val();
|
||||
});
|
||||
|
||||
// Make the REST API request
|
||||
$.ajax({
|
||||
url: netbox_api_path + 'users/config/',
|
||||
async: true,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
type: 'PATCH',
|
||||
beforeSend: function(xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", netbox_csrf_token);
|
||||
},
|
||||
data: JSON.stringify(data),
|
||||
}).done(function () {
|
||||
// Reload the page
|
||||
window.location.reload(true);
|
||||
}).fail(function (xhr, status, error) {
|
||||
alert("Failed to update user config (" + status + "): " + error);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,30 +0,0 @@
|
||||
<div class="container mb-2 mx-0">
|
||||
<div class="d-flex flex-wrap justify-content-end">
|
||||
<div class="d-flex flex-shrink-1 me-2">
|
||||
<button type="button" class="btn btn-sm btn-success">
|
||||
<i class="bi bi-plus-circle"></i>
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
<div class="d-flex flex-shrink-1">
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group me-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-upload"></i> Import
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-download"></i> Export
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-shrink-1">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-outline-secondary dropdown-toggle"
|
||||
>
|
||||
<i class="bi bi-sliders"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,4 +0,0 @@
|
||||
{% load static %}
|
||||
<div class="loading text-center">
|
||||
<img src="{% static 'img/ajax-loader.gif' %}" />
|
||||
</div>
|
@ -1,639 +0,0 @@
|
||||
{% load static %}
|
||||
{% load helpers %}
|
||||
<nav class="navbar navbar-default navbar-fixed-top navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="{% url 'home' %}">
|
||||
<img src="{% static 'img/netbox_logo.svg' %}" height="30" />
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
{% if request.user.is_authenticated or not settings.LOGIN_REQUIRED %}
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="organization" role="button" data-bs-toggle="dropdown" aria-expanded="false">Organization</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="organization">
|
||||
<li class="dropdown-header">Sites</li>
|
||||
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_site %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:site_list' %}">
|
||||
Sites
|
||||
</a>
|
||||
{% if perms.dcim.add_site %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<a href="{% url 'dcim:site_add' %}" class="btn btn-sm btn-success" title="Add" role="button">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:site_import' %}" class="btn btn-sm btn-info" title="Import" role="button">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_region %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:region_list' %}">Regions</a>
|
||||
{% if perms.dcim.add_region %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'dcim:region_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:region_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="dropdown-item{% if not perms.dcim.view_sitegroup %} disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:sitegroup_list' %}">Site Groups</a>
|
||||
{% if perms.dcim.add_sitegroup %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'dcim:sitegroup_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi bi-plus"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:sitegroup_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li class="dropdown-header">Racks</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_rack %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:rack_list' %}">Racks</a>
|
||||
{% if perms.dcim.add_rack %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'dcim:rack_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:rack_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_location %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:location_list' %}">Locations</a>
|
||||
{% if perms.dcim.add_location %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'dcim:location_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:location_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_rackrole %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:rackrole_list' %}">Rack Roles</a>
|
||||
{% if perms.dcim.add_rackrole %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'dcim:rackrole_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:rackrole_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_rackreservation %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:rackreservation_list' %}">Reservations</a>
|
||||
{% if perms.dcim.add_rackreservation %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'dcim:rackreservation_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'dcim:rackreservation_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.dcim.view_rack %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'dcim:rack_elevation_list' %}">Elevations</a>
|
||||
</li>
|
||||
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
||||
<li class="dropdown-header">Tenancy</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.tenancy.view_tenant %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'tenancy:tenant_list' %}">Tenants</a>
|
||||
{% if perms.tenancy.add_tenant %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'tenancy:tenant_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'tenancy:tenant_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.tenancy.view_tenantgroup %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'tenancy:tenantgroup_list' %}">Tenant Groups</a>
|
||||
{% if perms.tenancy.add_tenantgroup %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'tenancy:tenantgroup_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'tenancy:tenantgroup_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
||||
<li class="dropdown-header">Tags</li>
|
||||
<li class="dropdown-item dropdown-item-btns {% if not perms.extras.view_tag %}disabled{% endif %}">
|
||||
<a class="text-decoration-none" href="{% url 'extras:tag_list' %}">Tags</a>
|
||||
{% if perms.extras.add_tag %}
|
||||
<div class="btn-group btn-group-sm float-end">
|
||||
<a href="{% url 'extras:tag_add' %}" class="btn btn-sm btn-success" title="Add">
|
||||
<i class="bi-plus fs-6"></i>
|
||||
</a>
|
||||
<a href="{% url 'extras:tag_import' %}" class="btn btn-sm btn-info" title="Import">
|
||||
<i class="bi-download fs-6"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="devices" role="button" data-bs-toggle="dropdown" aria-expanded="false">Devices</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Devices</li>
|
||||
<li class="dropdown-item {% if not perms.dcim.view_device %}disabled{% endif %}">
|
||||
{% if perms.dcim.add_device %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:device_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:device_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:device_list' %}">Devices</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_devicerole %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_devicerole %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:devicerole_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:devicerole_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:devicerole_list' %}">Device Roles</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_platform %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_platform %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:platform_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:platform_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:platform_list' %}">Platforms</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_virtualchassis %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_virtualchassis %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:virtualchassis_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:virtualchassis_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:virtualchassis_list' %}">Virtual Chassis</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Device Types</li>
|
||||
<li{% if not perms.dcim.view_devicetype %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_devicetype %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:devicetype_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:devicetype_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:devicetype_list' %}">Device Types</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_manufacturer %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_manufacturer %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:manufacturer_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:manufacturer_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:manufacturer_list' %}">Manufacturers</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Connections</li>
|
||||
<li{% if not perms.dcim.view_cable %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_cable %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:cable_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:cable_list' %}">Cables</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_consoleport or not perms.dcim.view_consoleserverport %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'dcim:console_connections_list' %}">Console Connections</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_powerport or not perms.dcim.view_poweroutlet %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'dcim:power_connections_list' %}">Power Connections</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_interface %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'dcim:interface_connections_list' %}">Interface Connections</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Device Components</li>
|
||||
<li{% if not perms.dcim.view_interface %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_interface %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:interface_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:interface_list' %}">Interfaces</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_frontport %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_frontport %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:frontport_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:frontport_list' %}">Front Ports</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_rearport %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_rearport %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:rearport_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:rearport_list' %}">Rear Ports</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_consoleport %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_consoleport %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:consoleport_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:consoleport_list' %}">Console Ports</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_consoleserverport %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_consoleserverport %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:consoleserverport_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:consoleserverport_list' %}">Console Server Ports</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_powerport %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_powerport %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:powerport_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:powerport_list' %}">Power Ports</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_poweroutlet %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_poweroutlet %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:poweroutlet_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:poweroutlet_list' %}">Power Outlets</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_devicebay %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_devicebay %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:devicebay_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:devicebay_list' %}">Device Bays</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_inventoryitem %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_inventoryitem %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:inventoryitem_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:inventoryitem_list' %}">Inventory Items</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="ipam" role="button" data-bs-toggle="dropdown" aria-expanded="false">IPAM</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">IP Addresses</li>
|
||||
<li{% if not perms.ipam.view_ipaddress %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_ipaddress %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:ipaddress_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:ipaddress_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:ipaddress_list' %}">IP Addresses</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Prefixes</li>
|
||||
<li{% if not perms.ipam.view_prefix %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_prefix %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:prefix_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:prefix_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:prefix_list' %}">Prefixes</a>
|
||||
</li>
|
||||
<li{% if not perms.ipam.view_role %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_role %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:role_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:role_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:role_list' %}">Prefix/VLAN Roles</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Aggregates</li>
|
||||
<li{% if not perms.ipam.view_aggregate %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_aggregate %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:aggregate_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:aggregate_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:aggregate_list' %}">Aggregates</a>
|
||||
</li>
|
||||
<li{% if not perms.ipam.view_rir %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_rir %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:rir_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:rir_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:rir_list' %}">RIRs</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">VRFs</li>
|
||||
<li{% if not perms.ipam.view_vrf %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_vrf %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:vrf_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:vrf_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:vrf_list' %}">VRFs</a>
|
||||
</li>
|
||||
<li{% if not perms.ipam.view_routetarget %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_routetarget %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:routetarget_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:routetarget_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:routetarget_list' %}">Route Targets</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">VLANs</li>
|
||||
<li{% if not perms.ipam.view_vlan %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_vlan %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:vlan_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:vlan_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:vlan_list' %}">VLANs</a>
|
||||
</li>
|
||||
<li{% if not perms.ipam.view_vlangroup %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_vlangroup %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:vlangroup_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'ipam:vlangroup_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:vlangroup_list' %}">VLAN Groups</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Services</li>
|
||||
<li{% if not perms.ipam.view_service %} class="disabled"{% endif %}>
|
||||
{% if perms.ipam.add_service %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'ipam:service_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:service_list' %}">Services</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="virtualization" role="button" data-bs-toggle="dropdown" aria-expanded="false">Virtualization</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Virtual Machines</li>
|
||||
<li{% if not perms.virtualization.view_virtualmachine %} class="disabled"{% endif %}>
|
||||
{% if perms.virtualization.add_virtualmachine %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'virtualization:virtualmachine_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'virtualization:virtualmachine_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'virtualization:virtualmachine_list' %}">Virtual Machines</a>
|
||||
</li>
|
||||
<li{% if not perms.virtualization.view_vminterface%} class="disabled"{% endif %}>
|
||||
{% if perms.virtualization.add_vminterface %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'virtualization:vminterface_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'virtualization:vminterface_list' %}">Interfaces</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Clusters</li>
|
||||
<li{% if not perms.virtualization.view_cluster %} class="disabled"{% endif %}>
|
||||
{% if perms.virtualization.add_cluster %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'virtualization:cluster_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'virtualization:cluster_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'virtualization:cluster_list' %}">Clusters</a>
|
||||
</li>
|
||||
<li{% if not perms.virtualization.view_clustertype %} class="disabled"{% endif %}>
|
||||
{% if perms.virtualization.add_clustertype %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'virtualization:clustertype_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'virtualization:clustertype_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'virtualization:clustertype_list' %}">Cluster Types</a>
|
||||
</li>
|
||||
<li{% if not perms.virtualization.view_clustergroup %} class="disabled"{% endif %}>
|
||||
{% if perms.virtualization.add_clustergroup %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'virtualization:clustergroup_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'virtualization:clustergroup_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'virtualization:clustergroup_list' %}">Cluster Groups</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="circuits" role="button" data-bs-toggle="dropdown" aria-expanded="false">Circuits</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Circuits</li>
|
||||
<li{% if not perms.circuits.view_circuit %} class="disabled"{% endif %}>
|
||||
{% if perms.circuits.add_circuit %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'circuits:circuit_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'circuits:circuit_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'circuits:circuit_list' %}">Circuits</a>
|
||||
</li>
|
||||
<li{% if not perms.circuits.view_circuittype %} class="disabled"{% endif %}>
|
||||
{% if perms.circuits.add_circuittype %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'circuits:circuittype_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'circuits:circuittype_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'circuits:circuittype_list' %}">Circuit Types</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Providers</li>
|
||||
<li{% if not perms.circuits.view_provider %} class="disabled"{% endif %}>
|
||||
{% if perms.circuits.add_provider %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'circuits:provider_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'circuits:provider_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'circuits:provider_list' %}">Providers</a>
|
||||
<li{% if not perms.circuits.view_providernetwork %} class="disabled"{% endif %}>
|
||||
{% if perms.circuits.add_providernetwork %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'circuits:providernetwork_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'circuits:providernetwork_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'circuits:providernetwork_list' %}">Provider Networks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="power" role="button" data-bs-toggle="dropdown" aria-expanded="false">Power</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Power</li>
|
||||
<li{% if not perms.dcim.view_powerfeed %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_powerfeed %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:powerfeed_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:powerfeed_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:powerfeed_list' %}">Power Feeds</a>
|
||||
</li>
|
||||
<li{% if not perms.dcim.view_powerpanel %} class="disabled"{% endif %}>
|
||||
{% if perms.dcim.add_powerpanel %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'dcim:powerpanel_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'dcim:powerpanel_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:powerpanel_list' %}">Power Panels</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="secrets" role="button" data-bs-toggle="dropdown" aria-expanded="false">Secrets</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Secrets</li>
|
||||
<li{% if not perms.secrets.view_secret %} class="disabled"{% endif %}>
|
||||
{% if perms.secrets.add_secret %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'secrets:secret_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'secrets:secret_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'secrets:secret_list' %}">Secrets</a>
|
||||
</li>
|
||||
<li{% if not perms.secrets.view_secretrole %} class="disabled"{% endif %}>
|
||||
{% if perms.secrets.add_secretrole %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'secrets:secretrole_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
<a href="{% url 'secrets:secretrole_import' %}" class="btn btn-xs btn-info" title="Import"><i class="mdi mdi-database-import-outline"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'secrets:secretrole_list' %}">Secret Roles</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="other" role="button" data-bs-toggle="dropdown" aria-expanded="false">Other</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Logging</li>
|
||||
<li{% if not perms.extras.view_journalentry %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'extras:journalentry_list' %}">Journal Entries</a>
|
||||
</li>
|
||||
<li{% if not perms.extras.view_objectchange %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'extras:objectchange_list' %}">Change Log</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Miscellaneous</li>
|
||||
<li{% if not perms.extras.view_configcontext %} class="disabled"{% endif %}>
|
||||
{% if perms.extras.add_configcontext %}
|
||||
<div class="buttons pull-right">
|
||||
<a href="{% url 'extras:configcontext_add' %}" class="btn btn-xs btn-success" title="Add"><i class="mdi mdi-plus-thick"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{% url 'extras:configcontext_list' %}">Config Contexts</a>
|
||||
</li>
|
||||
<li{% if not perms.extras.view_script %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'extras:script_list' %}">Scripts</a>
|
||||
</li>
|
||||
<li{% if not perms.extras.view_report %} class="disabled"{% endif %}>
|
||||
<a href="{% url 'extras:report_list' %}">Reports</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
{% if registry.plugin_menu_items %}
|
||||
{% include 'inc/plugin_menu_items.html' %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if request.user.is_authenticated %}
|
||||
<li class="dropdown">
|
||||
<a a class="nav-link dropdown-toggle" href="#" id="user" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span id="navbar_user">{{ request.user|truncatechars:"30" }}</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'user:profile' %}"><i class="mdi mdi-account-box"></i> Profile</a></li>
|
||||
{% if request.user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}"><i class="mdi mdi-cogs"></i> Admin</a></li>
|
||||
{% endif %}
|
||||
<li class="divider"></li>
|
||||
<li><a href="{% url 'logout' %}"><i class="mdi mdi-logout"></i> Log out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
{% url 'login' as login_url %}
|
||||
{% if request.path == login_url %}
|
||||
<li><a href="{{ request.get_full_path }}"><i class="mdi mdi-login"></i> Log in</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ login_url }}?next={{ request.get_full_path | urlencode }}"><i class="mdi mdi-login"></i> Log in</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
<form action="{% url 'search' %}" method="get" class="navbar-form navbar-right" id="navbar_search" role="search">
|
||||
<div class="input-group">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
Loading…
Reference in New Issue
Block a user