mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Replace masonry with gridstack * Initial work on dashboard widgets * Implement function to save dashboard layout * Define a default dashboard * Clean up widgets * Implement widget configuration views & forms * Permit merging dict value with existing dict in user config * Add widget deletion view * Enable HTMX for widget configuration * Implement view to add dashboard widgets * ObjectCountsWidget: Identify models by app_label & name * Add color customization to dashboard widgets * Introduce Dashboard model to store user dashboard layout & config * Clean up utility functions * Remove hard-coded API URL * Use fixed grid cell height * Add modal close button * Clean up dashboard views * Rebuild JS
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { initForms } from './forms';
|
|
import { initBootstrap } from './bs';
|
|
import { initQuickSearch } from './search';
|
|
import { initSelect } from './select';
|
|
import { initButtons } from './buttons';
|
|
import { initColorMode } from './colorMode';
|
|
import { initMessages } from './messages';
|
|
import { initClipboard } from './clipboard';
|
|
import { initDateSelector } from './dateSelector';
|
|
import { initTableConfig } from './tableConfig';
|
|
import { initInterfaceTable } from './tables';
|
|
import { initSideNav } from './sidenav';
|
|
import { initDashboard } from './dashboard';
|
|
import { initRackElevation } from './racks';
|
|
import { initLinks } from './links';
|
|
import { initHtmx } from './htmx';
|
|
|
|
function initDocument(): void {
|
|
for (const init of [
|
|
initBootstrap,
|
|
initColorMode,
|
|
initMessages,
|
|
initForms,
|
|
initQuickSearch,
|
|
initSelect,
|
|
initDateSelector,
|
|
initButtons,
|
|
initClipboard,
|
|
initTableConfig,
|
|
initInterfaceTable,
|
|
initSideNav,
|
|
initDashboard,
|
|
initRackElevation,
|
|
initLinks,
|
|
initHtmx,
|
|
]) {
|
|
init();
|
|
}
|
|
}
|
|
|
|
function initWindow(): void {
|
|
const documentForms = document.forms;
|
|
for (const documentForm of documentForms) {
|
|
if (documentForm.method.toUpperCase() == 'GET') {
|
|
documentForm.addEventListener('formdata', function (event: FormDataEvent) {
|
|
const formData: FormData = event.formData;
|
|
for (const [name, value] of Array.from(formData.entries())) {
|
|
if (value === '') formData.delete(name);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
const contentContainer = document.querySelector<HTMLElement>('.content-container');
|
|
if (contentContainer !== null) {
|
|
// Focus the content container for accessible navigation.
|
|
contentContainer.focus();
|
|
}
|
|
}
|
|
|
|
window.addEventListener('load', initWindow);
|
|
|
|
if (document.readyState !== 'loading') {
|
|
initDocument();
|
|
} else {
|
|
document.addEventListener('DOMContentLoaded', initDocument);
|
|
}
|