Skip to content

Commit 01a7b3e

Browse files
authored
feat: tauri opener plugin support for deeplink auth (#472)
* chore: test script * fix: test script * chore: debug log * fix: key id * fix: key id * feat: tauri opener plugin * chore: format * fix: lint errors * chore: fix lint
1 parent f7faabe commit 01a7b3e

File tree

56 files changed

+2115
-399
lines changed

Some content is hidden

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

56 files changed

+2115
-399
lines changed

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

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export class EVaultService {
7979
*/
8080
static async getEVaultLogs(evaultId: string, tail?: number): Promise<string[]> {
8181
try {
82-
const url = new URL(`/api/evaults/${encodeURIComponent(evaultId)}/logs`, window.location.origin);
82+
const url = new URL(
83+
`/api/evaults/${encodeURIComponent(evaultId)}/logs`,
84+
window.location.origin
85+
);
8386
if (tail) {
8487
url.searchParams.set('tail', tail.toString());
8588
}
@@ -100,9 +103,7 @@ export class EVaultService {
100103
*/
101104
static async getEVaultDetails(evaultId: string): Promise<any> {
102105
try {
103-
const response = await fetch(
104-
`/api/evaults/${encodeURIComponent(evaultId)}/details`
105-
);
106+
const response = await fetch(`/api/evaults/${encodeURIComponent(evaultId)}/details`);
106107
if (!response.ok) {
107108
throw new Error(`HTTP error! status: ${response.status}`);
108109
}
@@ -113,4 +114,42 @@ export class EVaultService {
113114
throw error;
114115
}
115116
}
117+
118+
/**
119+
* Get logs for a specific eVault by namespace and podName
120+
*/
121+
static async getEVaultLogsByPod(namespace: string, podName: string): Promise<string[]> {
122+
try {
123+
const response = await fetch(
124+
`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/logs`
125+
);
126+
if (!response.ok) {
127+
throw new Error(`HTTP error! status: ${response.status}`);
128+
}
129+
const data = await response.json();
130+
return data.logs || [];
131+
} catch (error) {
132+
console.error('Failed to fetch eVault logs by pod:', error);
133+
throw error;
134+
}
135+
}
136+
137+
/**
138+
* Get metrics for a specific eVault by namespace and podName
139+
*/
140+
static async getEVaultMetrics(namespace: string, podName: string): Promise<any> {
141+
try {
142+
const response = await fetch(
143+
`/api/evaults/${encodeURIComponent(namespace)}/${encodeURIComponent(podName)}/metrics`
144+
);
145+
if (!response.ok) {
146+
throw new Error(`HTTP error! status: ${response.status}`);
147+
}
148+
const data = await response.json();
149+
return data.metrics || {};
150+
} catch (error) {
151+
console.error('Failed to fetch eVault metrics:', error);
152+
throw error;
153+
}
154+
}
116155
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ export class LokiService {
134134
).sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
135135

136136
// Extract log lines and limit to requested number
137-
const logLines = uniqueLogs
138-
.map((log) => log.line)
139-
.slice(-limit); // Get last N lines
137+
const logLines = uniqueLogs.map((log) => log.line).slice(-limit); // Get last N lines
140138

141139
return logLines;
142140
}
Lines changed: 129 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,140 @@
1-
import { env } from "$env/dynamic/public";
1+
import { env } from '$env/dynamic/public';
22

33
export interface Platform {
4-
name: string;
5-
url: string;
6-
status: "Active" | "Inactive";
7-
uptime: string;
4+
name: string;
5+
url: string;
6+
status: 'Active' | 'Inactive';
7+
uptime: string;
88
}
99

1010
export interface RegistryVault {
11-
ename: string;
12-
uri: string;
13-
evault: string;
14-
originalUri?: string;
15-
resolved?: boolean;
11+
ename: string;
12+
uri: string;
13+
evault: string;
14+
originalUri?: string;
15+
resolved?: boolean;
1616
}
1717

1818
export class RegistryService {
19-
private baseUrl: string;
20-
21-
constructor() {
22-
this.baseUrl =
23-
env.PUBLIC_REGISTRY_URL ||
24-
"https://registry.staging.metastate.foundation";
25-
}
26-
27-
async getEVaults(): Promise<RegistryVault[]> {
28-
try {
29-
const response = await fetch(`${this.baseUrl}/list`);
30-
31-
if (!response.ok) {
32-
throw new Error(`HTTP error! status: ${response.status}`);
33-
}
34-
35-
const vaults: RegistryVault[] = await response.json();
36-
return vaults;
37-
} catch (error) {
38-
console.error("Error fetching evaults from registry:", error);
39-
return [];
40-
}
41-
}
42-
43-
async getPlatforms(): Promise<Platform[]> {
44-
try {
45-
const response = await fetch(`${this.baseUrl}/platforms`);
46-
47-
if (!response.ok) {
48-
throw new Error(`HTTP error! status: ${response.status}`);
49-
}
50-
51-
const platformUrls: (string | null | undefined)[] =
52-
await response.json();
53-
54-
// Filter out null/undefined values and convert URLs to platform objects
55-
const platforms = platformUrls
56-
.filter(
57-
(url): url is string => url != null && url.trim() !== "",
58-
)
59-
.map((url) => {
60-
// Use the original URL from the registry (it already has the correct format)
61-
let displayUrl = url.trim();
62-
63-
// Ensure URL has protocol if it doesn't
64-
if (
65-
!displayUrl.startsWith("http://") &&
66-
!displayUrl.startsWith("https://")
67-
) {
68-
displayUrl = `http://${displayUrl}`;
69-
}
70-
71-
// Parse URL to extract platform name
72-
let name = "Unknown";
73-
try {
74-
const urlObj = new URL(displayUrl);
75-
const hostname = urlObj.hostname;
76-
// Extract platform name from hostname (remove port if present)
77-
const hostnameWithoutPort = hostname.split(":")[0];
78-
const namePart = hostnameWithoutPort.split(".")[0];
79-
80-
// Capitalize and format the name
81-
if (namePart === "pictique") name = "Pictique";
82-
else if (namePart === "blabsy") name = "Blabsy";
83-
else if (namePart === "charter") name = "Group Charter";
84-
else if (namePart === "cerberus") name = "Cerberus";
85-
else if (namePart === "evoting") name = "eVoting";
86-
else if (namePart === "dreamsync") name = "DreamSync";
87-
else if (namePart === "ereputation")
88-
name = "eReputation";
89-
else
90-
name =
91-
namePart.charAt(0).toUpperCase() +
92-
namePart.slice(1);
93-
} catch {
94-
// If URL parsing fails, try to extract name from the URL string
95-
const match = displayUrl.match(
96-
/(?:https?:\/\/)?([^:./]+)/,
97-
);
98-
if (match) {
99-
const namePart = match[1].toLowerCase();
100-
if (namePart === "pictique") name = "Pictique";
101-
else if (namePart === "blabsy") name = "Blabsy";
102-
else if (namePart === "charter")
103-
name = "Group Charter";
104-
else if (namePart === "cerberus") name = "Cerberus";
105-
else if (namePart === "evoting") name = "eVoting";
106-
else if (namePart === "dreamsync")
107-
name = "DreamSync";
108-
else if (namePart === "ereputation")
109-
name = "eReputation";
110-
else
111-
name =
112-
namePart.charAt(0).toUpperCase() +
113-
namePart.slice(1);
114-
}
115-
}
116-
117-
return {
118-
name,
119-
url: displayUrl,
120-
status: "Active" as const,
121-
uptime: "24h",
122-
};
123-
});
124-
125-
return platforms;
126-
} catch (error) {
127-
console.error("Error fetching platforms from registry:", error);
128-
129-
// Return fallback platforms if registry is unavailable
130-
return [
131-
{
132-
name: "Blabsy",
133-
url: "http://192.168.0.235:4444",
134-
status: "Active",
135-
uptime: "24h",
136-
},
137-
{
138-
name: "Pictique",
139-
url: "http://192.168.0.235:1111",
140-
status: "Active",
141-
uptime: "24h",
142-
},
143-
{
144-
name: "Group Charter",
145-
url: "http://192.168.0.235:5555",
146-
status: "Active",
147-
uptime: "24h",
148-
},
149-
{
150-
name: "Cerberus",
151-
url: "http://192.168.0.235:6666",
152-
status: "Active",
153-
uptime: "24h",
154-
},
155-
];
156-
}
157-
}
19+
private baseUrl: string;
20+
21+
constructor() {
22+
this.baseUrl = env.PUBLIC_REGISTRY_URL || 'https://registry.staging.metastate.foundation';
23+
}
24+
25+
async getEVaults(): Promise<RegistryVault[]> {
26+
try {
27+
const response = await fetch(`${this.baseUrl}/list`);
28+
29+
if (!response.ok) {
30+
throw new Error(`HTTP error! status: ${response.status}`);
31+
}
32+
33+
const vaults: RegistryVault[] = await response.json();
34+
return vaults;
35+
} catch (error) {
36+
console.error('Error fetching evaults from registry:', error);
37+
return [];
38+
}
39+
}
40+
41+
async getPlatforms(): Promise<Platform[]> {
42+
try {
43+
const response = await fetch(`${this.baseUrl}/platforms`);
44+
45+
if (!response.ok) {
46+
throw new Error(`HTTP error! status: ${response.status}`);
47+
}
48+
49+
const platformUrls: (string | null | undefined)[] = await response.json();
50+
51+
// Filter out null/undefined values and convert URLs to platform objects
52+
const platforms = platformUrls
53+
.filter((url): url is string => url != null && url.trim() !== '')
54+
.map((url) => {
55+
// Use the original URL from the registry (it already has the correct format)
56+
let displayUrl = url.trim();
57+
58+
// Ensure URL has protocol if it doesn't
59+
if (!displayUrl.startsWith('http://') && !displayUrl.startsWith('https://')) {
60+
displayUrl = `http://${displayUrl}`;
61+
}
62+
63+
// Parse URL to extract platform name
64+
let name = 'Unknown';
65+
try {
66+
const urlObj = new URL(displayUrl);
67+
const hostname = urlObj.hostname;
68+
// Extract platform name from hostname (remove port if present)
69+
const hostnameWithoutPort = hostname.split(':')[0];
70+
const namePart = hostnameWithoutPort.split('.')[0];
71+
72+
// Capitalize and format the name
73+
if (namePart === 'pictique') name = 'Pictique';
74+
else if (namePart === 'blabsy') name = 'Blabsy';
75+
else if (namePart === 'charter') name = 'Group Charter';
76+
else if (namePart === 'cerberus') name = 'Cerberus';
77+
else if (namePart === 'evoting') name = 'eVoting';
78+
else if (namePart === 'dreamsync') name = 'DreamSync';
79+
else if (namePart === 'ereputation') name = 'eReputation';
80+
else name = namePart.charAt(0).toUpperCase() + namePart.slice(1);
81+
} catch {
82+
// If URL parsing fails, try to extract name from the URL string
83+
const match = displayUrl.match(/(?:https?:\/\/)?([^:./]+)/);
84+
if (match) {
85+
const namePart = match[1].toLowerCase();
86+
if (namePart === 'pictique') name = 'Pictique';
87+
else if (namePart === 'blabsy') name = 'Blabsy';
88+
else if (namePart === 'charter') name = 'Group Charter';
89+
else if (namePart === 'cerberus') name = 'Cerberus';
90+
else if (namePart === 'evoting') name = 'eVoting';
91+
else if (namePart === 'dreamsync') name = 'DreamSync';
92+
else if (namePart === 'ereputation') name = 'eReputation';
93+
else name = namePart.charAt(0).toUpperCase() + namePart.slice(1);
94+
}
95+
}
96+
97+
return {
98+
name,
99+
url: displayUrl,
100+
status: 'Active' as const,
101+
uptime: '24h'
102+
};
103+
});
104+
105+
return platforms;
106+
} catch (error) {
107+
console.error('Error fetching platforms from registry:', error);
108+
109+
// Return fallback platforms if registry is unavailable
110+
return [
111+
{
112+
name: 'Blabsy',
113+
url: 'http://192.168.0.235:4444',
114+
status: 'Active',
115+
uptime: '24h'
116+
},
117+
{
118+
name: 'Pictique',
119+
url: 'http://192.168.0.235:1111',
120+
status: 'Active',
121+
uptime: '24h'
122+
},
123+
{
124+
name: 'Group Charter',
125+
url: 'http://192.168.0.235:5555',
126+
status: 'Active',
127+
uptime: '24h'
128+
},
129+
{
130+
name: 'Cerberus',
131+
url: 'http://192.168.0.235:6666',
132+
status: 'Active',
133+
uptime: '24h'
134+
}
135+
];
136+
}
137+
}
158138
}
159139

160140
export const registryService = new RegistryService();

infrastructure/control-panel/src/routes/+layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080

8181
// Navigate to monitoring
8282
goto('/monitoring');
83-
}}>Start Monitoring</ButtonAction
83+
}}
84+
>Start Monitoring</ButtonAction
8485
>
8586
</div>
8687
{:else}

infrastructure/control-panel/src/routes/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@
306306
},
307307
Uptime: {
308308
type: 'text',
309-
value: evault.age
309+
value: 'N/A'
310310
},
311311
IP: {
312312
type: 'text',
313-
value: evault.ip
313+
value: 'N/A'
314314
},
315315
URI: {
316316
type: 'link',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const GET: RequestHandler = async () => {
2222
registryVaults.map(async (vault) => {
2323
// Use evault identifier as the primary ID, fallback to ename
2424
const evaultId = vault.evault || vault.ename;
25-
25+
2626
// Determine display name (prefer ename, fallback to evault)
2727
const displayName = vault.ename || vault.evault || 'Unknown';
2828

0 commit comments

Comments
 (0)