Compare commits
No commits in common. "b997f554bc462795ed46d634f1384d3fde9e0115" and "26a364aad6dc04d237ff4756cd322508cdffb2b1" have entirely different histories.
b997f554bc
...
26a364aad6
10 changed files with 38 additions and 76 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(`ws://${ws}:8001/api/v1`);
|
const newSocket = new WebSocket(`wss://${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(`ws://${ip}:8001/api/v1`);
|
const testSocket = new WebSocket(`wss://${ip}:8001/api/v1`);
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
testSocket.close();
|
testSocket.close();
|
||||||
resolve(false);
|
resolve(false);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
const { contextBridge, ipcRenderer } = require('electron');
|
const { contextBridge, ipcRenderer } = require('electron');
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('electronAPI', {
|
contextBridge.exposeInMainWorld('electron', {
|
||||||
send: (channel, data) => ipcRenderer.send(channel, data),
|
send: (channel, data) => {
|
||||||
on: (channel, func) => ipcRenderer.on(channel, (event, ...args) => func(...args)),
|
ipcRenderer.send(channel, data);
|
||||||
quitApp: () => ipcRenderer.send('quit-app'),
|
},
|
||||||
|
on: (channel, func) => {
|
||||||
|
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||||
|
},
|
||||||
|
quitApp: () => {
|
||||||
|
ipcRenderer.send('quit-app');
|
||||||
|
},
|
||||||
|
|
||||||
showSaveDialog: (options) => ipcRenderer.invoke('show-save-dialog', options),
|
onThemeChange: (callback) => {
|
||||||
writeFile: (path, data) => ipcRenderer.invoke('write-file', { path, data }),
|
ipcRenderer.on('theme-update', (event, theme) => {
|
||||||
onThemeChange: (callback) => ipcRenderer.on('theme-update', (event, theme) => callback(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: `http://localhost:8001`,
|
baseURL: `https://localhost:8001`,
|
||||||
})
|
})
|
||||||
|
|
||||||
export class NetworkService {
|
export class NetworkService {
|
||||||
static createAxiosInstance(ipAddress: string) {
|
static createAxiosInstance(ipAddress: string) {
|
||||||
return axios.create({
|
return axios.create({
|
||||||
baseURL: `http://${ipAddress}:8001`,
|
baseURL: `https://${ipAddress}:8001`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
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, {useTheme} from "styled-components";
|
import styled 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;
|
||||||
}
|
}
|
||||||
|
|
@ -48,16 +47,6 @@ 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);
|
||||||
|
|
@ -68,13 +57,10 @@ 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 };
|
||||||
|
|
@ -140,12 +126,6 @@ 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>
|
||||||
|
|
@ -186,32 +166,20 @@ export const Settings = ({ onClose }: Props) => {
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<ButtonContainer>
|
<ButtonContainer>
|
||||||
<SettingsButtons>
|
<MainButton
|
||||||
<MainButton
|
type="button"
|
||||||
type="button"
|
size="small"
|
||||||
size="small"
|
title='Отменить'
|
||||||
title='Сбросить настройки'
|
onClick={handleCancel}
|
||||||
onClick={handleReset}
|
|
||||||
color={theme.offlineColor}
|
/>
|
||||||
hoverColor={theme.borderColor}
|
<MainButton
|
||||||
/>
|
type="button"
|
||||||
<span>
|
size="small"
|
||||||
<MainButton
|
title='Сохранить'
|
||||||
type="button"
|
onClick={handleSave}
|
||||||
size="small"
|
|
||||||
title='Отменить'
|
/>
|
||||||
onClick={handleCancel}
|
|
||||||
color={theme.offlineColor}
|
|
||||||
hoverColor={theme.borderColor}
|
|
||||||
/>
|
|
||||||
<MainButton
|
|
||||||
type="button"
|
|
||||||
size="small"
|
|
||||||
title='Сохранить'
|
|
||||||
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,11 +1,8 @@
|
||||||
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(`ws://${ws}:8001/api/v1`);
|
const newSocket = new WebSocket(`wss://${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(`ws://${ip}:8001/api/v1`);
|
const testSocket = new WebSocket(`wss://${ip}:8001/api/v1`);
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
testSocket.close();
|
testSocket.close();
|
||||||
resolve(false);
|
resolve(false);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
@ -59,16 +58,6 @@ 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