mirror of
https://github.com/RGJorge/ContainerFlow.git
synced 2026-08-03 07:21:42 +02:00
v0.1.6 — project aliases (closes #3)
Adds human-readable aliases for project groups (the wrapping label around services), useful when orchestrators like Coolify or Dokploy generate cryptic project keys. - New server module `src/server/project-aliases.ts` with load/save helpers, a 64-char max, and control-char sanitization. - New endpoints: GET /api/project-aliases, PUT /api/project-aliases, DELETE /api/project-aliases/:project. Aliases also returned in /api/init for first-paint hydration. - GroupNode header is now click-to-edit: short names prefill so users can tweak them, long cryptic names start blank for a fresh alias. The compose suffix (PROD/DEV/etc) stays visible and is not part of the alias. Reset icon appears only when an alias differs from the original project key. - App.tsx wires the alias state, the project filter dropdown shows the alias plus the compose suffix list joined by " - ". - MonitoringPage uses the alias in: project filter dropdown, the totals card title, and per-service card subtitles (which show only THAT service's compose, not the whole project list). - engine/layout.ts exports getComposeKey and stores the raw `project` key in group node data so the same alias scope matches the filter. - i18n: 4 new keys (EN + ES) for rename / reset / save / cancel.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const DATA_DIR = process.env.DATA_DIR || path.join(process.cwd(), "data");
|
||||
const ALIASES_FILE = path.join(DATA_DIR, ".dockerflow-project-aliases.json");
|
||||
|
||||
const MAX_ALIAS_LENGTH = 64;
|
||||
|
||||
export type ProjectAliases = Record<string, string>;
|
||||
|
||||
export function loadProjectAliases(): ProjectAliases {
|
||||
try {
|
||||
if (fs.existsSync(ALIASES_FILE)) {
|
||||
return JSON.parse(fs.readFileSync(ALIASES_FILE, "utf-8"));
|
||||
}
|
||||
} catch {}
|
||||
return {};
|
||||
}
|
||||
|
||||
export function saveProjectAliases(aliases: ProjectAliases): void {
|
||||
fs.writeFileSync(ALIASES_FILE, JSON.stringify(aliases, null, 2));
|
||||
}
|
||||
|
||||
export function sanitizeAlias(raw: string): string {
|
||||
return raw
|
||||
.replace(/[\x00-\x1f\x7f]/g, "") // strip control chars
|
||||
.trim()
|
||||
.slice(0, MAX_ALIAS_LENGTH);
|
||||
}
|
||||
Reference in New Issue
Block a user