Skip to content

Commit

Permalink
Merge pull request #65 from Zephyruso/fix-source-ip-all
Browse files Browse the repository at this point in the history
fix: source ip all
  • Loading branch information
xishang0128 committed Jun 29, 2023
2 parents d497b15 + 45b9e90 commit a0435f9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { connect } from './StateProvider';
import SvgYacd from './SvgYacd';

const { useEffect, useState, useRef, useCallback } = React;
const ALL_SOURCE_IP = 'ALL_SOURCE_IP';

const sourceMapInit = localStorage.getItem('sourceMap')
? JSON.parse(localStorage.getItem('sourceMap'))
Expand Down Expand Up @@ -89,7 +90,7 @@ function filterConns(conns: FormattedConn[], keyword: string, sourceIp: string)
})
);
}
if (sourceIp !== '') {
if (sourceIp !== ALL_SOURCE_IP) {
result = filterConnIps(result, sourceIp);
}

Expand Down Expand Up @@ -268,14 +269,14 @@ function Conn({ apiConfig }) {
const [closedConns, setClosedConns] = useState([]);

const [filterKeyword, setFilterKeyword] = useState('');
const [filterSourceIpStr, setFilterSourceIpStr] = useState('');
const [filterSourceIpStr, setFilterSourceIpStr] = useState(ALL_SOURCE_IP);

const filteredConns = filterConns(conns, filterKeyword, filterSourceIpStr);
const filteredClosedConns = filterConns(closedConns, filterKeyword, filterSourceIpStr);

const getConnIpList = (conns: FormattedConn[]) => {
return [
['', t('All')],
[ALL_SOURCE_IP, t('All')],
...Array.from(new Set(conns.map((x) => x.sourceIP)))
.sort()
.map((value) => {
Expand Down

0 comments on commit a0435f9

Please sign in to comment.