Commit graph

119 commits

Author SHA1 Message Date
Lazzexus
9bdb6a5812 Make browsers check for a new web map on every load
main.bundle.js and the CSS keep the same name in every version, and nginx
didn't send Cache-Control, so browsers could keep running the old bundle
after a deploy. Then new pages (like /research/tree) showed the landing
page, stuck on "Loading servers…".

Send Cache-Control: no-cache, so browsers revalidate each load; unchanged
files are still a cheap 304 via the ETag. Icons keep their 1 day expiry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:26:40 +01:00
Lazzexus
a0519a1b83 Show the research as a tree, like the game's technology screen
The research page has a new tree layout (/servers/{id}/research/tree),
next to the existing list, with List / Tree buttons to switch.

The tree goes from top to bottom: each technology is in the row of its
longest chain of prerequisites, and rows are ordered so technologies sit
near the ones they're linked to. Links are drawn between technologies and
their prerequisites, green once the prerequisite is researched.

- drag to move, scroll or pinch to zoom, and Fit to show the whole tree
- selecting a technology highlights all its prerequisites and links, and
  what it leads to, and shows the science packs still needed to reach it
- search highlights matching technologies; Enter goes to each in turn
- double-click (or Details) opens the same details as the list, whose
  details now have a 'Show in tree' link
- the selected technology is kept in the URL (?tech=), so it can be shared

The details pop-up is moved out of researchPage.kt into
TechnologyDetail.kt, so both layouts use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:26:40 +01:00
Lazzexus
0e1b315a6d Add a production dashboard
Every minute, the mod diffs the force's production statistics for each
surface against the totals it sent last time (kept in
storage.productionTotals), and sends what was produced and consumed as a
ProductionUpdate.

events-server-web keeps the statistics in ring buffers (1440 minutes and
168 hours), and serves them at
/kafkatorio/data/servers/{id}/production, for a range of game time and
optionally one surface.

The web map has a production page (/servers/{id}/production, linked from
the header) with science packs used per minute (in total and per pack),
production per minute as a line chart, and a searchable table of
everything produced and consumed.

export_building_icons.py now also exports every item and fluid icon and
name (items.json, fluids.json), for the production page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:26:25 +01:00
Lazzexus
8770a0617b Add a research page, and keep the topics that views are rebuilt from
The mod sends the research state of a force (researched technologies,
levels, current research, progress and queue) whenever research changes,
and every minute for the progress. events-server-web keeps the latest state
and serves it at /kafkatorio/data/servers/{id}/research.

The web map has a research page (/servers/{id}/research, linked from the
header), with:
- progress, the current research and the queue
- the science packs needed for everything that's left
- every technology, filterable by status, science pack and name, with its
  cost (including levelled technologies' count formulas)
- details: the total cost to reach a technology, its prerequisites, what it
  leads to and what it unlocks

The technology tree comes from export_building_icons.py, which now also
exports technologies.json, items.json and technology/science pack icons.

Kafka deleted data older than 7 days, but the building, resource and
research views are rebuilt by reading their topics from the beginning, so
buildings disappeared after a restart. These topics are now kept forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:46:09 +01:00
Lazzexus
930d746336 Redesign the web map landing page
A dark theme in the style of Factorio's UI, with a card per server that
shows a preview of the map around the origin and the server's surfaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:31:04 +01:00
Lazzexus
e1e59fe66c Draw belts, underground belts and splitters with their direction
Belts are drawn like the in-game map: a strip in the colour of their tier
(taken from the icon of the transport belt of the same tier), with an arrow
per lane in the direction items go. Splitters are drawn at their rotated
2x1 footprint with a bar across the back.

The mod now sends whether an underground belt is an entrance or an exit.
Entrances are capped on the side where items go underground, exits on the
side where they come out, and the hover tooltip says which it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:21:11 +01:00
Lazzexus
9d1f9b7623 Show building rotation, recipes and other surfaces on the web map
The mod now sends each building's direction and recipe (furnaces: the last
recipe, since they only have one while working).
- Rotated buildings are drawn at their real footprint.
- Crafting machines show their recipe icon, like Factorio's alt mode, and
  the hover tooltip includes the recipe.

The web map has a surface drop-down (e.g. Space Exploration planets and
orbits), backed by a new surfaces endpoint. Every layer, the resource labels
and the player markers follow the chosen surface.

Resource labels use the in-game names (e.g. "Iridite" instead of
"Se iridium ore"). export_building_icons.py also exports recipe icons, plus
recipe and resource names.

The three in-memory views in events-server-web now share one helper for
following a Kafka topic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 10:14:39 +02:00
Lazzexus
c773b05922 Add a building icon layer to the web map
events-server-web keeps the latest state of every building in memory (read
from the map-chunk-entity topic, like the resource patches) and serves them
per area. The web map draws the icons at their real size onto canvas tiles,
so large bases stay fast, and shows each building's name, status and health
on hover. Ghosts are ignored, and buildings are removed when they're mined.

