|
@@ -2,6 +2,20 @@ import { GridStack, GridStackOptions, GridStackWidget } from 'gridstack';
|
|
|
import { createToast } from './bs';
|
|
import { createToast } from './bs';
|
|
|
import { apiPatch, hasError } from './util';
|
|
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(
|
|
async function saveDashboardLayout(
|
|
|
url: string,
|
|
url: string,
|
|
|
gridData: GridStackWidget[] | GridStackOptions,
|
|
gridData: GridStackWidget[] | GridStackOptions,
|
|
@@ -22,6 +36,8 @@ export function initDashboard(): void {
|
|
|
// Initialize the grid
|
|
// Initialize the grid
|
|
|
let grid = GridStack.init({
|
|
let grid = GridStack.init({
|
|
|
cellHeight: 100,
|
|
cellHeight: 100,
|
|
|
|
|
+ disableDrag: true,
|
|
|
|
|
+ disableResize: true,
|
|
|
draggable: {
|
|
draggable: {
|
|
|
handle: '.grid-stack-item-content .card-header',
|
|
handle: '.grid-stack-item-content .card-header',
|
|
|
appendTo: 'body',
|
|
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
|
|
// Create a listener for the dashboard save button
|
|
|
const gridSaveButton = document.getElementById('save_dashboard') as HTMLButtonElement;
|
|
const gridSaveButton = document.getElementById('save_dashboard') as HTMLButtonElement;
|
|
|
if (gridSaveButton === null) {
|
|
if (gridSaveButton === null) {
|