621 lines
25 KiB
HTML
621 lines
25 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" data-bs-theme="{{ session.get('theme', 'dark') }}">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{{ title|default('Network Infrastructure Management') }}</title>
|
|
<!-- Bootstrap CSS -->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<!-- Tabler Icons -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@2.22.0/tabler-icons.min.css">
|
|
<!-- Font Awesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<!-- Google Fonts -->
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<!-- Custom CSS -->
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/app.css') }}">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/tabler.min.css') }}"
|
|
onerror="this.onerror=null;this.href='https://cdn.jsdelivr.net/npm/@tabler/core@latest/dist/css/tabler.min.css';">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='libs/tabler-icons/tabler-icons.min.css') }}"
|
|
onerror="this.onerror=null;this.href='https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/tabler-icons.min.css';">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/custom.css') }}">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/github-markdown-reading-view.css') }}">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/github-markdown-source-view.css') }}">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/theme.css') }}">
|
|
<!-- Favicon -->
|
|
<link rel="icon" type="image/png" href="{{ url_for('static', filename='img/favicon.png') }}">
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
{% block styles %}{% endblock %}
|
|
<script>
|
|
// Check for saved theme preference or respect OS preference
|
|
function initTheme() {
|
|
const storedTheme = localStorage.getItem('theme');
|
|
if (storedTheme) {
|
|
document.documentElement.setAttribute('data-bs-theme', storedTheme);
|
|
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
document.documentElement.setAttribute('data-bs-theme', 'dark');
|
|
localStorage.setItem('theme', 'dark');
|
|
}
|
|
}
|
|
|
|
// Run before page load to prevent flash
|
|
initTheme();
|
|
</script>
|
|
<style>
|
|
.sidebar-item-parent {
|
|
position: relative;
|
|
}
|
|
|
|
.sidebar-submenu {
|
|
display: none;
|
|
padding-left: 20px;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.sidebar-item-parent.expanded .sidebar-submenu {
|
|
display: block;
|
|
}
|
|
|
|
.sidebar-item-parent.expanded .toggle-icon {
|
|
transform: rotate(180deg);
|
|
}
|
|
|
|
.subnet-item,
|
|
.server-item {
|
|
padding: 5px 10px;
|
|
margin: 2px 0;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
text-decoration: none;
|
|
color: inherit;
|
|
}
|
|
|
|
.subnet-item:hover,
|
|
.server-item:hover {
|
|
background-color: rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.subnet-item.active,
|
|
.server-item.active {
|
|
background-color: rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.subnet-servers {
|
|
margin-left: 15px;
|
|
display: none;
|
|
}
|
|
|
|
.subnet-item-expanded .subnet-servers {
|
|
display: block;
|
|
}
|
|
|
|
.subnet-item-expanded .subnet-toggle-icon {
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
.subnet-toggle-icon {
|
|
transition: transform 0.2s ease;
|
|
margin-right: 5px;
|
|
}
|
|
|
|
.loading-placeholder {
|
|
color: #888;
|
|
font-style: italic;
|
|
padding: 5px 15px;
|
|
}
|
|
|
|
.site-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0.5rem 0.75rem;
|
|
color: var(--sidebar-color);
|
|
cursor: pointer;
|
|
background-color: rgba(0, 0, 0, 0.02);
|
|
border-radius: 4px;
|
|
margin: 2px 0;
|
|
}
|
|
|
|
.site-item:hover {
|
|
background-color: rgba(0, 0, 0, 0.04);
|
|
}
|
|
|
|
.site-toggle-icon {
|
|
transition: transform 0.2s;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.site-item-container {
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.subnet-item {
|
|
margin-left: 1rem;
|
|
}
|
|
|
|
.subnet-item a {
|
|
padding-left: 1rem;
|
|
display: block;
|
|
color: var(--sidebar-color);
|
|
}
|
|
|
|
.subnet-item a:hover {
|
|
background-color: rgba(0, 0, 0, 0.03);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
/* Navigation bar theming */
|
|
.navbar {
|
|
background-color: var(--bs-body-bg) !important;
|
|
border-bottom: 1px solid var(--bs-border-color);
|
|
}
|
|
|
|
.navbar .navbar-brand,
|
|
.navbar .nav-link,
|
|
.navbar .dropdown-toggle {
|
|
color: var(--bs-body-color) !important;
|
|
}
|
|
|
|
/* Markdown styling for better contrast in dark mode */
|
|
[data-bs-theme="dark"] .markdown-content {
|
|
color: rgba(255, 255, 255, 0.9);
|
|
}
|
|
|
|
[data-bs-theme="dark"] .markdown-content h1,
|
|
[data-bs-theme="dark"] .markdown-content h2,
|
|
[data-bs-theme="dark"] .markdown-content h3,
|
|
[data-bs-theme="dark"] .markdown-content h4,
|
|
[data-bs-theme="dark"] .markdown-content h5,
|
|
[data-bs-theme="dark"] .markdown-content h6 {
|
|
color: rgba(255, 255, 255, 0.95);
|
|
}
|
|
|
|
[data-bs-theme="dark"] .markdown-content code {
|
|
background-color: rgba(255, 255, 255, 0.1);
|
|
color: #e6e6e6;
|
|
}
|
|
|
|
[data-bs-theme="dark"] .markdown-content pre {
|
|
background-color: rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
[data-bs-theme="dark"] .markdown-content a {
|
|
color: #6ea8fe;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="{{ 'auth-page' if not current_user.is_authenticated else '' }}">
|
|
<!-- Notification Area -->
|
|
<div id="notification-area"></div>
|
|
|
|
{% if current_user.is_authenticated %}
|
|
<!-- Sidebar for authenticated users -->
|
|
<aside class="sidebar">
|
|
<div class="sidebar-brand">
|
|
<span class="ti ti-network"></span>
|
|
<span class="sidebar-brand-text">NetDocs</span>
|
|
</div>
|
|
|
|
<div class="sidebar-nav">
|
|
<div class="sidebar-heading">Main</div>
|
|
<a href="{{ url_for('dashboard.dashboard_home') }}"
|
|
class="sidebar-item {{ 'active' if request.endpoint == 'dashboard.dashboard_home' }}">
|
|
<span class="ti ti-dashboard me-2"></span> Dashboard
|
|
</a>
|
|
<a href="{{ url_for('dashboard.server_list') }}"
|
|
class="sidebar-item {{ 'active' if request.endpoint and request.endpoint.startswith('dashboard.server') }}">
|
|
<span class="ti ti-server me-2"></span> Servers
|
|
</a>
|
|
|
|
<!-- IPAM with Subnet Tree -->
|
|
<div class="sidebar-item-parent" id="ipam-menu">
|
|
<a href="{{ url_for('ipam.ipam_home') }}"
|
|
class="sidebar-item {{ 'active' if request.endpoint and request.endpoint.startswith('ipam.') }}">
|
|
<span class="ti ti-network me-2"></span> IPAM
|
|
<span class="ti ti-chevron-down ms-auto toggle-icon"></span>
|
|
</a>
|
|
<div class="sidebar-submenu">
|
|
<div id="subnet-tree-container">
|
|
<!-- Subnets will be loaded here -->
|
|
<div class="text-center py-2 d-none" id="subnet-loader">
|
|
<div class="spinner-border spinner-border-sm" role="status">
|
|
<span class="visually-hidden">Loading...</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sidebar-heading">Management</div>
|
|
<a href="{{ url_for('dashboard.server_new') }}" class="sidebar-item">
|
|
<span class="ti ti-plus me-2"></span> Add Server
|
|
</a>
|
|
<a href="{{ url_for('ipam.subnet_new') }}" class="sidebar-item">
|
|
<span class="ti ti-plus me-2"></span> Add Subnet
|
|
</a>
|
|
|
|
<div class="sidebar-heading">User</div>
|
|
<a href="{{ url_for('dashboard.settings') }}"
|
|
class="sidebar-item {{ 'active' if request.endpoint == 'dashboard.settings' }}">
|
|
<span class="ti ti-settings me-2"></span> Settings
|
|
</a>
|
|
<a href="{{ url_for('auth.logout') }}" class="sidebar-item">
|
|
<span class="ti ti-logout me-2"></span> Logout
|
|
</a>
|
|
</div>
|
|
</aside>
|
|
|
|
<!-- Main Content for authenticated users -->
|
|
<div class="main-content">
|
|
<!-- Top Navbar -->
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom mb-4">
|
|
<div class="container-fluid">
|
|
<button class="sidebar-toggler btn btn-outline-secondary d-lg-none me-2">
|
|
<span class="ti ti-menu-2"></span>
|
|
</button>
|
|
|
|
<span class="navbar-brand d-none d-lg-block">
|
|
{{ title if title else 'Network Documentation' }}
|
|
</span>
|
|
|
|
<div class="d-flex align-items-center">
|
|
<div class="dropdown">
|
|
<a href="#" class="d-flex align-items-center text-decoration-none dropdown-toggle"
|
|
id="user-dropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<span class="d-none d-md-inline me-2">{{ current_user.email }}</span>
|
|
<span class="ti ti-user"></span>
|
|
</a>
|
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="user-dropdown">
|
|
<li><a class="dropdown-item" href="{{ url_for('auth.logout') }}">Logout</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="navbar-nav flex-row order-md-last">
|
|
<div class="nav-item me-2">
|
|
<button id="theme-toggle" class="btn btn-icon" aria-label="Toggle theme">
|
|
<span class="ti ti-moon dark-icon d-none"></span>
|
|
<span class="ti ti-sun light-icon"></span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Flash Messages -->
|
|
<div class="container-fluid mt-3">
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
|
|
{{ message }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
</div>
|
|
{% else %}
|
|
<!-- Simple flash message container for non-authenticated users -->
|
|
<div class="container mt-3">
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
|
|
{{ message }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- ONLY ONE CONTENT BLOCK FOR BOTH AUTHENTICATED AND NON-AUTHENTICATED STATES -->
|
|
<div class="{{ 'py-4' if current_user.is_authenticated else '' }}">
|
|
{% block content %}{% endblock %}
|
|
</div>
|
|
|
|
{% if current_user.is_authenticated %}
|
|
</div> <!-- End of main-content div that was opened for authenticated users -->
|
|
{% endif %}
|
|
|
|
<!-- Bootstrap JS -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<!-- HTMX for dynamic content -->
|
|
<!-- <script src="https://unpkg.com/htmx.org@1.9.2"></script> -->
|
|
<!-- Custom JS -->
|
|
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
|
|
<script>
|
|
// Sidebar toggle for mobile - using modern event listener approach
|
|
const sidebarToggler = document.querySelector('.sidebar-toggler');
|
|
if (sidebarToggler) {
|
|
sidebarToggler.addEventListener('click', () => {
|
|
document.querySelector('.sidebar').classList.toggle('show');
|
|
});
|
|
}
|
|
</script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// Toggle sidebar submenus
|
|
document.querySelectorAll('.sidebar-item-parent > a').forEach(item => {
|
|
item.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
const parent = this.parentElement;
|
|
parent.classList.toggle('expanded');
|
|
|
|
// Save state in localStorage
|
|
const menuId = parent.id || parent.dataset.menu;
|
|
if (menuId) {
|
|
if (parent.classList.contains('expanded')) {
|
|
saveExpandedMenu(menuId);
|
|
|
|
// Load subnet data when IPAM is expanded
|
|
if (menuId === 'ipam-menu') {
|
|
loadSubnets();
|
|
}
|
|
} else {
|
|
removeExpandedMenu(menuId);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// Check and restore expanded menus from localStorage
|
|
restoreExpandedMenus();
|
|
|
|
function restoreExpandedMenus() {
|
|
const expandedMenus = getExpandedMenus();
|
|
|
|
// Expand saved menus
|
|
expandedMenus.forEach(menuId => {
|
|
const menuElement = document.getElementById(menuId);
|
|
if (menuElement) {
|
|
menuElement.classList.add('expanded');
|
|
|
|
// Load IPAM subnets if that menu is expanded
|
|
if (menuId === 'ipam-menu') {
|
|
loadSubnets();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function getExpandedMenus() {
|
|
const saved = localStorage.getItem('expandedMenus');
|
|
return saved ? JSON.parse(saved) : [];
|
|
}
|
|
|
|
function saveExpandedMenu(menuId) {
|
|
const expandedMenus = getExpandedMenus();
|
|
if (!expandedMenus.includes(menuId)) {
|
|
expandedMenus.push(menuId);
|
|
localStorage.setItem('expandedMenus', JSON.stringify(expandedMenus));
|
|
}
|
|
}
|
|
|
|
function removeExpandedMenu(menuId) {
|
|
let expandedMenus = getExpandedMenus();
|
|
expandedMenus = expandedMenus.filter(id => id !== menuId);
|
|
localStorage.setItem('expandedMenus', JSON.stringify(expandedMenus));
|
|
}
|
|
|
|
function loadSubnets() {
|
|
const subnetContainer = document.getElementById('subnet-tree-container');
|
|
const loader = document.getElementById('subnet-loader');
|
|
|
|
if (!loader || !subnetContainer) return;
|
|
|
|
// Check if we already have loaded subnets
|
|
if (subnetContainer.querySelector('.site-item-container') &&
|
|
!loader.classList.contains('d-none')) {
|
|
return; // Already loading or loaded
|
|
}
|
|
|
|
// Show loader
|
|
loader.classList.remove('d-none');
|
|
|
|
// Fetch subnets
|
|
fetch('/api/subnets')
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(sites => {
|
|
loader.classList.add('d-none');
|
|
|
|
if (sites.length === 0) {
|
|
subnetContainer.innerHTML = '<div class="text-muted px-3 py-2">No sites or subnets found</div>';
|
|
return;
|
|
}
|
|
|
|
let html = '';
|
|
// Loop through sites
|
|
sites.forEach(site => {
|
|
const siteId = `site-${site.name.replace(/[^a-z0-9]/gi, '-').toLowerCase()}`;
|
|
const isSiteExpanded = getExpandedMenus().includes(siteId);
|
|
|
|
html += `
|
|
<div class="site-item-container" id="${siteId}">
|
|
<div class="site-item">
|
|
<span class="ti ${isSiteExpanded ? 'ti-chevron-down' : 'ti-chevron-right'} site-toggle-icon me-1"></span>
|
|
<span class="ti ti-building me-1"></span>
|
|
<span class="flex-grow-1">${site.name}</span>
|
|
</div>
|
|
<div class="site-subnets ${isSiteExpanded ? '' : 'd-none'}">`;
|
|
|
|
// Add subnets for this site
|
|
if (site.subnets.length === 0) {
|
|
html += '<div class="text-muted px-3 py-2">No subnets in this site</div>';
|
|
} else {
|
|
site.subnets.forEach(subnet => {
|
|
html += `
|
|
<div class="subnet-item">
|
|
<a href="/ipam/subnet/${subnet.id}" class="text-reset text-decoration-none d-block ps-4 py-1">
|
|
<span class="ti ti-network me-1 small"></span>
|
|
${subnet.cidr}
|
|
</a>
|
|
</div>`;
|
|
});
|
|
}
|
|
|
|
html += `</div></div>`;
|
|
});
|
|
|
|
subnetContainer.innerHTML = html;
|
|
|
|
// Add click handlers to site items
|
|
document.querySelectorAll('.site-item').forEach(item => {
|
|
const toggleIcon = item.querySelector('.site-toggle-icon');
|
|
if (toggleIcon) {
|
|
toggleIcon.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
const siteContainer = item.closest('.site-item-container');
|
|
const siteId = siteContainer.id;
|
|
const subnetsContainer = item.nextElementSibling;
|
|
|
|
subnetsContainer.classList.toggle('d-none');
|
|
|
|
// Save state to localStorage
|
|
if (!subnetsContainer.classList.contains('d-none')) {
|
|
saveExpandedMenu(siteId);
|
|
} else {
|
|
removeExpandedMenu(siteId);
|
|
}
|
|
|
|
// Toggle icon
|
|
this.classList.toggle('ti-chevron-right');
|
|
this.classList.toggle('ti-chevron-down');
|
|
});
|
|
}
|
|
});
|
|
})
|
|
.catch(error => {
|
|
console.error('Error loading subnets:', error);
|
|
loader.classList.add('d-none');
|
|
subnetContainer.innerHTML = '<div class="text-danger px-3 py-2">Error loading subnets</div>';
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const themeToggle = document.getElementById('theme-toggle');
|
|
const darkIcon = document.querySelector('.dark-icon');
|
|
const lightIcon = document.querySelector('.light-icon');
|
|
|
|
// Set initial icon state
|
|
updateThemeIcon();
|
|
|
|
function updateThemeIcon() {
|
|
const currentTheme = localStorage.getItem('theme') ||
|
|
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
|
|
if (currentTheme === 'dark') {
|
|
darkIcon.classList.remove('d-none');
|
|
lightIcon.classList.add('d-none');
|
|
} else {
|
|
darkIcon.classList.add('d-none');
|
|
lightIcon.classList.remove('d-none');
|
|
}
|
|
}
|
|
|
|
themeToggle.addEventListener('click', function () {
|
|
const currentTheme = document.documentElement.getAttribute('data-bs-theme');
|
|
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
|
|
document.documentElement.setAttribute('data-bs-theme', newTheme);
|
|
localStorage.setItem('theme', newTheme);
|
|
updateThemeIcon();
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// Add transition class to main content
|
|
const mainContent = document.querySelector('.page-body');
|
|
if (mainContent) {
|
|
mainContent.classList.add('page-transition');
|
|
}
|
|
|
|
// Theme toggle enhancement
|
|
const themeToggle = document.getElementById('theme-toggle');
|
|
if (themeToggle) {
|
|
themeToggle.addEventListener('click', function () {
|
|
const currentTheme = document.documentElement.getAttribute('data-bs-theme');
|
|
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
|
|
document.documentElement.setAttribute('data-bs-theme', newTheme);
|
|
localStorage.setItem('theme', newTheme);
|
|
|
|
// Update toggle icon
|
|
const darkIcon = document.querySelector('.dark-icon');
|
|
const lightIcon = document.querySelector('.light-icon');
|
|
|
|
if (darkIcon && lightIcon) {
|
|
if (newTheme === 'dark') {
|
|
darkIcon.classList.remove('d-none');
|
|
lightIcon.classList.add('d-none');
|
|
} else {
|
|
darkIcon.classList.add('d-none');
|
|
lightIcon.classList.remove('d-none');
|
|
}
|
|
}
|
|
|
|
// Show theme change notification
|
|
showNotification('success', `${newTheme.charAt(0).toUpperCase() + newTheme.slice(1)} mode activated`);
|
|
});
|
|
}
|
|
});
|
|
|
|
// Notification function
|
|
function showNotification(type, message) {
|
|
const notificationArea = document.getElementById('notification-area');
|
|
if (!notificationArea) return;
|
|
|
|
const notification = document.createElement('div');
|
|
notification.className = `alert alert-${type} alert-dismissible fade show`;
|
|
notification.style.animation = 'fadeIn 0.3s ease-out';
|
|
notification.innerHTML = `
|
|
${message}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
`;
|
|
|
|
notificationArea.appendChild(notification);
|
|
|
|
// Auto dismiss after 3 seconds
|
|
setTimeout(() => {
|
|
notification.style.animation = 'fadeOut 0.3s ease-in';
|
|
setTimeout(() => {
|
|
notification.remove();
|
|
}, 300);
|
|
}, 3000);
|
|
}
|
|
|
|
@keyframes fadeOut {
|
|
from { opacity: 1; }
|
|
to { opacity: 0; }
|
|
}
|
|
</script>
|
|
<script>
|
|
// Add CSRF token to all AJAX requests
|
|
$(document).ready(function () {
|
|
$.ajaxSetup({
|
|
beforeSend: function (xhr, settings) {
|
|
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
|
xhr.setRequestHeader("X-CSRFToken", $('meta[name="csrf-token"]').attr('content'));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% block scripts %}{% endblock %}
|
|
</body>
|
|
|
|
</html>
|