The icons belong to Wube and the mod authors, so they aren't in the repo.
export_building_icons.py builds them from a Factorio client's
--dump-data/--dump-prototype-locale/--dump-icon-sprites output, and the
web-map nginx serves them from a mounted volume.

Also label single-well oil fields "1 well".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:52:07 +02:00
Lazzexus
3d8673fe03 Add resource patch labels to the web map
Group nearby resource tiles of the same type into patches, and label
them on the map, e.g. "Iron ore / 2.4M", or "Crude oil / 12 wells".

- events-library: ResourcePatch model, shared by the server and map.
- events-server-web: ResourcePatchService reads the map-chunk-resource
  topic from the beginning (read_committed) into memory, and on request
  groups tiles into connected patches (join distance 2 tiles for ore,
  12 for infinite resources, whose wells are spread out). Results are
  cached until new data arrives.
  New endpoint: GET .../servers/{id}/map/resources/s{surface}/patches
- web-map: toggleable "Resource patches" overlay with labels at each
  patch centre and a hover tooltip, refreshed every minute. Patches
  under 10 tiles are hidden. (Surface 1 only, like the rest of the map.)
- events-mod: mark resources infinite based on the prototype's
  infinite_resource. Entity initial_amount is nil for e.g. crude oil, so
  oil fields were treated as hundreds of tiny ore patches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 07:07:23 +02:00
Lazzexus
d023ec61d9 Fix web map blanking and websocket dropping behind a reverse proxy
- web-map: main() was bound to the whole site state, so every state
  update (e.g. each player position update over the websocket)
  re-rendered the page and re-attached the Leaflet map to a new
  element, blanking the tiles. Only re-render when the view, server
  list, or map instance changes.
- web-map: reconnect the websocket when it closes, instead of silently
  stopping live updates.
- events-server-web: send websocket pings every 30s, so idle
  connections aren't closed by reverse proxies (nginx defaults to a
  60s read timeout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 18:09:03 +02:00
Lazzexus
e52ea9d9cf Fix Docker image builds and local platform setup
Getting the backend running locally in Docker surfaced several issues:

- geedeecee: REGISTRY_HOST came from the unset Gradle property
  'dockerContainerRegistryHost'. A missing value in a MapProperty makes
  the whole map absent, so every generated .env was empty and all
  docker-compose builds failed. Default it to 'localhost'.
- kafka image: dlcdn.apache.org only hosts current releases, so Kafka
  3.3.1 404s. Use archive.apache.org. Replace the deprecated openjdk:11
  base with eclipse-temurin:11-jre, bump the download stage from EOL
  Debian 11 to 12, and drop 'COPY --chmod' so the image builds without
  BuildKit/buildx.
- web-map: the map calls the API and websocket on its own origin
  (/kafkatorio/...), which previously relied on an external reverse
  proxy. Proxy /kafkatorio/ to events-server-web in the map's nginx so
  one port serves everything, and publish that port in the example
  platform compose file.
- docs: the example secret config mapped server IDs to descriptions,
  but the schema is token (JWT 'sub') -> server ID, and both must match
  [a-zA-Z0-9-_]. Descriptions with spaces crashed every service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:27:11 +02:00
Lazzexus
519aba0eaf Remove dead kotlinx-nodejs dependency from web-map
Its only coordinate (org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7) was
published to Bintray's "kotlinx" repository, which has been shut down
since 2021 - it's unresolvable from any repo configured here (Maven
Central, JitPack, Gradle Plugin Portal, or JetBrains Space all 404 it),
blocking configuration of the whole build whenever a task touched
web-map. Turns out nothing in web-map's source actually imports
kotlinx.nodejs.* - the one require() call nearby is webpack's own
bundler global, unrelated to this library. It was also duplicated next
to a second, redundant kotlinx-html line. Just deleting the dependency
is the correct fix, not re-hosting a defunct artifact.

