Электрон проверка
This commit is contained in:
parent
c423cf7172
commit
ca33a55375
10 changed files with 74 additions and 39 deletions
|
|
@ -1,13 +1,13 @@
|
|||
import axios, { AxiosResponse } from "axios";
|
||||
|
||||
const axiosWithoutCredentials = axios.create({
|
||||
baseURL: `https://localhost:8001`,
|
||||
baseURL: `http://localhost:8001`,
|
||||
})
|
||||
|
||||
export class NetworkService {
|
||||
static createAxiosInstance(ipAddress: string) {
|
||||
return axios.create({
|
||||
baseURL: `https://${ipAddress}:8001`,
|
||||
baseURL: `http://${ipAddress}:8001`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { ModalContainer, ModalTitle, ModalContent, ButtonContainer } from "../modalwindows/style";
|
||||
import { MainButton } from "../UI/buttons/mainButton";
|
||||
import {useCallback, useEffect, useMemo, useState} from "react";
|
||||
import styled from "styled-components";
|
||||
import styled, {useTheme} from "styled-components";
|
||||
import {Setting, useSettingsStore} from "../../store/settings/settingsStore";
|
||||
import {SettingItem} from "./SettingItem";
|
||||
import {IconComponent} from "../../const/buttons/icons";
|
||||
import {buttonNames} from "../../const/buttons/names";
|
||||
|
||||
|
||||
interface Props {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
|
@ -47,6 +48,16 @@ const SectionLine = styled.span`
|
|||
const CloseBtn = styled.span`
|
||||
cursor: pointer;
|
||||
`
|
||||
const SettingsButtons = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
span{
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
`
|
||||
export const Settings = ({ onClose }: Props) => {
|
||||
const settingsConfig = useSettingsStore(state => state.settingsConfig);
|
||||
const settingsValues = useSettingsStore(state => state.settingsValues);
|
||||
|
|
@ -57,10 +68,13 @@ export const Settings = ({ onClose }: Props) => {
|
|||
const applyChanges = useSettingsStore(state => state.applyChanges);
|
||||
const discardChanges = useSettingsStore(state => state.discardChanges);
|
||||
const getSetting = useSettingsStore(state => state.getSetting);
|
||||
const resetToDefaults = useSettingsStore(state => state.resetToDefaults);
|
||||
const initializeSettings = useSettingsStore(state => state.initializeSettings);
|
||||
|
||||
const theme = useTheme()
|
||||
const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});
|
||||
|
||||
// Проверка действий
|
||||
const handleValidationError = useCallback((fieldId: string, error: string | null) => {
|
||||
setFieldErrors(prev => {
|
||||
const newErrors = { ...prev };
|
||||
|
|
@ -126,6 +140,12 @@ export const Settings = ({ onClose }: Props) => {
|
|||
onClose();
|
||||
}, [discardChanges, onClose]);
|
||||
|
||||
const handleReset = () => {
|
||||
if (window.confirm('Вы уверены, что хотите сбросить все настройки к значениям по умолчанию?')) {
|
||||
resetToDefaults();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ModalContainer style={{ height: '60vh', width: '50vw', minWidth: "800px" }}>
|
||||
<ModalTitle>
|
||||
|
|
@ -166,20 +186,32 @@ export const Settings = ({ onClose }: Props) => {
|
|||
</ModalContent>
|
||||
|
||||
<ButtonContainer>
|
||||
<MainButton
|
||||
type="button"
|
||||
size="small"
|
||||
title='Отменить'
|
||||
onClick={handleCancel}
|
||||
|
||||
/>
|
||||
<MainButton
|
||||
type="button"
|
||||
size="small"
|
||||
title='Сохранить'
|
||||
onClick={handleSave}
|
||||
|
||||
/>
|
||||
<SettingsButtons>
|
||||
<MainButton
|
||||
type="button"
|
||||
size="small"
|
||||
title='Сбросить настройки'
|
||||
onClick={handleReset}
|
||||
color={theme.offlineColor}
|
||||
hoverColor={theme.borderColor}
|
||||
/>
|
||||
<span>
|
||||
<MainButton
|
||||
type="button"
|
||||
size="small"
|
||||
title='Отменить'
|
||||
onClick={handleCancel}
|
||||
color={theme.offlineColor}
|
||||
hoverColor={theme.borderColor}
|
||||
/>
|
||||
<MainButton
|
||||
type="button"
|
||||
size="small"
|
||||
title='Сохранить'
|
||||
onClick={handleSave}
|
||||
/>
|
||||
</span>
|
||||
</SettingsButtons>
|
||||
</ButtonContainer>
|
||||
</ModalContainer>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ export const TableScanner = ({ devices }: TableScannerProps) => {
|
|||
default: return '';
|
||||
}
|
||||
})
|
||||
.filter(Boolean); // Убираем пустые значения
|
||||
.filter(Boolean);
|
||||
}, [ordersColumns, disabledColumns]);
|
||||
|
||||
// Пагинация
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import DeviceCard from "../../../../../UI/Dropdown/DeviceCard";
|
||||
import {DeviceUser} from "../../../../../../store/useDeviceStore";
|
||||
import TableScanner from "./TableScanner";
|
||||
import {TableScanner} from "./TableScanner";
|
||||
|
||||
|
||||
const ScanBtn = styled.button`
|
||||
position: relative;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export const NetworkInterfaces = ({ startConnection, ws }: Props) => {
|
|||
setHasInited(false)
|
||||
initializationAttempt.current = 0;
|
||||
|
||||
const newSocket = new WebSocket(`wss://${ws}:8001/api/v1`);
|
||||
const newSocket = new WebSocket(`ws://${ws}:8001/api/v1`);
|
||||
|
||||
let connectionTimeout;
|
||||
setSocket(newSocket);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export const DevicesBar = () => {
|
|||
|
||||
const checkWebSocketAvailability = async (ip: string): Promise<boolean> => {
|
||||
return new Promise((resolve) => {
|
||||
const testSocket = new WebSocket(`wss://${ip}:8001/api/v1`);
|
||||
const testSocket = new WebSocket(`ws://${ip}:8001/api/v1`);
|
||||
const timeout = setTimeout(() => {
|
||||
testSocket.close();
|
||||
resolve(false);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ type SettingsState = {
|
|||
resetSettings: () => void;
|
||||
applyChanges: () => void;
|
||||
discardChanges: () => void;
|
||||
resetToDefaults: () => void;
|
||||
getSettingValue: <T = any>(id: string) => T;
|
||||
getNumberSetting: (id: string, fallback?: number) => number;
|
||||
};
|
||||
|
|
@ -58,6 +59,16 @@ export const useSettingsStore = create<SettingsState>()(
|
|||
pendingChanges: { ...state.pendingChanges, [id]: value }
|
||||
})),
|
||||
|
||||
resetToDefaults: () => set({
|
||||
settingsValues: Object.fromEntries(
|
||||
get().settingsConfig.map(setting => [
|
||||
setting.id,
|
||||
setting.defaultValue
|
||||
])
|
||||
),
|
||||
pendingChanges: {}
|
||||
}),
|
||||
|
||||
applyChanges: () =>
|
||||
set((state) => ({
|
||||
settingsValues: { ...state.settingsValues, ...state.pendingChanges },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue