🚑️ Fix backend routes
This commit is contained in:
parent
0a9a5ed787
commit
e3ff52b020
@ -6,7 +6,7 @@ export class LogRepo
|
||||
|
||||
listen(namespace: string, name: string, onReceive: (logs: Log[]) => void)
|
||||
{
|
||||
const websocket = new WebSocket(StringUtils.format("ws://%s/api/logs/%s/%s", useRuntimeConfig().public.apiWsBase, namespace, name));
|
||||
const websocket = new WebSocket(StringUtils.format("%s/logs/%s/%s", ApiConfig.getWsBase(), namespace, name));
|
||||
websocket.addEventListener('open', () => {
|
||||
console.info("Opened Websocket.");
|
||||
})
|
||||
|
||||
@ -26,7 +26,7 @@ export class ResourceRepo<T extends HasMetadata>
|
||||
|
||||
listen(resource: string)
|
||||
{
|
||||
const websocket = new WebSocket(StringUtils.format("%s/api/watch/%s/%s", useRuntimeConfig().public.apiWsBase, resource, this.getNamespace()));
|
||||
const websocket = new WebSocket(StringUtils.format("%s/watch/%s/%s", ApiConfig.getWsBase(), resource, this.getNamespace()));
|
||||
websocket.addEventListener('open', () => {
|
||||
console.info("Opened Websocket.");
|
||||
})
|
||||
@ -122,7 +122,7 @@ export class ResourceRepo<T extends HasMetadata>
|
||||
private refresh(resourceType: string)
|
||||
{
|
||||
const namespace = this.getNamespace();
|
||||
let url = StringUtils.format("%s/resources/%s", useRuntimeConfig().public.apiBase, resourceType);
|
||||
let url = StringUtils.format("%s/resources/%s", ApiConfig.getHttpBase(), resourceType);
|
||||
if (namespace)
|
||||
{
|
||||
url = StringUtils.format("%s/%s", url, namespace);
|
||||
|
||||
@ -13,7 +13,7 @@ export class MonitoredResource<T>
|
||||
|
||||
static getMonitorings(monitoringId: string, onSuccess: (monitoredPod: MonitoredResource<Pod>[]) => void)
|
||||
{
|
||||
axios.get<MonitoredResource<Pod>[]>(useRuntimeConfig().public.apiBase + '/monitorings/' + monitoringId + '/jobs')
|
||||
axios.get<MonitoredResource<Pod>[]>(StringUtils.format("%s/monitorings/%s/jobs", ApiConfig.getHttpBase(), monitoringId))
|
||||
.then(response => {
|
||||
onSuccess(response.data)
|
||||
});
|
||||
@ -21,7 +21,7 @@ export class MonitoredResource<T>
|
||||
|
||||
static getNodeMonitorings(from: Date, to: Date, onSuccess: (monitoredPod: MonitoredResource<Node>[]) => void)
|
||||
{
|
||||
axios.get<MonitoredResource<Node>[]>(useRuntimeConfig().public.apiBase + '/monitorings/nodes/jobs', {
|
||||
axios.get<MonitoredResource<Node>[]>(ApiConfig.getHttpBase() + '/monitorings/nodes/jobs', {
|
||||
params: {
|
||||
from: from,
|
||||
to: to
|
||||
|
||||
@ -11,7 +11,7 @@ export class VolumeMonitoringConfig
|
||||
|
||||
static get(onSuccess: (monitorings: VolumeMonitoringConfig[]) => void)
|
||||
{
|
||||
axios.get<VolumeMonitoringConfig[]>(useRuntimeConfig().public.apiBase + '/monitorings')
|
||||
axios.get<VolumeMonitoringConfig[]>(ApiConfig.getHttpBase() + '/monitorings')
|
||||
.then(response => {
|
||||
onSuccess(response.data)
|
||||
});
|
||||
|
||||
2
components/pod/env/EnvVar.ts
vendored
2
components/pod/env/EnvVar.ts
vendored
@ -9,7 +9,7 @@ export class EnvVar
|
||||
|
||||
static get(namespace: string, name: string, onSuccess: (envVars: EnvVar[]) => void)
|
||||
{
|
||||
const url = StringUtils.format('%s/pods/%s/%s/env', useRuntimeConfig().public.apiBase, namespace, name);
|
||||
const url = StringUtils.format('%s/pods/%s/%s/env', ApiConfig.getHttpBase(), namespace, name);
|
||||
axios.get<EnvVar[]>(url)
|
||||
.then((response) => {
|
||||
onSuccess(response.data);
|
||||
|
||||
@ -12,8 +12,11 @@ export default defineNuxtConfig({
|
||||
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
apiBase: StringUtils.format("%s://%s", process.env.NUXT_PUBLIC_API_SCHEMA as string, process.env.NUXT_PUBLIC_API_HOST as string),
|
||||
apiWsBase: StringUtils.format("%s://%s", process.env.NUXT_PUBLIC_API_WS_SCHEMA as string, process.env.NUXT_PUBLIC_API_HOST as string)
|
||||
api: {
|
||||
host: process.env.NUXT_PUBLIC_API_HOST,
|
||||
schema: process.env.NUXT_PUBLIC_API_SCHEMA,
|
||||
wsSchema: process.env.NUXT_PUBLIC_API_WS_SCHEMA
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import type { Deployment } from "~/classes/Deployment";
|
||||
|
||||
export function getDeployments(namespace: string | undefined, onSuccess: (deployments: Deployment[]) => void)
|
||||
{
|
||||
axios.get<Deployment[]>(useRuntimeConfig().public.apiBase + '/deployments', {
|
||||
axios.get<Deployment[]>(ApiConfig.getHttpBase() + '/deployments', {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
},
|
||||
@ -25,7 +25,7 @@ export function rescaleDeployment(deployment: Deployment | undefined, replicaCou
|
||||
{
|
||||
throw new Error("Name or namespace cannot be null");
|
||||
}
|
||||
axios.patch<Deployment[]>(useRuntimeConfig().public.apiBase + '/deployments/' + deployment.metadata.namespace + "/" + deployment.metadata.name, replicaCount, {
|
||||
axios.patch<Deployment[]>(ApiConfig.getHttpBase() + '/deployments/' + deployment.metadata.namespace + "/" + deployment.metadata.name, replicaCount, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken(),
|
||||
"Content-Type": "text/plain"
|
||||
|
||||
@ -3,7 +3,7 @@ import type { Ingress } from "~/classes/Ingress";
|
||||
|
||||
export function getIngresses(namespace: string | undefined, onSuccess: (ingresses: Ingress[]) => void)
|
||||
{
|
||||
axios.get<Ingress[]>(useRuntimeConfig().public.apiBase + '/ingresses', {
|
||||
axios.get<Ingress[]>(ApiConfig.getHttpBase() + '/ingresses', {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@ import type { User } from "~/classes/User";
|
||||
|
||||
export function login(user: User, onSuccess: (token: string) => void)
|
||||
{
|
||||
axios.post<string>(useRuntimeConfig().public.apiBase + '/login', user)
|
||||
axios.post<string>(ApiConfig.getHttpBase() + '/login', user)
|
||||
.then((response) => {
|
||||
onSuccess(response.data);
|
||||
})
|
||||
|
||||
@ -10,7 +10,7 @@ export class Log
|
||||
|
||||
export function getLogs(podId: string | undefined, onSuccess: (logs: Log[]) => void)
|
||||
{
|
||||
axios.get<Log[]>(useRuntimeConfig().public.apiBase + '/pods/' + podId + "/logs", {
|
||||
axios.get<Log[]>(ApiConfig.getHttpBase() + '/pods/' + podId + "/logs", {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import type { Namespace } from "~/classes/Namespace";
|
||||
|
||||
export function getNamespaces(onSuccess: (namespaces: Namespace[]) => void)
|
||||
{
|
||||
axios.get<Namespace[]>(useRuntimeConfig().public.apiBase + '/namespaces', {
|
||||
axios.get<Namespace[]>(StringUtils.format("%s/namespaces", ApiConfig.getHttpBase()), {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
}
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import axios from "axios";
|
||||
import type { NodeStats } from "~/classes/Node";
|
||||
import { Node } from "~/classes/Node";
|
||||
|
||||
|
||||
export function getNodes(onSuccess: (nodes: NodeStats[]) => void)
|
||||
export function getNodes(onSuccess: (nodes: Node[]) => void)
|
||||
{
|
||||
axios.get<NodeStats[]>(useRuntimeConfig().public.apiBase + '/nodes', {
|
||||
axios.get<Node[]>(ApiConfig.getHttpBase() + '/nodes', {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
}
|
||||
|
||||
@ -1,23 +1,8 @@
|
||||
import axios from "axios";
|
||||
import type { Pod } from "~/classes/Pod";
|
||||
|
||||
export function getPods(namespace: string | undefined, onSuccess: (pods: Pod[]) => void)
|
||||
{
|
||||
axios.get<Pod[]>(useRuntimeConfig().public.apiBase + '/pods', {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
},
|
||||
params: getParams(namespace)
|
||||
})
|
||||
.then((response) => {
|
||||
onSuccess(response.data);
|
||||
})
|
||||
.catch();
|
||||
}
|
||||
|
||||
export function deletePod(namespace: string, name: string, onSuccess: () => void)
|
||||
{
|
||||
axios.delete(StringUtils.format('%s/pods/%s/%s', useRuntimeConfig().public.apiBase, namespace, name), {
|
||||
axios.delete(StringUtils.format('%s/pods/%s/%s', ApiConfig.getHttpBase(), namespace, name), {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
}
|
||||
@ -26,15 +11,4 @@ export function deletePod(namespace: string, name: string, onSuccess: () => void
|
||||
onSuccess();
|
||||
})
|
||||
.catch();
|
||||
}
|
||||
|
||||
function getParams(namespace: string | undefined)
|
||||
{
|
||||
if(namespace != undefined)
|
||||
{
|
||||
return {
|
||||
namespace: namespace
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@ -3,7 +3,7 @@ import type { Service } from "~/classes/Service";
|
||||
|
||||
export function getServices(namespace: string | undefined, onSuccess: (services: Service[]) => void)
|
||||
{
|
||||
axios.get<Service[]>(useRuntimeConfig().public.apiBase + '/services', {
|
||||
axios.get<Service[]>(ApiConfig.getHttpBase() + '/services', {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@ import type { User } from "~/classes/User";
|
||||
|
||||
export function getUser(username: string, token: string, onSuccess: (user: User) => void)
|
||||
{
|
||||
axios.get<User>(useRuntimeConfig().public.apiBase + '/users/' + username, {
|
||||
axios.get<User>(ApiConfig.getHttpBase() + '/users/' + username, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + token
|
||||
}
|
||||
@ -16,7 +16,7 @@ export function getUser(username: string, token: string, onSuccess: (user: User)
|
||||
|
||||
export function getUsers(onSuccess: (users: User[]) => void)
|
||||
{
|
||||
axios.get<User[]>(useRuntimeConfig().public.apiBase + '/users', {
|
||||
axios.get<User[]>(ApiConfig.getHttpBase() + '/users', {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
}
|
||||
@ -29,7 +29,7 @@ export function getUsers(onSuccess: (users: User[]) => void)
|
||||
|
||||
export function createUser(user: User, onSuccess: () => void)
|
||||
{
|
||||
axios.post(useRuntimeConfig().public.apiBase + '/users', user, {
|
||||
axios.post(ApiConfig.getHttpBase() + '/users', user, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken()
|
||||
}
|
||||
@ -46,7 +46,7 @@ export function changePassword(username: string | undefined, password: string, o
|
||||
{
|
||||
throw new Error("[Method: changePassword] username is undefined.");
|
||||
}
|
||||
axios.put(useRuntimeConfig().public.apiBase + '/users/' + username + '/password', password, {
|
||||
axios.put(ApiConfig.getHttpBase() + '/users/' + username + '/password', password, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + requireToken(),
|
||||
"Content-Type": "text/plain"
|
||||
|
||||
12
utils/ApiConfig.ts
Normal file
12
utils/ApiConfig.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export class ApiConfig
|
||||
{
|
||||
static getHttpBase()
|
||||
{
|
||||
return StringUtils.format("%s://%s/api", useRuntimeConfig().public.api.schema, useRuntimeConfig().public.api.host)
|
||||
}
|
||||
|
||||
static getWsBase()
|
||||
{
|
||||
return StringUtils.format("%s://%s/api", useRuntimeConfig().public.api.wsSchema, useRuntimeConfig().public.api.host)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user