feat: initialize VPS fleet manager with server management functionality

- Add package.json for project metadata and dependencies
- Create server.js for API endpoints and server logic
- Implement data persistence using JSON file for server information
- Add HTML frontend (vps_manager.html) for server management interface
- Include Leaflet for map visualization of server locations
- Create start.bat for easy server startup on Windows
This commit is contained in:
2026-05-25 20:19:24 -04:00
commit 1aafdc7b19
7 changed files with 1422 additions and 0 deletions

24
.wolf/anatomy.md Normal file
View File

@@ -0,0 +1,24 @@
# Project Anatomy: vps-manager
## Purpose
Single-page VPS fleet tracker — add/edit/delete servers with specs, IPs, cost, status.
## Files
- `vps_manager.html` — full UI (vanilla JS, IBM Plex font, dark GitHub-style theme)
- `server.js` — Express server; serves static files + REST API; binds 0.0.0.0:8080
- `package.json` — express ^4.18.2 dependency
- `start.bat` — double-click launcher for Windows
- `data/servers.json` — persistent JSON storage (auto-created on first run)
- `node_modules/` — npm dependencies
## API
- GET /api/servers → array of server objects
- POST /api/servers → upsert server (id present = update, absent = create)
- DELETE /api/servers/:id → remove server
## Data Shape
```json
{ "id": "srv_<timestamp>", "name": "", "status": "online|offline|maintenance",
"ipv4": "", "ipv6": "", "provider": "", "plan": "", "cpu": "", "ram": "",
"disk": "", "price": "", "location": "", "region": "", "sites": "", "notes": "" }
```

10
.wolf/cerebrum.md Normal file
View File

@@ -0,0 +1,10 @@
# Cerebrum: vps-manager
## Preferences
- Keep all UI in a single HTML file (no build step, no framework)
- Dark GitHub-style theme must be preserved exactly
- IBM Plex Mono / IBM Plex Sans fonts
## Do-Not-Repeat
- Do NOT use window.storage (non-standard, breaks in browser) — use fetch + REST API
- Do NOT split HTML/CSS/JS into separate files unless user asks

842
package-lock.json generated Normal file
View File

@@ -0,0 +1,842 @@
{
"name": "vps-manager",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "vps-manager",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.5",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz",
"integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.15.1",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/body-parser/node_modules/qs": {
"version": "6.15.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz",
"integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.3",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.14.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz",
"integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.14.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}

12
package.json Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "vps-manager",
"version": "1.0.0",
"description": "VPS fleet manager with persistent storage",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.18.2"
}
}

91
server.js Normal file
View File

@@ -0,0 +1,91 @@
const express = require('express');
const fs = require('fs');
const https = require('https');
const path = require('path');
const app = express();
const PORT = process.env.PORT || 8095;
const DATA_FILE = path.join(__dirname, 'data', 'servers.json');
app.use(express.json());
app.use(express.static(__dirname));
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'vps_manager.html'));
});
if (!fs.existsSync(path.join(__dirname, 'data'))) {
fs.mkdirSync(path.join(__dirname, 'data'));
}
function readData() {
try { return JSON.parse(fs.readFileSync(DATA_FILE, 'utf8')); }
catch { return []; }
}
function writeData(data) {
fs.writeFileSync(DATA_FILE, JSON.stringify(data, null, 2));
}
function geocode(location) {
return new Promise((resolve) => {
const q = encodeURIComponent(location);
const options = {
hostname: 'nominatim.openstreetmap.org',
path: `/search?q=${q}&format=json&limit=1`,
headers: { 'User-Agent': 'vps-fleet-manager/1.0' }
};
https.get(options, (res) => {
let data = '';
res.on('data', c => data += c);
res.on('end', () => {
try {
const r = JSON.parse(data);
resolve(r[0] ? { lat: parseFloat(r[0].lat), lng: parseFloat(r[0].lon) } : null);
} catch { resolve(null); }
});
}).on('error', () => resolve(null));
});
}
app.get('/api/servers', (req, res) => {
res.json(readData());
});
app.post('/api/servers', async (req, res) => {
const servers = readData();
const server = { ...req.body };
if (!server.id) server.id = 'srv_' + Date.now();
const existing = servers.find(s => s.id === server.id);
if (server.location && (!existing || existing.location !== server.location || !existing._lat)) {
const coords = await geocode(server.location);
if (coords) { server._lat = coords.lat; server._lng = coords.lng; }
} else if (existing && existing._lat) {
server._lat = existing._lat;
server._lng = existing._lng;
}
const idx = servers.findIndex(s => s.id === server.id);
if (idx > -1) servers[idx] = server;
else servers.push(server);
writeData(servers);
res.json(server);
});
app.delete('/api/servers/:id', (req, res) => {
writeData(readData().filter(s => s.id !== req.params.id));
res.json({ ok: true });
});
app.listen(PORT, '0.0.0.0', () => {
const { networkInterfaces } = require('os');
const nets = networkInterfaces();
const localIPs = Object.values(nets).flat()
.filter(n => n.family === 'IPv4' && !n.internal)
.map(n => n.address);
console.log(`\nvps/fleet running`);
console.log(` local → http://localhost:${PORT}`);
localIPs.forEach(ip => console.log(` network → http://${ip}:${PORT}`));
console.log('');
});

