dashboard: allow widget locking

This commit is contained in:
Stephan de Wit 2024-06-14 14:44:32 +02:00
parent 105ecf9a5a
commit 34cafe3e98
2 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,11 @@
--chart-js-font-color: #000000;
}
.btn-pressed, .btn-pressed:hover {
background-color: #d94f00;
color: white;
}
.fa-spinner {
font-size: 2em;
}

View File

@ -272,6 +272,11 @@ class WidgetManager {
</button>
`));
$btn_group.append($(`<button class="btn btn-secondary" id="restore-defaults">${this.gettext.restore}</button>`));
$btn_group.append($(`
<button class="btn btn-secondary" id="lock-grid">
<i class="fa fa-lock" style="font-size: 14px;"></i>
</button>
`));
// Initially hide the save button
$('#save-grid').hide();
@ -386,6 +391,24 @@ class WidgetManager {
}
});
});
$('#lock-grid').on('click', () => {
$('#lock-grid').toggleClass('btn-pressed');
if ($('#lock-grid').hasClass('btn-pressed')) {
this.grid.enableMove(false);
this.grid.enableResize(false);
$('.widget-content').css('cursor', 'default');
} else {
this.grid.enableMove(true);
this.grid.enableResize(true);
$('.widget-content').css('cursor', 'grab');
}
});
$('#lock-grid').mouseup(function() {
$(this).blur();
});
}
/* Executes all widget post-render callbacks asynchronously and in "parallel".