mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(ingress): ingresses datatable with add/edit ingresses EE-2615 (#7672)
This commit is contained in:
parent
393d1fc91d
commit
ef1d648c07
68 changed files with 4938 additions and 61 deletions
29
app/react/kubernetes/configs/queries.ts
Normal file
29
app/react/kubernetes/configs/queries.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
import { error as notifyError } from '@/portainer/services/notifications';
|
||||
|
||||
import { getConfigMaps } from './service';
|
||||
|
||||
export function useConfigurations(
|
||||
environmentId: EnvironmentId,
|
||||
namespace?: string
|
||||
) {
|
||||
return useQuery(
|
||||
[
|
||||
'environments',
|
||||
environmentId,
|
||||
'kubernetes',
|
||||
'namespaces',
|
||||
namespace,
|
||||
'configurations',
|
||||
],
|
||||
() => (namespace ? getConfigMaps(environmentId, namespace) : []),
|
||||
{
|
||||
onError: (err) => {
|
||||
notifyError('Failure', err as Error, 'Unable to get configurations');
|
||||
},
|
||||
enabled: !!namespace,
|
||||
}
|
||||
);
|
||||
}
|
18
app/react/kubernetes/configs/service.ts
Normal file
18
app/react/kubernetes/configs/service.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
|
||||
import { Configuration } from './types';
|
||||
|
||||
export async function getConfigMaps(
|
||||
environmentId: EnvironmentId,
|
||||
namespace: string
|
||||
) {
|
||||
try {
|
||||
const { data: configmaps } = await axios.get<Configuration[]>(
|
||||
`kubernetes/${environmentId}/namespaces/${namespace}/configmaps`
|
||||
);
|
||||
return configmaps;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, 'Unable to retrieve configmaps');
|
||||
}
|
||||
}
|
17
app/react/kubernetes/configs/types.ts
Normal file
17
app/react/kubernetes/configs/types.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
export interface Configuration {
|
||||
Id: string;
|
||||
Name: string;
|
||||
Type: number;
|
||||
Namespace: string;
|
||||
CreationDate: Date;
|
||||
|
||||
ConfigurationOwner: string;
|
||||
|
||||
Used: boolean;
|
||||
// Applications: any[];
|
||||
Data: Document;
|
||||
Yaml: string;
|
||||
|
||||
SecretType?: string;
|
||||
IsRegistrySecret?: boolean;
|
||||
}
|
30
app/react/kubernetes/namespaces/queries.ts
Normal file
30
app/react/kubernetes/namespaces/queries.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
import { error as notifyError } from '@/portainer/services/notifications';
|
||||
|
||||
import { getNamespaces, getNamespace } from './service';
|
||||
|
||||
export function useNamespaces(environmentId: EnvironmentId) {
|
||||
return useQuery(
|
||||
['environments', environmentId, 'kubernetes', 'namespaces'],
|
||||
() => getNamespaces(environmentId),
|
||||
{
|
||||
onError: (err) => {
|
||||
notifyError('Failure', err as Error, 'Unable to get namespaces.');
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function useNamespace(environmentId: EnvironmentId, namespace: string) {
|
||||
return useQuery(
|
||||
['environments', environmentId, 'kubernetes', 'namespaces', namespace],
|
||||
() => getNamespace(environmentId, namespace),
|
||||
{
|
||||
onError: (err) => {
|
||||
notifyError('Failure', err as Error, 'Unable to get namespace.');
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
39
app/react/kubernetes/namespaces/service.ts
Normal file
39
app/react/kubernetes/namespaces/service.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
|
||||
import { Namespaces } from './types';
|
||||
|
||||
export async function getNamespace(
|
||||
environmentId: EnvironmentId,
|
||||
namespace: string
|
||||
) {
|
||||
try {
|
||||
const { data: ingress } = await axios.get<Namespaces>(
|
||||
buildUrl(environmentId, namespace)
|
||||
);
|
||||
return ingress;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, 'Unable to retrieve network details');
|
||||
}
|
||||
}
|
||||
|
||||
export async function getNamespaces(environmentId: EnvironmentId) {
|
||||
try {
|
||||
const { data: ingresses } = await axios.get<Namespaces>(
|
||||
buildUrl(environmentId)
|
||||
);
|
||||
return ingresses;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, 'Unable to retrieve network details');
|
||||
}
|
||||
}
|
||||
|
||||
function buildUrl(environmentId: EnvironmentId, namespace?: string) {
|
||||
let url = `kubernetes/${environmentId}/namespaces`;
|
||||
|
||||
if (namespace) {
|
||||
url += `/${namespace}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
6
app/react/kubernetes/namespaces/types.ts
Normal file
6
app/react/kubernetes/namespaces/types.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export interface Namespaces {
|
||||
[key: string]: {
|
||||
IsDefault: boolean;
|
||||
IsSystem: boolean;
|
||||
};
|
||||
}
|
5
app/react/kubernetes/services/readme.md
Normal file
5
app/react/kubernetes/services/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
## Common Services
|
||||
|
||||
This folder contains rest api services that are shared by different features within kubernetes.
|
||||
|
||||
This includes api requests to the portainer backend, and also requests to the kubernetes api.
|
Loading…
Add table
Add a link
Reference in a new issue