init studio admin frontend

This commit is contained in:
2026-07-01 17:34:15 +09:00
commit c50bd2b941
64 changed files with 22452 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
import { apiRequest } from '../../lib/api';
import { filterAppsByCurrentAdmin } from '../../lib/admin-app-permissions';
import type { ApiApp, RuntimeEnvProfile, RuntimeEvent, RuntimePodMetric, RuntimeResourceResponse, RuntimeWorkloadLogResponse } from '../../types/runtime';
export function loadApps() {
return apiRequest<ApiApp[]>('/apps').then(filterAppsByCurrentAdmin);
}
export function loadRuntimeProfiles(appId?: string) {
const query = appId ? `?appId=${encodeURIComponent(appId)}` : '';
return apiRequest<RuntimeEnvProfile[]>(`/apps/runtime-profiles${query}`);
}
export function createRuntimeProfile(input: { appId: string; name: string; environment: string; namespace: string }) {
return apiRequest<{ profile: RuntimeEnvProfile }>('/apps/runtime-profiles', {
method: 'POST',
body: JSON.stringify(input)
});
}
export function createRuntimeVariable(
profileId: string,
input: { componentId: string; key: string; value: string; isSecret: boolean }
) {
return apiRequest(`/apps/runtime-profiles/${profileId}/variables`, {
method: 'POST',
body: JSON.stringify(input)
});
}
export function createRuntimeIngressRule(
profileId: string,
input: { componentId: string; host: string; path?: string; servicePort: number; tlsEnabled?: boolean; tlsSecretName?: string }
) {
return apiRequest(`/apps/runtime-profiles/${profileId}/ingress-rules`, {
method: 'POST',
body: JSON.stringify(input)
});
}
export function deleteRuntimeIngressRule(profileId: string, ruleId: string) {
return apiRequest(`/apps/runtime-profiles/${profileId}/ingress-rules/${ruleId}`, {
method: 'DELETE'
});
}
export function deleteRuntimeVariable(profileId: string, variableId: string) {
return apiRequest(`/apps/runtime-profiles/${profileId}/variables/${variableId}`, {
method: 'DELETE'
});
}
export function applyRuntimeProfile(profileId: string) {
return apiRequest<{ profile: RuntimeEnvProfile; logs: string }>(`/apps/runtime-profiles/${profileId}/apply`, {
method: 'PATCH'
});
}
export function loadRuntimeResources(namespace: string) {
return apiRequest<RuntimeResourceResponse>(`/apps/runtime-namespaces/${encodeURIComponent(namespace)}/resources`);
}
export function loadRuntimePodMetrics(namespace?: string) {
const query = namespace ? `?namespace=${encodeURIComponent(namespace)}` : '';
return apiRequest<RuntimePodMetric[]>(`/runtime/metrics/pods${query}`);
}
export function loadRuntimeEvents(namespace?: string) {
const query = namespace ? `?namespace=${encodeURIComponent(namespace)}` : '';
return apiRequest<RuntimeEvent[]>(`/runtime/events${query}`);
}
export function loadRuntimeWorkloadLogs(namespace: string, kind: string, name: string, tail = 100) {
return apiRequest<RuntimeWorkloadLogResponse>(
`/runtime/workloads/${encodeURIComponent(namespace)}/${encodeURIComponent(kind)}/${encodeURIComponent(name)}/logs?tail=${tail}`
);
}
export function ensureRuntimeNamespace(namespace: string) {
return apiRequest<{ namespace: string; created: boolean; logs: string }>('/apps/runtime-namespaces', {
method: 'POST',
body: JSON.stringify({ namespace })
});
}
export function scaleRuntimeWorkload(namespace: string, kind: string, name: string, replicas: number) {
return apiRequest(`/runtime/workloads/${encodeURIComponent(namespace)}/${encodeURIComponent(kind)}/${encodeURIComponent(name)}/scale`, {
method: 'POST',
body: JSON.stringify({ replicas })
});
}
export function restartRuntimeWorkload(namespace: string, kind: string, name: string) {
return apiRequest(`/runtime/workloads/${encodeURIComponent(namespace)}/${encodeURIComponent(kind)}/${encodeURIComponent(name)}/restart`, {
method: 'POST'
});
}