Compare commits
2 commits
26a364aad6
...
b997f554bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b997f554bc | ||
|
|
ca33a55375 |
10 changed files with 76 additions and 38 deletions
|
|
@ -76,7 +76,7 @@ export const NetworkInterfaces = ({ startConnection, ws }: Props) => {
|
||||||
setHasInited(false)
|
setHasInited(false)
|
||||||
initializationAttempt.current = 0;
|
initializationAttempt.current = 0;
|
||||||
|
|
||||||
const newSocket = new WebSocket(`wss://${ws}:8001/api/v1`);
|
const newSocket = new WebSocket(`ws://${ws}:8001/api/v1`);
|
||||||
|
|
||||||
let connectionTimeout;
|
let connectionTimeout;
|
||||||
setSocket(newSocket);
|
setSocket(newSocket);
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ export const DevicesBar = () => {
|
||||||
|
|
||||||
const checkWebSocketAvailability = async (ip: string): Promise<boolean> => {
|
const checkWebSocketAvailability = async (ip: string): Promise<boolean> => {
|
||||||
return new Promise((resolve) => {
|
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(() => {
|
const timeout = setTimeout(() => {
|
||||||
testSocket.close();
|
testSocket.close();
|
||||||
resolve(false);
|
resolve(false);
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,11 @@
|
||||||
const { contextBridge, ipcRenderer } = require('electron');
|
const { contextBridge, ipcRenderer } = require('electron');
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('electron', {
|
contextBridge.exposeInMainWorld('electronAPI', {
|
||||||
send: (channel, data) => {
|
send: (channel, data) => ipcRenderer.send(channel, data),
|
||||||
ipcRenderer.send(channel, data);
|
on: (channel, func) => ipcRenderer.on(channel, (event, ...args) => func(...args)),
|
||||||
},
|
quitApp: () => ipcRenderer.send('quit-app'),
|
||||||
on: (channel, func) => {
|
|
||||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
|
||||||
},
|
|
||||||
quitApp: () => {
|
|
||||||
ipcRenderer.send('quit-app');
|
|
||||||
},
|
|
||||||
|
|
||||||
onThemeChange: (callback) => {
|
showSaveDialog: (options) => ipcRenderer.invoke('show-save-dialog', options),
|
||||||
ipcRenderer.on('theme-update', (event, theme) => {
|
writeFile: (path, data) => ipcRenderer.invoke('write-file', { path, data }),
|
||||||
callback(theme);
|
onThemeChange: (callback) => ipcRenderer.on('theme-update', (event, theme) => callback(theme))
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import axios, { AxiosResponse } from "axios";
|
import axios, { AxiosResponse } from "axios";
|
||||||
|
|
||||||
const axiosWithoutCredentials = axios.create({
|
const axiosWithoutCredentials = axios.create({
|
||||||
baseURL: `https://localhost:8001`,
|
baseURL: `http://localhost:8001`,
|
||||||
})
|
})
|
||||||
|
|
||||||
export class NetworkService {
|
export class NetworkService {
|
||||||
static createAxiosInstance(ipAddress: string) {
|
static createAxiosInstance(ipAddress: string) {
|
||||||
return axios.create({
|
return axios.create({
|
||||||
baseURL: `https://${ipAddress}:8001`,
|
baseURL: `http://${ipAddress}:8001`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import { ModalContainer, ModalTitle, ModalContent, ButtonContainer } from "../modalwindows/style";
|
import { ModalContainer, ModalTitle, ModalContent, ButtonContainer } from "../modalwindows/style";
|
||||||
import { MainButton } from "../UI/buttons/mainButton";
|
import { MainButton } from "../UI/buttons/mainButton";
|
||||||
import {useCallback, useEffect, useMemo, useState} from "react";
|
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 {Setting, useSettingsStore} from "../../store/settings/settingsStore";
|
||||||
import {SettingItem} from "./SettingItem";
|
import {SettingItem} from "./SettingItem";
|
||||||
import {IconComponent} from "../../const/buttons/icons";
|
import {IconComponent} from "../../const/buttons/icons";
|
||||||
import {buttonNames} from "../../const/buttons/names";
|
import {buttonNames} from "../../const/buttons/names";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +48,16 @@ const SectionLine = styled.span`
|
||||||
const CloseBtn = styled.span`
|
const CloseBtn = styled.span`
|
||||||
cursor: pointer;
|
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) => {
|
export const Settings = ({ onClose }: Props) => {
|
||||||
const settingsConfig = useSettingsStore(state => state.settingsConfig);
|
const settingsConfig = useSettingsStore(state => state.settingsConfig);
|
||||||
const settingsValues = useSettingsStore(state => state.settingsValues);
|
const settingsValues = useSettingsStore(state => state.settingsValues);
|
||||||
|
|
@ -57,10 +68,13 @@ export const Settings = ({ onClose }: Props) => {
|
||||||
const applyChanges = useSettingsStore(state => state.applyChanges);
|
const applyChanges = useSettingsStore(state => state.applyChanges);
|
||||||
const discardChanges = useSettingsStore(state => state.discardChanges);
|
const discardChanges = useSettingsStore(state => state.discardChanges);
|
||||||
const getSetting = useSettingsStore(state => state.getSetting);
|
const getSetting = useSettingsStore(state => state.getSetting);
|
||||||
|
const resetToDefaults = useSettingsStore(state => state.resetToDefaults);
|
||||||
const initializeSettings = useSettingsStore(state => state.initializeSettings);
|
const initializeSettings = useSettingsStore(state => state.initializeSettings);
|
||||||
|
|
||||||
|
const theme = useTheme()
|
||||||
const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});
|
const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});
|
||||||
|
|
||||||
|
// Проверка действий
|
||||||
const handleValidationError = useCallback((fieldId: string, error: string | null) => {
|
const handleValidationError = useCallback((fieldId: string, error: string | null) => {
|
||||||
setFieldErrors(prev => {
|
setFieldErrors(prev => {
|
||||||
const newErrors = { ...prev };
|
const newErrors = { ...prev };
|
||||||
|
|
@ -126,6 +140,12 @@ export const Settings = ({ onClose }: Props) => {
|
||||||
onClose();
|
onClose();
|
||||||
}, [discardChanges, onClose]);
|
}, [discardChanges, onClose]);
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
if (window.confirm('Вы уверены, что хотите сбросить все настройки к значениям по умолчанию?')) {
|
||||||
|
resetToDefaults();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalContainer style={{ height: '60vh', width: '50vw', minWidth: "800px" }}>
|
<ModalContainer style={{ height: '60vh', width: '50vw', minWidth: "800px" }}>
|
||||||
<ModalTitle>
|
<ModalTitle>
|
||||||
|
|
@ -166,20 +186,32 @@ export const Settings = ({ onClose }: Props) => {
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<ButtonContainer>
|
<ButtonContainer>
|
||||||
|
<SettingsButtons>
|
||||||
|
<MainButton
|
||||||
|
type="button"
|
||||||
|
size="small"
|
||||||
|
title='Сбросить настройки'
|
||||||
|
onClick={handleReset}
|
||||||
|
color={theme.offlineColor}
|
||||||
|
hoverColor={theme.borderColor}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
<MainButton
|
<MainButton
|
||||||
type="button"
|
type="button"
|
||||||
size="small"
|
size="small"
|
||||||
title='Отменить'
|
title='Отменить'
|
||||||
onClick={handleCancel}
|
onClick={handleCancel}
|
||||||
|
color={theme.offlineColor}
|
||||||
|
hoverColor={theme.borderColor}
|
||||||
/>
|
/>
|
||||||
<MainButton
|
<MainButton
|
||||||
type="button"
|
type="button"
|
||||||
size="small"
|
size="small"
|
||||||
title='Сохранить'
|
title='Сохранить'
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
</span>
|
||||||
|
</SettingsButtons>
|
||||||
</ButtonContainer>
|
</ButtonContainer>
|
||||||
</ModalContainer>
|
</ModalContainer>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ export const TableScanner = ({ devices }: TableScannerProps) => {
|
||||||
default: return '';
|
default: return '';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Boolean); // Убираем пустые значения
|
.filter(Boolean);
|
||||||
}, [ordersColumns, disabledColumns]);
|
}, [ordersColumns, disabledColumns]);
|
||||||
|
|
||||||
// Пагинация
|
// Пагинация
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import DeviceCard from "../../../../../UI/Dropdown/DeviceCard";
|
|
||||||
import {DeviceUser} from "../../../../../../store/useDeviceStore";
|
import {DeviceUser} from "../../../../../../store/useDeviceStore";
|
||||||
import {TableScanner} from "./TableScanner";
|
import {TableScanner} from "./TableScanner";
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> 26a364aad6dc04d237ff4756cd322508cdffb2b1
|
||||||
|
|
||||||
const ScanBtn = styled.button`
|
const ScanBtn = styled.button`
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ export const NetworkInterfaces = ({ startConnection, ws }: Props) => {
|
||||||
setHasInited(false)
|
setHasInited(false)
|
||||||
initializationAttempt.current = 0;
|
initializationAttempt.current = 0;
|
||||||
|
|
||||||
const newSocket = new WebSocket(`wss://${ws}:8001/api/v1`);
|
const newSocket = new WebSocket(`ws://${ws}:8001/api/v1`);
|
||||||
|
|
||||||
let connectionTimeout;
|
let connectionTimeout;
|
||||||
setSocket(newSocket);
|
setSocket(newSocket);
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ export const DevicesBar = () => {
|
||||||
|
|
||||||
const checkWebSocketAvailability = async (ip: string): Promise<boolean> => {
|
const checkWebSocketAvailability = async (ip: string): Promise<boolean> => {
|
||||||
return new Promise((resolve) => {
|
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(() => {
|
const timeout = setTimeout(() => {
|
||||||
testSocket.close();
|
testSocket.close();
|
||||||
resolve(false);
|
resolve(false);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ type SettingsState = {
|
||||||
resetSettings: () => void;
|
resetSettings: () => void;
|
||||||
applyChanges: () => void;
|
applyChanges: () => void;
|
||||||
discardChanges: () => void;
|
discardChanges: () => void;
|
||||||
|
resetToDefaults: () => void;
|
||||||
getSettingValue: <T = any>(id: string) => T;
|
getSettingValue: <T = any>(id: string) => T;
|
||||||
getNumberSetting: (id: string, fallback?: number) => number;
|
getNumberSetting: (id: string, fallback?: number) => number;
|
||||||
};
|
};
|
||||||
|
|
@ -58,6 +59,16 @@ export const useSettingsStore = create<SettingsState>()(
|
||||||
pendingChanges: { ...state.pendingChanges, [id]: value }
|
pendingChanges: { ...state.pendingChanges, [id]: value }
|
||||||
})),
|
})),
|
||||||
|
|
||||||
|
resetToDefaults: () => set({
|
||||||
|
settingsValues: Object.fromEntries(
|
||||||
|
get().settingsConfig.map(setting => [
|
||||||
|
setting.id,
|
||||||
|
setting.defaultValue
|
||||||
|
])
|
||||||
|
),
|
||||||
|
pendingChanges: {}
|
||||||
|
}),
|
||||||
|
|
||||||
applyChanges: () =>
|
applyChanges: () =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
settingsValues: { ...state.settingsValues, ...state.pendingChanges },
|
settingsValues: { ...state.settingsValues, ...state.pendingChanges },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue