Skip to content

Commit 281fdbc

Browse files
author
Samyak Rout
committed
feat: Add initial setup for maintenance site with configuration and components
1 parent b1e9636 commit 281fdbc

File tree

114 files changed

+15542
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+15542
-3
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ infra_as_code/terraform_generator/backend/configs/terraform-generator.json.examp
3737
**/output/**/*
3838

3939
working-terraform-generator.json
40-
test-terraform-generator.json
40+
test-terraform-generator.json
41+
42+
**node_modules/**/*
43+
**node_modules
44+
**.next/**/*

infra_as_code/terraform_generator/backend/utils/file_utils.go

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,68 @@ func ToJSON(value interface{}) (string, error) {
4040
return string(jsonBytes), nil
4141
}
4242

43+
// formatValue dynamically formats values based on their types.
44+
func formatValue(value interface{}, varType string) string {
45+
switch varType {
46+
case "string":
47+
// Quote the value if it's a string and not a variable reference
48+
if strVal, ok := value.(string); ok {
49+
if strings.HasPrefix(strVal, "var.") {
50+
return strVal
51+
}
52+
return fmt.Sprintf("\"%s\"", strVal)
53+
}
54+
return "null"
55+
56+
case "bool", "number":
57+
// Render booleans and numbers as-is
58+
return fmt.Sprintf("%v", value)
59+
60+
case "map(string)":
61+
// Render map values
62+
if mapVal, ok := value.(map[string]interface{}); ok {
63+
if len(mapVal) == 0 {
64+
return "null"
65+
}
66+
var entries []string
67+
for key, val := range mapVal {
68+
entries = append(entries, fmt.Sprintf("\"%s\" = \"%v\"", key, val))
69+
}
70+
return fmt.Sprintf("{ %s }", strings.Join(entries, ", "))
71+
}
72+
return "null"
73+
74+
case "list(string)", "set(string)":
75+
// Render lists or sets
76+
if listVal, ok := value.([]interface{}); ok {
77+
var items []string
78+
for _, item := range listVal {
79+
items = append(items, fmt.Sprintf("\"%v\"", item))
80+
}
81+
if varType == "set(string)" {
82+
return fmt.Sprintf("toset([%s])", strings.Join(items, ", "))
83+
}
84+
return fmt.Sprintf("[%s]", strings.Join(items, ", "))
85+
}
86+
return "[]"
87+
88+
case "object", "tuple":
89+
// Handle objects or tuples
90+
if mapVal, ok := value.(map[string]interface{}); ok {
91+
var entries []string
92+
for key, val := range mapVal {
93+
entries = append(entries, fmt.Sprintf("\"%s\" = %v", key, val))
94+
}
95+
return fmt.Sprintf("{ %s }", strings.Join(entries, ", "))
96+
}
97+
return "{}"
98+
99+
default:
100+
// Default fallback for unknown types
101+
return fmt.Sprintf("%v", value)
102+
}
103+
}
104+
43105
// FormatDefault formats the default value of a variable
44106
func FormatDefault(varDef models.Variable) string {
45107
switch varDef.Type {
@@ -191,8 +253,8 @@ func GenerateFileFromTemplate(templatePath, destinationPath string, data interfa
191253
return fmt.Sprintf("%v", value)
192254
}
193255
},
194-
"formatDefault": FormatDefault,
195-
"formatType": formatType, // Add formatType to the funcMap
256+
"formatDefault": FormatDefault, // Existing functions
257+
"formatType": formatType, // Existing functions
196258
}
197259