4
start.bat Normal file
View File

@@ -0,0 +1,4 @@
@echo off
echo Starting vps/fleet...
node server.js
pause

439
vps_manager.html Normal file
View File

@@ -0,0 +1,439 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
<style>
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');
*{box-sizing:border-box;margin:0;padding:0}
:root{
--bg:#0d1117;--surface:#161b22;--surface2:#21262d;--border:#30363d;
--text:#e6edf3;--muted:#7d8590;--accent:#58a6ff;--green:#3fb950;
--red:#f85149;--amber:#d29922;--purple:#bc8cff;--font:'IBM Plex Sans',sans-serif;--mono:'IBM Plex Mono',monospace;
}
body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14px;min-height:100vh}
.app{max-width:900px;margin:0 auto;padding:20px 16px}
h1{font-family:var(--mono);font-size:18px;font-weight:500;color:var(--text);letter-spacing:-0.5px}
h1 span{color:var(--accent)}
.topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px;padding-bottom:16px;border-bottom:1px solid var(--border)}
.stats-row{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:20px}
.stat{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:12px 14px}
.stat-label{font-size:11px;color:var(--muted);font-family:var(--mono);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}
.stat-val{font-size:22px;font-weight:600;font-family:var(--mono)}
.stat-val.accent{color:var(--accent)}.stat-val.green{color:var(--green)}.stat-val.amber{color:var(--amber)}
.servers-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.servers-label{font-family:var(--mono);font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.5px}
.btn{font-family:var(--font);font-size:13px;padding:6px 14px;border-radius:6px;border:1px solid var(--border);background:var(--surface2);color:var(--text);cursor:pointer;transition:background .15s}
.btn:hover{background:var(--border)}
.btn-primary{background:var(--accent);color:#0d1117;border-color:var(--accent);font-weight:500}
.btn-primary:hover{background:#79b8ff}
.btn-danger{background:transparent;color:var(--red);border-color:var(--red)}
.btn-danger:hover{background:rgba(248,81,73,.1)}
.btn-sm{padding:4px 10px;font-size:12px}
.server-card{background:var(--surface);border:1px solid var(--border);border-radius:8px;margin-bottom:10px;overflow:hidden;transition:border-color .15s}
.server-card:hover{border-color:#58a6ff55}
.card-top{display:flex;align-items:center;padding:14px 16px;gap:14px;cursor:pointer}
.status-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.status-dot.online{background:var(--green);box-shadow:0 0 6px var(--green)}
.status-dot.offline{background:var(--red)}
.status-dot.maintenance{background:var(--amber)}
.srv-name{font-family:var(--mono);font-weight:500;font-size:14px;flex:1;min-width:0}
.srv-ip{font-family:var(--mono);font-size:12px;color:var(--muted);margin-top:2px}
.srv-specs{display:flex;gap:16px;align-items:center}
.spec-chip{font-family:var(--mono);font-size:11px;background:var(--surface2);padding:3px 8px;border-radius:4px;border:1px solid var(--border);color:var(--muted);white-space:nowrap}
.price-tag{font-family:var(--mono);font-size:13px;color:var(--amber);font-weight:500;min-width:60px;text-align:right}
.card-actions{display:flex;gap:8px;align-items:center;padding-left:12px;border-left:1px solid var(--border)}
.card-expanded{border-top:1px solid var(--border);padding:14px 16px;display:grid;grid-template-columns:1fr 1fr;gap:12px}
.exp-row{display:flex;flex-direction:column;gap:2px}
.exp-label{font-size:11px;color:var(--muted);font-family:var(--mono);text-transform:uppercase;letter-spacing:.4px}
.exp-val{font-size:13px;font-family:var(--mono);color:var(--text)}
.exp-note{font-size:12px;color:var(--muted);margin-top:4px;font-style:italic}
.badge{font-size:10px;font-family:var(--mono);padding:2px 7px;border-radius:4px;font-weight:500}
.badge-green{background:rgba(63,185,80,.15);color:var(--green);border:1px solid rgba(63,185,80,.3)}
.badge-red{background:rgba(248,81,73,.15);color:var(--red);border:1px solid rgba(248,81,73,.3)}
.badge-amber{background:rgba(210,153,34,.15);color:var(--amber);border:1px solid rgba(210,153,34,.3)}
.empty{text-align:center;padding:48px 20px;color:var(--muted);font-family:var(--mono)}
.empty-icon{font-size:32px;margin-bottom:12px;opacity:.4}
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:100;padding:20px}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:10px;width:100%;max-width:500px;max-height:90vh;overflow-y:auto}
.modal-header{padding:18px 20px 14px;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center}
.modal-title{font-family:var(--mono);font-size:15px;font-weight:500}
.modal-body{padding:20px}
.modal-footer{padding:14px 20px;border-top:1px solid var(--border);display:flex;gap:8px;justify-content:flex-end}
.field{margin-bottom:14px}
.field label{display:block;font-size:11px;color:var(--muted);font-family:var(--mono);text-transform:uppercase;letter-spacing:.4px;margin-bottom:5px}
.field input,.field select,.field textarea{width:100%;background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:8px 10px;color:var(--text);font-family:var(--mono);font-size:13px;outline:none;transition:border-color .15s}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--accent)}
.field textarea{resize:vertical;min-height:60px}
.field-row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.close-btn{background:none;border:none;color:var(--muted);cursor:pointer;font-size:18px;line-height:1;padding:2px}
.close-btn:hover{color:var(--text)}
select option{background:var(--surface)}
.tag-row{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
.tag{font-family:var(--mono);font-size:11px;background:var(--surface2);border:1px solid var(--border);padding:2px 8px;border-radius:4px;color:var(--muted)}
#mapView{height:500px;border-radius:8px;overflow:hidden;border:1px solid var(--border);margin-bottom:20px}
.dark-popup .leaflet-popup-content-wrapper{background:var(--surface);border:1px solid var(--border);color:var(--text);box-shadow:0 4px 20px rgba(0,0,0,.6);border-radius:8px;padding:0}
.dark-popup .leaflet-popup-content{margin:12px 14px;font-family:var(--mono);font-size:12px;line-height:1.6}
.dark-popup .leaflet-popup-tip-container{display:none}
.dark-popup .leaflet-popup-close-button{color:var(--muted);top:6px;right:8px;font-size:16px}
.dark-popup .leaflet-popup-close-button:hover{color:var(--text)}
.map-no-coords{text-align:center;padding:10px;color:var(--muted);font-family:var(--mono);font-size:11px;border-top:1px solid var(--border);margin-top:10px}
</style>
</head>
<body>
<div class="app">
<div class="topbar">
<h1>vps<span>/</span>fleet</h1>
<div style="display:flex;gap:8px;align-items:center">
<div style="display:flex;border:1px solid var(--border);border-radius:6px;overflow:hidden">
<button id="btnList" class="btn" style="border:none;border-radius:0;background:var(--accent);color:#0d1117;font-family:var(--mono);font-size:12px;padding:5px 12px" onclick="showView('list')">List</button>
<button id="btnMap" class="btn" style="border:none;border-radius:0;border-left:1px solid var(--border);font-family:var(--mono);font-size:12px;padding:5px 12px" onclick="showView('map')">Map</button>
</div>
<button class="btn btn-primary" onclick="openAddModal()">+ Add Server</button>
</div>
</div>
<div class="stats-row" id="statsRow"></div>
<div id="mapView" style="display:none"></div>
<div id="listView">
<div class="servers-header">
<span class="servers-label">Servers</span>
<div style="display:flex;gap:8px">
<select id="filterStatus" class="btn" style="font-family:var(--font);font-size:12px;padding:4px 8px" onchange="render()">
<option value="">All Status</option>
<option value="online">Online</option>
<option value="offline">Offline</option>
<option value="maintenance">Maintenance</option>
</select>
<select id="filterProvider" class="btn" style="font-family:var(--font);font-size:12px;padding:4px 8px" onchange="render()">
<option value="">All Providers</option>
</select>
</div>
</div>
<div id="serverList"></div>
</div>
</div>
<div class="modal-overlay" id="modal" style="display:none">
<div class="modal">
<div class="modal-header">
<span class="modal-title" id="modalTitle">Add Server</span>
<button class="close-btn" onclick="closeModal()"></button>
</div>
<div class="modal-body">
<div class="field-row">
<div class="field"><label>Hostname</label><input id="f-name" placeholder="mb1pruwdocsrv01"/></div>
<div class="field"><label>Status</label>
<select id="f-status">
<option value="online">Online</option>
<option value="offline">Offline</option>
<option value="maintenance">Maintenance</option>
</select>
</div>
</div>
<div class="field-row">
<div class="field"><label>IPv4</label><input id="f-ipv4" placeholder="5.78.140.206"/></div>
<div class="field"><label>IPv6</label><input id="f-ipv6" placeholder="2a01:4ff:..."/></div>
</div>
<div class="field-row">
<div class="field"><label>Provider</label><input id="f-provider" placeholder="Hetzner, DigitalOcean..."/></div>
<div class="field"><label>Plan / Type</label><input id="f-plan" placeholder="CPX21, s-2vcpu-4gb..."/></div>
</div>
<div class="field-row">
<div class="field"><label>vCPU</label><input id="f-cpu" type="number" placeholder="3"/></div>
<div class="field"><label>RAM (GB)</label><input id="f-ram" type="number" placeholder="4"/></div>
</div>
<div class="field-row">
<div class="field"><label>Disk (GB)</label><input id="f-disk" type="number" placeholder="80"/></div>
<div class="field"><label>Total Cost ($)</label><input id="f-price" type="number" step="0.01" placeholder="299.00"/></div>
</div>
<div class="field-row">
<div class="field"><label>Billing Cycle</label>
<select id="f-billing">
<option value="monthly">Monthly</option>
<option value="quarterly">Quarterly (3 mo)</option>
<option value="yearly">Yearly</option>
<option value="2year">2-Year</option>
<option value="3year">3-Year</option>
</select>
</div>
<div class="field"><label>Renewal Date</label><input id="f-renewal" type="date"/></div>
</div>
<div class="field-row">
<div class="field"><label>Location / City</label><input id="f-location" placeholder="Hillsboro, OR"/></div>
<div class="field"><label>Region</label><input id="f-region" placeholder="us-west"/></div>
</div>
<div class="field"><label>Sites / Services (one per line)</label><textarea id="f-sites" placeholder="docs.example.com&#10;app.example.com&#10;Nginx, Node 20"></textarea></div>
<div class="field"><label>Notes</label><textarea id="f-notes" placeholder="Any extra info..."></textarea></div>
</div>
<div class="modal-footer">
<button class="btn" onclick="closeModal()">Cancel</button>
<button class="btn btn-primary" onclick="saveServer()">Save Server</button>
</div>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
let servers = [];
let expanded = {};
let editId = null;
let map = null;
let mapMarkers = [];
function showView(view) {
const isMap = view === 'map';
document.getElementById('listView').style.display = isMap ? 'none' : '';
document.getElementById('mapView').style.display = isMap ? 'block' : 'none';
document.getElementById('btnList').style.cssText += isMap
? ';background:transparent;color:var(--text)'
: ';background:var(--accent);color:#0d1117';
document.getElementById('btnMap').style.cssText += isMap
? ';background:var(--accent);color:#0d1117'
: ';background:transparent;color:var(--text)';
if (isMap) initMap();
}
function initMap() {
if (!map) {
map = L.map('mapView', { zoomControl: true, attributionControl: true }).setView([20, 0], 2);
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OSM</a> &copy; <a href="https://carto.com/">CARTO</a>',
maxZoom: 18
}).addTo(map);
}
renderMap();
}
function renderMap() {
if (!map) return;
mapMarkers.forEach(m => m.remove());
mapMarkers = [];
const statusColors = { online: '#3fb950', offline: '#f85149', maintenance: '#d29922' };
const located = servers.filter(s => s._lat && s._lng);
const missing = servers.length - located.length;
located.forEach(s => {
const color = statusColors[s.status] || '#7d8590';
const marker = L.circleMarker([s._lat, s._lng], {
radius: 9, fillColor: color, color: '#0d1117',
weight: 2, opacity: 1, fillOpacity: 0.85
}).bindPopup(`
<div>
<div style="font-weight:500;font-size:13px;margin-bottom:6px;color:var(--text)">${s.name}</div>
${s.ipv4 ? `<div style="color:var(--muted)">${s.ipv4}${s.ipv6 ? ' · ' + s.ipv6 : ''}</div>` : ''}
${s.provider ? `<div style="margin-top:4px">${s.provider}${s.plan ? ' <span style="color:var(--muted)">· ' + s.plan + '</span>' : ''}</div>` : ''}
${s.location ? `<div style="color:var(--muted);margin-top:2px">${s.location}${s.region ? ' · ' + s.region : ''}</div>` : ''}
${s.price ? `<div style="color:var(--amber);margin-top:4px">$${parseFloat(s.price).toFixed(2)}${BILLING_TAG[s.billing]||'/mo'}</div>` : ''}
<div style="margin-top:6px;color:${color};font-weight:500">${s.status}</div>
</div>`, { className: 'dark-popup', maxWidth: 220 });
marker.addTo(map);
mapMarkers.push(marker);
});
// Remove old notice if any
const old = document.getElementById('mapNotice');
if (old) old.remove();
if (missing > 0) {
const notice = document.createElement('div');
notice.id = 'mapNotice';
notice.className = 'map-no-coords';
notice.textContent = `${missing} server${missing > 1 ? 's' : ''} missing location — add a Location when editing to place on map`;
document.getElementById('mapView').after(notice);
}
}
async function loadServers() {
try {
const r = await fetch('/api/servers');
servers = await r.json();
} catch(e) { servers = []; }
render();
if (map) renderMap();
}
const BILLING_DIV = { monthly:1, quarterly:3, yearly:12, '2year':24, '3year':36 };
const BILLING_TAG = { monthly:'/mo', quarterly:'/qtr', yearly:'/yr', '2year':'/2yr', '3year':'/3yr' };
const BILLING_NAME = { monthly:'Monthly', quarterly:'Quarterly', yearly:'Yearly', '2year':'2-Year', '3year':'3-Year' };
function monthlyEquiv(price, billing) {
return (parseFloat(price)||0) / (BILLING_DIV[billing]||1);
}
function renewalInfo(renewal) {
if (!renewal) return null;
const d = new Date(renewal);
const days = Math.round((d - new Date()) / 86400000);
const fmt = d.toLocaleDateString('en-US', { year:'numeric', month:'short', day:'numeric' });
return { fmt, days };
}
function statusBadge(s) {
const map = {online:'badge-green',offline:'badge-red',maintenance:'badge-amber'};
return `<span class="badge ${map[s]||'badge-amber'}">${s}</span>`;
}
function render() {
const fStatus = document.getElementById('filterStatus').value;
const fProv = document.getElementById('filterProvider').value;
// populate provider filter
const providers = [...new Set(servers.map(s=>s.provider).filter(Boolean))];
const pSel = document.getElementById('filterProvider');
const cur = pSel.value;
pSel.innerHTML = '<option value="">All Providers</option>' + providers.map(p=>`<option value="${p}" ${cur===p?'selected':''}>${p}</option>`).join('');
let list = servers.filter(s => (!fStatus || s.status===fStatus) && (!fProv || s.provider===fProv));
// stats
const total = servers.length;
const online = servers.filter(s=>s.status==='online').length;
const monthly = servers.reduce((a,s)=>a+monthlyEquiv(s.price,s.billing),0);
const totalCpu = servers.reduce((a,s)=>a+(parseInt(s.cpu)||0),0);
document.getElementById('statsRow').innerHTML = `
<div class="stat"><div class="stat-label">Servers</div><div class="stat-val accent">${total}</div></div>
<div class="stat"><div class="stat-label">Online</div><div class="stat-val green">${online}</div></div>
<div class="stat"><div class="stat-label">Total vCPU</div><div class="stat-val">${totalCpu}</div></div>
<div class="stat"><div class="stat-label">Monthly cost</div><div class="stat-val amber">$${monthly.toFixed(2)}</div></div>
`;
const el = document.getElementById('serverList');
if (list.length === 0) {
el.innerHTML = `<div class="empty"><div class="empty-icon">▣</div><div>No servers found</div><div style="margin-top:8px;font-size:12px">Click "+ Add Server" to get started</div></div>`;
return;
}
el.innerHTML = list.map(s => {
const isExp = expanded[s.id];
const sites = (s.sites||'').split('\n').map(x=>x.trim()).filter(Boolean);
const ri = renewalInfo(s.renewal);
const renewalSoon = ri && ri.days >= 0 && ri.days <= 30;
const billingTag = BILLING_TAG[s.billing]||'/mo';
const moEquiv = s.billing && s.billing !== 'monthly' ? monthlyEquiv(s.price,s.billing) : null;
return `
<div class="server-card">
<div class="card-top" onclick="toggleExpand('${s.id}')">
<div class="status-dot ${s.status||'offline'}"></div>
<div style="flex:1;min-width:0">
<div class="srv-name">${s.name||'unnamed'}${renewalSoon?` <span class="badge badge-amber" style="vertical-align:middle">renews in ${ri.days}d</span>`:''}</div>
<div class="srv-ip">${[s.ipv4,s.ipv6].filter(Boolean).join(' · ')||'no IP set'}</div>
</div>
<div class="srv-specs">
${s.cpu?`<span class="spec-chip">${s.cpu} vCPU</span>`:''}
${s.ram?`<span class="spec-chip">${s.ram} GB RAM</span>`:''}
${s.disk?`<span class="spec-chip">${s.disk} GB</span>`:''}
${s.location?`<span class="spec-chip" style="color:var(--purple)">${s.location}</span>`:''}
</div>
<div class="price-tag">${s.price?'$'+parseFloat(s.price).toFixed(2)+billingTag:''}</div>
<div class="card-actions">
<button class="btn btn-sm" onclick="event.stopPropagation();openEdit('${s.id}')">Edit</button>
<button class="btn btn-sm btn-danger" onclick="event.stopPropagation();deleteServer('${s.id}')">Del</button>
</div>
</div>
${isExp?`
<div class="card-expanded">
<div class="exp-row"><span class="exp-label">Provider</span><span class="exp-val">${s.provider||'—'} ${s.plan?`<span class="tag">${s.plan}</span>`:''}</span></div>
<div class="exp-row"><span class="exp-label">Region</span><span class="exp-val">${s.region||'—'}</span></div>
<div class="exp-row"><span class="exp-label">Status</span><span class="exp-val">${statusBadge(s.status||'offline')}</span></div>
<div class="exp-row"><span class="exp-label">IPv4</span><span class="exp-val" style="font-family:var(--mono)">${s.ipv4||'—'}</span></div>
<div class="exp-row"><span class="exp-label">Billing</span><span class="exp-val">${BILLING_NAME[s.billing]||'Monthly'}${s.price?` · $${parseFloat(s.price).toFixed(2)}${billingTag}`:''}${moEquiv?` <span style="color:var(--muted);font-size:11px">(≈$${moEquiv.toFixed(2)}/mo)</span>`:''}</span></div>
<div class="exp-row"><span class="exp-label">Renewal</span><span class="exp-val" style="${renewalSoon?'color:var(--amber)':''}">${ri?ri.fmt+(ri.days>=0?` <span style="color:var(--muted);font-size:11px">(${ri.days}d)</span>`:''):'—'}</span></div>
${s.ipv6?`<div class="exp-row" style="grid-column:span 2"><span class="exp-label">IPv6</span><span class="exp-val" style="font-size:12px">${s.ipv6}</span></div>`:''}
${sites.length?`<div class="exp-row" style="grid-column:span 2"><span class="exp-label">Sites / Services</span><div class="tag-row">${sites.map(t=>`<span class="tag">${t}</span>`).join('')}</div></div>`:''}
${s.notes?`<div class="exp-row" style="grid-column:span 2"><span class="exp-label">Notes</span><span class="exp-note">${s.notes}</span></div>`:''}
</div>`:''
}
</div>`;
}).join('');
}
function toggleExpand(id) {
expanded[id] = !expanded[id];
render();
}
function openAddModal() {
editId = null;
document.getElementById('modalTitle').textContent = 'Add Server';
['name','ipv4','ipv6','provider','plan','cpu','ram','disk','price','renewal','location','region','sites','notes'].forEach(f=>{
document.getElementById('f-'+f).value='';
});
document.getElementById('f-status').value='online';
document.getElementById('f-billing').value='monthly';
document.getElementById('modal').style.display='flex';
}
function openEdit(id) {
const s = servers.find(x=>x.id===id);
if (!s) return;
editId = id;
document.getElementById('modalTitle').textContent = 'Edit Server';
document.getElementById('f-name').value = s.name||'';
document.getElementById('f-status').value = s.status||'online';
document.getElementById('f-ipv4').value = s.ipv4||'';
document.getElementById('f-ipv6').value = s.ipv6||'';
document.getElementById('f-provider').value = s.provider||'';
document.getElementById('f-plan').value = s.plan||'';
document.getElementById('f-cpu').value = s.cpu||'';
document.getElementById('f-ram').value = s.ram||'';
document.getElementById('f-disk').value = s.disk||'';
document.getElementById('f-price').value = s.price||'';
document.getElementById('f-billing').value = s.billing||'monthly';
document.getElementById('f-renewal').value = s.renewal||'';
document.getElementById('f-location').value = s.location||'';
document.getElementById('f-region').value = s.region||'';
document.getElementById('f-sites').value = s.sites||'';
document.getElementById('f-notes').value = s.notes||'';
document.getElementById('modal').style.display='flex';
}
function closeModal() {
document.getElementById('modal').style.display='none';
}
async function saveServer() {
const data = {
name: document.getElementById('f-name').value.trim(),
status: document.getElementById('f-status').value,
ipv4: document.getElementById('f-ipv4').value.trim(),
ipv6: document.getElementById('f-ipv6').value.trim(),
provider: document.getElementById('f-provider').value.trim(),
plan: document.getElementById('f-plan').value.trim(),
cpu: document.getElementById('f-cpu').value,
ram: document.getElementById('f-ram').value,
disk: document.getElementById('f-disk').value,
price: document.getElementById('f-price').value,
billing: document.getElementById('f-billing').value,
renewal: document.getElementById('f-renewal').value,
location: document.getElementById('f-location').value.trim(),
region: document.getElementById('f-region').value.trim(),
sites: document.getElementById('f-sites').value.trim(),
notes: document.getElementById('f-notes').value.trim(),
};
if (!data.name) { alert('Hostname is required'); return; }
if (editId) data.id = editId;
await fetch('/api/servers', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
closeModal();
loadServers();
}
async function deleteServer(id) {
if (!confirm('Remove this server?')) return;
delete expanded[id];
await fetch('/api/servers/' + id, { method: 'DELETE' });
loadServers();
}
document.getElementById('modal').addEventListener('click', function(e){
if (e.target === this) closeModal();
});
loadServers();
</script>
</body>
</html>