Skip to content

Commit d47d24f

Browse files
committed
Merge branch 'dev'
2 parents 2addb88 + 64e72bc commit d47d24f

File tree

6 files changed

+87
-7
lines changed

6 files changed

+87
-7
lines changed

README.MD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# cloudflare-ip-tester-app
2+
3+
### Inspired by
4+
5+
- [CloudflareSpeedTest](https://github.com/XIU2/CloudflareSpeedTest)
6+
- [cloudflare-ip-tester](https://github.com/TulvL/cloudflare-ip-tester)
7+
8+
### Functions
9+
10+
- test cloudflare-ip as many as you want
11+
12+
13+
- generate a history statistics based on your test results.
14+
15+
<div style="display: flex;flex-flow:row wrap;">
16+
<img src="./assets/images/test-run-min.jpg" height="600">
17+
<img src="./assets/images/test-statistics-min.jpg" height="600">
18+
</div>
19+
20+
### MIT License

assets/images/test-run-min.jpg

201 KB
Loading

assets/images/test-statistics-min.jpg

239 KB
Loading

screens/TestRunScreen/components/TestPage.tsx

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StyleSheet, Button, TextInput } from "react-native";
22
import { Text, View } from "@/components/Themed";
3-
import { useState } from "react";
3+
import { useEffect, useState } from "react";
44
import { responseTestService } from "@/services/ResponseTest.service";
55
import { downloadTestService } from "@/services/DownloadTest.service";
66
import { TableHeader } from "@/components/Table/TableHeader";
@@ -9,7 +9,8 @@ import { useTableData } from "../hooks/useTableData";
99
import { useTestIpCount } from "../hooks/useTestIpCount";
1010
import { TableRows } from "@/components/Table/TableRows";
1111
import { initialTestPageTableHeaderCols, MyTableHeaderColumn } from "../model";
12-
import { RequestStatus } from "@/typings";
12+
import { useTestRunningStatus } from "../hooks/useTestRunningStatus";
13+
import { miniStyle } from "@/theme";
1314

1415
export default function TestPage({ path }: { path: string }) {
1516
const { testIpCount, setTestIpCount, getIpList } = useTestIpCount();
@@ -37,13 +38,32 @@ export default function TestPage({ path }: { path: string }) {
3738
changeTableHeadersSortType,
3839
} = useTableHeader<MyTableHeaderColumn>(initialTestPageTableHeaderCols);
3940

41+
const { testRunningStatus, nextTestRunningStatus } = useTestRunningStatus();
42+
4043
function onReset() {
4144
responseTestService.stop();
4245
downloadTestService.stop();
4346
resetTableData();
4447
resetTableHeader();
45-
initTableData(getIpList());
48+
const newIpList = getIpList();
49+
initTableData(newIpList);
50+
nextTestRunningStatus();
4651
}
52+
53+
useEffect(() => {
54+
// in the future may need to add a status check
55+
startResponseSpeedTest(
56+
getSelectedIpList(),
57+
Number(testIpCoCurrentCount),
58+
testUrl
59+
);
60+
startDownloadSpeedTest(
61+
getSelectedIpList(),
62+
Number(testIpCoCurrentCount),
63+
testUrl
64+
);
65+
}, [testRunningStatus]);
66+
4767
function onSort(
4868
colId: MyTableHeaderColumn["id"],
4969
sortType: MyTableHeaderColumn["sort"]
@@ -70,7 +90,7 @@ export default function TestPage({ path }: { path: string }) {
7090
}
7191
title="TEST RESPOND "
7292
/>
73-
<View style={{ marginRight: 10 }}></View>
93+
<View style={{ marginRight: 5 }}></View>
7494
<Button
7595
onPress={() =>
7696
startDownloadSpeedTest(
@@ -81,7 +101,7 @@ export default function TestPage({ path }: { path: string }) {
81101
}
82102
title="TEST DOWNLOAD"
83103
/>
84-
<View style={{ marginRight: 10 }}></View>
104+
<View style={{ marginRight: 5 }}></View>
85105
<Button onPress={onReset} title="START" />
86106
</View>
87107
<View style={styles.toolbar}>
@@ -109,8 +129,18 @@ export default function TestPage({ path }: { path: string }) {
109129
/>
110130
</View>
111131

112-
<TableHeader onSort={onSort} cols={tableHeaders} />
113-
<TableRows rows={tableData} columns={tableHeaders} rowKeyName={"ip"} />
132+
<TableHeader
133+
onSort={onSort}
134+
cols={tableHeaders}
135+
style={{ cellTextStyle: miniStyle.textStyle }}
136+
/>
137+
138+
<TableRows
139+
rows={tableData}
140+
columns={tableHeaders}
141+
rowKeyName={"ip"}
142+
style={{ cellTextStyle: miniStyle.textStyle }}
143+
/>
114144
</View>
115145
);
116146
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { useState } from "react";
2+
export enum TestRunningStatus {
3+
Uninitialized = "Uninitialized",
4+
Running = "Running",
5+
}
6+
const nextTestRunningStatusMap = {
7+
[TestRunningStatus.Uninitialized]: TestRunningStatus.Running as const,
8+
[TestRunningStatus.Running]: TestRunningStatus.Uninitialized as const,
9+
};
10+
export function useTestRunningStatus() {
11+
const [testRunningStatus, setTestRunningStatus] =
12+
useState<`${TestRunningStatus}`>(TestRunningStatus.Uninitialized);
13+
14+
function nextTestRunningStatus() {
15+
setTestRunningStatus((prev) => {
16+
return nextTestRunningStatusMap[prev];
17+
});
18+
}
19+
20+
return {
21+
testRunningStatus,
22+
nextTestRunningStatus,
23+
};
24+
}

theme/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { StyleSheet } from "react-native";
2+
export const miniStyle = StyleSheet.create({
3+
textStyle: {
4+
fontSize: 12,
5+
},
6+
});

0 commit comments

Comments
 (0)