@friggframework/devtools 2.0.0-next.29 → 2.0.0-next.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/frigg-cli/.eslintrc.js +141 -0
- package/frigg-cli/__tests__/jest.config.js +102 -0
- package/frigg-cli/__tests__/unit/commands/build.test.js +483 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +418 -0
- package/frigg-cli/__tests__/unit/commands/ui.test.js +592 -0
- package/frigg-cli/__tests__/utils/command-tester.js +170 -0
- package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
- package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
- package/frigg-cli/__tests__/utils/test-setup.js +286 -0
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +312 -0
- package/frigg-cli/generate-command/azure-generator.js +43 -0
- package/frigg-cli/generate-command/gcp-generator.js +47 -0
- package/frigg-cli/generate-command/index.js +332 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/index.js +19 -1
- package/frigg-cli/init-command/backend-first-handler.js +756 -0
- package/frigg-cli/init-command/index.js +93 -0
- package/frigg-cli/init-command/template-handler.js +143 -0
- package/frigg-cli/package.json +51 -0
- package/frigg-cli/test/init-command.test.js +180 -0
- package/frigg-cli/test/npm-registry.test.js +319 -0
- package/frigg-cli/ui-command/index.js +154 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +25 -0
- package/frigg-cli/utils/npm-registry.js +167 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/serverless-template.js +177 -292
- package/management-ui/.eslintrc.js +22 -0
- package/management-ui/README.md +203 -0
- package/management-ui/components.json +21 -0
- package/management-ui/docs/phase2-integration-guide.md +320 -0
- package/management-ui/{dist/index.html → index.html} +1 -2
- package/management-ui/package-lock.json +16517 -0
- package/management-ui/package.json +76 -0
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
- package/management-ui/postcss.config.js +6 -0
- package/management-ui/server/api/backend.js +256 -0
- package/management-ui/server/api/cli.js +315 -0
- package/management-ui/server/api/codegen.js +663 -0
- package/management-ui/server/api/connections.js +857 -0
- package/management-ui/server/api/discovery.js +185 -0
- package/management-ui/server/api/environment/index.js +1 -0
- package/management-ui/server/api/environment/router.js +378 -0
- package/management-ui/server/api/environment.js +328 -0
- package/management-ui/server/api/integrations.js +876 -0
- package/management-ui/server/api/logs.js +248 -0
- package/management-ui/server/api/monitoring.js +282 -0
- package/management-ui/server/api/open-ide.js +31 -0
- package/management-ui/server/api/project.js +1029 -0
- package/management-ui/server/api/users/sessions.js +371 -0
- package/management-ui/server/api/users/simulation.js +254 -0
- package/management-ui/server/api/users.js +362 -0
- package/management-ui/server/api-contract.md +275 -0
- package/management-ui/server/index.js +873 -0
- package/management-ui/server/middleware/errorHandler.js +93 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +346 -0
- package/management-ui/server/services/aws-monitor.js +413 -0
- package/management-ui/server/services/npm-registry.js +347 -0
- package/management-ui/server/services/template-engine.js +538 -0
- package/management-ui/server/utils/cliIntegration.js +220 -0
- package/management-ui/server/utils/environment/auditLogger.js +471 -0
- package/management-ui/server/utils/environment/awsParameterStore.js +264 -0
- package/management-ui/server/utils/environment/encryption.js +278 -0
- package/management-ui/server/utils/environment/envFileManager.js +286 -0
- package/management-ui/server/utils/import-commonjs.js +28 -0
- package/management-ui/server/utils/response.js +83 -0
- package/management-ui/server/websocket/handler.js +325 -0
- package/management-ui/src/App.jsx +109 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +70 -0
- package/management-ui/src/components/Card.jsx +97 -0
- package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
- package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
- package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
- package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
- package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
- package/management-ui/src/components/ErrorBoundary.jsx +73 -0
- package/management-ui/src/components/IntegrationCard.jsx +481 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +336 -0
- package/management-ui/src/components/Layout.jsx +716 -0
- package/management-ui/src/components/LoadingSpinner.jsx +113 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +350 -0
- package/management-ui/src/components/StatusBadge.jsx +208 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
- package/management-ui/src/components/UserSimulation.jsx +327 -0
- package/management-ui/src/components/Welcome.jsx +434 -0
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
- package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
- package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
- package/management-ui/src/components/codegen/index.js +10 -0
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
- package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
- package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
- package/management-ui/src/components/connections/index.js +5 -0
- package/management-ui/src/components/index.js +21 -0
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
- package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
- package/management-ui/src/components/monitoring/index.js +6 -0
- package/management-ui/src/components/monitoring/monitoring.css +218 -0
- package/management-ui/src/components/theme-provider.jsx +52 -0
- package/management-ui/src/components/theme-toggle.jsx +39 -0
- package/management-ui/src/components/ui/badge.tsx +36 -0
- package/management-ui/src/components/ui/button.test.jsx +56 -0
- package/management-ui/src/components/ui/button.tsx +57 -0
- package/management-ui/src/components/ui/card.tsx +76 -0
- package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
- package/management-ui/src/components/ui/select.tsx +157 -0
- package/management-ui/src/components/ui/skeleton.jsx +15 -0
- package/management-ui/src/hooks/useFrigg.jsx +601 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +193 -0
- package/management-ui/src/lib/utils.ts +6 -0
- package/management-ui/src/main.jsx +10 -0
- package/management-ui/src/pages/CodeGeneration.jsx +14 -0
- package/management-ui/src/pages/Connections.jsx +252 -0
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
- package/management-ui/src/pages/Dashboard.jsx +311 -0
- package/management-ui/src/pages/Environment.jsx +314 -0
- package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
- package/management-ui/src/pages/IntegrationTest.jsx +742 -0
- package/management-ui/src/pages/Integrations.jsx +253 -0
- package/management-ui/src/pages/Monitoring.jsx +17 -0
- package/management-ui/src/pages/Simulation.jsx +155 -0
- package/management-ui/src/pages/Users.jsx +492 -0
- package/management-ui/src/services/api.js +41 -0
- package/management-ui/src/services/apiModuleService.js +193 -0
- package/management-ui/src/services/websocket-handlers.js +120 -0
- package/management-ui/src/test/api/project.test.js +273 -0
- package/management-ui/src/test/components/Welcome.test.jsx +378 -0
- package/management-ui/src/test/mocks/server.js +178 -0
- package/management-ui/src/test/setup.js +61 -0
- package/management-ui/src/test/utils/test-utils.jsx +134 -0
- package/management-ui/src/utils/repository.js +98 -0
- package/management-ui/src/utils/repository.test.js +118 -0
- package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
- package/management-ui/tailwind.config.js +63 -0
- package/management-ui/tsconfig.json +37 -0
- package/management-ui/tsconfig.node.json +10 -0
- package/management-ui/vite.config.js +26 -0
- package/management-ui/vitest.config.js +38 -0
- package/package.json +5 -5
- package/management-ui/dist/assets/index-BA21WgFa.js +0 -1221
- package/management-ui/dist/assets/index-CbM64Oba.js +0 -1221
- package/management-ui/dist/assets/index-CkvseXTC.css +0 -1
- /package/management-ui/{dist/assets/FriggLogo-B7Xx8ZW1.svg → src/assets/FriggLogo.svg} +0 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useFrigg } from '../hooks/useFrigg'
|
|
3
|
+
import { useSocket } from '../hooks/useSocket'
|
|
4
|
+
|
|
5
|
+
const Dashboard = () => {
|
|
6
|
+
const { status, startFrigg, stopFrigg, restartFrigg, integrations, users, connections, getMetrics, getLogs } = useFrigg()
|
|
7
|
+
const { on } = useSocket()
|
|
8
|
+
const [logs, setLogs] = useState([])
|
|
9
|
+
const [metrics, setMetrics] = useState(null)
|
|
10
|
+
const [showAdvanced, setShowAdvanced] = useState(false)
|
|
11
|
+
const [startOptions, setStartOptions] = useState({
|
|
12
|
+
stage: 'dev',
|
|
13
|
+
verbose: false
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// Socket listeners for real-time updates
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const unsubscribeLogs = on('frigg:logs', (logData) => {
|
|
19
|
+
setLogs(logData)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const unsubscribeLog = on('frigg:log', (logEntry) => {
|
|
23
|
+
setLogs(prev => [...prev.slice(-99), logEntry]) // Keep last 100 logs
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// Fetch initial logs and metrics
|
|
27
|
+
const fetchData = async () => {
|
|
28
|
+
try {
|
|
29
|
+
if (typeof getLogs === 'function') {
|
|
30
|
+
const logsData = await getLogs(50)
|
|
31
|
+
setLogs(logsData)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof getMetrics === 'function') {
|
|
35
|
+
const metricsData = await getMetrics()
|
|
36
|
+
setMetrics(metricsData)
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error fetching data:', error)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fetchData()
|
|
44
|
+
|
|
45
|
+
// Update metrics periodically when running
|
|
46
|
+
const metricsInterval = setInterval(() => {
|
|
47
|
+
if (status === 'running' && typeof getMetrics === 'function') {
|
|
48
|
+
getMetrics().then(setMetrics).catch(console.error)
|
|
49
|
+
}
|
|
50
|
+
}, 5000)
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
unsubscribeLogs && unsubscribeLogs()
|
|
54
|
+
unsubscribeLog && unsubscribeLog()
|
|
55
|
+
clearInterval(metricsInterval)
|
|
56
|
+
}
|
|
57
|
+
}, [on, getLogs, getMetrics, status])
|
|
58
|
+
|
|
59
|
+
const handleStart = async () => {
|
|
60
|
+
try {
|
|
61
|
+
await startFrigg(startOptions)
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Failed to start Frigg:', error)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleStop = async (force = false) => {
|
|
68
|
+
try {
|
|
69
|
+
await stopFrigg(force)
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Failed to stop Frigg:', error)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleRestart = async () => {
|
|
76
|
+
try {
|
|
77
|
+
await restartFrigg(startOptions)
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('Failed to restart Frigg:', error)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const stats = [
|
|
84
|
+
{ name: 'Integrations', value: integrations.length, icon: '🔌' },
|
|
85
|
+
{ name: 'Test Users', value: users.length, icon: '👤' },
|
|
86
|
+
{ name: 'Active Connections', value: connections.filter(c => c.active).length, icon: '🔗' },
|
|
87
|
+
{ name: 'Total Entities', value: connections.reduce((sum, c) => sum + (c.entities?.length || 0), 0), icon: '📊' },
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
const formatUptime = (uptime) => {
|
|
91
|
+
if (!uptime) return 'N/A'
|
|
92
|
+
const seconds = Math.floor(uptime / 1000)
|
|
93
|
+
const minutes = Math.floor(seconds / 60)
|
|
94
|
+
const hours = Math.floor(minutes / 60)
|
|
95
|
+
|
|
96
|
+
if (hours > 0) return `${hours}h ${minutes % 60}m`
|
|
97
|
+
if (minutes > 0) return `${minutes}m ${seconds % 60}s`
|
|
98
|
+
return `${seconds}s`
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div>
|
|
103
|
+
<div className="mb-8">
|
|
104
|
+
<h2 className="text-3xl font-bold text-foreground">Dashboard</h2>
|
|
105
|
+
<p className="mt-2 text-muted-foreground">Manage your Frigg development environment</p>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
{/* Control Panel */}
|
|
109
|
+
<div className="bg-card shadow rounded-lg p-6 mb-8 border border-border">
|
|
110
|
+
<div className="flex justify-between items-center mb-4">
|
|
111
|
+
<h3 className="text-lg font-medium text-card-foreground">Frigg Server Control</h3>
|
|
112
|
+
<button
|
|
113
|
+
onClick={() => setShowAdvanced(!showAdvanced)}
|
|
114
|
+
className="text-sm text-primary hover:text-primary/80"
|
|
115
|
+
>
|
|
116
|
+
{showAdvanced ? 'Hide' : 'Show'} Advanced Options
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
{/* Advanced Options */}
|
|
121
|
+
{showAdvanced && (
|
|
122
|
+
<div className="mb-6 p-4 bg-muted/50 rounded-md">
|
|
123
|
+
<div className="grid grid-cols-2 gap-4">
|
|
124
|
+
<div>
|
|
125
|
+
<label className="block text-sm font-medium text-foreground mb-1">
|
|
126
|
+
Stage
|
|
127
|
+
</label>
|
|
128
|
+
<select
|
|
129
|
+
value={startOptions.stage}
|
|
130
|
+
onChange={(e) => setStartOptions(prev => ({ ...prev, stage: e.target.value }))}
|
|
131
|
+
className="w-full px-3 py-2 border border-input bg-background text-foreground rounded-md focus:outline-none focus:ring-2 focus:ring-ring"
|
|
132
|
+
>
|
|
133
|
+
<option value="dev">Development</option>
|
|
134
|
+
<option value="staging">Staging</option>
|
|
135
|
+
<option value="prod">Production</option>
|
|
136
|
+
</select>
|
|
137
|
+
</div>
|
|
138
|
+
<div className="flex items-center">
|
|
139
|
+
<input
|
|
140
|
+
type="checkbox"
|
|
141
|
+
id="verbose"
|
|
142
|
+
checked={startOptions.verbose}
|
|
143
|
+
onChange={(e) => setStartOptions(prev => ({ ...prev, verbose: e.target.checked }))}
|
|
144
|
+
className="mr-2"
|
|
145
|
+
/>
|
|
146
|
+
<label htmlFor="verbose" className="text-sm font-medium text-foreground">
|
|
147
|
+
Verbose logging
|
|
148
|
+
</label>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
)}
|
|
153
|
+
|
|
154
|
+
{/* Status Display */}
|
|
155
|
+
<div className="mb-4 p-4 bg-muted/50 rounded-md">
|
|
156
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
|
|
157
|
+
<div>
|
|
158
|
+
<span className="text-muted-foreground">Status:</span>
|
|
159
|
+
<span className={`ml-2 font-medium ${
|
|
160
|
+
status === 'running' ? 'text-green-600' :
|
|
161
|
+
status === 'stopped' ? 'text-red-600' :
|
|
162
|
+
'text-yellow-600'
|
|
163
|
+
}`}>
|
|
164
|
+
{status.charAt(0).toUpperCase() + status.slice(1)}
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
{metrics && (
|
|
168
|
+
<>
|
|
169
|
+
<div>
|
|
170
|
+
<span className="text-muted-foreground">PID:</span>
|
|
171
|
+
<span className="ml-2 font-medium">{metrics.pid || 'N/A'}</span>
|
|
172
|
+
</div>
|
|
173
|
+
<div>
|
|
174
|
+
<span className="text-muted-foreground">Uptime:</span>
|
|
175
|
+
<span className="ml-2 font-medium">{formatUptime(metrics.uptime)}</span>
|
|
176
|
+
</div>
|
|
177
|
+
<div>
|
|
178
|
+
<span className="text-muted-foreground">Stage:</span>
|
|
179
|
+
<span className="ml-2 font-medium">{startOptions.stage}</span>
|
|
180
|
+
</div>
|
|
181
|
+
</>
|
|
182
|
+
)}
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
{/* Control Buttons */}
|
|
187
|
+
<div className="flex items-center space-x-3">
|
|
188
|
+
<button
|
|
189
|
+
onClick={handleStart}
|
|
190
|
+
disabled={status === 'running' || status === 'starting'}
|
|
191
|
+
className={`px-6 py-3 rounded-md font-medium transition-colors ${
|
|
192
|
+
status === 'running' || status === 'starting'
|
|
193
|
+
? 'bg-muted text-muted-foreground cursor-not-allowed'
|
|
194
|
+
: 'bg-green-600 text-white hover:bg-green-700'
|
|
195
|
+
}`}
|
|
196
|
+
>
|
|
197
|
+
▶️ Start
|
|
198
|
+
</button>
|
|
199
|
+
|
|
200
|
+
<button
|
|
201
|
+
onClick={() => handleStop()}
|
|
202
|
+
disabled={status === 'stopped' || status === 'stopping'}
|
|
203
|
+
className={`px-6 py-3 rounded-md font-medium transition-colors ${
|
|
204
|
+
status === 'stopped' || status === 'stopping'
|
|
205
|
+
? 'bg-muted text-muted-foreground cursor-not-allowed'
|
|
206
|
+
: 'bg-red-600 text-white hover:bg-red-700'
|
|
207
|
+
}`}
|
|
208
|
+
>
|
|
209
|
+
⏹️ Stop
|
|
210
|
+
</button>
|
|
211
|
+
|
|
212
|
+
<button
|
|
213
|
+
onClick={handleRestart}
|
|
214
|
+
disabled={status === 'starting' || status === 'stopping'}
|
|
215
|
+
className={`px-6 py-3 rounded-md font-medium transition-colors ${
|
|
216
|
+
status === 'starting' || status === 'stopping'
|
|
217
|
+
? 'bg-muted text-muted-foreground cursor-not-allowed'
|
|
218
|
+
: 'bg-blue-600 text-white hover:bg-blue-700'
|
|
219
|
+
}`}
|
|
220
|
+
>
|
|
221
|
+
🔄 Restart
|
|
222
|
+
</button>
|
|
223
|
+
|
|
224
|
+
{(status === 'running' || status === 'stopping') && (
|
|
225
|
+
<button
|
|
226
|
+
onClick={() => handleStop(true)}
|
|
227
|
+
className="px-4 py-3 rounded-md font-medium bg-orange-600 text-white hover:bg-orange-700 transition-colors"
|
|
228
|
+
>
|
|
229
|
+
⚠️ Force Stop
|
|
230
|
+
</button>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
{/* Stats Grid */}
|
|
236
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
|
237
|
+
{stats.map((stat) => (
|
|
238
|
+
<div key={stat.name} className="bg-card shadow rounded-lg p-6 border border-border">
|
|
239
|
+
<div className="flex items-center">
|
|
240
|
+
<span className="text-3xl mr-3">{stat.icon}</span>
|
|
241
|
+
<div>
|
|
242
|
+
<p className="text-sm font-medium text-muted-foreground">{stat.name}</p>
|
|
243
|
+
<p className="text-2xl font-bold text-card-foreground">{stat.value}</p>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
))}
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
{/* Real-time Logs */}
|
|
251
|
+
<div className="bg-card shadow rounded-lg p-6 mb-8 border border-border">
|
|
252
|
+
<div className="flex justify-between items-center mb-4">
|
|
253
|
+
<h3 className="text-lg font-medium text-card-foreground">Real-time Logs</h3>
|
|
254
|
+
<button
|
|
255
|
+
onClick={() => setLogs([])}
|
|
256
|
+
className="text-sm text-red-600 hover:text-red-800"
|
|
257
|
+
>
|
|
258
|
+
Clear Logs
|
|
259
|
+
</button>
|
|
260
|
+
</div>
|
|
261
|
+
<div className="bg-muted/30 dark:bg-gray-900 text-foreground dark:text-gray-100 p-4 rounded-md h-64 overflow-y-auto font-mono text-sm border border-border">
|
|
262
|
+
{logs.length === 0 ? (
|
|
263
|
+
<div className="text-muted-foreground text-center py-8">
|
|
264
|
+
No logs available. Start Frigg to see real-time logs.
|
|
265
|
+
</div>
|
|
266
|
+
) : (
|
|
267
|
+
logs.map((log, index) => (
|
|
268
|
+
<div key={index} className="mb-1 flex">
|
|
269
|
+
<span className="text-muted-foreground mr-2 w-20 flex-shrink-0">
|
|
270
|
+
{new Date(log.timestamp).toLocaleTimeString()}
|
|
271
|
+
</span>
|
|
272
|
+
<span className={`mr-2 w-12 flex-shrink-0 ${
|
|
273
|
+
log.type === 'stderr' ? 'text-red-400' :
|
|
274
|
+
log.type === 'system' ? 'text-blue-400' :
|
|
275
|
+
'text-green-400'
|
|
276
|
+
}`}>
|
|
277
|
+
[{log.type.toUpperCase()}]
|
|
278
|
+
</span>
|
|
279
|
+
<span className="flex-1 break-all">{log.message}</span>
|
|
280
|
+
</div>
|
|
281
|
+
))
|
|
282
|
+
)}
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
{/* Recent Activity */}
|
|
287
|
+
<div className="bg-card shadow rounded-lg p-6 border border-border">
|
|
288
|
+
<h3 className="text-lg font-medium text-card-foreground mb-4">Recent Activity</h3>
|
|
289
|
+
<div className="space-y-3">
|
|
290
|
+
<div className="flex items-center text-sm">
|
|
291
|
+
<span className="w-2 h-2 bg-green-400 rounded-full mr-3"></span>
|
|
292
|
+
<span className="text-foreground">Frigg server started</span>
|
|
293
|
+
<span className="ml-auto text-muted-foreground">2 minutes ago</span>
|
|
294
|
+
</div>
|
|
295
|
+
<div className="flex items-center text-sm">
|
|
296
|
+
<span className="w-2 h-2 bg-blue-400 rounded-full mr-3"></span>
|
|
297
|
+
<span className="text-foreground">Integration 'Slack' installed</span>
|
|
298
|
+
<span className="ml-auto text-muted-foreground">15 minutes ago</span>
|
|
299
|
+
</div>
|
|
300
|
+
<div className="flex items-center text-sm">
|
|
301
|
+
<span className="w-2 h-2 bg-purple-400 rounded-full mr-3"></span>
|
|
302
|
+
<span className="text-foreground">Test user 'john.doe' created</span>
|
|
303
|
+
<span className="ml-auto text-muted-foreground">1 hour ago</span>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
</div>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export default Dashboard
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useFrigg } from '../hooks/useFrigg'
|
|
3
|
+
import { useSocket } from '../hooks/useSocket'
|
|
4
|
+
import api from '../services/api'
|
|
5
|
+
import EnvironmentEditor from '../components/EnvironmentEditor'
|
|
6
|
+
import EnvironmentSchema from '../components/EnvironmentSchema'
|
|
7
|
+
import EnvironmentCompare from '../components/EnvironmentCompare'
|
|
8
|
+
import EnvironmentImportExport from '../components/EnvironmentImportExport'
|
|
9
|
+
import EnvironmentSecurity from '../components/EnvironmentSecurity'
|
|
10
|
+
|
|
11
|
+
const Environment = () => {
|
|
12
|
+
const { envVariables, updateEnvVariable, refreshData } = useFrigg()
|
|
13
|
+
const { on } = useSocket()
|
|
14
|
+
const [activeTab, setActiveTab] = useState('editor') // editor, schema, compare, import-export, security
|
|
15
|
+
const [selectedEnvironment, setSelectedEnvironment] = useState('local')
|
|
16
|
+
const [variables, setVariables] = useState([])
|
|
17
|
+
const [loading, setLoading] = useState(false)
|
|
18
|
+
const [notification, setNotification] = useState(null)
|
|
19
|
+
|
|
20
|
+
// Load environment variables
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
loadEnvironmentVariables()
|
|
23
|
+
}, [selectedEnvironment])
|
|
24
|
+
|
|
25
|
+
// Listen for real-time updates
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const unsubscribe = on('env-update', (data) => {
|
|
28
|
+
if (data.environment === selectedEnvironment) {
|
|
29
|
+
loadEnvironmentVariables()
|
|
30
|
+
showNotification('Environment variables updated', 'success')
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
return unsubscribe
|
|
34
|
+
}, [on, selectedEnvironment])
|
|
35
|
+
|
|
36
|
+
const loadEnvironmentVariables = async () => {
|
|
37
|
+
setLoading(true)
|
|
38
|
+
try {
|
|
39
|
+
const response = await api.get(`/api/environment/variables/${selectedEnvironment}`)
|
|
40
|
+
setVariables(response.data.variables || [])
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('Error loading variables:', error)
|
|
43
|
+
showNotification('Failed to load environment variables', 'error')
|
|
44
|
+
} finally {
|
|
45
|
+
setLoading(false)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const handleSaveVariables = async (updatedVariables) => {
|
|
50
|
+
try {
|
|
51
|
+
await api.put(`/api/environment/variables/${selectedEnvironment}`, {
|
|
52
|
+
variables: updatedVariables
|
|
53
|
+
})
|
|
54
|
+
await loadEnvironmentVariables()
|
|
55
|
+
showNotification('Environment variables saved successfully', 'success')
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('Error saving variables:', error)
|
|
58
|
+
showNotification('Failed to save environment variables', 'error')
|
|
59
|
+
throw error
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const handleVariableUpdate = async (key, value) => {
|
|
64
|
+
try {
|
|
65
|
+
await api.post('/api/environment', { key, value })
|
|
66
|
+
await loadEnvironmentVariables()
|
|
67
|
+
showNotification(`Variable ${key} updated`, 'success')
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('Error updating variable:', error)
|
|
70
|
+
showNotification('Failed to update variable', 'error')
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const handleVariableDelete = async (key) => {
|
|
75
|
+
if (!window.confirm(`Are you sure you want to delete ${key}?`)) return
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await api.delete(`/api/environment/${key}`)
|
|
79
|
+
await loadEnvironmentVariables()
|
|
80
|
+
showNotification(`Variable ${key} deleted`, 'success')
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Error deleting variable:', error)
|
|
83
|
+
showNotification('Failed to delete variable', 'error')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const showNotification = (message, type = 'info') => {
|
|
88
|
+
setNotification({ message, type })
|
|
89
|
+
setTimeout(() => setNotification(null), 5000)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div>
|
|
94
|
+
{/* Header */}
|
|
95
|
+
<div className="mb-8">
|
|
96
|
+
<div className="flex items-center justify-between">
|
|
97
|
+
<div>
|
|
98
|
+
<h2 className="text-3xl font-bold text-gray-900">Environment Variables</h2>
|
|
99
|
+
<p className="mt-2 text-gray-600">Manage environment variables across different environments</p>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{/* Environment Selector */}
|
|
103
|
+
<div className="flex items-center space-x-2">
|
|
104
|
+
<label className="text-sm font-medium text-gray-700">Environment:</label>
|
|
105
|
+
<select
|
|
106
|
+
value={selectedEnvironment}
|
|
107
|
+
onChange={(e) => setSelectedEnvironment(e.target.value)}
|
|
108
|
+
className="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500"
|
|
109
|
+
>
|
|
110
|
+
<option value="local">Local</option>
|
|
111
|
+
<option value="staging">Staging</option>
|
|
112
|
+
<option value="production">Production</option>
|
|
113
|
+
</select>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{/* Notification */}
|
|
119
|
+
{notification && (
|
|
120
|
+
<div className={`mb-4 p-4 rounded-md ${
|
|
121
|
+
notification.type === 'success' ? 'bg-green-50 text-green-800' :
|
|
122
|
+
notification.type === 'error' ? 'bg-red-50 text-red-800' :
|
|
123
|
+
'bg-blue-50 text-blue-800'
|
|
124
|
+
}`}>
|
|
125
|
+
<div className="flex">
|
|
126
|
+
<div className="flex-shrink-0">
|
|
127
|
+
{notification.type === 'success' && (
|
|
128
|
+
<svg className="h-5 w-5 text-green-400" fill="currentColor" viewBox="0 0 20 20">
|
|
129
|
+
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
|
|
130
|
+
</svg>
|
|
131
|
+
)}
|
|
132
|
+
{notification.type === 'error' && (
|
|
133
|
+
<svg className="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
|
134
|
+
<path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clipRule="evenodd" />
|
|
135
|
+
</svg>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
<div className="ml-3">
|
|
139
|
+
<p className="text-sm font-medium">{notification.message}</p>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
|
|
145
|
+
{/* Tabs */}
|
|
146
|
+
<div className="mb-6">
|
|
147
|
+
<div className="border-b border-gray-200">
|
|
148
|
+
<nav className="-mb-px flex space-x-8">
|
|
149
|
+
<button
|
|
150
|
+
onClick={() => setActiveTab('editor')}
|
|
151
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
152
|
+
activeTab === 'editor'
|
|
153
|
+
? 'border-blue-500 text-blue-600'
|
|
154
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
155
|
+
}`}
|
|
156
|
+
>
|
|
157
|
+
Editor
|
|
158
|
+
</button>
|
|
159
|
+
<button
|
|
160
|
+
onClick={() => setActiveTab('schema')}
|
|
161
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
162
|
+
activeTab === 'schema'
|
|
163
|
+
? 'border-blue-500 text-blue-600'
|
|
164
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
165
|
+
}`}
|
|
166
|
+
>
|
|
167
|
+
Schema & Validation
|
|
168
|
+
</button>
|
|
169
|
+
<button
|
|
170
|
+
onClick={() => setActiveTab('compare')}
|
|
171
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
172
|
+
activeTab === 'compare'
|
|
173
|
+
? 'border-blue-500 text-blue-600'
|
|
174
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
175
|
+
}`}
|
|
176
|
+
>
|
|
177
|
+
Compare & Sync
|
|
178
|
+
</button>
|
|
179
|
+
<button
|
|
180
|
+
onClick={() => setActiveTab('import-export')}
|
|
181
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
182
|
+
activeTab === 'import-export'
|
|
183
|
+
? 'border-blue-500 text-blue-600'
|
|
184
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
185
|
+
}`}
|
|
186
|
+
>
|
|
187
|
+
Import/Export
|
|
188
|
+
</button>
|
|
189
|
+
<button
|
|
190
|
+
onClick={() => setActiveTab('security')}
|
|
191
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
192
|
+
activeTab === 'security'
|
|
193
|
+
? 'border-blue-500 text-blue-600'
|
|
194
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
195
|
+
}`}
|
|
196
|
+
>
|
|
197
|
+
Security
|
|
198
|
+
</button>
|
|
199
|
+
</nav>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
{/* Tab Content */}
|
|
204
|
+
<div className="mt-6">
|
|
205
|
+
{loading ? (
|
|
206
|
+
<div className="flex items-center justify-center h-64">
|
|
207
|
+
<div className="text-gray-500">Loading...</div>
|
|
208
|
+
</div>
|
|
209
|
+
) : (
|
|
210
|
+
<>
|
|
211
|
+
{/* Editor Tab */}
|
|
212
|
+
{activeTab === 'editor' && (
|
|
213
|
+
<EnvironmentEditor
|
|
214
|
+
variables={variables}
|
|
215
|
+
environment={selectedEnvironment}
|
|
216
|
+
onSave={handleSaveVariables}
|
|
217
|
+
onVariableUpdate={handleVariableUpdate}
|
|
218
|
+
onVariableDelete={handleVariableDelete}
|
|
219
|
+
readOnly={selectedEnvironment === 'production'}
|
|
220
|
+
/>
|
|
221
|
+
)}
|
|
222
|
+
|
|
223
|
+
{/* Schema Tab */}
|
|
224
|
+
{activeTab === 'schema' && (
|
|
225
|
+
<EnvironmentSchema
|
|
226
|
+
variables={variables}
|
|
227
|
+
environment={selectedEnvironment}
|
|
228
|
+
onSchemaUpdate={(schema) => {
|
|
229
|
+
showNotification('Schema updated', 'success')
|
|
230
|
+
}}
|
|
231
|
+
/>
|
|
232
|
+
)}
|
|
233
|
+
|
|
234
|
+
{/* Compare Tab */}
|
|
235
|
+
{activeTab === 'compare' && (
|
|
236
|
+
<EnvironmentCompare
|
|
237
|
+
onSync={(result) => {
|
|
238
|
+
showNotification(
|
|
239
|
+
`Synced ${result.count} variables from ${result.source} to ${result.target}`,
|
|
240
|
+
'success'
|
|
241
|
+
)
|
|
242
|
+
if (result.target === selectedEnvironment) {
|
|
243
|
+
loadEnvironmentVariables()
|
|
244
|
+
}
|
|
245
|
+
}}
|
|
246
|
+
/>
|
|
247
|
+
)}
|
|
248
|
+
|
|
249
|
+
{/* Import/Export Tab */}
|
|
250
|
+
{activeTab === 'import-export' && (
|
|
251
|
+
<EnvironmentImportExport
|
|
252
|
+
environment={selectedEnvironment}
|
|
253
|
+
onImport={(result) => {
|
|
254
|
+
showNotification(
|
|
255
|
+
`Imported ${result.imported} variables`,
|
|
256
|
+
'success'
|
|
257
|
+
)
|
|
258
|
+
loadEnvironmentVariables()
|
|
259
|
+
}}
|
|
260
|
+
onExport={(result) => {
|
|
261
|
+
showNotification(
|
|
262
|
+
`Exported variables as ${result.format.toUpperCase()}`,
|
|
263
|
+
'success'
|
|
264
|
+
)
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
)}
|
|
268
|
+
|
|
269
|
+
{/* Security Tab */}
|
|
270
|
+
{activeTab === 'security' && (
|
|
271
|
+
<EnvironmentSecurity
|
|
272
|
+
environment={selectedEnvironment}
|
|
273
|
+
/>
|
|
274
|
+
)}
|
|
275
|
+
</>
|
|
276
|
+
)}
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
{/* AWS Parameter Store Status (for production) */}
|
|
280
|
+
{selectedEnvironment === 'production' && (
|
|
281
|
+
<div className="mt-6 bg-yellow-50 border border-yellow-200 rounded-lg p-4">
|
|
282
|
+
<div className="flex items-center justify-between">
|
|
283
|
+
<div className="flex">
|
|
284
|
+
<svg className="h-5 w-5 text-yellow-400 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
|
285
|
+
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
|
|
286
|
+
</svg>
|
|
287
|
+
<div className="text-sm text-yellow-700">
|
|
288
|
+
<p className="font-medium">Production Environment</p>
|
|
289
|
+
<p>This environment can sync with AWS Parameter Store for secure secret management.</p>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
<button
|
|
293
|
+
onClick={async () => {
|
|
294
|
+
try {
|
|
295
|
+
await api.post('/api/environment/sync/aws-parameter-store', {
|
|
296
|
+
environment: 'production'
|
|
297
|
+
})
|
|
298
|
+
showNotification('Synced with AWS Parameter Store', 'success')
|
|
299
|
+
} catch (error) {
|
|
300
|
+
showNotification('Failed to sync with AWS', 'error')
|
|
301
|
+
}
|
|
302
|
+
}}
|
|
303
|
+
className="px-3 py-1 text-sm bg-yellow-600 text-white rounded hover:bg-yellow-700"
|
|
304
|
+
>
|
|
305
|
+
Sync with AWS
|
|
306
|
+
</button>
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
)}
|
|
310
|
+
</div>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export default Environment
|