fix: conflicts
This commit is contained in:
@@ -7,6 +7,12 @@ import type {
|
||||
LogFilters,
|
||||
InsertLogRequest,
|
||||
InsertLogsRequest,
|
||||
TokenUpdate,
|
||||
TokenUpdatePermissions,
|
||||
TokenPasswordReset,
|
||||
RegistrationRequest,
|
||||
DeployAgentsRequest,
|
||||
DeployResponse,
|
||||
} from "../types/agent.types";
|
||||
|
||||
class AgentApiService {
|
||||
@@ -20,7 +26,9 @@ class AgentApiService {
|
||||
}
|
||||
|
||||
async getUsers(): Promise<TokenUser[]> {
|
||||
const response = await apiClient.get<TokenUser[]>(`${this.authBasePath}/tokens`);
|
||||
const response = await apiClient.get<TokenUser[]>(
|
||||
`${this.authBasePath}/tokens`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
@@ -60,17 +68,85 @@ class AgentApiService {
|
||||
}
|
||||
|
||||
async getDistinctAgents(): Promise<string[]> {
|
||||
const response = await apiClient.get<string[]>(`${this.logsBasePath}/agents`);
|
||||
const response = await apiClient.get<string[]>(
|
||||
`${this.logsBasePath}/agents`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getDistinctLevels(): Promise<string[]> {
|
||||
const response = await apiClient.get<string[]>(`${this.logsBasePath}/levels`);
|
||||
const response = await apiClient.get<string[]>(
|
||||
`${this.logsBasePath}/levels`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getDistinctServices(): Promise<string[]> {
|
||||
const response = await apiClient.get<string[]>(`${this.logsBasePath}/services`);
|
||||
const response = await apiClient.get<string[]>(
|
||||
`${this.logsBasePath}/services`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// User management methods
|
||||
async getUserByLogin(login: string): Promise<TokenUser> {
|
||||
const response = await apiClient.get<TokenUser>(
|
||||
`${this.authBasePath}/users/${login}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getInactiveUsers(): Promise<TokenUser[]> {
|
||||
const response = await apiClient.get<TokenUser[]>(
|
||||
`${this.authBasePath}/users/inactive`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async updateUser(login: string, data: TokenUpdate): Promise<void> {
|
||||
await apiClient.put(`${this.authBasePath}/users/${login}`, data);
|
||||
}
|
||||
|
||||
async updateUserPermissions(
|
||||
login: string,
|
||||
data: TokenUpdatePermissions,
|
||||
): Promise<void> {
|
||||
await apiClient.put(
|
||||
`${this.authBasePath}/users/${login}/permissions`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
async resetUserPassword(
|
||||
login: string,
|
||||
data: TokenPasswordReset,
|
||||
): Promise<void> {
|
||||
await apiClient.put(`${this.authBasePath}/users/${login}/password`, data);
|
||||
}
|
||||
|
||||
async activateUser(login: string): Promise<void> {
|
||||
await apiClient.post(`${this.authBasePath}/users/${login}/activate`);
|
||||
}
|
||||
|
||||
async deactivateUser(login: string): Promise<void> {
|
||||
await apiClient.post(`${this.authBasePath}/users/${login}/deactivate`);
|
||||
}
|
||||
|
||||
async createRegistrationToken(
|
||||
data: RegistrationRequest,
|
||||
): Promise<Record<string, string>> {
|
||||
const response = await apiClient.post<Record<string, string>>(
|
||||
`${this.basePath}/register-token`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async deployAgents(data: DeployAgentsRequest): Promise<DeployResponse> {
|
||||
const response = await apiClient.post<DeployResponse>(
|
||||
`${this.basePath}/deploy`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,12 @@ export type {
|
||||
InsertLogRequest,
|
||||
InsertLogsRequest,
|
||||
LogFilters,
|
||||
TokenUpdate,
|
||||
TokenUpdatePermissions,
|
||||
TokenPasswordReset,
|
||||
RegistrationRequest,
|
||||
DeployResult,
|
||||
DeployAgentsRequest,
|
||||
AgentDeployConfig,
|
||||
DeployResponse,
|
||||
} from "./types/agent.types";
|
||||
|
||||
@@ -74,3 +74,51 @@ export interface LogFilters {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface TokenUpdate {
|
||||
name?: string;
|
||||
last_name?: string;
|
||||
}
|
||||
|
||||
export interface TokenUpdatePermissions {
|
||||
is_active?: boolean;
|
||||
permission_admin?: boolean;
|
||||
permission_manage_agent?: boolean;
|
||||
permission_view?: boolean;
|
||||
}
|
||||
|
||||
export interface TokenPasswordReset {
|
||||
new_password: string;
|
||||
}
|
||||
|
||||
export interface RegistrationRequest {
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface DeployResult {
|
||||
agent_label: string;
|
||||
error?: string;
|
||||
ip: string;
|
||||
success: boolean;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface DeployAgentsRequest {
|
||||
servers: AgentDeployConfig[];
|
||||
}
|
||||
|
||||
export interface AgentDeployConfig {
|
||||
agentLabel: string;
|
||||
authMethod: "key" | "password";
|
||||
deployType: "docker" | "binary";
|
||||
ip: string;
|
||||
password?: string;
|
||||
port?: number;
|
||||
sshKey?: string;
|
||||
user: string;
|
||||
}
|
||||
|
||||
export interface DeployResponse {
|
||||
message?: string;
|
||||
results: DeployResult[];
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
FiPlus,
|
||||
FiTrash2,
|
||||
FiSettings,
|
||||
FiLink,
|
||||
} from "react-icons/fi";
|
||||
import { SiDocker } from "react-icons/si";
|
||||
import { FiPackage, FiUploadCloud } from "react-icons/fi";
|
||||
@@ -20,8 +21,10 @@ interface ExtraField {
|
||||
}
|
||||
|
||||
export interface SSHAgentConfig {
|
||||
agentLabel: string;
|
||||
user: string;
|
||||
ip: string;
|
||||
port: number;
|
||||
authMethod: AuthMethod;
|
||||
sshKey?: string;
|
||||
password?: string;
|
||||
@@ -189,11 +192,31 @@ export const SSHAgentForm: React.FC<SSHAgentFormProps> = ({
|
||||
</div>
|
||||
|
||||
<div style={{ display: "grid", gap: "20px" }}>
|
||||
{/* User и IP */}
|
||||
{/* Agent Label */}
|
||||
<div>
|
||||
<label style={labelStyle}>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: "6px" }}>
|
||||
<FiServer size={14} />
|
||||
Метка агента *
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.agentLabel}
|
||||
onChange={(e) => handleChange("agentLabel", e.target.value)}
|
||||
required
|
||||
style={inputBaseStyle}
|
||||
onFocus={handleFocus}
|
||||
onBlur={handleBlur}
|
||||
placeholder="production-server-1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* User, IP и Port */}
|
||||
<div
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "1fr 1fr",
|
||||
gridTemplateColumns: "1fr 1fr 1fr",
|
||||
gap: "16px",
|
||||
}}
|
||||
>
|
||||
@@ -238,6 +261,31 @@ export const SSHAgentForm: React.FC<SSHAgentFormProps> = ({
|
||||
placeholder="192.168.1.1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style={labelStyle}>
|
||||
<span
|
||||
style={{ display: "flex", alignItems: "center", gap: "6px" }}
|
||||
>
|
||||
<FiLink size={14} />
|
||||
Порт *
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={config.port}
|
||||
onChange={(e) =>
|
||||
handleChange("port", parseInt(e.target.value) || 22)
|
||||
}
|
||||
required
|
||||
min={1}
|
||||
max={65535}
|
||||
style={inputBaseStyle}
|
||||
onFocus={handleFocus}
|
||||
onBlur={handleBlur}
|
||||
placeholder="22"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Метод аутентификации */}
|
||||
@@ -457,7 +505,7 @@ export const SSHAgentForm: React.FC<SSHAgentFormProps> = ({
|
||||
<div
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "1fr 1fr 1fr",
|
||||
gridTemplateColumns: "1fr 1fr",
|
||||
gap: "8px",
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -17,12 +17,18 @@ const login = async (credentials: LoginCredentials): Promise<LoginResponse> => {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const register = async (data: RegisterData): Promise<LoginResponse> => {
|
||||
const response = await apiClient.post<LoginResponse>("/auth/register", {
|
||||
const register = async (
|
||||
data: RegisterData,
|
||||
): Promise<Record<string, string>> => {
|
||||
const response = await apiClient.post<Record<string, string>>("/auth/token", {
|
||||
login: data.login,
|
||||
password: data.password,
|
||||
name: data.firstName,
|
||||
last_name: data.lastName,
|
||||
is_active: data.is_active,
|
||||
permission_admin: data.permission_admin,
|
||||
permission_manage_agent: data.permission_manage_agent,
|
||||
permission_view: data.permission_view,
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
@@ -62,9 +68,10 @@ export const useAuthStore = create<AuthState>()(
|
||||
register: async (data: RegisterData) => {
|
||||
set({ isLoading: true, error: null });
|
||||
try {
|
||||
const response = await register(data);
|
||||
const user = mapResponseToUser(response);
|
||||
set({ user, token: response.token, isLoading: false });
|
||||
await register(data);
|
||||
// После регистрации пользователь не авторизуется автоматически
|
||||
// Нужно войти через /auth/login
|
||||
set({ isLoading: false });
|
||||
} catch (error) {
|
||||
set({
|
||||
error:
|
||||
|
||||
@@ -8,6 +8,10 @@ export interface RegisterData {
|
||||
password: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
is_active?: boolean;
|
||||
permission_admin?: boolean;
|
||||
permission_manage_agent?: boolean;
|
||||
permission_view?: boolean;
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
|
||||
Reference in New Issue
Block a user