Sites on a map, rooms, floor plans with racks you can place
CI / go (push) Successful in 42s
CI / agent (push) Successful in 3s
CI / site (push) Successful in 2s

The Sites page shows sites on an OpenStreetMap map (Leaflet 1.9.4 in the
binary, checked against cdnjs's SRI; the CSP allows OSM tiles and the
tile layer sends a referrer as OSM's policy asks). A site opens its
rooms, a room its floor plan: racks on 600 mm tiles, one wide and two
deep, front edge marked, coloured by their machines with a bar for the
units used; a rack opens its front, and the rack is part of the URL.
An edit mode drags racks into place and rotates them; racks nobody
placed are laid out in rows facing alternate aisles.

With NetBox as the IPAM authority, sites (coordinates, address),
locations and racks are read on every reconcile, never written back.
Otherwise sites are placed by clicking the map. Rack positions are
Rollcall's (NetBox has none).

Checked in headless Chrome with a synthetic site, including a scripted
drag, rotate and save of a rack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-11-01 00:20:56 +01:00
1 parent 9b0b27fce6
commit 148c602b82
15 files changed
+1420 -35

No files matched your search

+6
View File
@@ -7,6 +7,12 @@ publish a tag that has no section here.
## [Unreleased]
### Added
- Sites page: sites on an OpenStreetMap map (Leaflet shipped in the binary), a site's rooms, and a
room's floor plan with racks on 600 mm tiles coloured by their machines; a rack opens its front.
Racks are placed by dragging and rotated in an edit mode; unplaced ones are laid out
automatically. With NetBox, sites (with coordinates), locations and racks are read from it;
otherwise, or without coordinates there, sites are placed on the map. `/api/v1/sites`,
`/api/v1/rooms`, `POST /api/v1/racks/positions`. The web UI's CSP allows OSM tile images.
- Server heights without typing them in: SMBIOS chassis height from commissioning, else a model
table checked against vendor documentation (Dell, HPE, Lenovo, xFusion, Fujitsu, Inspur/KAYTUS,
GIGABYTE; not Supermicro, whose model numbers do not carry it), else `rack_units` per model in
+16
View File
@@ -308,6 +308,22 @@ units: the elevation draws them as one block, and NetBox gets a device type
of height 0 placed in the rack without a position. The elevation spans each
server over its height, marks unknown heights `?U` and warns about overlaps.
**Sites, rooms and floor plans.** The **Sites** page puts sites on an
OpenStreetMap map (Leaflet, shipped in the binary; the browser loads tiles
from `tile.openstreetmap.org`), coloured by the worst machine state; a site
opens its rooms, a room its floor plan: racks on 600 mm floor tiles, one wide
and two deep, a thick edge for the front, coloured by their machines with a
bar for the units used; a rack opens its front (the elevation above), and
`#/sites/SITE/ROOM/RACK` links to it. **Edit layout** drags racks to their
place and rotates them; racks nobody placed are laid out in rows facing
alternate aisles (drawn dashed). With NetBox as the IPAM authority, sites
(name, coordinates, address), locations (rooms) and racks (name, height) are
read from it on every reconcile and never written back; without NetBox, or
for a site NetBox has no coordinates for, sites are placed by clicking the
map. Rack positions are Rollcall's either way (NetBox has no floor
coordinates). API: `/api/v1/sites`, `/api/v1/rooms`, `POST
/api/v1/racks/positions`.
## Network and rack controllers
### Model
+5
View File
@@ -327,6 +327,11 @@ func (a *App) reconcileIPAM(ctx context.Context, dry bool) ipamReport {
return rep
}
a.reconcileAddrs(ctx, local, &rep)
if !dry { // the map and floor plans follow NetBox's sites, locations and racks
if err := a.syncLayout(ctx); err != nil {
rep.fail("layout: " + err.Error())
}
}
if nb, ok := a.ipam.(*netBox); ok && a.cfg.IPAM.DeviceSync != nil && !dry {
// after the addresses: the sync assigns them to the interfaces
if ms, err := a.store.List(ctx); err != nil {
+289
View File
@@ -0,0 +1,289 @@
package main
// Physical layout: sites with coordinates (the map), rooms and where each
// rack stands in its room (the floor plan). With NetBox as the IPAM
// authority, sites (name, coordinates, address), locations (rooms) and racks
// (name, height) are read from it on every reconcile and never written back;
// otherwise they are entered here. Rack positions are Rollcall's either way:
// NetBox has no floor coordinates. A position is in floor tiles (600 mm): a
// rack is one tile wide and two deep, its front facing N, E, S or W.
//
// A machine's building is matched to a site by name or slug, ignoring case.
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"
)
type Site struct {
Name string `json:"name"`
Slug string `json:"slug,omitempty"`
Lat *float64 `json:"lat"`
Lon *float64 `json:"lon"`
Address string `json:"address,omitempty"`
Source string `json:"source"` // local | netbox
}
type Room struct {
Building string `json:"building"`
Name string `json:"name"`
Width int `json:"width"` // floor tiles; 0 = from the racks
Depth int `json:"depth"`
Source string `json:"source"`
}
// ---------------------------------------------------------------- store
func (s *Store) Sites(ctx context.Context) ([]Site, error) {
rows, err := s.pool.Query(ctx, `SELECT name, coalesce(slug,''), lat, lon, coalesce(address,''), source FROM sites ORDER BY name`)
if err != nil {
return nil, err
}
defer rows.Close()
out := []Site{}
for rows.Next() {
var x Site
if err := rows.Scan(&x.Name, &x.Slug, &x.Lat, &x.Lon, &x.Address, &x.Source); err != nil {
return nil, err
}
out = append(out, x)
}
return out, rows.Err()
}
// PutSite stores a site; coordinates that are nil keep the stored ones.
func (s *Store) PutSite(ctx context.Context, x Site) error {
_, err := s.pool.Exec(ctx, `INSERT INTO sites(name, slug, lat, lon, address, source) VALUES ($1, nullif($2,''), $3, $4, nullif($5,''), $6)
ON CONFLICT (name) DO UPDATE SET slug=coalesce(nullif($2,''), sites.slug), lat=coalesce($3, sites.lat), lon=coalesce($4, sites.lon),
address=coalesce(nullif($5,''), sites.address), source=$6`, x.Name, x.Slug, x.Lat, x.Lon, x.Address, orDefault(x.Source, "local"))
return err
}
func (s *Store) DeleteSite(ctx context.Context, name string) error {
_, err := s.pool.Exec(ctx, `DELETE FROM sites WHERE name=$1`, name)
return err
}
func (s *Store) Rooms(ctx context.Context) ([]Room, error) {
rows, err := s.pool.Query(ctx, `SELECT building, name, width, depth, source FROM rooms ORDER BY building, name`)
if err != nil {
return nil, err
}
defer rows.Close()
out := []Room{}
for rows.Next() {
var x Room
if err := rows.Scan(&x.Building, &x.Name, &x.Width, &x.Depth, &x.Source); err != nil {
return nil, err
}
out = append(out, x)
}
return out, rows.Err()
}
// PutRoom stores a room; a size of 0 keeps the stored one.
func (s *Store) PutRoom(ctx context.Context, x Room) error {
_, err := s.pool.Exec(ctx, `INSERT INTO rooms(building, name, width, depth, source) VALUES ($1,$2,$3,$4,$5)
ON CONFLICT (building, name) DO UPDATE SET width=CASE WHEN $3>0 THEN $3 ELSE rooms.width END,
depth=CASE WHEN $4>0 THEN $4 ELSE rooms.depth END, source=$5`, x.Building, x.Name, x.Width, x.Depth, orDefault(x.Source, "local"))
return err
}
// SetRackPosition places a rack on its room's floor (nil x/y: back to automatic).
func (s *Store) SetRackPosition(ctx context.Context, building, room, name string, x, y *int, facing string) error {
tag, err := s.pool.Exec(ctx, `UPDATE racks SET x=$4, y=$5, facing=nullif($6,'') WHERE building=$1 AND room=$2 AND name=$3`, building, room, name, x, y, facing)
if err != nil {
return err
}
if tag.RowsAffected() == 0 {
return errNotFound
}
return nil
}
// ---------------------------------------------------------------- handlers
func (a *App) handleSites(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
xs, err := a.store.Sites(r.Context())
if err != nil {
fail(w, 500, err)
return
}
writeJSON(w, 200, xs)
case http.MethodPost:
var x Site
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<16)).Decode(&x); err != nil || strings.TrimSpace(x.Name) == "" {
fail(w, 400, errors.New("name is required"))
return
}
x.Name, x.Source = strings.TrimSpace(x.Name), "local"
if (x.Lat == nil) != (x.Lon == nil) || x.Lat != nil && (*x.Lat < -90 || *x.Lat > 90 || *x.Lon < -180 || *x.Lon > 180) {
fail(w, 400, errors.New("lat and lon go together: -90..90, -180..180"))
return
}
if cur, _ := a.store.Sites(r.Context()); a.ipamIsNetBox() {
for _, c := range cur {
if c.Name == x.Name && c.Source == "netbox" {
x.Source = "netbox" // coordinates set here stand until NetBox has its own
}
}
}
if err := a.store.PutSite(r.Context(), x); err != nil {
fail(w, 500, err)
return
}
writeJSON(w, 200, x)
case http.MethodDelete:
if err := a.store.DeleteSite(r.Context(), r.URL.Query().Get("name")); err != nil {
fail(w, 500, err)
return
}
writeJSON(w, 200, obj{"deleted": r.URL.Query().Get("name")})
}
}
func (a *App) handleRooms(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
xs, err := a.store.Rooms(r.Context())
if err != nil {
fail(w, 500, err)
return
}
writeJSON(w, 200, xs)
case http.MethodPost:
var x Room
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<16)).Decode(&x); err != nil || strings.TrimSpace(x.Building) == "" {
fail(w, 400, errors.New("building is required"))
return
}
if x.Width < 0 || x.Depth < 0 || x.Width > 500 || x.Depth > 500 {
fail(w, 400, errors.New("width and depth are floor tiles, 0..500"))
return
}
x.Source = "local"
if err := a.store.PutRoom(r.Context(), x); err != nil {
fail(w, 500, err)
return
}
writeJSON(w, 200, x)
}
}
// handleRackPositions places racks: [{"building","room","name","x","y","facing"}].
func (a *App) handleRackPositions(w http.ResponseWriter, r *http.Request) {
var req []struct {
Building, Room, Name string
X, Y *int
Facing string
}
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20)).Decode(&req); err != nil {
fail(w, 400, err)
return
}
for _, p := range req {
if p.Facing != "" && !strings.Contains("NESW", p.Facing) || len(p.Facing) > 1 {
fail(w, 400, fmt.Errorf("%s: facing is N, E, S or W", p.Name))
return
}
if (p.X == nil) != (p.Y == nil) || p.X != nil && (*p.X < 0 || *p.Y < 0 || *p.X > 500 || *p.Y > 500) {
fail(w, 400, fmt.Errorf("%s: x and y go together, 0..500 tiles", p.Name))
return
}
if err := a.store.SetRackPosition(r.Context(), p.Building, p.Room, p.Name, p.X, p.Y, p.Facing); err != nil {
fail(w, 400, fmt.Errorf("%s: %w", p.Name, err))
return
}
}
writeJSON(w, 200, obj{"placed": len(req)})
}
func (a *App) ipamIsNetBox() bool { _, ok := a.ipam.(*netBox); return ok }
// ---------------------------------------------------------------- NetBox
// syncLayout copies NetBox's sites, locations and racks: what Rollcall shows
// on the map and the floor plans. Nothing is deleted here: a site, room or
// rack that left NetBox stays until removed by hand.
func (a *App) syncLayout(ctx context.Context) error {
nb, ok := a.ipam.(*netBox)
if !ok {
return nil
}
sites, rooms, racks, err := nb.layout(ctx)
if err != nil {
return err
}
for _, x := range sites {
if err := a.store.PutSite(ctx, x); err != nil {
return err
}
}
for _, x := range rooms {
if err := a.store.PutRoom(ctx, x); err != nil {
return err
}
}
have, _ := a.store.Racks(ctx)
for _, x := range racks {
for _, h := range have { // keep the comment written here
if h.Building == x.Building && h.Room == x.Room && h.Name == x.Name {
x.Comment = h.Comment
}
}
if err := a.store.PutRack(ctx, x); err != nil {
return err
}
}
return nil
}
// layout reads NetBox's sites (coordinates when set), locations as rooms and racks.
func (n *netBox) layout(ctx context.Context) ([]Site, []Room, []Rack, error) {
ss, err := n.all(ctx, "dcim/sites/", nil)
if err != nil {
return nil, nil, nil, err
}
var sites []Site
byID := map[int64]string{}
for _, s := range ss {
name := str(s["name"])
byID[nbID(s)] = name
x := Site{Name: name, Slug: str(s["slug"]), Address: oneLine(str(s["physical_address"])), Source: "netbox"}
if lat, ok := s["latitude"].(float64); ok {
if lon, ok := s["longitude"].(float64); ok {
x.Lat, x.Lon = &lat, &lon
}
}
sites = append(sites, x)
}
ls, err := n.all(ctx, "dcim/locations/", nil)
if err != nil {
return nil, nil, nil, fmt.Errorf("locations: %w", err)
}
var rooms []Room
locName := map[int64]string{}
for _, l := range ls {
locName[nbID(l)] = str(l["name"])
if site := byID[nbRef(l, "site")]; site != "" {
rooms = append(rooms, Room{Building: site, Name: str(l["name"]), Source: "netbox"})
}
}
rs, err := n.all(ctx, "dcim/racks/", nil)
if err != nil {
return nil, nil, nil, fmt.Errorf("racks: %w", err)
}
var racks []Rack
for _, rk := range rs {
if site := byID[nbRef(rk, "site")]; site != "" {
racks = append(racks, Rack{Building: site, Room: locName[nbRef(rk, "location")], Name: str(rk["name"]), Height: int(num(rk["u_height"]))})
}
}
return sites, rooms, racks, nil
}
+44
View File
@@ -0,0 +1,44 @@
package main
import (
"fmt"
"testing"
)
func TestNetBoxLayout(t *testing.T) {
nb, f := testDCIM(t) // sites Ev and DC1, location Hall A (DC1), rack R12 in both
dc := f.find("dcim/sites/", "slug", "dc1")
dc["latitude"], dc["longitude"], dc["physical_address"] = 41.0082, 28.9784, "Hall Street 1\nIstanbul"
for _, r := range f.objs["dcim/racks/"] {
r["u_height"] = float64(48)
if r["site"] == dc["id"] {
r["location"] = f.find("dcim/locations/", "name", "Hall A")["id"]
}
}
sites, rooms, racks, err := nb.layout(t.Context())
if err != nil {
t.Fatal(err)
}
got := map[string]Site{}
for _, s := range sites {
got[s.Name] = s
}
if d := got["DC1"]; d.Lat == nil || *d.Lat != 41.0082 || *d.Lon != 28.9784 || d.Address != "Hall Street 1 · Istanbul" || d.Slug != "dc1" || d.Source != "netbox" {
t.Fatalf("DC1: %+v", d)
}
if e := got["Ev"]; e.Lat != nil {
t.Fatalf("a site without coordinates got some: %+v", e)
}
if fmt.Sprint(rooms) != "[{DC1 Hall A 0 0 netbox}]" {
t.Fatalf("rooms %v", rooms)
}
want := map[string]string{"DC1": "Hall A", "Ev": ""}
for _, r := range racks {
if r.Name != "R12" || r.Height != 48 || want[r.Building] != r.Room {
t.Fatalf("rack %+v", r)
}
}
if len(racks) != 2 {
t.Fatalf("racks %v", racks)
}
}
+6 -2
View File
@@ -50,6 +50,10 @@ type Rack struct {
Height int `json:"height"`
Comment string `json:"comment"`
Machines int `json:"machines,omitempty"`
// on the room's floor (layout.go): tiles from the room's corner, front facing N/E/S/W
X *int `json:"x"`
Y *int `json:"y"`
Facing string `json:"facing,omitempty"`
}
// ---------------------------------------------------------------- store
@@ -67,7 +71,7 @@ func (s *Store) SetLocation(ctx context.Context, id string, l Location) error {
}
func (s *Store) Racks(ctx context.Context) ([]Rack, error) {
rows, err := s.pool.Query(ctx, `SELECT building, room, name, height, coalesce(comment,'') FROM racks ORDER BY building, room, name`)
rows, err := s.pool.Query(ctx, `SELECT building, room, name, height, coalesce(comment,''), x, y, coalesce(facing,'') FROM racks ORDER BY building, room, name`)
if err != nil {
return nil, err
}
@@ -75,7 +79,7 @@ func (s *Store) Racks(ctx context.Context) ([]Rack, error) {
out := []Rack{}
for rows.Next() {
var r Rack
if err := rows.Scan(&r.Building, &r.Room, &r.Name, &r.Height, &r.Comment); err != nil {
if err := rows.Scan(&r.Building, &r.Room, &r.Name, &r.Height, &r.Comment, &r.X, &r.Y, &r.Facing); err != nil {
return nil, err
}
out = append(out, r)
+7 -1
View File
@@ -285,6 +285,12 @@ func (a *App) routes() http.Handler {
mux.HandleFunc("GET /api/v1/racks", a.adminAuth(a.handleRacks))
mux.HandleFunc("POST /api/v1/racks", a.adminAuth(a.handleRacks))
mux.HandleFunc("DELETE /api/v1/racks", a.adminAuth(a.handleRacks))
mux.HandleFunc("POST /api/v1/racks/positions", a.adminAuth(a.handleRackPositions))
mux.HandleFunc("GET /api/v1/sites", a.adminAuth(a.handleSites))
mux.HandleFunc("POST /api/v1/sites", a.adminAuth(a.handleSites))
mux.HandleFunc("DELETE /api/v1/sites", a.adminAuth(a.handleSites))
mux.HandleFunc("GET /api/v1/rooms", a.adminAuth(a.handleRooms))
mux.HandleFunc("POST /api/v1/rooms", a.adminAuth(a.handleRooms))
// tags
mux.HandleFunc("GET /api/v1/tags", a.adminAuth(a.handleTags))
mux.HandleFunc("POST /api/v1/tags", a.adminAuth(a.handleTags))
@@ -311,7 +317,7 @@ func (a *App) routes() http.Handler {
func uiHeaders(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h := w.Header()
h.Set("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'")
h.Set("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://tile.openstreetmap.org; connect-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'")
h.Set("X-Content-Type-Options", "nosniff")
h.Set("X-Frame-Options", "DENY")
h.Set("Referrer-Policy", "no-referrer")
+19
View File
@@ -101,6 +101,25 @@ CREATE TABLE IF NOT EXISTS racks (
comment text,
PRIMARY KEY (building, room, name)
);
ALTER TABLE racks ADD COLUMN IF NOT EXISTS x int;
ALTER TABLE racks ADD COLUMN IF NOT EXISTS y int;
ALTER TABLE racks ADD COLUMN IF NOT EXISTS facing text;
CREATE TABLE IF NOT EXISTS sites (
name text PRIMARY KEY,
slug text,
lat double precision,
lon double precision,
address text,
source text NOT NULL DEFAULT 'local'
);
CREATE TABLE IF NOT EXISTS rooms (
building text NOT NULL,
name text NOT NULL,
width int NOT NULL DEFAULT 0,
depth int NOT NULL DEFAULT 0,
source text NOT NULL DEFAULT 'local',
PRIMARY KEY (building, name)
);
ALTER TABLE machines ADD COLUMN IF NOT EXISTS rack_controller text;
ALTER TABLE machines ADD COLUMN IF NOT EXISTS net_layout text;
ALTER TABLE tags ADD COLUMN IF NOT EXISTS net_layout text;
+41 -32
View File
@@ -14,7 +14,7 @@ let token = '';
try { token = localStorage.getItem('rollcall.token') || ''; } catch (e) { /* storage unavailable */ }
// ?token=… on the URL signs in once and is removed from the address bar (for bookmarks/kiosks)
{ const u = new URL(location.href); const t = u.searchParams.get('token'); if (t) { token = t; try { localStorage.setItem('rollcall.token', t); } catch (e) { /* ignore */ } u.searchParams.delete('token'); history.replaceState(null, '', u.pathname + u.search + u.hash); } }
const S = { machines: [], tags: [], profiles: [], os: [], jobs: [], events: [], racks: [], subnets: [], controllers: [], layouts: [], fabrics: [], ips: [], ipam: null, sel: new Set(), q: '', states: new Set(), tagf: new Set(), loc: { building: '', room: '', rack: '' }, page: 0, per: 50, sort: 'name', dir: 1, loaded: false };
const S = { sites: [], rooms: [], machines: [], tags: [], profiles: [], os: [], jobs: [], events: [], racks: [], subnets: [], controllers: [], layouts: [], fabrics: [], ips: [], ipam: null, sel: new Set(), q: '', states: new Set(), tagf: new Set(), loc: { building: '', room: '', rack: '' }, page: 0, per: 50, sort: 'name', dir: 1, loaded: false };
const locStr = l => { if (!l) return ''; const p = [l.building, l.room, l.rack].filter(Boolean).join(' / '); return p + (l.unit ? ` U${l.unit}` : ''); };
let timer = null;
@@ -77,6 +77,7 @@ async function refresh(full) {
const page = route().page;
if (full || page === 'overview' || page === 'jobs') S.jobs = await api('GET', '/api/v1/jobs');
if (full || page === 'overview') S.events = await api('GET', '/api/v1/events');
if (full || page === 'sites') [S.sites, S.rooms] = await Promise.all([api('GET', '/api/v1/sites'), api('GET', '/api/v1/rooms')]);
if (full || page === 'overview' || page === 'network') {
[S.ips, S.ipam] = await Promise.all([api('GET', '/api/v1/ips'), api('GET', '/api/v1/ipam').catch(() => null)]);
}
@@ -102,7 +103,7 @@ function schedule() {
function route() {
const h = location.hash.replace(/^#\/?/, '').split('/');
if (h[0] === 'machine' && h[1]) return { page: 'machine', id: h[1], tab: h[2] || 'overview' };
return { page: h[0] || 'overview', arg: h[1] };
return { page: h[0] || 'overview', arg: h[1], arg2: h[2], arg3: h[3] };
}
window.addEventListener('hashchange', () => { S.sel.clear(); render(); });
function nav(page) { location.hash = '#/' + page; }
@@ -117,11 +118,13 @@ function render() {
const r = route();
$$('.side a[data-nav]').forEach(a => a.classList.toggle('active', a.dataset.nav === r.page || (r.page === 'machine' && a.dataset.nav === 'machines')));
const main = $('#main');
if (r.page !== 'sites') { main.dataset.view = ''; if (SITE.map) { SITE.map.remove(); SITE.map = null; } SITE.edit = null; }
switch (r.page) {
case 'machines': main.innerHTML = pageMachines(); wireMachines(); break;
case 'machine': if (!detailCache[r.id]) { main.innerHTML = '<p class="muted">loading…</p>'; loadDetail(r.id); } else { main.innerHTML = pageMachine(detailCache[r.id], r.tab); wireMachine(detailCache[r.id]); } break;
case 'jobs': main.innerHTML = pageJobs(); wireJobs(); break;
case 'racks': main.innerHTML = pageRacks(); wireRacks(); break;
case 'sites': renderSites(); break;
case 'network': main.innerHTML = pageNetwork(); wireNetwork(); break;
case 'tags': main.innerHTML = pageTags(); wireTags(); break;
case 'profiles': main.innerHTML = pageProfiles(); wireProfiles(); break;
@@ -597,6 +600,41 @@ function pageJobs() {
function wireJobs() { $('#refresh').onclick = () => refresh(true); }
// ---------------------------------------------------------------- racks
// rackElev: a rack's front, servers spanning their height (shared by the
// Racks page and the floor plans in sites.js)
function rackElev(rk) {
const keyOf = (b, rm, n) => `${b}|${rm}|${n}`;
const placed = S.machines.filter(m => m.location && m.location.rack);
const ms = placed.filter(m => (m.location.building || '') === rk.building && (m.location.room || '') === rk.room && m.location.rack === rk.name);
// blocks of units: a server spans its height (size from the firmware or the
// model, ?U when unknown); sleds of one multi-node chassis share one block
const H = rk.height || 42, noU = [], blocks = [];
for (const m of ms) {
if (!(m.location.unit > 0)) { noU.push(m); continue; }
const sz = m.size || {}, h = Math.max(1, sz.u || 1), unit = m.location.unit;
const b = sz.node && blocks.find(x => x.node && x.unit === unit);
if (b) b.ms.push(m); else blocks.push({ unit, h, node: !!sz.node, known: !!sz.u, ms: [m] });
}
const clash = [];
blocks.forEach((a, i) => blocks.slice(i + 1).forEach(b => { if (a.unit <= b.unit + b.h - 1 && b.unit <= a.unit + a.h - 1) clash.push(`${a.ms.map(nameOf).join('+')} and ${b.ms.map(nameOf).join('+')} overlap at U${Math.max(a.unit, b.unit)}`); }));
const top = {}, covered = new Set();
for (const b of blocks) { const t = Math.min(H, b.unit + b.h - 1); if (top[t] || [...Array(t - b.unit + 1).keys()].some(k => covered.has(b.unit + k))) continue; top[t] = b; for (let u = b.unit; u <= t; u++) covered.add(u); }
let rows = '';
for (let u = H; u >= 1; u--) {
rows += `<div class="u">${u}</div>`;
const b = top[u];
if (b) {
const m = b.ms[0], worst = b.ms.map(x => x.state).sort((x, y) => ['bad', 'warn', 'ok', 'idle'].indexOf(stateClass(x)) - ['bad', 'warn', 'ok', 'idle'].indexOf(stateClass(y)))[0];
const span = Math.min(H, b.unit + b.h - 1) - b.unit + 1;
const label = b.node ? `${b.ms.length} node${b.ms.length > 1 ? 's' : ''}: ${b.ms.map(nameOf).join(', ')}` : nameOf(m);
const tip = b.ms.map(x => `${nameOf(x)} · ${x.state} · ${(x.manufacturer || '') + ' ' + (x.product || '')}`).join('\n') + (b.known ? `\n${b.h}U${b.node ? ' chassis' : ''} (${(m.size || {}).source})` : '\nheight unknown: set rack_units for this model');
rows += `<div class="slot m ${esc(worst)}${b.node ? ' node' : ''}" data-id="${esc(m.id)}" style="grid-row:span ${span}" title="${esc(tip)}">${esc(label)} <span class="muted">${b.node ? '' : esc(m.os || m.profile || '')}${b.known ? '' : ' ?U'}</span></div>`;
} else if (!covered.has(u)) rows += '<div class="slot"></div>';
}
return `<div class="rack"><h4><span>${esc(rk.name)} <span class="muted">${esc([rk.building, rk.room].filter(Boolean).join(' / '))}</span></span><span class="muted">${ms.length} · ${H}U <a href="#" data-rackedit="${esc(keyOf(rk.building, rk.room, rk.name))}" title="height / comment">✎</a></span></h4>
<div class="elev">${rows}</div>${clash.length ? `<div class="bad" style="margin-top:6px">${clash.map(esc).join('<br>')}</div>` : ''}${noU.length ? `<div class="muted" style="margin-top:6px">no U: ${noU.map(m => `<a href="#/machine/${esc(m.id)}">${esc(nameOf(m))}</a>`).join(', ')}</div>` : ''}${rk.comment ? `<div class="muted" style="margin-top:4px">${esc(rk.comment)}</div>` : ''}</div>`;
}
function pageRacks() {
const r = route(); const sel = r.arg ? decodeURIComponent(r.arg) : '';
const placed = S.machines.filter(m => m.location && m.location.rack);
@@ -609,36 +647,7 @@ function pageRacks() {
const buildings = [...new Set(list.map(x => x.building))].sort();
const tree = buildings.map(b => { const rooms = [...new Set(list.filter(x => x.building === b).map(x => x.room))].sort(); return `<span class="chip${sel === b ? ' on' : ''}" data-rsel="${esc(b)}"><b>${esc(b || '(no building)')}</b><span class="n">${list.filter(x => x.building === b).length} racks</span></span>` + rooms.map(rm => `<span class="chip${sel === b + '/' + rm ? ' on' : ''}" data-rsel="${esc(b + '/' + rm)}">${esc(rm || '(no room)')}<span class="n">${list.filter(x => x.building === b && x.room === rm).length}</span></span>`).join(''); }).join('<span class="sep" style="width:12px"></span>');
const shown = list.filter(x => !sel || x.building === sel || x.building + '/' + x.room === sel);
const elevation = rk => {
const ms = placed.filter(m => (m.location.building || '') === rk.building && (m.location.room || '') === rk.room && m.location.rack === rk.name);
// blocks of units: a server spans its height (size from the firmware or the
// model, ?U when unknown); sleds of one multi-node chassis share one block
const H = rk.height || 42, noU = [], blocks = [];
for (const m of ms) {
if (!(m.location.unit > 0)) { noU.push(m); continue; }
const sz = m.size || {}, h = Math.max(1, sz.u || 1), unit = m.location.unit;
const b = sz.node && blocks.find(x => x.node && x.unit === unit);
if (b) b.ms.push(m); else blocks.push({ unit, h, node: !!sz.node, known: !!sz.u, ms: [m] });
}
const clash = [];
blocks.forEach((a, i) => blocks.slice(i + 1).forEach(b => { if (a.unit <= b.unit + b.h - 1 && b.unit <= a.unit + a.h - 1) clash.push(`${a.ms.map(nameOf).join('+')} and ${b.ms.map(nameOf).join('+')} overlap at U${Math.max(a.unit, b.unit)}`); }));
const top = {}, covered = new Set();
for (const b of blocks) { const t = Math.min(H, b.unit + b.h - 1); if (top[t] || [...Array(t - b.unit + 1).keys()].some(k => covered.has(b.unit + k))) continue; top[t] = b; for (let u = b.unit; u <= t; u++) covered.add(u); }
let rows = '';
for (let u = H; u >= 1; u--) {
rows += `<div class="u">${u}</div>`;
const b = top[u];
if (b) {
const m = b.ms[0], worst = b.ms.map(x => x.state).sort((x, y) => ['bad', 'warn', 'ok', 'idle'].indexOf(stateClass(x)) - ['bad', 'warn', 'ok', 'idle'].indexOf(stateClass(y)))[0];
const span = Math.min(H, b.unit + b.h - 1) - b.unit + 1;
const label = b.node ? `${b.ms.length} node${b.ms.length > 1 ? 's' : ''}: ${b.ms.map(nameOf).join(', ')}` : nameOf(m);
const tip = b.ms.map(x => `${nameOf(x)} · ${x.state} · ${(x.manufacturer || '') + ' ' + (x.product || '')}`).join('\n') + (b.known ? `\n${b.h}U${b.node ? ' chassis' : ''} (${(m.size || {}).source})` : '\nheight unknown: set rack_units for this model');
rows += `<div class="slot m ${esc(worst)}${b.node ? ' node' : ''}" data-id="${esc(m.id)}" style="grid-row:span ${span}" title="${esc(tip)}">${esc(label)} <span class="muted">${b.node ? '' : esc(m.os || m.profile || '')}${b.known ? '' : ' ?U'}</span></div>`;
} else if (!covered.has(u)) rows += '<div class="slot"></div>';
}
return `<div class="rack"><h4><span>${esc(rk.name)} <span class="muted">${esc([rk.building, rk.room].filter(Boolean).join(' / '))}</span></span><span class="muted">${ms.length} · ${H}U <a href="#" data-rackedit="${esc(keyOf(rk.building, rk.room, rk.name))}" title="height / comment">✎</a></span></h4>
<div class="elev">${rows}</div>${clash.length ? `<div class="bad" style="margin-top:6px">${clash.map(esc).join('<br>')}</div>` : ''}${noU.length ? `<div class="muted" style="margin-top:6px">no U: ${noU.map(m => `<a href="#/machine/${esc(m.id)}">${esc(nameOf(m))}</a>`).join(', ')}</div>` : ''}${rk.comment ? `<div class="muted" style="margin-top:4px">${esc(rk.comment)}</div>` : ''}</div>`;
};
const elevation = rk => rackElev(rk);
return `<div class="page-head"><h1>Racks</h1><span class="sub">${list.length} racks · ${placed.length} machines placed${unplaced ? ` · <a href="#/machines" id="go-unplaced">${unplaced} without location</a>` : ''}</span>
<div class="right"><button class="btn" id="import-loc">Import CSV…</button><button class="btn" id="new-rack">New rack…</button></div></div>
${list.length ? `<div class="tree">${tree}${sel ? '<button class="btn ghost sm" id="rclear">all</button>' : ''}</div><div class="racks">${shown.map(elevation).join('')}</div>`
+2
View File
@@ -12,6 +12,7 @@
<div class="brand">Rollcall<span class="muted">bare-metal fleet</span></div>
<a href="#/overview" data-nav="overview">Overview</a>
<a href="#/machines" data-nav="machines">Machines <span class="count" id="n-machines"></span></a>
<a href="#/sites" data-nav="sites">Sites</a>
<a href="#/racks" data-nav="racks">Racks <span class="count" id="n-racks"></span></a>
<a href="#/network" data-nav="network">Network <span class="count" id="n-net"></span></a>
<a href="#/jobs" data-nav="jobs">Jobs <span class="count" id="n-jobs"></span></a>
@@ -50,6 +51,7 @@
<div id="toast" hidden></div>
<script src="topo.js"></script>
<script src="netview.js"></script>
<script src="sites.js"></script>
<script src="app.js"></script>
</body>
</html>
+264
View File
@@ -0,0 +1,264 @@
'use strict';
// Sites on a map (OpenStreetMap through Leaflet, loaded on first use), a
// site's rooms, and a room's floor plan: racks on 600 mm floor tiles, one
// tile wide and two deep, coloured by their machines; a rack opens its front
// (rackElev). Positions are edited by dragging; racks without one are laid
// out in rows facing alternate aisles until someone places them.
const SITE = { map: null, markers: null, placing: '', sel: '', edit: null };
const lc = s => String(s || '').toLowerCase();
// siteOf: the site a building name belongs to (name or slug, any case)
function siteOf(building) {
const b = lc(building);
return S.sites.find(s => lc(s.name) === b || (s.slug && lc(s.slug) === b));
}
const inSite = (site, building) => { const so = siteOf(building); return so ? so.name === site.name : lc(building) === lc(site.name); };
// siteList: the registered sites plus buildings machines or racks name without one
function siteList() {
const out = S.sites.map(s => ({ ...s }));
const extra = new Set([...S.machines.map(m => m.location && m.location.building), ...S.racks.map(r => r.building)].filter(b => b && !siteOf(b)));
for (const b of [...extra].sort()) out.push({ name: b, lat: null, lon: null, source: 'unregistered' });
return out;
}
function siteStats(site) {
const ms = S.machines.filter(m => m.location && inSite(site, m.location.building));
const racks = S.racks.filter(r => inSite(site, r.building));
const by = {}; for (const m of ms) by[stateClass(m.state)] = (by[stateClass(m.state)] || 0) + 1;
const worst = ['bad', 'warn', 'ok', 'idle'].find(k => by[k]) || 'idle';
const rooms = [...new Set([...racks.map(r => r.room), ...S.rooms.filter(r => inSite(site, r.building)).map(r => r.name), ...ms.map(m => m.location.room || '')])].sort();
return { ms, racks, by, worst, rooms };
}
// ---------------------------------------------------------------- map page
function loadLeaflet() {
if (window.L) return Promise.resolve();
if (!loadLeaflet.p) {
loadLeaflet.p = new Promise((ok, bad) => {
const css = document.createElement('link'); css.rel = 'stylesheet'; css.href = 'vendor/leaflet/leaflet.css'; document.head.appendChild(css);
const js = document.createElement('script'); js.src = 'vendor/leaflet/leaflet.js'; js.onload = ok; js.onerror = () => bad(new Error('leaflet did not load')); document.head.appendChild(js);
});
}
return loadLeaflet.p;
}
function pageSites() {
const list = siteList();
const rows = list.map(s => {
const st = siteStats(s);
const where = s.lat != null ? `<span class="mono muted">${s.lat.toFixed(4)}, ${s.lon.toFixed(4)}</span>` : '<span class="muted">not on the map</span>';
return [`<a href="#/sites/${encodeURIComponent(s.name)}"><b>${esc(s.name)}</b></a>${s.address ? `<br><span class="muted">${esc(s.address)}</span>` : ''}`,
`<span class="pill tag">${esc(s.source)}</span>`, st.rooms.filter(Boolean).length || '—', st.racks.length, st.ms.length,
`<span class="dot ${st.worst}"></span>${esc(groupLine(Object.fromEntries(st.ms.map(m => [m.state, st.ms.filter(x => x.state === m.state).length])), 40) || '—')}`,
where, `<button class="btn sm" data-place="${esc(s.name)}">${s.lat != null ? 'move' : 'place on map'}</button>`];
});
return `<div class="page-head"><h1>Sites</h1><span class="sub">${list.length} sites · map © OpenStreetMap contributors${S.ipam && S.ipam.provider === 'netbox' ? ' · sites, rooms and racks come from NetBox' : ''}</span></div>
${SITE.placing ? `<div class="nv-issues"><span class="dot warn"></span>Click the map where <b>${esc(SITE.placing)}</b> is. <a href="#" id="place-cancel">cancel</a></div>` : ''}
<div class="card wide" style="margin-bottom:12px;padding:0;overflow:hidden"><div id="site-map"></div></div>
<div class="card wide" id="site-list"><h3>Sites</h3><div class="tw">${table(['Site', 'Source', 'Rooms', 'Racks', 'Machines', 'State', 'Location', ''], rows)}</div></div>`;
}
function wireSites() {
$$('[data-place]').forEach(b => b.onclick = () => { SITE.placing = b.dataset.place; render(); });
const c = $('#place-cancel'); if (c) c.onclick = ev => { ev.preventDefault(); SITE.placing = ''; render(); };
loadLeaflet().then(() => {
const el = $('#site-map'); if (!el) return;
if (SITE.map) { SITE.map.remove(); SITE.map = null; }
const map = L.map(el, { worldCopyJump: true, attributionControl: true });
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19, referrerPolicy: 'strict-origin-when-cross-origin', // OSM's tile policy asks for a referrer
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors',
}).addTo(map);
SITE.map = map; SITE.markers = L.layerGroup().addTo(map);
sitesMarkers(true);
map.on('click', async ev => {
if (!SITE.placing) return;
const name = SITE.placing; SITE.placing = '';
const lat = Math.round(ev.latlng.lat * 1e5) / 1e5, lon = Math.round(L.Util.wrapNum(ev.latlng.lng, [-180, 180], true) * 1e5) / 1e5;
try { await api('POST', '/api/v1/sites', { name, lat, lon }); toast(`${name} placed at ${lat}, ${lon}`); refresh(true); } catch (e) { toast(e.message, true); render(); }
});
if (SITE.placing) el.style.cursor = 'crosshair';
}).catch(e => { const el = $('#site-map'); if (el) el.innerHTML = `<div class="empty">${esc(e.message)}</div>`; });
}
// sitesMarkers draws (or redraws, on refresh) one marker per site with coordinates
function sitesMarkers(fit) {
if (!SITE.map) return;
SITE.markers.clearLayers();
const pts = [];
const color = { bad: getComputedStyle(document.body).getPropertyValue('--danger'), warn: getComputedStyle(document.body).getPropertyValue('--warn'), ok: getComputedStyle(document.body).getPropertyValue('--ok'), idle: getComputedStyle(document.body).getPropertyValue('--muted') };
for (const s of siteList()) {
if (s.lat == null) continue;
const st = siteStats(s);
const mk = L.circleMarker([s.lat, s.lon], { radius: 7 + Math.min(14, Math.log2(1 + st.ms.length) * 2), color: color[st.worst].trim(), weight: 2, fillOpacity: 0.45 });
mk.bindTooltip(`<b>${esc(s.name)}</b><br>${st.ms.length} machines · ${st.racks.length} racks${st.by.bad ? `<br>${st.by.bad} failed` : ''}`, { direction: 'top' });
mk.on('click', () => { if (!SITE.placing) location.hash = '#/sites/' + encodeURIComponent(s.name); });
mk.addTo(SITE.markers); pts.push([s.lat, s.lon]);
}
if (!fit) return;
if (pts.length > 1) SITE.map.fitBounds(pts, { padding: [40, 40], maxZoom: 12 });
else if (pts.length === 1) SITE.map.setView(pts[0], 12);
else SITE.map.setView([30, 15], 2);
}
// refreshSites keeps the map (and the tiles it loaded) on the 5 s refresh
function refreshSites() {
if (!SITE.map || !$('#site-map') || SITE.placing) return false;
sitesMarkers(false);
const tmp = document.createElement('div'); tmp.innerHTML = pageSites();
const fresh = $('#site-list', tmp); if (fresh) { $('#site-list').replaceWith(fresh); $$('[data-place]').forEach(b => b.onclick = () => { SITE.placing = b.dataset.place; render(); }); }
return true;
}
// ---------------------------------------------------------------- one site
function pageSite(name) {
const site = siteList().find(s => s.name === name);
if (!site) return `<div class="empty">No site ${esc(name)}. <a href="#/sites">Sites</a></div>`;
const st = siteStats(site);
const cards = st.rooms.map(rm => {
const racks = st.racks.filter(r => r.room === rm), ms = st.ms.filter(m => (m.location.room || '') === rm);
const bad = ms.filter(m => stateClass(m.state) === 'bad').length;
return `<a class="card room-card" href="#/sites/${encodeURIComponent(site.name)}/${encodeURIComponent(rm || '-')}"><h3>${esc(rm || '(no room)')}</h3>
<div class="room-mini">${floorSVG(site, rm, { mini: true })}</div>
<div class="muted">${racks.length} racks · ${ms.length} machines${bad ? ` · <span class="bad">${bad} failed</span>` : ''}</div></a>`;
});
return `<div class="page-head"><h1><a href="#/sites" class="muted" style="font-weight:400">Sites</a> / ${esc(site.name)}</h1><span class="sub">${esc(site.address || '')} · ${st.racks.length} racks · ${st.ms.length} machines</span>
<div class="right"><button class="btn" id="new-room">New room…</button></div></div>
${cards.length ? `<div class="room-cards">${cards.join('')}</div>` : '<div class="empty">No rooms or racks here yet: add a room, or set machines\' location to this site.</div>'}`;
}
function wireSite(name) {
const b = $('#new-room'); if (b) b.onclick = async () => {
const v = await dialog(`New room in ${name}`, [{ name: 'name', label: 'Room' }, { name: 'width', label: 'Width (tiles)', value: '0', help: '600 mm floor tiles; 0 = as far as the racks go' }, { name: 'depth', label: 'Depth (tiles)', value: '0' }], '', 'Add');
if (!v) return;
try { await api('POST', '/api/v1/rooms', { building: name, name: v.name.trim(), width: Number(v.width) || 0, depth: Number(v.depth) || 0 }); refresh(true); } catch (e) { toast(e.message, true); }
};
}
// ---------------------------------------------------------------- floor plan
// racksOnFloor: the room's racks with positions; racks without one get
// automatic places in rows of ten below the placed ones, fronts facing
// alternate aisles (cold aisle between rows 0/1, 2/3, ...).
function racksOnFloor(site, room) {
const racks = S.racks.filter(r => inSite(site, r.building) && r.room === room)
.map(r => ({ ...r, auto: r.x == null, facing: r.facing || 'N' }));
const placed = racks.filter(r => !r.auto);
let y0 = placed.length ? Math.max(...placed.map(r => r.y + footprint(r).h)) + 2 : 1;
racks.filter(r => r.auto).sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true })).forEach((r, i) => {
const row = Math.floor(i / 10);
r.x = 1 + (i % 10); r.y = y0 + row * 4 - (row % 2); r.facing = row % 2 ? 'N' : 'S';
});
return racks;
}
const footprint = r => (r.facing === 'E' || r.facing === 'W') ? { w: 2, h: 1 } : { w: 1, h: 2 };
function rackState(site, r) {
const ms = S.machines.filter(m => m.location && inSite(site, m.location.building) && (m.location.room || '') === r.room && m.location.rack === r.name);
const used = ms.reduce((a, m) => a + (m.size && m.size.node ? 0 : Math.max(1, (m.size && m.size.u) || 1)), 0) +
new Set(ms.filter(m => m.size && m.size.node).map(m => m.location.unit)).size * 2;
const worst = ['bad', 'warn', 'ok', 'idle'].find(k => ms.some(m => stateClass(m.state) === k)) || 'vacant';
return { ms, used, worst };
}
// floorSVG draws the room; opt.mini: a thumbnail for the site page
function floorSVG(site, room, opt = {}) {
const racks = SITE.edit && !opt.mini ? SITE.edit.racks : racksOnFloor(site, room);
const rm = S.rooms.find(r => inSite(site, r.building) && r.name === room) || {};
const T = opt.mini ? 9 : 40;
const W = Math.max(rm.width || 0, ...racks.map(r => r.x + footprint(r).w + 1), 8), D = Math.max(rm.depth || 0, ...racks.map(r => r.y + footprint(r).h + 1), 6);
const o = [`<svg class="floor${opt.mini ? ' mini' : ''}" viewBox="0 0 ${W * T} ${D * T}" width="${W * T}" height="${D * T}"${opt.mini ? ' style="max-width:100%;height:auto"' : ''}>`];
o.push(`<rect class="room" x="0.5" y="0.5" width="${W * T - 1}" height="${D * T - 1}"/>`);
if (!opt.mini) { for (let x = 1; x < W; x++) o.push(`<line class="tile" x1="${x * T}" y1="0" x2="${x * T}" y2="${D * T}"/>`); for (let y = 1; y < D; y++) o.push(`<line class="tile" x1="0" y1="${y * T}" x2="${W * T}" y2="${y * T}"/>`); }
for (const r of racks) {
const f = footprint(r), st = rackState(site, r), x = r.x * T, y = r.y * T, w = f.w * T, h = f.h * T;
const pct = r.height ? Math.min(1, st.used / r.height) : 0;
const front = { N: [x, y, x + w, y], S: [x, y + h, x + w, y + h], E: [x + w, y, x + w, y + h], W: [x, y, x, y + h] }[r.facing];
const fillBar = (r.facing === 'E' || r.facing === 'W') ? `<rect class="fill" x="${x + 2}" y="${y + h - 4}" width="${(w - 4) * pct}" height="2"/>` : `<rect class="fill" x="${x + w - 4}" y="${y + 2 + (h - 4) * (1 - pct)}" width="2" height="${(h - 4) * pct}"/>`;
const sel = SITE.sel === r.name && !opt.mini;
o.push(`<g class="rk ${st.worst}${r.auto ? ' auto' : ''}${sel ? ' sel' : ''}" data-rack="${esc(r.name)}"><title>${esc(`${r.name} · ${st.ms.length} machines · ${st.used}/${r.height}U used${r.auto ? ' · not placed yet (automatic)' : ''}`)}</title>
<rect class="body" x="${x + 1}" y="${y + 1}" width="${w - 2}" height="${h - 2}" rx="${opt.mini ? 1 : 3}"/>${opt.mini ? '' : fillBar}
<line class="front" x1="${front[0]}" y1="${front[1]}" x2="${front[2]}" y2="${front[3]}"/>
${opt.mini ? '' : `<text x="${x + w / 2}" y="${y + h / 2 + 4}" text-anchor="middle">${esc(r.name.length > 6 ? r.name.slice(-6) : r.name)}</text>`}</g>`);
}
o.push('</svg>');
return o.join('');
}
function pageRoom(siteName, roomArg) {
const site = siteList().find(s => s.name === siteName);
if (!site) return `<div class="empty">No site ${esc(siteName)}.</div>`;
const room = roomArg === '-' ? '' : roomArg;
const racks = racksOnFloor(site, room);
const autoN = racks.filter(r => r.auto).length;
const selRack = racks.find(r => r.name === SITE.sel);
const panel = selRack ? `<div class="card floor-side"><h3>${esc(selRack.name)} <span class="muted">${selRack.height}U · front ${({ N: 'north', S: 'south', E: 'east', W: 'west' })[selRack.facing]}</span></h3>
${SITE.edit ? `<div class="actions" style="margin-bottom:8px"><button class="btn sm" id="rk-rotate">Rotate</button></div>` : ''}
${rackElev(selRack)}</div>`
: `<div class="card floor-side muted">Click a rack for its front.${autoN ? `<br><br>${autoN} rack(s) have no place yet and are laid out automatically (dashed): Edit layout to place them.` : ''}</div>`;
return `<div class="page-head"><h1><a href="#/sites" class="muted" style="font-weight:400">Sites</a> / <a href="#/sites/${encodeURIComponent(site.name)}" class="muted" style="font-weight:400">${esc(site.name)}</a> / ${esc(room || '(no room)')}</h1>
<span class="sub">${racks.length} racks · floor tiles of 600 mm</span>
<div class="right">${SITE.edit ? '<button class="btn" id="fl-cancel">Cancel</button><button class="btn" id="fl-auto">Automatic again</button><button class="btn primary" id="fl-save">Save layout</button>' : '<button class="btn" id="fl-edit">Edit layout</button>'}</div></div>
<div class="floor-wrap"><div class="card floor-card">${floorSVG(site, room)}
<div class="legend"><span><b class="lg ok"></b>deployed / ready</span><span><b class="lg warn"></b>busy / new</span><span><b class="lg bad"></b>failed</span><span><b class="lg vacant"></b>empty</span><span>thick edge: the front · bar: units used${SITE.edit ? ' · drag to move, select and Rotate' : ''}</span></div></div>${panel}</div>`;
}
function wireRoom(siteName, roomArg) {
const site = siteList().find(s => s.name === siteName); if (!site) return;
const room = roomArg === '-' ? '' : roomArg;
const svg = $('svg.floor'); if (!svg) return;
// the selected rack is part of the address (#/sites/SITE/ROOM/RACK): a rack can be linked to
$$('svg.floor .rk').forEach(g => g.onclick = () => {
if (SITE.dropped) return; // the click that ends a drag is not a selection
const base = '#/sites/' + encodeURIComponent(siteName) + '/' + encodeURIComponent(roomArg);
if (SITE.edit) { SITE.sel = SITE.sel === g.dataset.rack ? '' : g.dataset.rack; render(); return; }
location.hash = SITE.sel === g.dataset.rack ? base : base + '/' + encodeURIComponent(g.dataset.rack);
});
const e = $('#fl-edit'); if (e) e.onclick = () => { SITE.edit = { racks: racksOnFloor(site, room).map(r => ({ ...r })) }; render(); };
const c = $('#fl-cancel'); if (c) c.onclick = () => { SITE.edit = null; render(); };
const save = async (auto) => {
const body = SITE.edit.racks.map(r => {
const orig = S.racks.find(x => x.name === r.name && x.room === room && inSite(site, x.building));
return { building: orig.building, room, name: r.name, x: auto ? null : r.x, y: auto ? null : r.y, facing: auto ? '' : r.facing };
});
try { await api('POST', '/api/v1/racks/positions', body); SITE.edit = null; toast(auto ? 'racks laid out automatically again' : `layout of ${room || site.name} saved`); refresh(true); } catch (err) { toast(err.message, true); }
};
const s = $('#fl-save'); if (s) s.onclick = () => save(false);
const a = $('#fl-auto'); if (a) a.onclick = () => { if (confirm('Forget the places of every rack in this room?')) save(true); };
const rot = $('#rk-rotate'); if (rot) rot.onclick = () => { const r = SITE.edit.racks.find(x => x.name === SITE.sel); if (r) { r.facing = { N: 'E', E: 'S', S: 'W', W: 'N' }[r.facing]; r.auto = false; render(); } };
if (!SITE.edit) return;
const T = 40;
svg.onpointerdown = ev => {
const g = ev.target.closest('.rk'); if (!g) return;
const r = SITE.edit.racks.find(x => x.name === g.dataset.rack); if (!r) return;
SITE.drag = { r, g, x0: ev.clientX, y0: ev.clientY, nx: r.x, ny: r.y, moved: false };
try { svg.setPointerCapture(ev.pointerId); } catch (e) { /* not a live pointer */ }
};
svg.onpointermove = ev => { // only the dragged rack moves until it is dropped
const d = SITE.drag; if (!d) return;
const scale = svg.getBoundingClientRect().width / svg.viewBox.baseVal.width;
d.nx = Math.max(0, d.r.x + Math.round((ev.clientX - d.x0) / scale / T));
d.ny = Math.max(0, d.r.y + Math.round((ev.clientY - d.y0) / scale / T));
d.moved = d.moved || d.nx !== d.r.x || d.ny !== d.r.y;
d.g.setAttribute('transform', `translate(${(d.nx - d.r.x) * T},${(d.ny - d.r.y) * T})`);
};
svg.onpointerup = () => {
const d = SITE.drag; if (!d) return;
SITE.drag = null; // before render: renderSites holds off while a drag is on
if (!d.moved) return;
SITE.dropped = true; setTimeout(() => { SITE.dropped = false; }, 0);
d.r.x = d.nx; d.r.y = d.ny; d.r.auto = false; SITE.sel = d.r.name; render();
};
}
function renderSites() {
const r = route();
const main = $('#main');
if (r.arg2) {
if (SITE.edit && SITE.drag) return;
if (!SITE.edit) SITE.sel = r.arg3 ? decodeURIComponent(r.arg3) : ''; main.innerHTML = pageRoom(decodeURIComponent(r.arg), decodeURIComponent(r.arg2)); wireRoom(decodeURIComponent(r.arg), decodeURIComponent(r.arg2)); return; }
SITE.edit = null;
if (r.arg) { main.innerHTML = pageSite(decodeURIComponent(r.arg)); wireSite(decodeURIComponent(r.arg)); return; }
if (main.dataset.view === 'sites' && refreshSites()) return;
main.innerHTML = pageSites(); main.dataset.view = 'sites'; wireSites();
}
+28
View File
@@ -206,3 +206,31 @@ table.nv-matrix { min-width: 0; } .nv-matrix td, .nv-matrix th { padding: 5px 8p
.legend b.g { color: var(--ok); font-weight: 400; } .legend b.r { color: var(--danger); font-weight: 400; }
.nv-pathcard { margin-bottom: 12px; } .nv-path { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.nv-path .arr { color: var(--muted); }
/* sites, map, floor plans (sites.js) */
#site-map { height: 440px; background: var(--bg); }
.room-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.room-card { display: block; text-decoration: none; color: inherit; } .room-card:hover { background: var(--hover); }
.room-mini { margin: 4px 0 8px; }
.floor-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.floor-card { overflow: auto; } .floor-side { position: sticky; top: 12px; max-height: calc(100vh - 40px); overflow: auto; }
@media (max-width: 1100px) { .floor-wrap { grid-template-columns: 1fr; } }
svg.floor { display: block; touch-action: none; user-select: none; }
svg.floor .room { fill: var(--bg); stroke: var(--line2); }
svg.floor .tile { stroke: var(--line); stroke-width: 0.5; }
svg.floor .rk { cursor: pointer; } svg.floor .rk .body { fill: var(--pill); stroke: var(--line2); }
svg.floor .rk.ok .body { fill: color-mix(in srgb, var(--ok) 28%, var(--panel)); stroke: var(--ok); }
svg.floor .rk.warn .body { fill: color-mix(in srgb, var(--warn) 28%, var(--panel)); stroke: var(--warn); }
svg.floor .rk.bad .body { fill: color-mix(in srgb, var(--danger) 32%, var(--panel)); stroke: var(--danger); }
svg.floor .rk.idle .body { fill: var(--pill); stroke: var(--muted); }
svg.floor .rk.auto .body { stroke-dasharray: 3 2; }
svg.floor .rk.sel .body { stroke: var(--accent); stroke-width: 2.5; }
svg.floor .rk .front { stroke: var(--fg); stroke-width: 3; stroke-linecap: round; }
svg.floor.mini .rk .front { stroke-width: 1.5; }
svg.floor .rk .fill { fill: var(--accent); }
svg.floor .rk text { font-size: 9px; fill: var(--fg); pointer-events: none; font-family: var(--mono); }
.legend b.lg { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 5px; vertical-align: middle; border: 1px solid var(--line2); }
.legend b.lg.ok { background: color-mix(in srgb, var(--ok) 28%, var(--panel)); border-color: var(--ok); }
.legend b.lg.warn { background: color-mix(in srgb, var(--warn) 28%, var(--panel)); border-color: var(--warn); }
.legend b.lg.bad { background: color-mix(in srgb, var(--danger) 32%, var(--panel)); border-color: var(--danger); }
.legend b.lg.vacant { background: var(--pill); }
+26
View File
@@ -0,0 +1,26 @@
BSD 2-Clause License
Copyright (c) 2010-2023, Volodymyr Agafonkin
Copyright (c) 2010-2011, CloudMade
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+661
View File
@@ -0,0 +1,661 @@
/* required styles */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
position: absolute;
left: 0;
top: 0;
}
.leaflet-container {
overflow: hidden;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-user-drag: none;
}
/* Prevents IE11 from highlighting tiles in blue */
.leaflet-tile::selection {
background: transparent;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
image-rendering: -webkit-optimize-contrast;
}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
width: 1600px;
height: 1600px;
-webkit-transform-origin: 0 0;
}
.leaflet-marker-icon,
.leaflet-marker-shadow {
display: block;
}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg {
max-width: none !important;
max-height: none !important;
}
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
max-width: none !important;
max-height: none !important;
width: auto;
padding: 0;
}
.leaflet-container img.leaflet-tile {
/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
mix-blend-mode: plus-lighter;
}
.leaflet-container.leaflet-touch-zoom {
-ms-touch-action: pan-x pan-y;
touch-action: pan-x pan-y;
}
.leaflet-container.leaflet-touch-drag {
-ms-touch-action: pinch-zoom;
/* Fallback for FF which doesn't support pinch-zoom */
touch-action: none;
touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
-ms-touch-action: none;
touch-action: none;
}
.leaflet-container {
-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
filter: inherit;
visibility: hidden;
}
.leaflet-tile-loaded {
visibility: inherit;
}
.leaflet-zoom-box {
width: 0;
height: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
z-index: 800;
}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
-moz-user-select: none;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-vml-shape {
width: 1px;
height: 1px;
}
.lvml {
behavior: url(#default#VML);
display: inline-block;
position: absolute;
}
/* control positioning */
.leaflet-control {
position: relative;
z-index: 800;
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
position: absolute;
z-index: 1000;
pointer-events: none;
}
.leaflet-top {
top: 0;
}
.leaflet-right {
right: 0;
}
.leaflet-bottom {
bottom: 0;
}
.leaflet-left {
left: 0;
}
.leaflet-control {
float: left;
clear: both;
}
.leaflet-right .leaflet-control {
float: right;
}
.leaflet-top .leaflet-control {
margin-top: 10px;
}
.leaflet-bottom .leaflet-control {
margin-bottom: 10px;
}
.leaflet-left .leaflet-control {
margin-left: 10px;
}
.leaflet-right .leaflet-control {
margin-right: 10px;
}
/* zoom and fade animations */
.leaflet-fade-anim .leaflet-popup {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1;
}
.leaflet-zoom-animated {
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
}
svg.leaflet-zoom-animated {
will-change: transform;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
-webkit-transition: none;
-moz-transition: none;
transition: none;
}
.leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden;
}
/* cursors */
.leaflet-interactive {
cursor: pointer;
}
.leaflet-grab {
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
cursor: crosshair;
}
.leaflet-popup-pane,
.leaflet-control {
cursor: auto;
}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
pointer-events: none;
}
.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
/* visual tweaks */
.leaflet-container {
background: #ddd;
outline-offset: 1px;
}
.leaflet-container a {
color: #0078A8;
}
.leaflet-zoom-box {
border: 2px dotted #38f;
background: rgba(255,255,255,0.5);
}
/* general typography */
.leaflet-container {
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
font-size: 12px;
font-size: 0.75rem;
line-height: 1.5;
}
/* general toolbar styles */
.leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a {
background-color: #fff;
border-bottom: 1px solid #ccc;
width: 26px;
height: 26px;
line-height: 26px;
display: block;
text-align: center;
text-decoration: none;
color: black;
}
.leaflet-bar a,
.leaflet-control-layers-toggle {
background-position: 50% 50%;
background-repeat: no-repeat;
display: block;
}
.leaflet-bar a:hover,
.leaflet-bar a:focus {
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.leaflet-bar a:last-child {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
.leaflet-bar a.leaflet-disabled {
cursor: default;
background-color: #f4f4f4;
color: #bbb;
}
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
line-height: 30px;
}
.leaflet-touch .leaflet-bar a:first-child {
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}
.leaflet-touch .leaflet-bar a:last-child {
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
}
/* zoom control */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
font-size: 22px;
}
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
background: #fff;
border-radius: 5px;
}
.leaflet-control-layers-toggle {
background-image: url(images/layers.png);
width: 36px;
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png);
background-size: 26px 26px;
}
.leaflet-touch .leaflet-control-layers-toggle {
width: 44px;
height: 44px;
}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none;
}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block;
position: relative;
}
.leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px;
color: #333;
background: #fff;
}
.leaflet-control-layers-scrollbar {
overflow-y: scroll;
overflow-x: hidden;
padding-right: 5px;
}
.leaflet-control-layers-selector {
margin-top: 2px;
position: relative;
top: 1px;
}
.leaflet-control-layers label {
display: block;
font-size: 13px;
font-size: 1.08333em;
}
.leaflet-control-layers-separator {
height: 0;
border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px;
}
/* Default icon URLs */
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
background-image: url(images/marker-icon.png);
}
/* attribution and scale controls */
.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.8);
margin: 0;
}
.leaflet-control-attribution,
.leaflet-control-scale-line {
padding: 0 5px;
color: #333;
line-height: 1.4;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover,
.leaflet-control-attribution a:focus {
text-decoration: underline;
}
.leaflet-attribution-flag {
display: inline !important;
vertical-align: baseline !important;
width: 1em;
height: 0.6669em;
}
.leaflet-left .leaflet-control-scale {
margin-left: 5px;
}
.leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px;
}
.leaflet-control-scale-line {
border: 2px solid #777;
border-top: none;
line-height: 1.1;
padding: 2px 5px 1px;
white-space: nowrap;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: rgba(255, 255, 255, 0.8);
text-shadow: 1px 1px #fff;
}
.leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777;
border-bottom: none;
margin-top: -2px;
}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777;
}
.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
box-shadow: none;
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
/* popup */
.leaflet-popup {
position: absolute;
text-align: center;
margin-bottom: 20px;
}
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 24px 13px 20px;
line-height: 1.3;
font-size: 13px;
font-size: 1.08333em;
min-height: 1px;
}
.leaflet-popup-content p {
margin: 17px 0;
margin: 1.3em 0;
}
.leaflet-popup-tip-container {
width: 40px;
height: 20px;
position: absolute;
left: 50%;
margin-top: -1px;
margin-left: -20px;
overflow: hidden;
pointer-events: none;
}
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0;
pointer-events: auto;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
background: white;
color: #333;
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}
.leaflet-container a.leaflet-popup-close-button {
position: absolute;
top: 0;
right: 0;
border: none;
text-align: center;
width: 24px;
height: 24px;
font: 16px/24px Tahoma, Verdana, sans-serif;
color: #757575;
text-decoration: none;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
color: #585858;
}
.leaflet-popup-scrolled {
overflow: auto;
}
.leaflet-oldie .leaflet-popup-content-wrapper {
-ms-zoom: 1;
}
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}
.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999;
}
/* div icon */
.leaflet-div-icon {
background: #fff;
border: 1px solid #666;
}
/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
position: absolute;
padding: 6px;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
color: #222;
white-space: nowrap;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-tooltip.leaflet-interactive {
cursor: pointer;
pointer-events: auto;
}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
position: absolute;
pointer-events: none;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Directions */
.leaflet-tooltip-bottom {
margin-top: 6px;
}
.leaflet-tooltip-top {
margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
left: 50%;
margin-left: -6px;
}
.leaflet-tooltip-top:before {
bottom: 0;
margin-bottom: -12px;
border-top-color: #fff;
}
.leaflet-tooltip-bottom:before {
top: 0;
margin-top: -12px;
margin-left: -6px;
border-bottom-color: #fff;
}
.leaflet-tooltip-left {
margin-left: -6px;
}
.leaflet-tooltip-right {
margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
top: 50%;
margin-top: -6px;
}
.leaflet-tooltip-left:before {
right: 0;
margin-right: -12px;
border-left-color: #fff;
}
.leaflet-tooltip-right:before {
left: 0;
margin-left: -12px;
border-right-color: #fff;
}
/* Printing */
@media print {
/* Prevent printers from removing background-images of controls. */
.leaflet-control {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
+6
View File
@@ -0,0 +1,6 @@
/* @preserve
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var e,i,n=1,o=arguments.length;n<o;n++)for(e in i=arguments[n])t[e]=i[e];return t}var R=Object.create||function(t){return N.prototype=t,new N};function N(){}function a(t,e){var i,n=Array.prototype.slice;return t.bind?t.bind.apply(t,n.call(arguments,1)):(i=n.call(arguments,2),function(){return t.apply(e,i.length?i.concat(n.call(arguments)):arguments)})}var D=0;function h(t){return"_leaflet_id"in t||(t._leaflet_id=++D),t._leaflet_id}function j(t,e,i){var n,o,s=function(){n=!1,o&&(r.apply(i,o),o=!1)},r=function(){n?o=arguments:(t.apply(i,arguments),setTimeout(s,e),n=!0)};return r}function H(t,e,i){var n=e[1],e=e[0],o=n-e;return t===n&&i?t:((t-e)%o+o)%o+e}function u(){return!1}function i(t,e){return!1===e?t:(e=Math.pow(10,void 0===e?6:e),Math.round(t*e)/e)}function W(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(t){return W(t).split(/\s+/)}function c(t,e){for(var i in Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?R(t.options):{}),e)t.options[i]=e[i];return t.options}function U(t,e,i){var n,o=[];for(n in t)o.push(encodeURIComponent(i?n.toUpperCase():n)+"="+encodeURIComponent(t[n]));return(e&&-1!==e.indexOf("?")?"&":"?")+o.join("&")}var V=/\{ *([\w_ -]+) *\}/g;function q(t,i){return t.replace(V,function(t,e){e=i[e];if(void 0===e)throw new Error("No value provided for variable "+t);return e="function"==typeof e?e(i):e})}var d=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function G(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1}var K="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Y(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var X=0;function J(t){var e=+new Date,i=Math.max(0,16-(e-X));return X=e+i,window.setTimeout(t,i)}var $=window.requestAnimationFrame||Y("RequestAnimationFrame")||J,Q=window.cancelAnimationFrame||Y("CancelAnimationFrame")||Y("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function x(t,e,i){if(!i||$!==J)return $.call(window,a(t,e));t.call(e)}function r(t){t&&Q.call(window,t)}var tt={__proto__:null,extend:l,create:R,bind:a,get lastId(){return D},stamp:h,throttle:j,wrapNum:H,falseFn:u,formatNum:i,trim:W,splitWords:F,setOptions:c,getParamString:U,template:q,isArray:d,indexOf:G,emptyImageUrl:K,requestFn:$,cancelFn:Q,requestAnimFrame:x,cancelAnimFrame:r};function et(){}et.extend=function(t){function e(){c(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var i,n=e.__super__=this.prototype,o=R(n);for(i in(o.constructor=e).prototype=o,this)Object.prototype.hasOwnProperty.call(this,i)&&"prototype"!==i&&"__super__"!==i&&(e[i]=this[i]);if(t.statics&&l(e,t.statics),t.includes){var s=t.includes;if("undefined"!=typeof L&&L&&L.Mixin){s=d(s)?s:[s];for(var r=0;r<s.length;r++)s[r]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",(new Error).stack)}l.apply(null,[o].concat(t.includes))}return l(o,t),delete o.statics,delete o.includes,o.options&&(o.options=n.options?R(n.options):{},l(o.options,t.options)),o._initHooks=[],o.callInitHooks=function(){if(!this._initHooksCalled){n.callInitHooks&&n.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,e=o._initHooks.length;t<e;t++)o._initHooks[t].call(this)}},e},et.include=function(t){var e=this.prototype.options;return l(this.prototype,t),t.options&&(this.prototype.options=e,this.mergeOptions(t.options)),this},et.mergeOptions=function(t){return l(this.prototype.options,t),this},et.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i),this};var e={on:function(t,e,i){if("object"==typeof t)for(var n in t)this._on(n,t[n],e);else for(var o=0,s=(t=F(t)).length;o<s;o++)this._on(t[o],e,i);return this},off:function(t,e,i){if(arguments.length)if("object"==typeof t)for(var n in t)this._off(n,t[n],e);else{t=F(t);for(var o=1===arguments.length,s=0,r=t.length;s<r;s++)o?this._off(t[s]):this._off(t[s],e,i)}else delete this._events;return this},_on:function(t,e,i,n){"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1===this._listens(t,e,i)&&(e={fn:e,ctx:i=i===this?void 0:i},n&&(e.once=!0),this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e))},_off:function(t,e,i){var n,o,s;if(this._events&&(n=this._events[t]))if(1===arguments.length){if(this._firingCount)for(o=0,s=n.length;o<s;o++)n[o].fn=u;delete this._events[t]}else"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1!==(e=this._listens(Line truncated
//# sourceMappingURL=leaflet.js.map