mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 14:55:27 +02:00
refactor(environments): move environments ts code to react [EE-3443] (#7747)
This commit is contained in:
parent
1b12cc9f31
commit
e48ceb15e9
154 changed files with 195 additions and 179 deletions
|
@ -1,8 +1,8 @@
|
|||
import angular from 'angular';
|
||||
import _ from 'lodash-es';
|
||||
|
||||
import { EdgeTypes } from '@/portainer/environments/types';
|
||||
import { getEnvironments } from '@/portainer/environments/environment.service';
|
||||
import { EdgeTypes } from '@/react/portainer/environments/types';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
import { getTags } from '@/portainer/tags/tags.service';
|
||||
|
||||
class AssoicatedEndpointsSelectorController {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash-es';
|
||||
import angular from 'angular';
|
||||
import { endpointsByGroup } from '@/portainer/environments/environment.service';
|
||||
import { endpointsByGroup } from '@/react/portainer/environments/environment.service';
|
||||
import { notifyError } from '@/portainer/services/notifications';
|
||||
|
||||
class GroupFormController {
|
||||
|
|
|
@ -1,253 +0,0 @@
|
|||
import { Gpu } from '@/react/portainer/environments/wizard/EnvironmentsCreationView/shared/Hardware/GpusList';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { type EnvironmentGroupId } from '@/portainer/environment-groups/types';
|
||||
import { type TagId } from '@/portainer/tags/types';
|
||||
|
||||
import { type Environment, EnvironmentCreationTypes } from '../types';
|
||||
|
||||
import { arrayToJson, buildUrl, json2formData } from './utils';
|
||||
|
||||
export interface EnvironmentMetadata {
|
||||
groupId?: EnvironmentGroupId;
|
||||
tagIds?: TagId[];
|
||||
}
|
||||
|
||||
interface CreateLocalDockerEnvironment {
|
||||
name: string;
|
||||
socketPath?: string;
|
||||
publicUrl?: string;
|
||||
meta?: EnvironmentMetadata;
|
||||
gpus?: Gpu[];
|
||||
}
|
||||
|
||||
export async function createLocalDockerEnvironment({
|
||||
name,
|
||||
socketPath = '',
|
||||
publicUrl = '',
|
||||
meta = { tagIds: [] },
|
||||
gpus = [],
|
||||
}: CreateLocalDockerEnvironment) {
|
||||
const url = prefixPath(socketPath);
|
||||
|
||||
return createEnvironment(
|
||||
name,
|
||||
EnvironmentCreationTypes.LocalDockerEnvironment,
|
||||
{
|
||||
url,
|
||||
publicUrl,
|
||||
meta,
|
||||
gpus,
|
||||
}
|
||||
);
|
||||
|
||||
function prefixPath(path: string) {
|
||||
if (path === '') {
|
||||
return path;
|
||||
}
|
||||
|
||||
// Windows named pipe
|
||||
if (path.startsWith('//./pipe/')) {
|
||||
return `npipe://${path}`;
|
||||
}
|
||||
|
||||
return `unix://${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
interface CreateLocalKubernetesEnvironment {
|
||||
name: string;
|
||||
meta?: EnvironmentMetadata;
|
||||
}
|
||||
|
||||
export async function createLocalKubernetesEnvironment({
|
||||
name,
|
||||
meta = { tagIds: [] },
|
||||
}: CreateLocalKubernetesEnvironment) {
|
||||
return createEnvironment(
|
||||
name,
|
||||
EnvironmentCreationTypes.LocalKubernetesEnvironment,
|
||||
{ meta, tls: { skipClientVerify: true, skipVerify: true } }
|
||||
);
|
||||
}
|
||||
|
||||
interface AzureSettings {
|
||||
applicationId: string;
|
||||
tenantId: string;
|
||||
authenticationKey: string;
|
||||
}
|
||||
|
||||
interface CreateAzureEnvironment {
|
||||
name: string;
|
||||
azure: AzureSettings;
|
||||
meta?: EnvironmentMetadata;
|
||||
}
|
||||
|
||||
export async function createAzureEnvironment({
|
||||
name,
|
||||
azure,
|
||||
meta = { tagIds: [] },
|
||||
}: CreateAzureEnvironment) {
|
||||
return createEnvironment(name, EnvironmentCreationTypes.AzureEnvironment, {
|
||||
meta,
|
||||
azure,
|
||||
});
|
||||
}
|
||||
|
||||
interface TLSSettings {
|
||||
skipVerify?: boolean;
|
||||
skipClientVerify?: boolean;
|
||||
caCertFile?: File;
|
||||
certFile?: File;
|
||||
keyFile?: File;
|
||||
}
|
||||
|
||||
export interface EnvironmentOptions {
|
||||
url?: string;
|
||||
publicUrl?: string;
|
||||
meta?: EnvironmentMetadata;
|
||||
azure?: AzureSettings;
|
||||
tls?: TLSSettings;
|
||||
isEdgeDevice?: boolean;
|
||||
gpus?: Gpu[];
|
||||
pollFrequency?: number;
|
||||
}
|
||||
|
||||
interface CreateRemoteEnvironment {
|
||||
name: string;
|
||||
creationType: Exclude<
|
||||
EnvironmentCreationTypes,
|
||||
EnvironmentCreationTypes.EdgeAgentEnvironment
|
||||
>;
|
||||
url: string;
|
||||
options?: Omit<EnvironmentOptions, 'url'>;
|
||||
}
|
||||
|
||||
export async function createRemoteEnvironment({
|
||||
creationType,
|
||||
name,
|
||||
url,
|
||||
options = {},
|
||||
}: CreateRemoteEnvironment) {
|
||||
return createEnvironment(name, creationType, {
|
||||
...options,
|
||||
url: `tcp://${url}`,
|
||||
});
|
||||
}
|
||||
|
||||
export interface CreateAgentEnvironmentValues {
|
||||
name: string;
|
||||
environmentUrl: string;
|
||||
meta: EnvironmentMetadata;
|
||||
gpus: Gpu[];
|
||||
}
|
||||
|
||||
export function createAgentEnvironment({
|
||||
name,
|
||||
environmentUrl,
|
||||
meta = { tagIds: [] },
|
||||
}: CreateAgentEnvironmentValues) {
|
||||
return createRemoteEnvironment({
|
||||
name,
|
||||
url: environmentUrl,
|
||||
creationType: EnvironmentCreationTypes.AgentEnvironment,
|
||||
options: {
|
||||
meta,
|
||||
tls: {
|
||||
skipVerify: true,
|
||||
skipClientVerify: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
interface CreateEdgeAgentEnvironment {
|
||||
name: string;
|
||||
portainerUrl: string;
|
||||
meta?: EnvironmentMetadata;
|
||||
pollFrequency: number;
|
||||
gpus?: Gpu[];
|
||||
isEdgeDevice?: boolean;
|
||||
}
|
||||
|
||||
export function createEdgeAgentEnvironment({
|
||||
name,
|
||||
portainerUrl,
|
||||
meta = { tagIds: [] },
|
||||
gpus = [],
|
||||
isEdgeDevice,
|
||||
pollFrequency,
|
||||
}: CreateEdgeAgentEnvironment) {
|
||||
return createEnvironment(
|
||||
name,
|
||||
EnvironmentCreationTypes.EdgeAgentEnvironment,
|
||||
{
|
||||
url: portainerUrl,
|
||||
tls: {
|
||||
skipVerify: true,
|
||||
skipClientVerify: true,
|
||||
},
|
||||
gpus,
|
||||
isEdgeDevice,
|
||||
pollFrequency,
|
||||
meta,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function createEnvironment(
|
||||
name: string,
|
||||
creationType: EnvironmentCreationTypes,
|
||||
options?: EnvironmentOptions
|
||||
) {
|
||||
let payload: Record<string, unknown> = {
|
||||
Name: name,
|
||||
EndpointCreationType: creationType,
|
||||
};
|
||||
|
||||
if (options) {
|
||||
const { groupId, tagIds = [] } = options.meta || {};
|
||||
|
||||
payload = {
|
||||
...payload,
|
||||
URL: options.url,
|
||||
PublicURL: options.publicUrl,
|
||||
GroupID: groupId,
|
||||
TagIds: arrayToJson(tagIds),
|
||||
CheckinInterval: options.pollFrequency,
|
||||
IsEdgeDevice: options.isEdgeDevice,
|
||||
Gpus: arrayToJson(options.gpus),
|
||||
};
|
||||
|
||||
const { tls, azure } = options;
|
||||
|
||||
if (tls) {
|
||||
payload = {
|
||||
...payload,
|
||||
TLS: true,
|
||||
TLSSkipVerify: tls.skipVerify,
|
||||
TLSSkipClientVerify: tls.skipClientVerify,
|
||||
TLSCACertFile: tls.caCertFile,
|
||||
TLSCertFile: tls.certFile,
|
||||
TLSKeyFile: tls.keyFile,
|
||||
};
|
||||
}
|
||||
|
||||
if (azure) {
|
||||
payload = {
|
||||
...payload,
|
||||
AzureApplicationID: azure.applicationId,
|
||||
AzureTenantID: azure.tenantId,
|
||||
AzureAuthenticationKey: azure.authenticationKey,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const formPayload = json2formData(payload);
|
||||
try {
|
||||
const { data } = await axios.post<Environment>(buildUrl(), formPayload);
|
||||
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
|
||||
interface GenerateUrlResponse {
|
||||
edgeKey: string;
|
||||
}
|
||||
|
||||
export async function generateKey() {
|
||||
try {
|
||||
const { data } = await axios.post<GenerateUrlResponse>(
|
||||
`/endpoints/edge/generate-key`
|
||||
);
|
||||
return data.edgeKey;
|
||||
} catch (err) {
|
||||
throw parseAxiosError(err as Error, 'Unable to generate key');
|
||||
}
|
||||
}
|
|
@ -1,255 +0,0 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { type EnvironmentGroupId } from '@/portainer/environment-groups/types';
|
||||
import { type TagId } from '@/portainer/tags/types';
|
||||
import { UserId } from '@/portainer/users/types';
|
||||
import { TeamId } from '@/react/portainer/users/teams/types';
|
||||
|
||||
import type {
|
||||
Environment,
|
||||
EnvironmentId,
|
||||
EnvironmentType,
|
||||
EnvironmentSecuritySettings,
|
||||
EnvironmentStatus,
|
||||
} from '../types';
|
||||
|
||||
import { buildUrl } from './utils';
|
||||
|
||||
export interface EnvironmentsQueryParams {
|
||||
search?: string;
|
||||
types?: EnvironmentType[] | readonly EnvironmentType[];
|
||||
tagIds?: TagId[];
|
||||
endpointIds?: EnvironmentId[];
|
||||
tagsPartialMatch?: boolean;
|
||||
groupIds?: EnvironmentGroupId[];
|
||||
status?: EnvironmentStatus[];
|
||||
edgeDevice?: boolean;
|
||||
edgeDeviceUntrusted?: boolean;
|
||||
excludeSnapshots?: boolean;
|
||||
provisioned?: boolean;
|
||||
name?: string;
|
||||
agentVersions?: string[];
|
||||
}
|
||||
|
||||
export interface GetEnvironmentsOptions {
|
||||
start?: number;
|
||||
limit?: number;
|
||||
sort?: { by?: string; order?: 'asc' | 'desc' };
|
||||
query?: EnvironmentsQueryParams;
|
||||
}
|
||||
|
||||
export async function getEnvironments(
|
||||
{
|
||||
start,
|
||||
limit,
|
||||
sort = { by: '', order: 'asc' },
|
||||
query = {},
|
||||
}: GetEnvironmentsOptions = { query: {} }
|
||||
) {
|
||||
if (query.tagIds && query.tagIds.length === 0) {
|
||||
return { totalCount: 0, value: <Environment[]>[] };
|
||||
}
|
||||
|
||||
const url = buildUrl();
|
||||
|
||||
const params: Record<string, unknown> = {
|
||||
start,
|
||||
limit,
|
||||
sort: sort.by,
|
||||
order: sort.order,
|
||||
...query,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.get<Environment[]>(url, { params });
|
||||
const totalCount = response.headers['x-total-count'];
|
||||
const totalAvailable = response.headers['x-total-available'];
|
||||
|
||||
return {
|
||||
totalCount: parseInt(totalCount, 10),
|
||||
value: response.data,
|
||||
totalAvailable: parseInt(totalAvailable, 10),
|
||||
};
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAgentVersions() {
|
||||
try {
|
||||
const response = await axios.get<string[]>(
|
||||
buildUrl(undefined, 'agent_versions')
|
||||
);
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEndpoint(id: EnvironmentId) {
|
||||
try {
|
||||
const { data: endpoint } = await axios.get<Environment>(buildUrl(id));
|
||||
return endpoint;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function snapshotEndpoints() {
|
||||
try {
|
||||
await axios.post<void>(buildUrl(undefined, 'snapshot'));
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function snapshotEndpoint(id: EnvironmentId) {
|
||||
try {
|
||||
await axios.post<void>(buildUrl(id, 'snapshot'));
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function endpointsByGroup(
|
||||
groupId: EnvironmentGroupId,
|
||||
start: number,
|
||||
limit: number,
|
||||
query: Omit<EnvironmentsQueryParams, 'groupIds'>
|
||||
) {
|
||||
return getEnvironments({
|
||||
start,
|
||||
limit,
|
||||
query: { groupIds: [groupId], ...query },
|
||||
});
|
||||
}
|
||||
|
||||
export async function disassociateEndpoint(id: EnvironmentId) {
|
||||
try {
|
||||
await axios.delete(buildUrl(id, 'association'));
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
interface UpdatePayload {
|
||||
TLSCACert?: File;
|
||||
TLSCert?: File;
|
||||
TLSKey?: File;
|
||||
|
||||
Name: string;
|
||||
PublicURL: string;
|
||||
GroupID: EnvironmentGroupId;
|
||||
TagIds: TagId[];
|
||||
|
||||
EdgeCheckinInterval: number;
|
||||
|
||||
TLS: boolean;
|
||||
TLSSkipVerify: boolean;
|
||||
TLSSkipClientVerify: boolean;
|
||||
AzureApplicationID: string;
|
||||
AzureTenantID: string;
|
||||
AzureAuthenticationKey: string;
|
||||
}
|
||||
|
||||
async function uploadTLSFilesForEndpoint(
|
||||
id: EnvironmentId,
|
||||
tlscaCert?: File,
|
||||
tlsCert?: File,
|
||||
tlsKey?: File
|
||||
) {
|
||||
await Promise.all([
|
||||
uploadCert('ca', tlscaCert),
|
||||
uploadCert('cert', tlsCert),
|
||||
uploadCert('key', tlsKey),
|
||||
]);
|
||||
|
||||
function uploadCert(type: 'ca' | 'cert' | 'key', cert?: File) {
|
||||
if (!cert) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return axios.post<void>(`upload/tls/${type}`, cert, {
|
||||
params: { folder: id },
|
||||
});
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateEndpoint(
|
||||
id: EnvironmentId,
|
||||
payload: UpdatePayload
|
||||
) {
|
||||
try {
|
||||
await uploadTLSFilesForEndpoint(
|
||||
id,
|
||||
payload.TLSCACert,
|
||||
payload.TLSCert,
|
||||
payload.TLSKey
|
||||
);
|
||||
|
||||
const { data: endpoint } = await axios.put<Environment>(
|
||||
buildUrl(id),
|
||||
payload
|
||||
);
|
||||
|
||||
return endpoint;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, 'Unable to update environment');
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteEndpoint(id: EnvironmentId) {
|
||||
try {
|
||||
await axios.delete(buildUrl(id));
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function updatePoolAccess(
|
||||
id: EnvironmentId,
|
||||
resourcePool: string,
|
||||
usersToAdd: UserId[],
|
||||
teamsToAdd: TeamId[],
|
||||
usersToRemove: UserId[],
|
||||
teamsToRemove: TeamId[]
|
||||
) {
|
||||
try {
|
||||
await axios.put<void>(`${buildUrl(id, 'pools')}/${resourcePool}/access`, {
|
||||
usersToAdd,
|
||||
teamsToAdd,
|
||||
usersToRemove,
|
||||
teamsToRemove,
|
||||
});
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function forceUpdateService(
|
||||
id: EnvironmentId,
|
||||
serviceID: string,
|
||||
pullImage: boolean
|
||||
) {
|
||||
try {
|
||||
await axios.put(buildUrl(id, 'forceupdateservice'), {
|
||||
serviceID,
|
||||
pullImage,
|
||||
});
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateSettings(
|
||||
id: EnvironmentId,
|
||||
settings: EnvironmentSecuritySettings
|
||||
) {
|
||||
try {
|
||||
await axios.put(buildUrl(id, 'settings'), settings);
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { TeamId } from '@/react/portainer/users/teams/types';
|
||||
import { UserId } from '@/portainer/users/types';
|
||||
|
||||
import { EnvironmentId } from '../types';
|
||||
|
||||
import { buildUrl } from './utils';
|
||||
|
||||
export type RoleId = number;
|
||||
interface AccessPolicy {
|
||||
RoleId: RoleId;
|
||||
}
|
||||
|
||||
type UserAccessPolicies = Record<UserId, AccessPolicy>; // map[UserID]AccessPolicy
|
||||
type TeamAccessPolicies = Record<TeamId, AccessPolicy>;
|
||||
|
||||
export type RegistryId = number;
|
||||
export interface Registry {
|
||||
Id: RegistryId;
|
||||
Name: string;
|
||||
}
|
||||
|
||||
interface RegistryAccess {
|
||||
UserAccessPolicies: UserAccessPolicies;
|
||||
TeamAccessPolicies: TeamAccessPolicies;
|
||||
Namespaces: string[];
|
||||
}
|
||||
|
||||
export async function updateEnvironmentRegistryAccess(
|
||||
id: EnvironmentId,
|
||||
registryId: RegistryId,
|
||||
access: RegistryAccess
|
||||
) {
|
||||
try {
|
||||
await axios.put<void>(buildRegistryUrl(id, registryId), access);
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEnvironmentRegistries(
|
||||
id: EnvironmentId,
|
||||
namespace: string
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get<Registry[]>(buildRegistryUrl(id), {
|
||||
params: { namespace },
|
||||
});
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEnvironmentRegistry(
|
||||
endpointId: EnvironmentId,
|
||||
registryId: RegistryId
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get<Registry>(
|
||||
buildRegistryUrl(endpointId, registryId)
|
||||
);
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
function buildRegistryUrl(id: EnvironmentId, registryId?: RegistryId) {
|
||||
let url = `${buildUrl(id)}/registries`;
|
||||
|
||||
if (registryId) {
|
||||
url += `/${registryId}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
import { EnvironmentId } from '../types';
|
||||
|
||||
export function buildUrl(id?: EnvironmentId, action?: string) {
|
||||
let baseUrl = 'endpoints';
|
||||
if (id) {
|
||||
baseUrl += `/${id}`;
|
||||
}
|
||||
|
||||
if (action) {
|
||||
baseUrl += `/${action}`;
|
||||
}
|
||||
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
export function arrayToJson<T>(arr?: Array<T>) {
|
||||
if (!arr) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return JSON.stringify(arr);
|
||||
}
|
||||
|
||||
export function json2formData(json: Record<string, unknown>) {
|
||||
const formData = new FormData();
|
||||
|
||||
Object.entries(json).forEach(([key, value]) => {
|
||||
if (typeof value === 'undefined' || value === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
formData.append(key, value as string);
|
||||
});
|
||||
|
||||
return formData;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
import { useStatus } from '@/portainer/services/api/status.service';
|
||||
import { useSettings } from '@/react/portainer/settings/queries';
|
||||
|
||||
export function useAgentDetails() {
|
||||
const settingsQuery = useSettings((settings) => settings.AgentSecret);
|
||||
|
||||
const versionQuery = useStatus((status) => status.Version);
|
||||
|
||||
if (!versionQuery.isSuccess || !settingsQuery.isSuccess) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const agentVersion = versionQuery.data;
|
||||
const agentSecret = settingsQuery.data;
|
||||
|
||||
return { agentVersion, agentSecret };
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import { getAgentVersions } from '../environment.service';
|
||||
|
||||
export function useAgentVersionsList() {
|
||||
return useQuery(['environments', 'agentVersions'], () => getAgentVersions());
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
import { useQueryClient, useMutation, MutationFunction } from 'react-query';
|
||||
|
||||
import {
|
||||
createRemoteEnvironment,
|
||||
createLocalDockerEnvironment,
|
||||
createAzureEnvironment,
|
||||
createAgentEnvironment,
|
||||
createEdgeAgentEnvironment,
|
||||
createLocalKubernetesEnvironment,
|
||||
} from '../environment.service/create';
|
||||
|
||||
export function useCreateAzureEnvironmentMutation() {
|
||||
return useGenericCreationMutation(createAzureEnvironment);
|
||||
}
|
||||
|
||||
export function useCreateLocalDockerEnvironmentMutation() {
|
||||
return useGenericCreationMutation(createLocalDockerEnvironment);
|
||||
}
|
||||
|
||||
export function useCreateLocalKubernetesEnvironmentMutation() {
|
||||
return useGenericCreationMutation(createLocalKubernetesEnvironment);
|
||||
}
|
||||
|
||||
export function useCreateRemoteEnvironmentMutation(
|
||||
creationType: Parameters<typeof createRemoteEnvironment>[0]['creationType']
|
||||
) {
|
||||
return useGenericCreationMutation(
|
||||
(
|
||||
params: Omit<
|
||||
Parameters<typeof createRemoteEnvironment>[0],
|
||||
'creationType'
|
||||
>
|
||||
) => createRemoteEnvironment({ creationType, ...params })
|
||||
);
|
||||
}
|
||||
|
||||
export function useCreateAgentEnvironmentMutation() {
|
||||
return useGenericCreationMutation(createAgentEnvironment);
|
||||
}
|
||||
|
||||
export function useCreateEdgeAgentEnvironmentMutation() {
|
||||
return useGenericCreationMutation(createEdgeAgentEnvironment);
|
||||
}
|
||||
|
||||
function useGenericCreationMutation<TData = unknown, TVariables = void>(
|
||||
mutation: MutationFunction<TData, TVariables>
|
||||
) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(mutation, {
|
||||
onSuccess() {
|
||||
return queryClient.invalidateQueries(['environments']);
|
||||
},
|
||||
meta: {
|
||||
error: {
|
||||
title: 'Failure',
|
||||
message: 'Unable to create environment',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import { getEndpoint } from '@/portainer/environments/environment.service';
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
export function useEnvironment(id?: EnvironmentId) {
|
||||
return useQuery(['environments', id], () => (id ? getEndpoint(id) : null), {
|
||||
...withError('Failed loading environment'),
|
||||
staleTime: 50,
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
import { EnvironmentStatus } from '../types';
|
||||
import {
|
||||
EnvironmentsQueryParams,
|
||||
getEnvironments,
|
||||
} from '../environment.service';
|
||||
|
||||
export const ENVIRONMENTS_POLLING_INTERVAL = 30000; // in ms
|
||||
|
||||
export interface Query extends EnvironmentsQueryParams {
|
||||
page?: number;
|
||||
pageLimit?: number;
|
||||
sort?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
type GetEndpointsResponse = Awaited<ReturnType<typeof getEnvironments>>;
|
||||
|
||||
export function refetchIfAnyOffline(data?: GetEndpointsResponse) {
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const hasOfflineEnvironment = data.value.some(
|
||||
(env) => env.Status === EnvironmentStatus.Down
|
||||
);
|
||||
|
||||
if (!hasOfflineEnvironment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ENVIRONMENTS_POLLING_INTERVAL;
|
||||
}
|
||||
|
||||
export function useEnvironmentList(
|
||||
{ page = 1, pageLimit = 100, sort, order, ...query }: Query = {},
|
||||
refetchInterval?:
|
||||
| number
|
||||
| false
|
||||
| ((data?: GetEndpointsResponse) => false | number),
|
||||
staleTime = 0,
|
||||
enabled = true
|
||||
) {
|
||||
const { isLoading, data } = useQuery(
|
||||
[
|
||||
'environments',
|
||||
{
|
||||
page,
|
||||
pageLimit,
|
||||
sort,
|
||||
order,
|
||||
...query,
|
||||
},
|
||||
],
|
||||
async () => {
|
||||
const start = (page - 1) * pageLimit + 1;
|
||||
return getEnvironments({
|
||||
start,
|
||||
limit: pageLimit,
|
||||
sort: { by: sort, order },
|
||||
query,
|
||||
});
|
||||
},
|
||||
{
|
||||
staleTime,
|
||||
keepPreviousData: true,
|
||||
refetchInterval,
|
||||
enabled,
|
||||
...withError('Failure retrieving environments'),
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
environments: data ? data.value : [],
|
||||
totalCount: data ? data.totalCount : 0,
|
||||
totalAvailable: data ? data.totalAvailable : 0,
|
||||
};
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
import { TagId } from '@/portainer/tags/types';
|
||||
import { EnvironmentGroupId } from '@/portainer/environment-groups/types';
|
||||
|
||||
export type EnvironmentId = number;
|
||||
|
||||
export enum EnvironmentType {
|
||||
// Docker represents an environment(endpoint) connected to a Docker environment(endpoint)
|
||||
Docker = 1,
|
||||
// AgentOnDocker represents an environment(endpoint) connected to a Portainer agent deployed on a Docker environment(endpoint)
|
||||
AgentOnDocker,
|
||||
// Azure represents an environment(endpoint) connected to an Azure environment(endpoint)
|
||||
Azure,
|
||||
// EdgeAgentOnDocker represents an environment(endpoint) connected to an Edge agent deployed on a Docker environment(endpoint)
|
||||
EdgeAgentOnDocker,
|
||||
// KubernetesLocal represents an environment(endpoint) connected to a local Kubernetes environment(endpoint)
|
||||
KubernetesLocal,
|
||||
// AgentOnKubernetes represents an environment(endpoint) connected to a Portainer agent deployed on a Kubernetes environment(endpoint)
|
||||
AgentOnKubernetes,
|
||||
// EdgeAgentOnKubernetes represents an environment(endpoint) connected to an Edge agent deployed on a Kubernetes environment(endpoint)
|
||||
EdgeAgentOnKubernetes,
|
||||
}
|
||||
|
||||
export const EdgeTypes = [
|
||||
EnvironmentType.EdgeAgentOnDocker,
|
||||
EnvironmentType.EdgeAgentOnKubernetes,
|
||||
] as const;
|
||||
|
||||
export enum EnvironmentStatus {
|
||||
Up = 1,
|
||||
Down,
|
||||
}
|
||||
|
||||
export interface DockerSnapshot {
|
||||
TotalCPU: number;
|
||||
TotalMemory: number;
|
||||
NodeCount: number;
|
||||
ImageCount: number;
|
||||
VolumeCount: number;
|
||||
RunningContainerCount: number;
|
||||
StoppedContainerCount: number;
|
||||
HealthyContainerCount: number;
|
||||
UnhealthyContainerCount: number;
|
||||
Time: number;
|
||||
StackCount: number;
|
||||
ServiceCount: number;
|
||||
Swarm: boolean;
|
||||
DockerVersion: string;
|
||||
GpuUseAll: boolean;
|
||||
GpuUseList: string[];
|
||||
}
|
||||
|
||||
export interface KubernetesSnapshot {
|
||||
KubernetesVersion: string;
|
||||
TotalCPU: number;
|
||||
TotalMemory: number;
|
||||
Time: number;
|
||||
NodeCount: number;
|
||||
}
|
||||
|
||||
export type IngressClass = {
|
||||
Name: string;
|
||||
Type: string;
|
||||
};
|
||||
|
||||
export interface KubernetesConfiguration {
|
||||
UseLoadBalancer?: boolean;
|
||||
UseServerMetrics?: boolean;
|
||||
EnableResourceOverCommit?: boolean;
|
||||
ResourceOverCommitPercentage?: number;
|
||||
RestrictDefaultNamespace?: boolean;
|
||||
IngressClasses: IngressClass[];
|
||||
IngressAvailabilityPerNamespace: boolean;
|
||||
}
|
||||
|
||||
export interface KubernetesSettings {
|
||||
Snapshots?: KubernetesSnapshot[] | null;
|
||||
Configuration: KubernetesConfiguration;
|
||||
}
|
||||
|
||||
export type EnvironmentEdge = {
|
||||
AsyncMode: boolean;
|
||||
PingInterval: number;
|
||||
SnapshotInterval: number;
|
||||
CommandInterval: number;
|
||||
};
|
||||
|
||||
export interface EnvironmentSecuritySettings {
|
||||
// Whether non-administrator should be able to use bind mounts when creating containers
|
||||
allowBindMountsForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to use privileged mode when creating containers
|
||||
allowPrivilegedModeForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to browse volumes
|
||||
allowVolumeBrowserForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to use the host pid
|
||||
allowHostNamespaceForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to use device mapping
|
||||
allowDeviceMappingForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to manage stacks
|
||||
allowStackManagementForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to use container capabilities
|
||||
allowContainerCapabilitiesForRegularUsers: boolean;
|
||||
// Whether non-administrator should be able to use sysctl settings
|
||||
allowSysctlSettingForRegularUsers: boolean;
|
||||
// Whether host management features are enabled
|
||||
enableHostManagementFeatures: boolean;
|
||||
}
|
||||
|
||||
export type Environment = {
|
||||
Agent: { Version: string };
|
||||
Id: EnvironmentId;
|
||||
Type: EnvironmentType;
|
||||
TagIds: TagId[];
|
||||
GroupId: EnvironmentGroupId;
|
||||
EdgeID?: string;
|
||||
EdgeKey: string;
|
||||
EdgeCheckinInterval?: number;
|
||||
QueryDate?: number;
|
||||
LastCheckInDate?: number;
|
||||
Name: string;
|
||||
Status: EnvironmentStatus;
|
||||
URL: string;
|
||||
Snapshots: DockerSnapshot[];
|
||||
Kubernetes: KubernetesSettings;
|
||||
PublicURL?: string;
|
||||
IsEdgeDevice?: boolean;
|
||||
UserTrusted: boolean;
|
||||
AMTDeviceGUID?: string;
|
||||
Edge: EnvironmentEdge;
|
||||
SecuritySettings: EnvironmentSecuritySettings;
|
||||
Gpus: { name: string; value: string }[];
|
||||
};
|
||||
|
||||
/**
|
||||
* TS reference of endpoint_create.go#EndpointCreationType iota
|
||||
*/
|
||||
export enum EnvironmentCreationTypes {
|
||||
LocalDockerEnvironment = 1,
|
||||
AgentEnvironment,
|
||||
AzureEnvironment,
|
||||
EdgeAgentEnvironment,
|
||||
LocalKubernetesEnvironment,
|
||||
KubeConfigEnvironment,
|
||||
}
|
||||
|
||||
export enum PlatformType {
|
||||
Docker,
|
||||
Kubernetes,
|
||||
Azure,
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
import { Environment, EnvironmentType, PlatformType } from './types';
|
||||
|
||||
export function getPlatformType(envType: EnvironmentType) {
|
||||
switch (envType) {
|
||||
case EnvironmentType.KubernetesLocal:
|
||||
case EnvironmentType.AgentOnKubernetes:
|
||||
case EnvironmentType.EdgeAgentOnKubernetes:
|
||||
return PlatformType.Kubernetes;
|
||||
case EnvironmentType.Docker:
|
||||
case EnvironmentType.AgentOnDocker:
|
||||
case EnvironmentType.EdgeAgentOnDocker:
|
||||
return PlatformType.Docker;
|
||||
case EnvironmentType.Azure:
|
||||
return PlatformType.Azure;
|
||||
default:
|
||||
throw new Error(`${envType} is not a supported environment type`);
|
||||
}
|
||||
}
|
||||
|
||||
export function isDockerEnvironment(envType: EnvironmentType) {
|
||||
return getPlatformType(envType) === PlatformType.Docker;
|
||||
}
|
||||
|
||||
export function isKubernetesEnvironment(envType: EnvironmentType) {
|
||||
return getPlatformType(envType) === PlatformType.Kubernetes;
|
||||
}
|
||||
|
||||
export function isAgentEnvironment(envType: EnvironmentType) {
|
||||
return (
|
||||
isEdgeEnvironment(envType) ||
|
||||
[EnvironmentType.AgentOnDocker, EnvironmentType.AgentOnKubernetes].includes(
|
||||
envType
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function isEdgeEnvironment(envType: EnvironmentType) {
|
||||
return [
|
||||
EnvironmentType.EdgeAgentOnDocker,
|
||||
EnvironmentType.EdgeAgentOnKubernetes,
|
||||
].includes(envType);
|
||||
}
|
||||
|
||||
export function isUnassociatedEdgeEnvironment(env: Environment) {
|
||||
return isEdgeEnvironment(env.Type) && !env.EdgeID;
|
||||
}
|
||||
|
||||
export function getRoute(environment: Environment) {
|
||||
if (isEdgeEnvironment(environment.Type) && !environment.EdgeID) {
|
||||
return 'portainer.endpoints.endpoint';
|
||||
}
|
||||
|
||||
const platform = getPlatformType(environment.Type);
|
||||
|
||||
switch (platform) {
|
||||
case PlatformType.Azure:
|
||||
return 'azure.dashboard';
|
||||
case PlatformType.Docker:
|
||||
return 'docker.dashboard';
|
||||
case PlatformType.Kubernetes:
|
||||
return 'kubernetes.dashboard';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import { Zap } from 'react-feather';
|
||||
|
||||
import { EnvironmentType } from '@/portainer/environments/types';
|
||||
import { EnvironmentType } from '@/react/portainer/environments/types';
|
||||
import {
|
||||
isAgentEnvironment,
|
||||
isEdgeEnvironment,
|
||||
} from '@/portainer/environments/utils';
|
||||
} from '@/react/portainer/environments/utils';
|
||||
|
||||
interface Props {
|
||||
type: EnvironmentType;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import clsx from 'clsx';
|
||||
|
||||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
import { Environment } from '@/portainer/environments/types';
|
||||
import { Environment } from '@/react/portainer/environments/types';
|
||||
import { usePublicSettings } from '@/react/portainer/settings/queries';
|
||||
import { PublicSettingsViewModel } from '@/portainer/models/settings';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { environmentTypeIcon } from '@/portainer/filters/filters';
|
|||
import dockerEdge from '@/assets/images/edge_endpoint.png';
|
||||
import kube from '@/assets/images/kubernetes_endpoint.png';
|
||||
import kubeEdge from '@/assets/images/kubernetes_edge_endpoint.png';
|
||||
import { EnvironmentType } from '@/portainer/environments/types';
|
||||
import { EnvironmentType } from '@/react/portainer/environments/types';
|
||||
import azure from '@/assets/ico/vendor/azure.svg';
|
||||
import docker from '@/assets/ico/vendor/docker.svg';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
Environment,
|
||||
EnvironmentStatus,
|
||||
EnvironmentType,
|
||||
} from '@/portainer/environments/types';
|
||||
} from '@/react/portainer/environments/types';
|
||||
import { createMockEnvironment } from '@/react-tools/test-mocks';
|
||||
|
||||
import { EnvironmentItem } from './EnvironmentItem';
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
EnvironmentGroup,
|
||||
EnvironmentGroupId,
|
||||
} from '@/portainer/environment-groups/types';
|
||||
import { Environment } from '@/portainer/environments/types';
|
||||
import { Environment } from '@/react/portainer/environments/types';
|
||||
import { UserContext } from '@/portainer/hooks/useUser';
|
||||
import { UserViewModel } from '@/portainer/models/user';
|
||||
import { Tag } from '@/portainer/tags/types';
|
||||
|
|
|
@ -7,12 +7,15 @@ import {
|
|||
humanize,
|
||||
stripProtocol,
|
||||
} from '@/portainer/filters/filters';
|
||||
import { type Environment, PlatformType } from '@/portainer/environments/types';
|
||||
import {
|
||||
type Environment,
|
||||
PlatformType,
|
||||
} from '@/react/portainer/environments/types';
|
||||
import {
|
||||
getPlatformType,
|
||||
isDockerEnvironment,
|
||||
isEdgeEnvironment,
|
||||
} from '@/portainer/environments/utils';
|
||||
} from '@/react/portainer/environments/utils';
|
||||
import type { TagId } from '@/portainer/tags/types';
|
||||
import { useTags } from '@/portainer/tags/queries';
|
||||
import { useUser } from '@/portainer/hooks/useUser';
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { Environment, PlatformType } from '@/portainer/environments/types';
|
||||
import { getPlatformType } from '@/portainer/environments/utils';
|
||||
import {
|
||||
Environment,
|
||||
PlatformType,
|
||||
} from '@/react/portainer/environments/types';
|
||||
import { getPlatformType } from '@/react/portainer/environments/utils';
|
||||
|
||||
import { EnvironmentStatsDocker } from './EnvironmentStatsDocker';
|
||||
import { EnvironmentStatsKubernetes } from './EnvironmentStatsKubernetes';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
DockerSnapshot,
|
||||
EnvironmentType,
|
||||
} from '@/portainer/environments/types';
|
||||
} from '@/react/portainer/environments/types';
|
||||
import { addPlural } from '@/portainer/helpers/strings';
|
||||
|
||||
import { AgentVersionTag } from './AgentVersionTag';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
EnvironmentType,
|
||||
KubernetesSnapshot,
|
||||
} from '@/portainer/environments/types';
|
||||
} from '@/react/portainer/environments/types';
|
||||
import { humanize } from '@/portainer/filters/filters';
|
||||
import { addPlural } from '@/portainer/helpers/strings';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import clsx from 'clsx';
|
||||
|
||||
import { EnvironmentStatus } from '@/portainer/environments/types';
|
||||
import { EnvironmentStatus } from '@/react/portainer/environments/types';
|
||||
|
||||
interface Props {
|
||||
status: EnvironmentStatus;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Environment } from '@/portainer/environments/types';
|
||||
import { Environment } from '@/react/portainer/environments/types';
|
||||
import { UserContext } from '@/portainer/hooks/useUser';
|
||||
import { UserViewModel } from '@/portainer/models/user';
|
||||
import { renderWithQueryClient } from '@/react-tools/test-utils';
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
EnvironmentStatus,
|
||||
PlatformType,
|
||||
EdgeTypes,
|
||||
} from '@/portainer/environments/types';
|
||||
} from '@/react/portainer/environments/types';
|
||||
import { EnvironmentGroupId } from '@/portainer/environment-groups/types';
|
||||
import {
|
||||
HomepageFilter,
|
||||
|
@ -20,12 +20,12 @@ import { useDebounce } from '@/portainer/hooks/useDebounce';
|
|||
import {
|
||||
refetchIfAnyOffline,
|
||||
useEnvironmentList,
|
||||
} from '@/portainer/environments/queries/useEnvironmentList';
|
||||
} from '@/react/portainer/environments/queries/useEnvironmentList';
|
||||
import { useGroups } from '@/portainer/environment-groups/queries';
|
||||
import { useTags } from '@/portainer/tags/queries';
|
||||
import { Filter } from '@/portainer/home/types';
|
||||
import { useAgentVersionsList } from '@/portainer/environments/queries/useAgentVersionsList';
|
||||
import { EnvironmentsQueryParams } from '@/portainer/environments/environment.service';
|
||||
import { useAgentVersionsList } from '@/react/portainer/environments/queries/useAgentVersionsList';
|
||||
import { EnvironmentsQueryParams } from '@/react/portainer/environments/environment.service';
|
||||
import { useUser } from '@/portainer/hooks/useUser';
|
||||
|
||||
import { TableFooter } from '@@/datatables/TableFooter';
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { useState } from 'react';
|
||||
import { Download } from 'react-feather';
|
||||
|
||||
import { Environment } from '@/portainer/environments/types';
|
||||
import { isKubernetesEnvironment } from '@/portainer/environments/utils';
|
||||
import { Environment } from '@/react/portainer/environments/types';
|
||||
import { isKubernetesEnvironment } from '@/react/portainer/environments/utils';
|
||||
import { trackEvent } from '@/angulartics.matomo/analytics-services';
|
||||
import { Query } from '@/portainer/environments/queries/useEnvironmentList';
|
||||
import { Query } from '@/react/portainer/environments/queries/useEnvironmentList';
|
||||
|
||||
import { Button } from '@@/buttons';
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ import { DialogOverlay } from '@reach/dialog';
|
|||
|
||||
import * as kcService from '@/kubernetes/services/kubeconfig.service';
|
||||
import * as notifications from '@/portainer/services/notifications';
|
||||
import { EnvironmentType } from '@/portainer/environments/types';
|
||||
import { EnvironmentType } from '@/react/portainer/environments/types';
|
||||
import { usePaginationLimitState } from '@/portainer/hooks/usePaginationLimitState';
|
||||
import { usePublicSettings } from '@/react/portainer/settings/queries';
|
||||
import {
|
||||
Query,
|
||||
useEnvironmentList,
|
||||
} from '@/portainer/environments/queries/useEnvironmentList';
|
||||
} from '@/react/portainer/environments/queries/useEnvironmentList';
|
||||
|
||||
import { PaginationControls } from '@@/PaginationControls';
|
||||
import { Checkbox } from '@@/form-components/Checkbox';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useState } from 'react';
|
||||
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
export function useSelection() {
|
||||
const [selection, setSelection] = useState<Record<EnvironmentId, boolean>>(
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import { useRouter } from '@uirouter/react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { Environment } from '@/react/portainer/environments/types';
|
||||
import { snapshotEndpoints } from '@/react/portainer/environments/environment.service';
|
||||
import { isEdgeEnvironment } from '@/react/portainer/environments/utils';
|
||||
|
||||
import { PageHeader } from '@@/PageHeader';
|
||||
|
||||
import * as notifications from '../services/notifications';
|
||||
import { Environment } from '../environments/types';
|
||||
import { snapshotEndpoints } from '../environments/environment.service';
|
||||
import { isEdgeEnvironment } from '../environments/utils';
|
||||
import { confirmAsync } from '../services/modal.service/confirm';
|
||||
import { buildTitle } from '../services/modal.service/utils';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useEnvironment } from '../environments/queries/useEnvironment';
|
||||
import { useEnvironment } from '@/react/portainer/environments/queries/useEnvironment';
|
||||
|
||||
import { useEnvironmentId } from './useEnvironmentId';
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import {
|
|||
} from 'react';
|
||||
|
||||
import { isAdmin } from '@/portainer/users/user.helpers';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { getUser } from '../users/user.service';
|
||||
import { User, UserId } from '../users/types';
|
||||
import { EnvironmentId } from '../environments/types';
|
||||
|
||||
import { useLocalStorage } from './useLocalStorage';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/portainer/environments/types';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import {
|
||||
OpenAMTConfiguration,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash-es';
|
||||
import { isLimitedToBE } from '@/portainer/feature-flags/feature-flags.service';
|
||||
|
||||
import { getEnvironments } from '@/portainer/environments/environment.service';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
import AccessViewerPolicyModel from '../../models/access';
|
||||
|
||||
export default class AccessViewerController {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import angular from 'angular';
|
||||
import { getEnvironments } from '../environments/environment.service';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
|
||||
angular.module('portainer.app').factory('NameValidator', NameValidatorFactory);
|
||||
/* @ngInject */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Environment } from '../environments/types';
|
||||
import { Environment } from '@/react/portainer/environments/types';
|
||||
|
||||
export interface EndpointProvider {
|
||||
setEndpointID(id: Environment['Id']): void;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { EnvironmentId } from '../environments/types';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
export type UserId = number;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import angular from 'angular';
|
||||
import uuidv4 from 'uuid/v4';
|
||||
import { getEnvironments } from '@/portainer/environments/environment.service';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
|
||||
class AuthenticationController {
|
||||
/* @ngInject */
|
||||
|
|
|
@ -6,7 +6,7 @@ import { EndpointSecurityFormData } from '@/portainer/components/endpointSecurit
|
|||
import EndpointHelper from '@/portainer/helpers/endpointHelper';
|
||||
import { getAMTInfo } from 'Portainer/hostmanagement/open-amt/open-amt.service';
|
||||
import { confirmDestructiveAsync } from '@/portainer/services/modal.service/confirm';
|
||||
import { isEdgeEnvironment } from '@/portainer/environments/utils';
|
||||
import { isEdgeEnvironment } from '@/react/portainer/environments/utils';
|
||||
|
||||
import { commandsTabs } from '@/react/edge/components/EdgeScriptForm/scripts';
|
||||
import { GpusListAngular } from '@/react/portainer/environments/wizard/EnvironmentsCreationView/shared/Hardware/GpusList';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { map } from 'lodash';
|
||||
import EndpointHelper from '@/portainer/helpers/endpointHelper';
|
||||
import { getEnvironments } from '@/portainer/environments/environment.service';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
|
||||
export class EndpointsController {
|
||||
/* @ngInject */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { getEnvironments } from '@/portainer/environments/environment.service';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
|
||||
angular.module('portainer.app').controller('InitAdminController', [
|
||||
'$scope',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ResourceControlType } from '@/react/portainer/access-control/types';
|
||||
import { AccessControlFormData } from 'Portainer/components/accessControlForm/porAccessControlFormModel';
|
||||
import { FeatureId } from 'Portainer/feature-flags/enums';
|
||||
import { getEnvironments } from '@/portainer/environments/environment.service';
|
||||
import { getEnvironments } from '@/react/portainer/environments/environment.service';
|
||||
import { StackStatus, StackType } from '@/react/docker/stacks/types';
|
||||
|
||||
angular.module('portainer.app').controller('StackController', [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue