diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 82215659f..7f20abbd6 100644 Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index b9fb5a27c..1cb775229 100644 Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ diff --git a/netbox/project-static/src/dashboard.ts b/netbox/project-static/src/dashboard.ts index b5d5da9e3..df200fffd 100644 --- a/netbox/project-static/src/dashboard.ts +++ b/netbox/project-static/src/dashboard.ts @@ -2,6 +2,20 @@ import { GridStack, GridStackOptions, GridStackWidget } from 'gridstack'; import { createToast } from './bs'; import { apiPatch, hasError } from './util'; +function lockDashboard(): void { + const dashboard = document.getElementById('dashboard') as any; + if (dashboard) { + dashboard.gridstack.disable(); + } +} + +function unlockDashboard(): void { + const dashboard = document.getElementById('dashboard') as any; + if (dashboard) { + dashboard.gridstack.enable(); + } +} + async function saveDashboardLayout( url: string, gridData: GridStackWidget[] | GridStackOptions, @@ -22,6 +36,8 @@ export function initDashboard(): void { // Initialize the grid let grid = GridStack.init({ cellHeight: 100, + disableDrag: true, + disableResize: true, draggable: { handle: '.grid-stack-item-content .card-header', appendTo: 'body', @@ -29,6 +45,22 @@ export function initDashboard(): void { } }); + // Create a listener for the dashboard lock button + const gridLockButton = document.getElementById('lock_dashboard') as HTMLButtonElement; + if (gridLockButton) { + gridLockButton.addEventListener('click', () => { + lockDashboard(); + }); + } + + // Create a listener for the dashboard unlock button + const gridUnlockButton = document.getElementById('unlock_dashboard') as HTMLButtonElement; + if (gridUnlockButton) { + gridUnlockButton.addEventListener('click', () => { + unlockDashboard(); + }); + } + // Create a listener for the dashboard save button const gridSaveButton = document.getElementById('save_dashboard') as HTMLButtonElement; if (gridSaveButton === null) { diff --git a/netbox/templates/home.html b/netbox/templates/home.html index 846ef9758..414ac3488 100644 --- a/netbox/templates/home.html +++ b/netbox/templates/home.html @@ -29,25 +29,39 @@ {% include 'extras/dashboard/widget.html' %} {% endfor %} -