This document describes all Centreon-specific changes compared to upstream draw.io v20.5.3.
The fork embeds the draw.io diagram editor inside Centreon's map application
(centreon-map4-web-client). The editor runs in an iframe, and all communication
with the parent Centreon application uses window.postMessage.
To see the full diff: git diff -w v20.5.3 -- src/main/webapp/js/ ':!*.min.js'
Changes that remove or modify draw.io UI elements irrelevant to Centreon's embedded context.
Removed cloud storage dialogs (Google Drive, GitHub, OneDrive, etc.). Centreon handles diagram persistence itself through postMessage IPC — these dialogs would show non-functional options.
Specifically removed:
sysFontRadioinput element (system fonts radio button in font dialog)- Entire Google Fonts section (radio button, font name input, URL input, preview)
- The font dialog now only shows system fonts, since Google Fonts requires external network access that may not be available in Centreon deployments.
Removed menu items for cloud storage, collaboration, and sharing features that are managed by Centreon's platform and irrelevant to the embedded editor.
The exit action was rewritten to use page-level unsaved tracking instead of
the global editor.modified flag. On exit:
- Counts pages where
page.getSaved() === 'false' - If all pages are saved → exits immediately
- Otherwise → shows a confirm dialog with "Save and Exit" / "Proceed" (discard)
The save handler no longer resets editor.modified = false after postMessage
(handled via urlParams['keepmodified'] = '1').
Reduced the font dialog height from 180 to 100 when Editor.enableWebFonts is
false, since the Google Fonts section is removed (see Dialogs.js).
Tailored the "min" theme (compact layout with floating panels) toolbar:
- Removed sharing, external storage, and template insertion items
- Kept floating format and sidebar panels that Centreon's map editor uses
- Preserved page tab container styling (
tabContainer.style.right = '70px') to make room for the zoom level indicator
Removed fill/stroke color pickers from the toolbar. Centreon manages cell
appearance through its own editCentreonStyle dialog, not raw draw.io style
properties. Exposing these in the toolbar would bypass Centreon's validation.
Reduced and reordered shape palette groups. Standard draw.io stencil libraries are mostly irrelevant since shapes come from Centreon's resource catalog.
Minor palette visibility toggle (hiding search or basic shapes palette that Centreon does not need).
The largest and most functionally rich changed file. Defines how draw.io actions interact with Centreon's backend.
Upstream draw.io's editData opens a dialog for editing raw XML attributes on a
cell. Centreon replaces this completely. Instead of showing a dialog, it:
- Reads cell attributes from the underlying XML node, filtered by cell type:
- For RESOURCE: reads
modelId,type,style,label,resourceId - For LINK: reads
linkType,modelId,label, etc.
- For RESOURCE: reads
- Packages them as JSON and calls:
parent.postMessage( JSON.stringify({ mxObject: cellAttributes, mxStyle: cell.getStyle(), event: "setShowWizardShapeProperties", }), "*", );
- Centreon's React frontend opens its own resource-linking wizard.
The reason: Centreon cells need Centreon-specific properties (modelId linking
to a backend resource, viewId linking to a map page) that the generic XML
editor would expose in a confusing raw format.
Sends the selected cell's style attribute ('ICON', 'WEATHER', or
'GEOMETRIC') to the parent via postMessage with event 'setCentreonStyle'.
The parent then shows its own style-picker UI.
Reads CONTAINER cell properties and sends them to the parent with event
'createMapFromContainer'. Allows the Centreon UI to create a new map linked to
an existing CONTAINER cell on the diagram.
Checks if a CONTAINER cell has both viewId and a non-empty label. If the
label matches an existing page name, shows an error ('pageAlreadyExists').
Otherwise sends event 'createDrawioPageFromContainer' to the parent. This
enables Centreon's "drill-down" navigation where clicking a CONTAINER opens a
dedicated sub-map page.
Both clear modelId="" on pasted/duplicated cells so they do not claim to be
linked to a backend resource. For CONTAINER cells, they also move viewId to
sourceViewId (preserving the reference to the original map) while removing
viewId so the duplicate does not claim ownership of that map view.
The reason: if a user copies a cell that represents a router, the copy should not also claim to represent the same router — it needs to be re-linked via the wizard.
Before any vertex is deleted, finds all connected edges and marks them as dashed
(graph.setCellStyles(mxConstants.STYLE_DASHED, '1', edges)). This is part of
the dashed edge semantics: dashed = "this connection involves an unresolved
resource".
On every selection change:
- If a cell has
style === 'WEATHER'and no overlay yet → callsaddWeatherIconToResource(cell)to show the weather icon - If a cell previously had WEATHER style but no longer does → calls
removeWeatherIconToResource(cell)to remove the overlay - If a cell has
style === 'GEOMETRIC'and width > 84 → resets its size to 20×20 (GEOMETRIC shapes are small geometry primitives) - For connected edges: if selected vertex has
isDataAddedToEdgeorlinkType === 'SIMPLE', restoresdashed=0on those edges
Sets clones[i].setAttribute('modelId', "") so duplicated cells do not
inherit the backend resource link.
Checks if an edge has both resourceId and linkType in ['METRIC', 'STATUS'].
Used to determine if an edge carries monitoring data.
When an edge is connected to a terminal:
- If the edge is a data edge or SIMPLE link with both source and target →
sets
dashed=0(solid line = valid connection) - Otherwise → sets
dashed=1(dashed line = unresolved connection)
Constructs the absolute path to Centreon's own image assets using
localStorage.getItem('centreon-url'):
return `${window.localStorage.getItem("centreon-url")}/modules/centreon-map4-web-client/img/${image}`;Enforces Centreon's size rules:
- WIDGET: minimum dimension of 84
- RESOURCE/CONTAINER with non-GEOMETRIC style: minimum dimension clamped to 84
- RESOURCE/CONTAINER with GEOMETRIC style: dimension clamped to range [20, 84]
Called when a cell's Centreon style property changes:
- Switching to GEOMETRIC → resets cell size to 20×20
- Switching away from GEOMETRIC → resets cell size to 84×84
- Switching to WEATHER → adds weather overlay
- Switching away from WEATHER → removes weather overlay
Creates an mxCellOverlay using an SVG image fetched from
getCentrenMapImagePath('weather.svg') and positions it at the top-left corner
of the cell. Centreon's "weather" display shows a color-coded status icon on a
resource.
Helper that clones the cell's geometry and applies new dimensions via
graph.getModel().setGeometry().
Blocks in-place label editing on OUTPUT widget cells:
if (
cell.getAttribute("type") === "WIDGET" &&
cell.getAttribute("widgetType") === "OUTPUT"
)
return;These widgets display dynamic content from Centreon's monitoring system and their labels are managed externally.
Added 'editCentreonStyle' item to the standard edit menu, alongside
editData and editTooltip.
The entire right-click context menu was rewritten. Upstream draw.io's popup menu shows items for history, style, cell manipulation, connection manipulation, and selection. Centreon's version removes all of these and replaces them with:
- Edit items: delete, cut, copy, duplicate, lock
- Arrange items (via
addPopupMenuArrangeItems) - Centreon items, shown conditionally by cell type:
editDatafor LINK/MEDIA/RESOURCE/WIDGET/CONTAINEReditCentreonStylefor RESOURCE and CONTAINERcreateMapFromContainerandeditContentfor CONTAINER cells with bothviewIdandlabel- LINK_LEGEND widgets and SIMPLE-type links are excluded from Centreon items
The reason: draw.io's standard context menu exposes general diagramming features (change style, edit XML, add connection points) that are meaningless in Centreon's context where visual properties come from a Centreon-managed wizard.
Both widthUpdate and heightUpdate in the Arrange panel now route through
graph.getValueByCell(cell, value) before setting the geometry. When a user
manually types a size, Centreon's size constraints are enforced (e.g., a
RESOURCE cell snaps back to 84 minimum).
Various draw.io style options that conflict with Centreon's managed appearance are removed or simplified.
TextFormatPanel.addFont returns early when graph.cellEditor.isContentEditing(),
so the Text tab shows no attribute controls while a label is being edited inline.
In content-editing mode draw.io's text controls (font family, bold/italic,
alignment, line-height, …) apply via document.execCommand and write inline HTML
into the label — markup that has no dedicated column on the Centreon side and
would be persisted into the label value. Text styling is instead done with the
shape selected, where the same controls write cell-level style properties
(fontFamily, fontStyle, align, fontColor, …).
This replaces an earlier workaround that hid only individual content-editing
controls via the TextFormatPanel-addFont-stylePanel-ContentEditing CSS class
(removed from styles/centreon.css).
DiagramPage.prototype.getViewId = function() { ... }
DiagramPage.prototype.setViewId = function(value) { ... }
DiagramPage.prototype.getSaved = function() { ... }
DiagramPage.prototype.setSaved = function(value) { ... }viewIdlinks a draw.io page to its corresponding Centreon map view in the backend databasesavedtracks whether the page has unsaved changes
If this.pages.length <= 1, shows an error dialog with message key
'canNotDeleteContainer' and returns early. In Centreon's model, a map always
has at least one page.
When page.getSaved() == 'false', an orange dot is rendered on the page tab:
dot.style.backgroundColor = "#FFA500";This gives visual feedback about which pages have local changes not yet synced to the Centreon backend.
mxGeometryChange, mxValueChange, mxStyleChange, and mxChildChange all
call this.currentPage.setSaved(false) and updateTabs(). Any cell movement,
style change, value change, or structural change marks the current page as
having unsaved work.
dragover and drop event handlers on the graph container return early.
Centreon handles file import through its own workflow — allowing raw file drops
could bypass Centreon's validation and import process.
When the graph view is reset (page load, page switch), iterates all vertex cells
and re-adds weather overlays for any cells with style === 'WEATHER'. Ensures
weather icons persist across page navigation.
Same return; guards added to dragover/drop handlers in the diagramly-layer
EditorUi. Belt-and-suspenders approach since both grapheditor and diagramly
layers register their own drag handlers.
Also disables addFileDropHandler (returns early) and removes
installImagePasteHandler from init to prevent clipboard image pasting.
Receives messages from the Centreon parent application to load/save diagrams, switch pages, and update cell data. This is the inbound side of the IPC contract.
When saving (getFileData), the current viewport state is embedded in the
mxGraphModel XML node:
scale— current zoom levelscrollLeft,scrollTop— scroll positionmarginTop,marginLeft— background page shape offsets
When loading (setFileData):
- Remembers the current page name before resetting
- Pre-parses the XML to extract scroll/scale from the matching page
- After loading, selects the previously active page by name
- Restores the scale and scroll position
This preserves the editor's viewport across save/reload cycles.
The upstream SelectPage.prototype.execute sets
graph.model.prefix = Editor.guid() + '-' on every page switch, adding a
GUID prefix to all new cell IDs. The fork removes this so cell IDs stay
consistent with what the Centreon backend expects.
- Multi-line support: messages are split on literal
\nsequences (escaped in resource strings) to render multiple paragraphs - Dialog width increased from 340px to 400px
- Button styling:
marginRight: 7pxon cancel,marginLeft: 15pxon OK
Configuration flags adjusted for embedded context:
Editor.enableWebFonts = false— web font loading disabled for CSP compliance in Centreon's server environmentEditor.enableServiceWorkerdisabled — the PWA service worker is irrelevant for an embedded iframe- Compression settings adjusted
Shows or hides cell labels based on the displayLabel XML attribute:
displayLabel="false"→state.text.node.style.display = 'none'displayLabel="true"and currently hidden → restores display
This allows Centreon to control label visibility per cell without changing the label text itself.
All draw.io ↔ Centreon communication uses parent.postMessage with JSON
payloads:
parent.postMessage(JSON.stringify({
event: '<eventName>',
mxObject: [cellAttributes...],
mxStyle: '<styleString>'
}), '*');Events sent from draw.io to Centreon:
setShowWizardShapeProperties— open resource-linking wizardsetCentreonStyle— open style-picker (ICON/WEATHER/GEOMETRIC)createMapFromContainer— create a new map from a container cellcreateDrawioPageFromContainer— add a new page linked to a container
Every Centreon cell has a type XML attribute:
- RESOURCE — represents a monitored resource (host, service)
- CONTAINER — a grouping element that can link to a sub-map
- LINK — a connection between resources (SIMPLE, METRIC, or STATUS)
- MEDIA — an image or media element
- WIDGET — a dynamic display element (OUTPUT, LINK_LEGEND, etc.)
Additional key attributes:
modelId— links a cell to a Centreon backend resource. Empty = "unlinked"viewId— links a page or container to a map viewstyle— Centreon visual style:ICON,WEATHER, orGEOMETRIClinkType— for LINK cells:SIMPLE,METRIC, orSTATUSresourceId— for data-bearing links: the monitored resource providing data
Dashed edges = "this connection involves an unresolved resource". This visual language is implemented across multiple files:
- Actions.js
deleteCells: marks edges dashed when a vertex is deleted - Actions.js
pasteHere/duplicate: clearsmodelId, so connected edges become dashed on next redraw - Graph.js selection listener: restores
dashed=0on edges when a vertex with data is selected - Graph.js
connectCell: setsdashed=0when edge has both endpoints resolved,dashed=1otherwise
Centreon enforces cell sizes based on type and style:
| Cell Type | Style | Size Rules |
|---|---|---|
| WIDGET | any | minimum 84×84 |
| RESOURCE/CONTAINER | GEOMETRIC | 20×20 to 84×84 |
| RESOURCE/CONTAINER | other | minimum 84×84 |
Enforced in:
Graph.jsgetValueByCell— runtime enforcementFormat.jswidth/height inputs — Arrange panel enforcementGraph.jshandleCentreonStyleChange— resets size on style switch