Verified: `:modules:events-mod:build :modules:events-library:check`
now gets past configuration and all JVM-side tasks succeed (the JS
browser test target still needs a locally installed Chrome for Karma,
which is an unrelated environment requirement, not a dependency issue).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 15:46:04 +02:00
Adam
fcb870072a version bumps 2022-12-06 00:23:52 +01:00
Adam
531b8e193e tidy up gradle plugins (mostly removing comments) 2022-10-30 17:13:03 +01:00
Adam
e05557c97c [web-map] fix missing css/image in dockerfile 2022-10-22 20:54:40 +02:00
Adam
9b331cc105 update dockerfiles
- define user uid/gid
- use new geedeecee files (hopefully means smaller images, faster building)
2022-10-22 19:55:02 +02:00
Adam
da7b4b6ad1 version bumps 2022-10-16 13:07:43 +02:00
Adam
e6ffe4cba5 update bootstrap css (some sort of encoding change with a "-NBSP" 2022-10-16 12:47:45 +02:00
Adam
32b4bbffe2 maybe fix webmap nginx css... 2022-10-08 16:05:44 +02:00
Adam
11cca3c8c3 fix gradle task output (zip depends on browserDistribution), add util function for filtering tasks by name 2022-10-08 16:04:50 +02:00
Adam
59dc4ce336 add nginx events section 2022-10-08 14:52:40 +02:00
Adam
6507f13462 fix docker image building 2022-10-05 08:52:39 +02:00
Adam
b61ee6bf5c apply geedeecee plugin, or update config. Update kvision dependency helper. 2022-10-04 22:52:19 +02:00
Adam
562296aa96 Dockerfiles: add syntax=docker header 2022-10-04 22:28:04 +02:00
Adam
0044f0cb98 create and use APP_NAME, APP_GROUP in docker compose files 2022-10-04 22:27:43 +02:00
Adam
99d1f92bbb update docker image names to include REGISTRY_HOST, and group, and correct image name 2022-10-02 14:51:00 +02:00
Adam
b171f88435 geedeecee: fix DockerEnvUpdateTask 2022-10-02 13:57:15 +02:00
Adam
f804c39a3b migrate docker-compose convention plugin out of buildSrc 2022-10-02 12:11:06 +02:00
Adam
9071148944 start dockerising the modules... 2022-09-18 23:38:15 +02:00
Adam
f12a505d22 migrate buildSrc plugins to includedBuild plugins 2022-09-18 20:49:32 +02:00
Adam
16dc72ae71 version bumps (minor bumps) 2022-09-18 13:59:43 +02:00
Adam
873983f9a3 big ol' refactor to split up the events-server and events-processors 2022-09-13 17:56:57 +02:00
Adam
80e8c95bc9 fix webpack dev server, redownload bootstrap.min.css 2022-09-10 10:07:46 +02:00
Adam
47c47690a7 refactor so files match contents 2022-09-09 17:33:48 +02:00
Adam
a84c4a2f76 refactor web-map to be SPA 2022-09-09 17:21:09 +02:00
Adam
de419aeae8 web-map tidy up, and add diagram to README 2022-09-03 11:15:43 +02:00
Adam
3976c3cc1b fix webmap after multi-server refactor, and add styling 2022-09-02 23:22:18 +02:00
Adam
8a6c49a74b initial hacky implementation of multi-server support in the frontend 2022-09-01 23:19:59 +02:00
Adam
ece583e93c bump kvision, remove manual npm version settings (I think it's been fixed now) 2022-09-01 23:18:47 +02:00
Adam
02edffa2e9 version bump to 0.9.0 (just prepping for the next release) 2022-09-01 23:17:56 +02:00
Adam
4bc46f9753 progress towards multi-server handling
- bump some versions
- validate Factorio server ID & token
-
2022-08-28 19:37:49 +02:00
Adam
a8784db5b2 update player state booleans - they default to false now 2022-07-17 12:15:46 +02:00
Adam
10c54998c7 version bump to 0.8.0 2022-07-16 23:23:55 +02:00
Adam
b507081eac Render buildings and resources
- create LuaJsonList to handle empty Lua JSON lists being sent as empty objects
- fix exporting of resources and entities
- split up map tiles into different layer directories
- add 'chunk size' to MapChunkPosition
- move tests to correct packages
- bump tstl
- decrease tstl logging
- remove some defined, but unused, kafka topics
- syslog, rest, websocket servers & web-map: decrease logging
- webmap: add additional layers for buildings and resources
2022-07-16 23:11:40 +02:00
Adam
ae0eb98f12 version bump 2022-07-08 21:48:19 +02:00
Adam
665327e010 bump project to 0.7.0 (and fix docker .env task for all docker .envs) 2022-07-06 17:43:50 +02:00
Adam
5fcb831df2 use version platform more, try fixing projects must be configuring bug 2022-07-06 17:16:09 +02:00
Adam
8f4823ae97 add MapChunkEntityUpdate to webmap 2022-07-06 16:22:50 +02:00
Adam
b9b6065735 try fixing projects must be configuring bug 2022-07-06 16:18:48 +02:00
Adam
90dc520d22 massive refactor to export entities (buildings and resources)
- minor version bumps
- new Factorio version
- use both prototype name and type to identify a prototype
- kxs-ts-gen: use BrandTyping, but exclude some identifiers
- kxs-ts-gen: manually create zip dist, so it can run after the project compiles
- mod: use typed-factorio strict types
- mod: refactor event handlers to be a little more consistent and object-oriented
2022-07-05 23:44:23 +02:00