Skip to content

Commit 1362ede

Browse files
authored
fix: ios drawer fix (#291)
* fix: ios drawer fix * chore: format
1 parent 33c6798 commit 1362ede

File tree

16 files changed

+1147
-1086
lines changed

16 files changed

+1147
-1086
lines changed

infrastructure/control-panel/src/lib/services/evaultService.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ export class EVaultService {
1515
}
1616
}
1717

18-
static async getEVaultLogs(namespace: string, podName: string, tail: number = 100): Promise<string[]> {
18+
static async getEVaultLogs(
19+
namespace: string,
20+
podName: string,
21+
tail: number = 100
22+
): Promise<string[]> {
1923
try {
20-
const response = await fetch(`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/logs?tail=${tail}`);
24+
const response = await fetch(
25+
`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/logs?tail=${tail}`
26+
);
2127
if (!response.ok) {
2228
throw new Error('Failed to fetch logs');
2329
}
@@ -31,7 +37,9 @@ export class EVaultService {
3137

3238
static async getEVaultDetails(namespace: string, podName: string): Promise<any> {
3339
try {
34-
const response = await fetch(`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/details`);
40+
const response = await fetch(
41+
`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/details`
42+
);
3543
if (!response.ok) {
3644
throw new Error('Failed to fetch eVault details');
3745
}
@@ -44,7 +52,9 @@ export class EVaultService {
4452

4553
static async getEVaultMetrics(namespace: string, podName: string): Promise<any> {
4654
try {
47-
const response = await fetch(`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/metrics`);
55+
const response = await fetch(
56+
`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/metrics`
57+
);
4858
if (!response.ok) {
4959
throw new Error('Failed to fetch metrics');
5060
}
@@ -54,4 +64,4 @@ export class EVaultService {
5464
return null;
5565
}
5666
}
57-
}
67+
}

infrastructure/control-panel/src/routes/api/evaults/+server.ts

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,60 @@ export const GET: RequestHandler = async () => {
2626
// Get minikube IP for NodePort services
2727
let minikubeIP = 'localhost';
2828
try {
29-
const { stdout: minikubeIPOutput } = await execAsync('minikube ip 2>/dev/null || echo "localhost"');
29+
const { stdout: minikubeIPOutput } = await execAsync(
30+
'minikube ip 2>/dev/null || echo "localhost"'
31+
);
3032
if (minikubeIPOutput.trim()) {
3133
minikubeIP = minikubeIPOutput.trim();
3234
}
3335
} catch (ipError) {
3436
console.log('Could not get minikube IP, using localhost');
3537
}
36-
38+
3739
console.log('Using IP:', minikubeIP);
38-
40+
3941
// Get all namespaces
4042
const { stdout: namespacesOutput } = await execAsync('kubectl get namespaces -o json');
4143
const namespaces = JSON.parse(namespacesOutput);
42-
44+
4345
// Filter for eVault namespaces
4446
const evaultNamespaces = namespaces.items
4547
.filter((ns: any) => ns.metadata.name.startsWith('evault-'))
4648
.map((ns: any) => ns.metadata.name);
47-
49+
4850
console.log('Found eVault namespaces:', evaultNamespaces);
49-
51+
5052
let allEVaults: EVault[] = [];
5153

5254
// Get services and pods from each eVault namespace
5355
for (const namespace of evaultNamespaces) {
5456
try {
5557
// Get services in this namespace as JSON
56-
const { stdout: servicesOutput } = await execAsync(`kubectl get services -n ${namespace} -o json`);
58+
const { stdout: servicesOutput } = await execAsync(
59+
`kubectl get services -n ${namespace} -o json`
60+
);
5761
const services = JSON.parse(servicesOutput);
58-
62+
5963
// Get pods in this namespace as JSON
60-
const { stdout: podsOutput } = await execAsync(`kubectl get pods -n ${namespace} -o json`);
64+
const { stdout: podsOutput } = await execAsync(
65+
`kubectl get pods -n ${namespace} -o json`
66+
);
6167
const pods = JSON.parse(podsOutput);
62-
68+
6369
console.log(`=== SERVICES FOR ${namespace} ===`);
6470
console.log(JSON.stringify(services, null, 2));
6571
console.log(`=== PODS FOR ${namespace} ===`);
6672
console.log(JSON.stringify(pods, null, 2));
6773
console.log(`=== END DATA ===`);
68-
74+
6975
if (services.items && services.items.length > 0) {
7076
for (const service of services.items) {
7177
const serviceName = service.metadata.name;
7278
const serviceType = service.spec.type;
7379
const ports = service.spec.ports;
74-
80+
7581
console.log(`Service: ${serviceName}, Type: ${serviceType}, Ports:`, ports);
76-
82+
7783
// Find NodePort for NodePort services
7884
let nodePort = null;
7985
if (serviceType === 'NodePort' && ports) {
@@ -84,9 +90,9 @@ export const GET: RequestHandler = async () => {
8490
}
8591
}
8692
}
87-
93+
8894
console.log(`NodePort: ${nodePort}`);
89-
95+
9096
// Get pod data for this service
9197
let podData = {
9298
status: 'Unknown',
@@ -98,28 +104,39 @@ export const GET: RequestHandler = async () => {
98104
node: 'N/A',
99105
podName: 'N/A'
100106
};
101-
107+
102108
if (pods.items && pods.items.length > 0) {
103109
// Find pod that matches this service (usually same name or has service label)
104-
const matchingPod = pods.items.find((pod: any) =>
105-
pod.metadata.name.includes(serviceName.replace('-service', '')) ||
106-
pod.metadata.labels?.app === 'evault'
110+
const matchingPod = pods.items.find(
111+
(pod: any) =>
112+
pod.metadata.name.includes(
113+
serviceName.replace('-service', '')
114+
) || pod.metadata.labels?.app === 'evault'
107115
);
108-
116+
109117
if (matchingPod) {
110118
const pod = matchingPod;
111-
const readyCount = pod.status.containerStatuses?.filter((cs: any) => cs.ready).length || 0;
119+
const readyCount =
120+
pod.status.containerStatuses?.filter((cs: any) => cs.ready)
121+
.length || 0;
112122
const totalCount = pod.status.containerStatuses?.length || 0;
113-
const restarts = pod.status.containerStatuses?.reduce((sum: number, cs: any) => sum + (cs.restartCount || 0), 0) || 0;
114-
123+
const restarts =
124+
pod.status.containerStatuses?.reduce(
125+
(sum: number, cs: any) => sum + (cs.restartCount || 0),
126+
0
127+
) || 0;
128+
115129
// Calculate age
116130
const creationTime = new Date(pod.metadata.creationTimestamp);
117131
const now = new Date();
118132
const ageMs = now.getTime() - creationTime.getTime();
119133
const ageDays = Math.floor(ageMs / (1000 * 60 * 60 * 24));
120-
const ageHours = Math.floor((ageMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
121-
const age = ageDays > 0 ? `${ageDays}d${ageHours}h` : `${ageHours}h`;
122-
134+
const ageHours = Math.floor(
135+
(ageMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
136+
);
137+
const age =
138+
ageDays > 0 ? `${ageDays}d${ageHours}h` : `${ageHours}h`;
139+
123140
podData = {
124141
status: pod.status.phase || 'Unknown',
125142
age: age,
@@ -132,18 +149,18 @@ export const GET: RequestHandler = async () => {
132149
};
133150
}
134151
}
135-
152+
136153
// Extract the eVault ID from the namespace
137154
const evaultId = namespace.replace('evault-', '');
138-
155+
139156
// Generate service URL
140157
let serviceUrl = '';
141158
if (nodePort) {
142159
serviceUrl = `http://${minikubeIP}:${nodePort}`;
143160
}
144-
161+
145162
console.log(`Service URL: ${serviceUrl}`);
146-
163+
147164
allEVaults.push({
148165
id: serviceName,
149166
name: serviceName,
@@ -172,4 +189,4 @@ export const GET: RequestHandler = async () => {
172189
console.error('Error fetching eVaults:', error);
173190
return json({ error: 'Failed to fetch eVaults', evaults: [] }, { status: 500 });
174191
}
175-
};
192+
};

infrastructure/control-panel/src/routes/api/evaults/[namespace]/[pod]/details/+server.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ export const GET: RequestHandler = async ({ params }) => {
1111
try {
1212
// Get detailed pod information
1313
const { stdout: podInfo } = await execAsync(`kubectl describe pod -n ${namespace} ${pod}`);
14-
14+
1515
// Get pod YAML
16-
const { stdout: podYaml } = await execAsync(`kubectl get pod -n ${namespace} ${pod} -o yaml`);
17-
16+
const { stdout: podYaml } = await execAsync(
17+
`kubectl get pod -n ${namespace} ${pod} -o yaml`
18+
);
19+
1820
// Get pod metrics if available
1921
let metrics = null;
2022
try {
21-
const { stdout: metricsOutput } = await execAsync(`kubectl top pod -n ${namespace} ${pod}`);
23+
const { stdout: metricsOutput } = await execAsync(
24+
`kubectl top pod -n ${namespace} ${pod}`
25+
);
2226
metrics = metricsOutput.trim();
2327
} catch (metricsError) {
2428
// Metrics might not be available
@@ -34,4 +38,4 @@ export const GET: RequestHandler = async ({ params }) => {
3438
console.error('Error fetching pod details:', error);
3539
return json({ error: 'Failed to fetch pod details' }, { status: 500 });
3640
}
37-
};
41+
};

infrastructure/control-panel/src/routes/api/evaults/[namespace]/[pod]/logs/+server.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ export const GET: RequestHandler = async ({ params, url }) => {
1010
const tail = url.searchParams.get('tail') || '100';
1111

1212
try {
13-
const { stdout } = await execAsync(`kubectl logs -n ${namespace} ${pod} -c evault --tail=${tail}`);
14-
const logs = stdout.trim().split('\n').filter(line => line.trim());
15-
13+
const { stdout } = await execAsync(
14+
`kubectl logs -n ${namespace} ${pod} -c evault --tail=${tail}`
15+
);
16+
const logs = stdout
17+
.trim()
18+
.split('\n')
19+
.filter((line) => line.trim());
20+
1621
return json({ logs });
1722
} catch (error) {
1823
console.error('Error fetching logs:', error);
1924
return json({ error: 'Failed to fetch logs', logs: [] }, { status: 500 });
2025
}
21-
};
26+
};

0 commit comments

Comments
 (0)