+1
This commit is contained in:
parent
b77725b9f9
commit
8b936603cc
3 changed files with 86 additions and 19 deletions
|
|
@ -96,24 +96,86 @@ export const TableScanner = ({ devices }: TableScannerProps) => {
|
|||
});
|
||||
};
|
||||
|
||||
const defaultOrder = useMemo(() => ([
|
||||
t('settings-status'),
|
||||
t('settings-name'),
|
||||
t('settings-vendor'),
|
||||
t('settings-ipAddress'),
|
||||
t('settings-openPorts'),
|
||||
t('settings-lastActivity'),
|
||||
t('settings-note'),
|
||||
t('settings-action'),
|
||||
]), [t]);
|
||||
|
||||
const normalizedOrders = useMemo(
|
||||
() => (Array.isArray(ordersColumns) && ordersColumns.length ? ordersColumns : defaultOrder),
|
||||
[ordersColumns, defaultOrder]
|
||||
);
|
||||
const normalizedDisabled = useMemo(
|
||||
() => (Array.isArray(disabledColumns) ? disabledColumns : []),
|
||||
[disabledColumns]
|
||||
);
|
||||
|
||||
const visibleColumns = useMemo(() => {
|
||||
return ordersColumns
|
||||
.filter(column => !disabledColumns.includes(ordersColumns.indexOf(column)))
|
||||
.map(column => {
|
||||
switch(column) {
|
||||
case 'Онлайн': return 'status';
|
||||
case 'Имя': return 'name';
|
||||
case 'Производитель': return 'vendor';
|
||||
case 'IP адрес': return 'ip';
|
||||
case 'Открытые порты': return 'ports';
|
||||
case 'Последняя активность': return 'activity';
|
||||
case 'Заметка': return 'note';
|
||||
case 'Действие': return 'action';
|
||||
default: return '';
|
||||
}
|
||||
})
|
||||
const normalizeColumnName = (column: string) => column?.toLowerCase();
|
||||
|
||||
const columnToKey = (column: string) => {
|
||||
const col = normalizeColumnName(column);
|
||||
switch (col) {
|
||||
case 'settings-status':
|
||||
case normalizeColumnName(t('settings-status')):
|
||||
case 'онлайн':
|
||||
case 'status':
|
||||
return 'status';
|
||||
case 'settings-name':
|
||||
case normalizeColumnName(t('settings-name')):
|
||||
case 'имя':
|
||||
case 'name':
|
||||
return 'name';
|
||||
case 'settings-vendor':
|
||||
case normalizeColumnName(t('settings-vendor')):
|
||||
case 'производитель':
|
||||
case 'vendor':
|
||||
return 'vendor';
|
||||
case 'settings-ipaddress':
|
||||
case normalizeColumnName(t('settings-ipAddress')):
|
||||
case 'ip адрес':
|
||||
case 'ip address':
|
||||
case 'ip':
|
||||
return 'ip';
|
||||
case 'settings-openports':
|
||||
case normalizeColumnName(t('settings-openPorts')):
|
||||
case 'открытые порты':
|
||||
case 'open ports':
|
||||
case 'ports':
|
||||
return 'ports';
|
||||
case 'settings-lastactivity':
|
||||
case normalizeColumnName(t('settings-lastActivity')):
|
||||
case 'последняя активность':
|
||||
case 'last activity':
|
||||
case 'activity':
|
||||
return 'activity';
|
||||
case 'settings-note':
|
||||
case normalizeColumnName(t('settings-note')):
|
||||
case 'заметка':
|
||||
case 'note':
|
||||
return 'note';
|
||||
case 'settings-action':
|
||||
case normalizeColumnName(t('settings-action')):
|
||||
case 'действие':
|
||||
case 'action':
|
||||
return 'action';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
return normalizedOrders
|
||||
.map((column, index) => ({ column, index }))
|
||||
.filter(({ index }) => !normalizedDisabled.includes(index))
|
||||
.map(({ column }) => columnToKey(column))
|
||||
.filter(Boolean);
|
||||
}, [ordersColumns, disabledColumns]);
|
||||
}, [normalizedOrders, normalizedDisabled, t]);
|
||||
|
||||
// Пагинация
|
||||
const indexOfLastDevice = currentPage * devicesPerPage;
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ export default function UserScanner() {
|
|||
}
|
||||
setScanInitiated(true);
|
||||
const res = await NetworkService.scanUser(ipAddress, ipScanning);
|
||||
console.log(res)
|
||||
setDevices(res.data.devices || []);
|
||||
} catch (err) {
|
||||
console.error("Ошибка сканирования сети:", err);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,12 @@ export const I18nProvider = ({ children, initialLanguage }: I18nProviderProps) =
|
|||
await Promise.all(
|
||||
namespaces.map(async (ns) => {
|
||||
try {
|
||||
const data = await import(`../../../public/locales/${lang}/${ns}.json`);
|
||||
newTranslations[lang][ns] = data.default || data;
|
||||
const res = await fetch(`/locales/${lang}/${ns}.json`);
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`);
|
||||
}
|
||||
const data = await res.json();
|
||||
newTranslations[lang][ns] = data;
|
||||
} catch (e) {
|
||||
console.error(`Failed to load ${lang}/${ns} translations`, e);
|
||||
newTranslations[lang][ns] = {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue