Network Mapper - edmozley/freeitsm GitHub Wiki
Folder: network-mapper/
Colour: Cyan gradient
Under the hood: Developer Guide Β· Shapes, pages and layers Β· Icon libraries and images Β· Knowledge links and export
Visual architecture diagrams that stay bound to the CMDB. Every node on the canvas references a real cmdb_objects row β not a free-floating label β so the diagram can't drift from reality. Rename an object in CMDB and the diagram updates. Mark it as planned and it renders with a dashed amber border. Decommission it and the diagram says so.
The killer feature is Add related objects β pick any placed node, click one button, and the modal lists every CMDB neighbour (outgoing relationships, incoming relationships, property references). Tick the ones you want, hit Add, and they land in a ring around the source with connectors auto-drawn β guided graph exploration rather than blank-canvas overwhelm.
Grid of cards showing each diagram's title, version pill (showing the chain length when a diagram has more than one version), description, node + connector counts, author, and last-updated date. Filter by title and New sit in the action row under the module header (UI style guide); New opens a modal that collects title, optional description, and an initial version label (defaults to v1). Click a card to open the editor.
Three-pane layout: the palette on the left, the canvas in the middle, a side panel on the right (it slides in when something is selected). Across the top:
- The toolbar - Autosave, Paper, Layers, Articles, zoom, Branding, Centre, PNG / PDF and Present. It fits on one row on a normal laptop screen; on a narrower one the buttons wrap onto a second line rather than pushing anything off the screen
- The title row - the diagram's title, its version pill and Edit, then Author / Created / Updated, then Versions, Save as new version and Save on the right
Edit beside the title changes the title and description of the version you are on. It saves straight away and does not touch unsaved changes on the canvas.
Two tabs:
- CMDB classes - every active CMDB class with its icon and object count. Drag a class tile onto the canvas to place a node of that class
- Shapes - freestanding shapes, imported icon libraries and your own pictures (see Shapes below)
- Drag a class tile onto the canvas
- Drop opens an object picker scoped to that class β type-ahead filter, arrow keys + Enter to pick
- Picker auto-filters out objects already on this diagram (no double-placing)
- Node lands at the drop coordinates, snapped to the 20px grid, with the object's name as the label
Click to select, drag to move, Delete to remove. Click an empty area of the canvas to deselect.
Each node uses its CMDB class's icon. Set the default once in CMDB β Settings β Classes (edit a class and pick an Icon), and every node of that class uses it, on every diagram, unless a node picks its own (see Per-Node Icon Override).
A few behaviours worth knowing:
- The picker preloads the class's full object list; the type-ahead filter re-queries server-side with a 200ms debounce
- A drag only marks the diagram dirty if the node actually moved, so a click-without-drag selects but doesn't dirty
- Every successful save re-fetches the diagram so temp ids (negative numbers used for unsaved nodes) resolve into real auto-increment ids β vital before any connector references a node. The current selection is preserved across the reload by matching on
cmdb_object_idrather than node id - Deleting a node cascades down any incident connectors so
save_diagram.phpdoesn't reject the payload - Read-only versions accept selection but reject drop / drag / delete (the backend would refuse anyway)
Hover or select a node or a shape and small cyan dots appear just outside its edges. Press on a dot, drag to another node or shape, and let go to create the connector. A dashed cyan line follows the cursor while you drag.
- Any two things - node to node, shape to shape, or shape to node. The line follows when either end moves
- Direction - the arrow points from where you started to where you let go. Swap in the Format panel turns it round
- Label - double-click a connector and type at its midpoint (Enter saves, Esc cancels; an emptied label clears it)
- Format panel - click a connector to open it:
| Setting | Choices |
|---|---|
| Colour and width | Any colour, any width |
| Line | Solid, dashed or dotted (dashed suits backup links or planned connections) |
| Arrowheads | At either end: arrow, open, diamond, circle or none |
| Route | Straight, elbow or curved |
| Swap | Turns the connector round |
| Reset | Back to the normal look |
- Delete removes a selected connector; a wide invisible hit area underneath each line makes it easy to click
- Self-loops and duplicate connectors (same direction between the same pair) are refused
- Connectors made by Add related objects carry
cmdb_relationship_id, so they point back at the real CMDB relationship
Select a placed node and click Add related objects in the detail panel footer. Modal lists every CMDB object connected to this one across three buckets:
| Bucket | Source | Verb on the connector |
|---|---|---|
| This object β others |
cmdb_object_relationships where this object is from_object_id
|
The relationship verb (e.g. depends on, hosts) |
| Others β this object |
cmdb_object_relationships where this object is to_object_id
|
The inverse verb so it reads naturally from this POV |
| Referenced by properties |
cmdb_object_properties where value_object_id = this id |
The property name (e.g. Owner, Host Server) |
Tick the rows you want, hit Add N objects, and the selected objects place in a ring around the source β angle starts at 12 o'clock and walks clockwise; radius scales with count. Connectors auto-drawn in the correct direction for each relationship type. Already-on-canvas objects show a grey "on canvas" badge with the checkbox disabled.
The endpoint returns one row per (object, path) β so an object reachable via two paths surfaces as two tickable rows. Additions are deduplicated by cmdb_object_id. Property-ref connectors leave cmdb_relationship_id NULL and carry the property name as their label. On a read-only version the panel still shows, but the Add related objects button is disabled with a tooltip explaining why.
Selects any placed node to open. Shows the node's icon, name, class, planned status, and a deep-link to the CMDB object page. Also lazy-fetches and renders every CMDB property that has a value on the bound object:
| Property type | Rendering |
|---|---|
text |
Auto-detects HTTP/HTTPS URLs and linkifies them |
number |
Locale-formatted with thousand separators |
date |
Locale-formatted date |
boolean |
Green Yes or grey No pill |
dropdown |
Coloured pill picking up the option's CMDB colour with luminance-based text contrast |
object_ref |
Pink-pill link straight to the referenced object's CMDB page (new tab) |
Empty properties hidden so the panel stays tight. Add related objects button pinned to the bottom of the panel as a sticky footer so it's always reachable regardless of property count.
If a CMDB object has is_planned = 1 (set on the CMDB object detail page), the node renders with:
- Dashed amber border
- Soft
#fffbebbackground tint - Italic amber label
- Small PLANNED pill between the icon and the label
Lets you draw as-is and to-be on the same diagram without needing two separate ones. When the object goes live, flip the planned flag off in CMDB and the diagram restyles on next load β no edits needed.
The ~65-icon built-in set lives in assets/js/network-mapper-icons.js, which ships a window.NM_ICONS map plus window.NM_ICON_META (label + category per icon), window.NM_ICON_CATEGORIES (display order / labels) and an nmRenderIcon(key, size, extra) helper. Twelve categories:
| Category | Icons |
|---|---|
| Compute & Servers | server / server-rack / server-blade / server-tower / mainframe / vm / function / workstation |
| Databases | database / database-cluster / database-cache |
| Storage | storage / storage-san / storage-tape / backup |
| Networking | network / router / switch / firewall / load-balancer / proxy / vpn / gateway / wireless-ap / modem / cdn / dns |
| Security | shield / lock / key / ids / siem |
| Cloud | cloud / cloud-private / cloud-public / cloud-hybrid / region |
| Containers | container / container-pod / kubernetes / registry |
| Applications & Data | application / service / website / api / microservice / queue / cache / dashboard |
| Endpoints | laptop / mobile / tablet / iot / printer |
| Monitoring & Ops | monitor / alert / log |
| People & Org | person / team / org |
| Files & Generic | document / folder / globe / mail / calendar / box |
Feather-style 24Γ24 viewBox, stroke 1.8, currentColor so they tint with any container. Unknown keys fall back to box. The full set is also seeded into cmdb_icons, so CMDB Classes settings can pick from the wider library when defining new classes. Multiple variants per concept (three server styles, three database styles, four cloud styles, etc.) exist precisely so the per-node icon override below can visually distinguish two objects of the same class.
Each node defaults to its CMDB class's icon, but you can override per-node β useful when you want to distinguish two objects of the same class visually (e.g. Production MS SQL as a clustered-cylinder, Reporting Oracle as a single cylinder, both still bound to the Database Server class).
- Select a node, click Change next to the Icon row in the detail panel
- Picker modal shows ~65 icons in a 12-category grid with type-ahead search (matches icon key + human label)
- Currently-used icon highlighted with a thicker cyan border
- Click an icon to commit immediately (no separate Save button)
- Reset clears the override and goes back to the class default
Stored as icon_override on network_diagram_nodes β a VARCHAR(100) that must hold a key from the icon library (cmdb_icons) - an unknown key is refused when the diagram is saved. If you pick the same icon as the class default, the override is stored as NULL rather than a redundant duplicate.
Select a node and its side panel has:
- Colour - eight swatches or any colour from the picker. It shows on the border, the icon and a soft tint behind
- Icon size - small, medium or large
- Box size - drag the small square at the corner of the selected box to make it bigger, so a long name wraps in full instead of being cut short. Icon and name stay centred both ways and connectors follow the icon. Reset goes back to automatic
- Style - the same fill, gradient, border, shadow, opacity, rounded corner and label font controls as a shape, with Reset
All of it is copied into new versions and shows in exports.
The Shapes tab holds 61 shapes in five groups - basic, flowchart, arrows, zones and containers, text and notes - with a search box. Shapes are not linked to the CMDB: use them to group, label and explain (a zone for a site or a VLAN, a sticky note, a title).
- Add - drag a shape onto the canvas, or click it to drop it in the middle of the view
- Move and resize - drag it, or drag any of the eight squares around a selected shape. Arrow keys nudge one pixel, Shift and an arrow ten. A shape can be rotated
- Type - double-click and type. Enter starts a new line; click elsewhere to finish, Esc cancels
- Format panel - fill (none, a colour or a gradient), border (colour, width, solid / dashed / dotted), opacity, shadow, rounded corners, and the font, size, colour and alignment of its text. Right-click Copy style / Paste style carries a look from one item to another
- Arrange - Behind nodes keeps a zone underneath everything, In front puts a shape over the nodes, and Front / Back reorder shapes within the same layer
Libraries on the Shapes tab opens the icon catalogue from icons.diagrams.net - about a thousand sets, from vendors such as AWS, Azure, Cisco and Kubernetes to general-purpose sets.
- Search the list, or filter it by All, Vendors or Imported
- Click a set to preview every icon in it, with its licence, author and source
- Import copies the icons into this install in batches, with a progress bar. After that they need no internet connection
Imported sets appear as groups on the Shapes tab; drag an icon onto the canvas like any shape. Every icon is cleaned when it is imported (no script, event handlers or outside references survive), and served so that even opening its address directly runs nothing. Any analyst with Network Mapper access can import or remove a set.
Upload on the Shapes tab adds your own pictures - PNG, JPEG, GIF or WebP, up to 4 MB each - to a shared My images group. Or copy a picture or a screenshot and press Ctrl+V on the diagram: it lands where the mouse is, at up to 240px, keeping its shape.
Pictures are checked by their contents, not just their name, and SVG is never accepted from an upload. The small cross on a picture in the palette removes it from the group - it shows on your own pictures, and an admin sees it on all of them. Shapes already using the picture keep their place.
One diagram can have several pages - an overview, then a page per site or per rack - and each page has layers.
| Pages (tabs under the canvas) | |
|---|---|
| Add | + at the end of the tabs |
| Rename | Double-click a tab |
| Duplicate, move, delete | Right-click a tab. Duplicate copies the page with its connectors |
| Move between pages | Click a tab, or Page Up / Page Down (in Present mode too) |
| Layers (the Layers button) | |
|---|---|
| Active layer | Click a layer: new nodes and shapes go on it |
| Show / hide | The eye |
| Lock | The padlock - nothing on a locked layer can be selected or moved |
| Order | The arrows. Things on a higher layer are drawn over those on a lower one |
| Rename | Double-click the name |
| Delete | What was on it moves to the layer below |
To move something to another layer, select it and pick the Layer in its side panel, or right-click it. Each page has its own CMDB objects, so the same server can appear on the overview and on its site page. Export and Present show the page you are on, without its hidden layers.
Background Picture (discussion #434)
Each page can have a background: a floor plan, a site map or a photo of a rack, so icons and CMDB objects go where they really are.
| Set it | Layers β Set background, or right-click an empty part of the page β Background... |
| From | A PNG, JPEG, GIF or WebP upload, a page of a PDF (you pick which), or one of My images |
| From Visio | File β Save As β PDF or PNG in Visio first; .vsdx files aren't read |
| Where it goes | Its own Background layer, always at the bottom and locked, so clicking on the plan never moves it. Fitted to the paper when one is set, otherwise to what is on the page |
| Adjust it | Layers β Adjust, or right-click β Adjust background: drag to move, corners keep its shape (Shift stretches), and a bar with Opacity, Fit, Original, Remove and Done (or Esc) |
| Change or remove | Layers β Change / Remove. The picture stays in My images |
A big picture is made smaller in the browser (up to 4,000 pixels across, as WebP) before it's uploaded, so it works whatever the server's upload limit. A PDF page is drawn in the browser with the same pdf.js the Files module uses. Corner handles keep every picture's proportions now, not only a background's; the side handles still stretch it one way.
A read-only map for other people: export the page as PNG or PDF and Save to Files into a folder their team can open (saving again with the same name adds a new version), or put it in a Knowledge article with Insert picture from Files so requesters see it in the Help Centre. Both are snapshots. The design and what might follow: A background picture on a diagram page - design.
- Shift+click or Ctrl+click adds or removes an item; drag on empty space draws a selection box; Ctrl+A selects everything on the page
- The selection moves together, nudges with the arrow keys and deletes with Delete
- The Selection panel aligns (left, centre, right, top, middle, bottom), distributes across or down, moves everything to a layer and styles every item at once
- Group (Ctrl+G) keeps items together: a click selects the whole group, Alt+click picks one item inside it. Ungroup is Ctrl+Shift+G
- Ctrl+C / Ctrl+V copy and paste onto any page, and Ctrl+X cuts. Connectors between copied items come too; a CMDB object that is already on the target page is left out, because one object appears once per page
Right-click anything for what you can do with it:
| On | You get |
|---|---|
| A shape | Edit text, cut / copy / paste / duplicate / delete, bring to front / send to back, behind or in front of nodes, move to layer, copy / paste / reset style, link a Knowledge article |
| A node | Open in CMDB, add related objects, change icon, cut / copy / delete, move to layer, style, link a Knowledge article |
| A connector | Edit label, swap, route, delete |
| A selection | Cut, copy, delete, group / ungroup, align, distribute, move to layer, paste style |
| Empty canvas | Paste here (drops it where you clicked), select all, zoom to fit, centre |
| A page tab | Rename, duplicate, move, delete |
On a read-only version the menus only offer what changes nothing.
Diagrams and Knowledge articles can point at each other in two ways:
- On a node or a shape - Link beside Article in its side panel (or right-click it) and pick an article. A small book marks the item; click the book to open the article. In Present mode a plain click on the item opens it
- On the whole diagram - the Articles button in the toolbar lists related articles (a runbook, the site's documentation) and adds or removes them
It works both ways: an article lists the diagrams that use it under Network diagrams, so a reader can jump from the runbook to the picture. Knowledge's own visibility rules apply throughout - an article you cannot read shows as an article you don't have access to, never its title. Links you add go on the version you are editing, and Save as new version carries them forward.
The Paper button in the toolbar (it reads Paper: Off or Paper: A4 Portrait) cycles between Off / A4 / A3 / A2 / Letter / Tabloid Γ portrait / landscape. Picking a size renders a subtle dashed cyan outline at the actual paper dimensions (96 DPI). Useful for composing diagrams inside the printable area before sharing / exporting.
- Persisted per-diagram (
paper_size+paper_orientationcolumns) - Carried forward on save-as-new-version so analysts don't re-pick on every fork
- Corner text label names the paper (e.g. A3 landscape) so the active size is visible at a glance
- The outline renders inside the SVG layer with a soft white fill that lets the dot-grid bleed through, so on-page vs off-page is visually distinct
- Drives the export bounds β see PNG / PDF Export below
- Read-only versions can view the outline but can't change it (rejected with a toast)
Six-slot strip (left / centre / right, top + bottom) rendered along the page outline edges. Renders the org logo, title, author, version, modified date β same six anchors as a Word header / footer.
Org-wide defaults configured at System β Branding (logo upload + the six text slots). Per-diagram override via the Branding button in the editor toolbar β modal shows the org defaults as input placeholders so you see what you're overriding.
Template tokens resolved client-side at render time:
| Token | Renders |
|---|---|
{{logo}} |
The org-wide uploaded logo as an <img>
|
{{title}} |
Diagram title |
{{author}} |
Author's full name |
{{version}} |
Version label |
{{modified}} |
Locale-formatted updated datetime |
{{page}}, {{pages}}
|
1 - a diagram is one page. The tokens exist for Knowledge article PDFs (5.15.0, #493); before then a diagram would have printed them as typed |
Tokens are HTML-escaped at substitution so a diagram named <script> can't break out into JS. The logo renders as an <img> with max-height 28px so it sits neatly inside the strip. Requires a page size to be set (the page outline gives the strip its anchor points). Empty slots in the override modal mean explicit blank (overrides the org default with nothing); Reset clears all six overrides back to NULL so they inherit again. Per-diagram overrides live on six nullable VARCHAR(200) columns on network_diagrams and are carried forward on save-as-new-version.
Zoom controls β segmented 4-button group in the toolbar: β zoom out / current level (click to reset to 100%) / + zoom in / Fit (scales to fit the page outline if set, else the bounding box of placed nodes + 40px padding). Discrete steps: 25 / 50 / 75 / 100 / 125 / 150 / 200 / 300%.
Present mode β Present button hides everything except the canvas (toolbar, palette, detail panel, meta row, read-only banner) so screen-sharing the diagram in a meeting doesn't reveal the editor chrome. A floating Exit Present pill (top-right) leaves it; Esc also exits regardless of focus. Also hides the module nav bar and tight-fits the diagram edge-to-edge. F11 takes the browser fullscreen for a true edge-to-edge view. Restores the user's previous zoom + scroll on exit.
One-click button that recentres every node so the diagram's bounding box sits centred on the selected paper size. Computes the bbox of placed nodes including the label that hangs below each icon (so optical centre matches visual centre), reads the page rectangle, computes the shift, snaps the delta to 20px (preserving the grid), and applies it to every node. Persistent β mutates node coordinates so the centring survives save / reload and is captured by exports.
PNG and PDF buttons in the toolbar produce WYSIWYG snapshots of the page you are on, without its hidden layers. Each button asks where the file should go:
- Download - saves it to your computer, as before
- Save to Files - opens the same Save to Files dialog tickets use: pick a folder you can upload to, and if a file with that name is already there choose New version, Keep both or Skip. Only export formats are accepted this way, checked by their contents
Without the Files module the buttons just download. Capture clips exactly to the page rectangle if a paper size is set, otherwise crops to the bounding box of placed nodes plus 40px padding. Branding header / footer, page outline, connectors, node icons, and labels all render in the output exactly as they appear on screen.
- html2canvas 1.4.1 (~200 KB) for rasterisation; the picture is placed in the PDF by FreeITSM's shared PDF writer (
assets/js/pdf-writer.js, on PDFKit 0.20.2, since #254) - all vendored locally so the feature works offline - 2Γ scale for crisp output on retina screens and during presentations
- PDFs use the actual paper size + orientation so the file opens at the right physical dimensions for printing
- Filename slugifies the diagram title + version label (e.g. Production Network v2 β
production-network-v2.png) - Selection rings / connector cyan-highlights are hidden during capture so they don't bleed into the output (via an
.is-exportingclass that also hides edge handles and the empty-state placeholder) - The capture pass stashes the current zoom / scroll / selection, resets zoom to 1Γ so the rasteriser captures at native resolution, then restores everything afterwards
- Refuses to export an empty diagram with no paper size set (toast: "Nothing to export β place some nodes or set a page size first")
- Read-only versions can export too β it's a view-only operation
Every diagram is part of a linear version chain. The leaf (no children) is the editable current version; older nodes in the chain are read-only history.
-
Save as new version clones the current state forward into a new editable leaf and demotes the old leaf to historical. It auto-saves first if the canvas is dirty (since
create_version.phpclones from the persisted state), then opens a modal pre-filled with the current diagram's metadata and a suggested incremented label β the trailing integer in the version label bumps automatically (v3βv4) -
Versions dropdown in the toolbar lists the chain β newest first, each row showing author + date, with a cyan Viewing pill on the current view, cyan Current pill on the editable leaf, amber Read-only pill on the rest. Rows are real
<a href>links so middle-click / Ctrl-click opens in a new tab for side-by-side comparison - Copies everything - shapes, pages, layers, groups, styles and Knowledge links all come forward into the new version
- No branching - a parent can have at most one child; the chain is strictly linear. Need to explore an alternative? Create a separate diagram
Read-only versions render an amber banner across the top, disable Save + Save-as-new-version, and gate markDirty() so even programmatic edits can't dirty them. The Branding modal also can't open on a historical version.
Two modes:
-
Autosave (toggle in the toolbar) β saves ~2 seconds after your last edit. Word-style status indicator cycles through Unsaved / Savingβ¦ / β Saved / β Save failed β retry / Autosave off. Toggle state persisted per-analyst in
user_preferencesunder thenetwork_mapper_autosavekey - Manual save β Save button or Ctrl+S. Works regardless of autosave state
Autosave defers if you're mid-drag so a save never clobbers a drag in progress. Browser beforeunload prompts on navigate if there are unsaved changes.
Interactive help guide with a sticky scroll-spy sidebar covering the end-to-end workflow: overview, creating a diagram, placing nodes, drawing connectors, shapes and styling, pages and layers, adding related objects, planned objects, paper size, header and footer, versioning, saving, and quick tips.
| Table | Purpose |
|---|---|
network_diagrams |
One row per version. parent_diagram_id self-FK chains versions; the leaf (no children) is current. Holds title, description, version_label, paper_size, paper_orientation, the 6 header / footer override columns |
network_diagram_nodes |
Node placements: diagram_id, the cmdb_object_id binding, x / y, size, icon_override, colour_override, w / h, style, page_key, layer_key, group_key, article_id
|
network_diagram_connectors |
Edges between nodes (from_node_id / to_node_id) or shapes (from_shape_uid / to_shape_uid), with optional cmdb_relationship_id (provenance), label, line_style and style
|
network_diagram_shapes |
Freestanding shapes and placed icons: shape_type, position, size, rotation, text, style, layer / z (drawing order), icon_id, page_key, layer_key, group_key, uid, article_id
|
network_diagram_pages |
The page tabs of a version: page_key, name, sort
|
network_diagram_layers |
The layers of each page: layer_key, name, sort, visible, locked
|
network_diagram_articles |
Knowledge articles related to the whole diagram |
network_icon_libraries |
Imported icon sets, and the shared My images set: slug, title, licence, author, source, counts, status
|
network_icon_library_icons |
The icons themselves (mime, data, w / h), served by api/network-mapper/icon.php
|
Foreign keys cascade - delete a diagram and its nodes, connectors, shapes, pages and layers go too; delete a node and its connectors go too. The parent_diagram_id FK uses ON DELETE SET NULL so deleting one version doesn't cascade the chain, and deleting a Knowledge article clears the links to it rather than touching the diagram.
| Endpoint | Purpose |
|---|---|
list_diagrams.php |
Leaf-only diagram list with per-row node / connector / version counts |
list_versions.php |
Root-to-leaf chain for a given diagram, each flagged is_current
|
get_diagram.php |
Single version hydrated β nodes carry CMDB object name / class / icon / planned flag; connectors include CMDB relationship link |
create_diagram.php |
POST title / description / version_label |
create_version.php |
Clones nodes, connectors, shapes, pages, layers and Knowledge links forward into a new diagram row chained to the parent. Refuses to fork an already-forked parent (no branching in v1) |
save_diagram.php |
Transactional delete + reinsert with tempβreal node id mapping. Refuses non-leaf versions. Per-field partial saves supported |
delete_diagram.php |
Single version delete β older versions preserved via the SET NULL parent FK |
articles.php |
Knowledge links: search articles, list the diagrams using an article, add / remove a related article |
icon_libraries.php |
The icons.diagrams.net catalogue, preview, batched import, My images upload / delete, and the Shapes tab palette |
icon.php |
Serves one imported icon or picture (sandbox CSP, cached) |
get_related_objects.php |
Powers Add related objects β returns the three buckets (outgoing / incoming / property-ref) for a given source object |
list_diagrams.php finds the leaves with WHERE id NOT IN (SELECT parent_diagram_id β¦) β a leaf is simply a version no other version points at as its parent.