Skip to content

Commit 6ce7658

Browse files
Upstream sync
Merge upstream main into fork main
2 parents d77d417 + 9299d50 commit 6ce7658

72 files changed

Lines changed: 4600 additions & 314 deletions

File tree

Some content is hidden

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

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
"@radix-ui/react-tabs": "^1.1.1",
3030
"@radix-ui/react-tooltip": "^1.1.4",
3131
"axios": "^1.7.2",
32+
"chart.js": "^4.5.1",
33+
"chartjs-plugin-zoom": "^2.2.0",
3234
"class-variance-authority": "^0.7.0",
3335
"clsx": "^2.1.1",
3436
"framer-motion": "^11.3.31",
3537
"jszip": "^3.10.1",
3638
"lucide-react": "^0.509.0",
3739
"next-themes": "^0.3.0",
3840
"react": "^18.3.1",
41+
"react-chartjs-2": "^5.3.1",
3942
"react-dom": "^18.3.1",
4043
"react-responsive": "^10.0.0",
4144
"react-router-dom": "^6.25.1",

public/callback.html

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@
3636
</div>
3737

3838
<script>
39+
function normalizeLoopbackAPIEndpoint(endpoint, currentOrigin) {
40+
try {
41+
const endpointURL = new URL(endpoint);
42+
const originURL = new URL(currentOrigin);
43+
const isLoopbackHostname = (hostname) =>
44+
hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]' || hostname === '::1';
45+
46+
const isLoopbackUpgrade =
47+
endpointURL.protocol === 'http:' &&
48+
originURL.protocol === 'https:' &&
49+
isLoopbackHostname(endpointURL.hostname) &&
50+
isLoopbackHostname(originURL.hostname) &&
51+
endpointURL.hostname === originURL.hostname &&
52+
(endpointURL.port === '' || endpointURL.port === '80') &&
53+
(originURL.port === '' || originURL.port === '443');
54+
55+
if (isLoopbackUpgrade) {
56+
return originURL.origin;
57+
}
58+
} catch (error) {
59+
return endpoint;
60+
}
61+
62+
return endpoint;
63+
}
64+
65+
const apiEndpoint = normalizeLoopbackAPIEndpoint(localStorage.getItem('api'), location.origin);
66+
localStorage.setItem('api', apiEndpoint);
3967
const baseUrl = localStorage.getItem('provider_url');
4068
const client_id = localStorage.getItem('client_id');
4169
const client_secret = localStorage.getItem('client_secret');
@@ -116,7 +144,7 @@
116144
"password": "tokens['access_token']",
117145
"token": tokens['access_token'],
118146
"refresh_token": tokens['refresh_token'],
119-
"endpoint": localStorage.getItem('api'),
147+
"endpoint": apiEndpoint,
120148
"egiSession": users
121149
})
122150
localStorage.setItem("authData",authData);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { PresignedURIRequest, PresignedURIResponse } from "@/models/presignedURI";
2+
import axios from "axios";
3+
4+
async function createPresignedObjectUrlApi(bucketName: string, request: PresignedURIRequest): Promise<PresignedURIResponse> {
5+
const response = await axios.post(`/system/buckets/${bucketName}/presign`, request)
6+
return response.data as PresignedURIResponse;
7+
}
8+
9+
export default createPresignedObjectUrlApi;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import axios from "axios";
2+
import { DeploymentLogStream } from "@/pages/ui/services/models/deployment";
3+
4+
interface DeploymentLogsOptions {
5+
timestamps?: boolean;
6+
tailLines?: number;
7+
}
8+
9+
async function getDeploymentLogsApi(
10+
serviceName: string,
11+
options: DeploymentLogsOptions = {}
12+
) {
13+
const response = await axios.get(
14+
`/system/services/${serviceName}/deployment/logs`,
15+
{
16+
params: {
17+
timestamps: options.timestamps ?? false,
18+
tailLines: options.tailLines ?? 200,
19+
},
20+
}
21+
);
22+
23+
return response.data as DeploymentLogStream;
24+
}
25+
26+
export default getDeploymentLogsApi;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import axios from "axios";
2+
import { DeploymentStatus } from "@/pages/ui/services/models/deployment";
3+
4+
async function getDeploymentStatusApi(serviceName: string) {
5+
const response = await axios.get(`/system/services/${serviceName}/deployment`);
6+
7+
return response.data as DeploymentStatus;
8+
}
9+
10+
export default getDeploymentStatusApi;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ClusterLog } from "@/models/clusterLogs";
2+
import axios from "axios";
3+
4+
export async function getClusterServiceLogsApi() {
5+
const response = await axios.get(`/system/logs`);
6+
7+
return response.data.logs as Array<ClusterLog>;
8+
}

src/api/quotas/getQuotaApi.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
import { parseCpuToMillicores, parseMemoryToBytes } from "@/lib/utils";
3+
import { ClusterUserQuota } from "@/models/clusterUserQuota";
4+
import axios from "axios";
5+
6+
function parseQuotaResources(data: ClusterUserQuota): ClusterUserQuota {
7+
const { cpu, memory } = data.resources;
8+
return {
9+
...data,
10+
resources: {
11+
cpu: {
12+
max: typeof cpu.max === "string" ? parseCpuToMillicores(cpu.max) : cpu.max,
13+
used: typeof cpu.used === "string" ? parseCpuToMillicores(cpu.used) : cpu.used,
14+
},
15+
memory: {
16+
max: typeof memory.max === "string" ? parseMemoryToBytes(memory.max) : memory.max,
17+
used: typeof memory.used === "string" ? parseMemoryToBytes(memory.used) : memory.used,
18+
},
19+
},
20+
};
21+
}
22+
23+
async function getUserQuotaApi(user?: string): Promise<ClusterUserQuota> {
24+
const response = await axios.get(`/system/quotas/user${user ? "/" + user : ""}`);
25+
return parseQuotaResources(response.data);
26+
}
27+
28+
export default getUserQuotaApi;

src/api/quotas/putQuotaApi.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
import { ClusterUserQuota, QuotaUpdateRequest } from "@/models/clusterUserQuota";
3+
import axios from "axios";
4+
5+
async function putUserQuotaApi(uid: string, userQuota: QuotaUpdateRequest): Promise<ClusterUserQuota> {
6+
const response = await axios.put(`/system/quotas/user/${uid}`, userQuota);
7+
return response.data as ClusterUserQuota;
8+
}
9+
10+
export default putUserQuotaApi;

src/api/services/getServicesApi.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { Service } from "@/pages/ui/services/models/service";
22
import axios from "axios";
33

4-
async function getServicesApi() {
5-
const response = await axios.get("/system/services");
4+
interface GetServicesApiOptions {
5+
includeDeployment?: boolean;
6+
}
7+
8+
async function getServicesApi(options: GetServicesApiOptions = {}): Promise<Service[]> {
9+
const response = await axios.get("/system/services", {
10+
params: options.includeDeployment ? { include: "deployment" } : undefined,
11+
});
612

713
return response.data as Service[];
814
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ManagedVolumeCreateRequest } from "@/pages/ui/services/models/service";
2+
import axios from "axios";
3+
4+
async function createVolumesApi(volume: ManagedVolumeCreateRequest) {
5+
const response = await axios.post("/system/volumes", volume);
6+
return response.data;
7+
}
8+
9+
export default createVolumesApi;

0 commit comments

Comments
 (0)