Skip to content

Commit 74ae2be

Browse files
committed
feat(executions): add puppet and package execution types
Add support for 'puppet' and 'package' execution types throughout the application. Backend changes: - Update database schema with migration to add puppet and package to type constraint - Update ExecutionResult type definition to include new types - Modify execution repository and route handlers to support new types Frontend changes: - Add color coding for new types (puppet: orange, package: green) - Add display label mapping (puppet → 'puppet run', package → 'package') - Update ExecutionsPage component with type badges and labels - Update type definitions across components (PackageInstallInterface, PuppetRunInterface, TaskRunInterface, RealtimeOutputViewer, NodeDetailPage) This enables proper tracking and display of Puppet runs and package installations in the execution history.
1 parent a42d31b commit 74ae2be

File tree

13 files changed

+73
-21
lines changed

13 files changed

+73
-21
lines changed

backend/src/bolt/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export interface Facts {
152152
*/
153153
export interface ExecutionResult {
154154
id: string;
155-
type: "command" | "task" | "facts";
155+
type: "command" | "task" | "facts" | "puppet" | "package";
156156
targetNodes: string[];
157157
action: string;
158158
parameters?: Record<string, unknown>;

backend/src/database/ExecutionRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface DbRow {
2727
/**
2828
* Execution types
2929
*/
30-
export type ExecutionType = "command" | "task" | "facts";
30+
export type ExecutionType = "command" | "task" | "facts" | "puppet" | "package";
3131

3232
/**
3333
* Execution status

backend/src/database/migrations.sql

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,38 @@ ALTER TABLE executions ADD COLUMN command TEXT;
66

77
-- Add expert_mode column if it doesn't exist
88
ALTER TABLE executions ADD COLUMN expert_mode INTEGER DEFAULT 0;
9+
10+
-- Migration: Update execution type constraint to include 'puppet' and 'package' types
11+
-- This migration recreates the executions table with the updated type constraint
12+
13+
-- Step 1: Create new table with updated constraint
14+
CREATE TABLE IF NOT EXISTS executions_new (
15+
id TEXT PRIMARY KEY,
16+
type TEXT NOT NULL CHECK(type IN ('command', 'task', 'facts', 'puppet', 'package')),
17+
target_nodes TEXT NOT NULL,
18+
action TEXT NOT NULL,
19+
parameters TEXT,
20+
status TEXT NOT NULL CHECK(status IN ('running', 'success', 'failed', 'partial')),
21+
started_at TEXT NOT NULL,
22+
completed_at TEXT,
23+
results TEXT NOT NULL,
24+
error TEXT,
25+
command TEXT,
26+
expert_mode INTEGER DEFAULT 0
27+
);
28+
29+
-- Step 2: Copy data from old table to new table
30+
INSERT INTO executions_new SELECT * FROM executions;
31+
32+
-- Step 3: Drop old table
33+
DROP TABLE executions;
34+
35+
-- Step 4: Rename new table to original name
36+
ALTER TABLE executions_new RENAME TO executions;
37+
38+
-- Step 5: Recreate indexes
39+
CREATE INDEX IF NOT EXISTS idx_executions_started ON executions(started_at DESC);
40+
CREATE INDEX IF NOT EXISTS idx_executions_status ON executions(status);
41+
CREATE INDEX IF NOT EXISTS idx_executions_type ON executions(type);
42+
CREATE INDEX IF NOT EXISTS idx_executions_status_started ON executions(status, started_at DESC);
43+
CREATE INDEX IF NOT EXISTS idx_executions_type_started ON executions(type, started_at DESC);

backend/src/database/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Executions table for storing command and task execution history
22
CREATE TABLE IF NOT EXISTS executions (
33
id TEXT PRIMARY KEY,
4-
type TEXT NOT NULL CHECK(type IN ('command', 'task', 'facts')),
4+
type TEXT NOT NULL CHECK(type IN ('command', 'task', 'facts', 'puppet', 'package')),
55
target_nodes TEXT NOT NULL, -- JSON array of target node IDs
66
action TEXT NOT NULL,
77
parameters TEXT, -- JSON object of parameters

backend/src/routes/executions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ExecutionIdParamSchema = z.object({
1313
});
1414

1515
const ExecutionFiltersQuerySchema = z.object({
16-
type: z.enum(['command', 'task', 'facts']).optional(),
16+
type: z.enum(['command', 'task', 'facts', 'puppet', 'package']).optional(),
1717
status: z.enum(['running', 'success', 'failed', 'partial']).optional(),
1818
targetNode: z.string().optional(),
1919
startDate: z.string().datetime().optional(),

backend/src/routes/packages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function createPackagesRouter(
9696

9797
// Create initial execution record
9898
const executionId = await executionRepository.create({
99-
type: "task",
99+
type: "package",
100100
targetNodes: [nodeId],
101101
action: taskName,
102102
parameters: { packageName, ensure, version, settings },

backend/src/routes/puppet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function createPuppetRouter(
7070

7171
// Create initial execution record
7272
const executionId = await executionRepository.create({
73-
type: "task",
73+
type: "puppet",
7474
targetNodes: [nodeId],
7575
action: "psick::puppet_agent",
7676
parameters: config,

frontend/src/components/PackageInstallInterface.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
interface ExecutionResult {
2929
id: string;
30-
type: 'command' | 'task' | 'facts';
30+
type: 'command' | 'task' | 'facts' | 'puppet' | 'package';
3131
targetNodes: string[];
3232
action: string;
3333
parameters?: Record<string, unknown>;

frontend/src/components/PuppetRunInterface.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
2626
interface ExecutionResult {
2727
id: string;
28-
type: 'command' | 'task' | 'facts';
28+
type: 'command' | 'task' | 'facts' | 'puppet' | 'package';
2929
targetNodes: string[];
3030
action: string;
3131
parameters?: Record<string, unknown>;
@@ -296,7 +296,7 @@
296296
>
297297
<span
298298
class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out {noop ? 'translate-x-5' : 'translate-x-0'}"
299-
/>
299+
></span>
300300
</button>
301301
</div>
302302

@@ -321,7 +321,7 @@
321321
>
322322
<span
323323
class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out {noNoop ? 'translate-x-5' : 'translate-x-0'}"
324-
/>
324+
></span>
325325
</button>
326326
</div>
327327

@@ -346,7 +346,7 @@
346346
>
347347
<span
348348
class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out {debug ? 'translate-x-5' : 'translate-x-0'}"
349-
/>
349+
></span>
350350
</button>
351351
</div>
352352

@@ -355,6 +355,7 @@
355355
type="button"
356356
class="text-sm text-purple-600 hover:text-purple-700 dark:text-purple-400 dark:hover:text-purple-300"
357357
onclick={() => showAdvanced = !showAdvanced}
358+
aria-label={showAdvanced ? 'Hide advanced options' : 'Show advanced options'}
358359
>
359360
{showAdvanced ? 'Hide' : 'Show'} advanced options
360361
</button>

frontend/src/components/RealtimeOutputViewer.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
1616
// Auto-scroll state
1717
let autoScroll = $state(true);
18-
let stdoutContainer: HTMLElement | null = null;
19-
let stderrContainer: HTMLElement | null = null;
18+
let stdoutContainer = $state<HTMLElement | null>(null);
19+
let stderrContainer = $state<HTMLElement | null>(null);
2020
2121
// Elapsed time tracking
22-
let startTime: number | null = null;
22+
let startTime = $state<number | null>(null);
2323
let elapsedTime = $state(0);
2424
let elapsedInterval: ReturnType<typeof setInterval> | null = null;
2525
@@ -557,11 +557,11 @@
557557
}
558558
559559
/* Dark mode scrollbar */
560-
.dark .realtime-output-viewer ::-webkit-scrollbar-thumb {
560+
:global(.dark) .realtime-output-viewer ::-webkit-scrollbar-thumb {
561561
background: rgba(75, 85, 99, 0.5);
562562
}
563563
564-
.dark .realtime-output-viewer ::-webkit-scrollbar-thumb:hover {
564+
:global(.dark) .realtime-output-viewer ::-webkit-scrollbar-thumb:hover {
565565
background: rgba(75, 85, 99, 0.7);
566566
}
567567
</style>

0 commit comments

Comments
 (0)