198260
// Parse the template with the function map
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
:root {
6+
--foreground-rgb: 0, 0, 0;
7+
--background-start-rgb: 214, 219, 220;
8+
--background-end-rgb: 255, 255, 255;
9+
}
10+
11+
@media (prefers-color-scheme: dark) {
12+
:root {
13+
--foreground-rgb: 255, 255, 255;
14+
--background-start-rgb: 0, 0, 0;
15+
--background-end-rgb: 0, 0, 0;
16+
}
17+
}
18+
19+
@layer base {
20+
:root {
21+
--background: 0 0% 100%;
22+
--foreground: 0 0% 3.9%;
23+
--card: 0 0% 100%;
24+
--card-foreground: 0 0% 3.9%;
25+
--popover: 0 0% 100%;
26+
--popover-foreground: 0 0% 3.9%;
27+
--primary: 221.2 83.2% 53.3%;
28+
--primary-foreground: 210 40% 98%;
29+
--secondary: 210 40% 96.1%;
30+
--secondary-foreground: 222.2 47.4% 11.2%;
31+
--muted: 210 40% 96.1%;
32+
--muted-foreground: 215.4 16.3% 46.9%;
33+
--accent: 210 40% 96.1%;
34+
--accent-foreground: 222.2 47.4% 11.2%;
35+
--destructive: 0 84.2% 60.2%;
36+
--destructive-foreground: 210 40% 98%;
37+
--border: 214.3 31.8% 91.4%;
38+
--input: 214.3 31.8% 91.4%;
39+
--ring: 221.2 83.2% 53.3%;
40+
--radius: 0.75rem;
41+
}
42+
43+
.dark {
44+
--background: 222.2 84% 4.9%;
45+
--foreground: 210 40% 98%;
46+
--card: 222.2 84% 4.9%;
47+
--card-foreground: 210 40% 98%;
48+
--popover: 222.2 84% 4.9%;
49+
--popover-foreground: 210 40% 98%;
50+
--primary: 217.2 91.2% 59.8%;
51+
--primary-foreground: 222.2 47.4% 11.2%;
52+
--secondary: 217.2 32.6% 17.5%;
53+
--secondary-foreground: 210 40% 98%;
54+
--muted: 217.2 32.6% 17.5%;
55+
--muted-foreground: 215 20.2% 65.1%;
56+
--accent: 217.2 32.6% 17.5%;
57+
--accent-foreground: 210 40% 98%;
58+
--destructive: 0 62.8% 30.6%;
59+
--destructive-foreground: 210 40% 98%;
60+
--border: 217.2 32.6% 17.5%;
61+
--input: 217.2 32.6% 17.5%;
62+
--ring: 224.3 76.3% 48%;
63+
}
64+
}
65+
66+
@layer base {
67+
* {
68+
@apply border-border;
69+
}
70+
body {
71+
@apply bg-background text-foreground antialiased;
72+
}
73+
}
74+
75+
@keyframes fade-in {
76+
from {
77+
opacity: 0;
78+
transform: translateY(-20px);
79+
}
80+
to {
81+
opacity: 1;
82+
transform: translateY(0);
83+
}
84+
}
85+
86+
@keyframes slide-in {
87+
from {
88+
opacity: 0;
89+
transform: translateX(-20px);
90+
}
91+
to {
92+
opacity: 1;
93+
transform: translateX(0);
94+
}
95+
}
96+
97+
@keyframes scale-in {
98+
from {
99+
opacity: 0;
100+
transform: scale(0.95);
101+
}
102+
to {
103+
opacity: 1;
104+
transform: scale(1);
105+
}
106+
}
107+
108+
.animate-fade-in {
109+
animation: fade-in 0.6s cubic-bezier(0.4, 0, 0.2, 1);
110+
}
111+
112+
.animate-slide-in {
113+
animation: slide-in 0.5s cubic-bezier(0.4, 0, 0.2, 1);
114+
}
115+
116+
.animate-scale-in {
117+
animation: scale-in 0.5s cubic-bezier(0.4, 0, 0.2, 1);
118+
}
119+
120+
.bg-grid-slate-100 {
121+
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='32' height='32' fill='none' stroke='rgb(51 65 85 / 0.04)'%3e%3cpath d='M0 .5H31.5V32'/%3e%3c/svg%3e");
122+
}
123+
124+
.bg-grid-slate-700 {
125+
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='32' height='32' fill='none' stroke='rgb(51 65 85 / 0.1)'%3e%3cpath d='M0 .5H31.5V32'/%3e%3c/svg%3e");
126+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// app/layout.tsx
2+
import './globals.css';
3+
import type { Metadata } from 'next';
4+
import { Inter } from 'next/font/google';
5+
import { Toaster } from '@/components/ui/sonner';
6+
7+
const inter = Inter({ subsets: ['latin'] });
8+
9+
export const metadata: Metadata = {
10+
title: 'SRE Data Management',
11+
description: 'Update system components and maintenance information',
12+
};
13+
14+
export default function RootLayout({
15+
children,
16+
}: {
17+
children: React.ReactNode;
18+
}) {
19+
return (
20+
<html lang="en">
21+
<body className={inter.className}>
22+
{children}
23+
<Toaster />
24+
</body>
25+
</html>
26+
);
27+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// app/page.tsx
2+
import { DataEntryForm } from '@/components/data-entry-form';
3+
import { WrenchIcon, ActivityIcon, DatabaseIcon } from 'lucide-react';
4+
5+
export default function Home() {
6+
return (
7+
<main className="min-h-screen bg-[radial-gradient(ellipse_at_top_right,_var(--tw-gradient-stops))] from-blue-100 via-slate-50 to-purple-100 dark:from-slate-900 dark:via-blue-950 dark:to-slate-900 p-4 md:p-8 overflow-hidden">
8+
<div className="absolute inset-0 bg-grid-slate-100 [mask-image:radial-gradient(ellipse_at_center,white,transparent)] dark:bg-grid-slate-700/25 pointer-events-none" />
9+
<div className="mx-auto max-w-4xl relative">
10+
<div className="absolute top-[-120px] right-[-120px] w-[300px] h-[300px] bg-primary/20 rounded-full blur-3xl animate-pulse" />
11+
<div className="absolute bottom-[-120px] left-[-120px] w-[300px] h-[300px] bg-purple-500/20 rounded-full blur-3xl animate-pulse" />
12+
13+
<div className="mb-12 text-center animate-fade-in relative">
14+
<div className="flex items-center justify-center gap-4 mb-8">
15+
<div className="relative group">
16+
<div className="absolute inset-0 rounded-xl bg-gradient-to-r from-primary/60 to-purple-500/60 blur-xl opacity-75 group-hover:opacity-100 transition-all duration-500" />
17+
<div className="relative bg-white dark:bg-slate-900 p-4 rounded-xl shadow-2xl">
18+
<WrenchIcon className="h-8 w-8 text-primary animate-pulse" />
19+
</div>
20+
</div>
21+
<div className="relative group">
22+
<div className="absolute inset-0 rounded-xl bg-gradient-to-r from-purple-500/60 to-blue-500/60 blur-xl opacity-75 group-hover:opacity-100 transition-all duration-500" />
23+
<div className="relative bg-white dark:bg-slate-900 p-4 rounded-xl shadow-2xl">
24+
<ActivityIcon className="h-8 w-8 text-purple-500 animate-pulse [animation-delay:200ms]" />
25+
</div>
26+
</div>
27+
<div className="relative group">
28+
<div className="absolute inset-0 rounded-xl bg-gradient-to-r from-blue-500/60 to-primary/60 blur-xl opacity-75 group-hover:opacity-100 transition-all duration-500" />
29+
<div className="relative bg-white dark:bg-slate-900 p-4 rounded-xl shadow-2xl">
30+
<DatabaseIcon className="h-8 w-8 text-blue-500 animate-pulse [animation-delay:400ms]" />
31+
</div>
32+
</div>
33+
</div>
34+
<div className="relative">
35+
<h1 className="text-5xl font-bold tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-primary via-purple-500 to-blue-500 pb-2">
36+
SRE Data Management
37+
</h1>
38+
<div className="absolute inset-0 bg-gradient-to-r from-primary/20 via-purple-500/20 to-blue-500/20 blur-3xl -z-10" />
39+
</div>
40+
<p className="mt-4 text-muted-foreground text-lg max-w-2xl mx-auto leading-relaxed">
41+
Streamline your infrastructure updates with our centralized management system.
42+
Efficiently manage components, maintenance windows, and system updates.
43+
</p>
44+
</div>
45+
<DataEntryForm />
46+
</div>
47+
</main>
48+
);
49+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// app/types/form-schemas.ts
2+
import { z } from 'zod';
3+
4+
export const baseSchema = z.object({
5+
email: z.string().email('Please enter a valid email address'),
6+
updateType: z.enum(['system_components', 'maintenance_windows', 'maintenance_updates']),
7+
});
8+
9+
export const systemComponentsSchema = z.object({
10+
componentName: z.string().min(1, 'Component name is required'),
11+
componentType: z.string().min(1, 'Component type is required'),
12+
componentStatus: z.enum(['operational', 'degraded', 'maintenance']),
13+
});
14+
15+
export const maintenanceWindowsSchema = baseSchema.extend({
16+
startTime: z.string().min(1, 'Required'),
17+
estimatedDuration: z.string().min(1, 'Required'),
18+
description: z.string().min(1, 'Required'),
19+
});
20+
21+
export const maintenanceUpdatesSchema = baseSchema.extend({
22+
message: z.string().min(1, 'Required'),
23+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// app/types/index.ts
2+
export interface ComponentStatus {
3+
key: string;
4+
value: string;
5+
}
6+
7+
export interface SystemComponent {
8+
id: number;
9+
name: string;
10+
type: string;
11+
status: ComponentStatus;
12+
}
13+
14+
export interface MaintenanceWindow {
15+
start_time: Date;
16+
estimated_duration: string;
17+
description: string;
18+
}
19+
20+
export interface MaintenanceUpdate {
21+
message: string;
22+
}
23+
24+
export interface FormData {
25+
email: string;
26+
updateType: 'system_components' | 'maintenance_windows' | 'maintenance_updates';
27+
systemComponent?: SystemComponent;
28+
maintenanceWindow?: MaintenanceWindow;
29+
maintenanceUpdate?: MaintenanceUpdate;
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
}
20+
}

0 commit comments

Comments
 (0)