Files
peardock/config.js
T
Raven Scott 637c386e33
Release rolling / release (push) Successful in 7m55s
Bring Back Realtime Table Stats
2026-08-04 22:37:41 -04:00

118 lines
4.1 KiB
JavaScript

/**
* Centralized configuration constants
*/
export const CONFIG = {
// Stats collection (server/services/stats.js)
// Demand-driven: live stream:true only while a client is on Containers /
// Dashboard / container-details. Fully off otherwise. See Settings → Performance.
STATS: {
INTERVAL_MS: 1000, // allStats push cadence while watching
ACTIVE_INTERVAL_MS: 1000, // alias for broadcast when watching
IDLE_INTERVAL_MS: 5000, // reserved
CACHE_TTL_MS: 1000,
CONCURRENCY: 2, // legacy (stream mode)
SAMPLES_PER_TICK: 4, // legacy (stream mode)
LIST_INTERVAL_MS: 10000, // re-list running containers while watching
SMOOTHING_FACTOR: 0.2,
},
// UI updates
UI: {
DEBOUNCE_MS: 300, // Debounce time for UI updates
SKELETON_LOADER_DELAY: 200, // Delay before showing skeleton
ALERT_DURATION_MS: 5000, // Alert display duration
},
// Connection
CONNECTION: {
TIMEOUT_MS: 30000, // Connection timeout
/** Fixed delay between automatic peer reconnect attempts */
RECONNECT_DELAY_MS: 5000,
/**
* Default max automatic reconnect attempts when Settings has no override.
* 0 = unlimited. Runtime/UI caps at 8 (see Settings → Behavior).
* Client default preference is 8 tries via settings cache.
*/
RECONNECT_MAX_ATTEMPTS: 0,
HEALTH_CHECK_INTERVAL_MS: 10000, // Health check interval
},
// Container operations
CONTAINER: {
MAX_NAME_LENGTH: 63,
MIN_NAME_LENGTH: 1,
MAX_IMAGE_LENGTH: 255,
/** RPC timeout for lifecycle ops (remove/stop/restart/…) — longer than dial timeout */
OPERATION_TIMEOUT_MS: 120000,
},
// Terminal
TERMINAL: {
MIN_HEIGHT: 150,
MAX_HEIGHT_RATIO: 0.9, // Max height as ratio of window
SCROLLBACK_LINES: 10000,
HISTORY_SIZE: 1000,
},
// Storage
STORAGE: {
COOKIE_SIZE_LIMIT: 4000, // 4KB cookie limit (legacy)
CONNECTIONS_KEY: 'peardock_connections', // localStorage mirror key
USE_LOCALSTORAGE_KEY: 'peardock_use_localstorage',
TEMPLATES_KEY: 'peardock_templates', // legacy LS; primary is cache/templates.json
/** Desktop peer roster: ~/.config/peardock/cache/peers.json */
PEERS_CACHE_REL: '.config/peardock/cache/peers.json',
/** Client prefs (theme, density, filters, table cols, …): ~/.config/peardock/cache/settings.json */
SETTINGS_CACHE_REL: '.config/peardock/cache/settings.json',
/** Saved deploy templates: ~/.config/peardock/cache/templates.json */
TEMPLATES_CACHE_REL: '.config/peardock/cache/templates.json',
/** Notification center history: ~/.config/peardock/cache/notifications.json */
NOTIFICATIONS_CACHE_REL: '.config/peardock/cache/notifications.json',
/** Local backup history: ~/.config/peardock/cache/backups.json */
BACKUPS_CACHE_REL: '.config/peardock/cache/backups.json',
/** Server alerts snapshot (synced from admin export): ~/.config/peardock/cache/alerts.json */
ALERTS_CACHE_REL: '.config/peardock/cache/alerts.json',
/** localStorage key mirrored from settings cache */
SETTINGS_KEY: 'peardock.settings.v1',
},
// Docker command validation
DOCKER: {
MAX_COMMAND_LENGTH: 500,
ALLOWED_COMMANDS: [
'ps', 'images', 'volumes', 'networks', 'info', 'version',
'logs', 'inspect', 'stats', 'top', 'diff', 'port',
'history', 'search', 'events', 'system', 'help'
],
BLOCKED_COMMANDS: [
'exec', 'run', 'create', 'start', 'stop', 'restart', 'kill',
'rm', 'rmi', 'prune', 'build', 'commit', 'push', 'pull',
'tag', 'load', 'save', 'import', 'export', 'cp', 'update'
],
},
// Status codes
STATUS: {
CONNECTED: 'connected',
DISCONNECTED: 'disconnected',
CONNECTING: 'connecting',
ERROR: 'error',
},
// Error codes
ERROR_CODES: {
RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
INVALID_INPUT: 'INVALID_INPUT',
CONNECTION_FAILED: 'CONNECTION_FAILED',
OPERATION_TIMEOUT: 'OPERATION_TIMEOUT',
PERMISSION_DENIED: 'PERMISSION_DENIED',
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
},
};