-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Charging #58
Charging #58
Conversation
802a1f7
to
4e9e3d6
Compare
rebase and resolve conflicts |
4bf6f7c
to
578d219
Compare
@@ -6,6 +6,17 @@ configuration: | |||
mongodb: # the mongodb connected by this webui | |||
name: free5gc # name of the mongodb | |||
url: mongodb://localhost:27017 # a valid URL of the mongodb | |||
webServer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webServer:
scheme: http
ipv4Address: 0.0.0.0
port: 5000
7684d0a
to
74f2951
Compare
Hi @brianchennn Please also remember to replace all of the |
4c3bd41
to
42cc353
Compare
55b81cf
to
2a894bb
Compare
7500661
to
7ab8eb2
Compare
f4cb14b
to
919594a
Compare
5df73e0
to
2cb4f1c
Compare
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0. - [Commits](golang/crypto@v0.14.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Hi @yccodr Please help to review this PR (especially the Front End part). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FE reviewed
const [onlineChargingData, setOnlineChargingData] = useState<ChargingData[]>([]); | ||
const [offlineChargingData, setOfflineChargingData] = useState<ChargingData[]>([]); | ||
const [chargingRecord, setChargingRecord] = useState<FlowChargingRecord[]>([]); | ||
|
||
const fetchChargingRecord = () => { | ||
const MSG_FETCH_ERROR = "Get Charging Record error"; | ||
axios | ||
.get("/api/charging-record") | ||
.then((res) => { | ||
setChargingRecord(res.data ? res.data : chargingRecord); | ||
console.log("Charging Record", chargingRecord); | ||
}) | ||
.catch((err) => { | ||
console.log(MSG_FETCH_ERROR, err); | ||
}); | ||
}; | ||
|
||
const fetchChargingData = ( | ||
chargingMethod: string, | ||
setChargingData: React.Dispatch<React.SetStateAction<ChargingData[]>>, | ||
) => { | ||
const MSG_FETCH_ERROR = "Get Charging Data error"; | ||
axios | ||
.get("/api/charging-data/" + chargingMethod) | ||
.then((res) => { | ||
if (res.data) setChargingData(res.data); | ||
}) | ||
.catch((err) => { | ||
console.log(MSG_FETCH_ERROR, err); | ||
}); | ||
}; | ||
|
||
const onRefresh = () => { | ||
fetchChargingData("Online", setOnlineChargingData); | ||
fetchChargingData("Offline", setOfflineChargingData); | ||
fetchChargingRecord(); | ||
setCurrentTime(new Date()); | ||
}; | ||
|
||
useEffect(() => { | ||
onRefresh(); | ||
const id = setInterval(() => { | ||
onRefresh(); | ||
}, 10000); | ||
return () => clearInterval(id); | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be wrapped into a custom hook to make component more leaner.
const [onlineChargingData, setOnlineChargingData] = useState<ChargingData[]>([]); | |
const [offlineChargingData, setOfflineChargingData] = useState<ChargingData[]>([]); | |
const [chargingRecord, setChargingRecord] = useState<FlowChargingRecord[]>([]); | |
const fetchChargingRecord = () => { | |
const MSG_FETCH_ERROR = "Get Charging Record error"; | |
axios | |
.get("/api/charging-record") | |
.then((res) => { | |
setChargingRecord(res.data ? res.data : chargingRecord); | |
console.log("Charging Record", chargingRecord); | |
}) | |
.catch((err) => { | |
console.log(MSG_FETCH_ERROR, err); | |
}); | |
}; | |
const fetchChargingData = ( | |
chargingMethod: string, | |
setChargingData: React.Dispatch<React.SetStateAction<ChargingData[]>>, | |
) => { | |
const MSG_FETCH_ERROR = "Get Charging Data error"; | |
axios | |
.get("/api/charging-data/" + chargingMethod) | |
.then((res) => { | |
if (res.data) setChargingData(res.data); | |
}) | |
.catch((err) => { | |
console.log(MSG_FETCH_ERROR, err); | |
}); | |
}; | |
const onRefresh = () => { | |
fetchChargingData("Online", setOnlineChargingData); | |
fetchChargingData("Offline", setOfflineChargingData); | |
fetchChargingRecord(); | |
setCurrentTime(new Date()); | |
}; | |
useEffect(() => { | |
onRefresh(); | |
const id = setInterval(() => { | |
onRefresh(); | |
}, 10000); | |
return () => clearInterval(id); | |
}, []); | |
const { onlineChargingData, offlineChargingData, chargingRecord } = useChargingData(); | |
const useChargingData = () => { | |
const [onlineChargingData, setOnlineChargingData] = useState<ChargingData[]>([]); | |
const [offlineChargingData, setOfflineChargingData] = useState<ChargingData[]>([]); | |
const [chargingRecord, setChargingRecord] = useState<FlowChargingRecord[]>([]); | |
const fetchChargingRecord = () => { | |
const MSG_FETCH_ERROR = "Get Charging Record error"; | |
axios | |
.get("/api/charging-record") | |
.then((res) => { | |
setChargingRecord(res.data ? res.data : chargingRecord); | |
console.log("Charging Record", chargingRecord); | |
}) | |
.catch((err) => { | |
console.log(MSG_FETCH_ERROR, err); | |
}); | |
}; | |
const fetchChargingData = ( | |
chargingMethod: string, | |
setChargingData: React.Dispatch<React.SetStateAction<ChargingData[]>>, | |
) => { | |
const MSG_FETCH_ERROR = "Get Charging Data error"; | |
axios | |
.get("/api/charging-data/" + chargingMethod) | |
.then((res) => { | |
if (res.data) setChargingData(res.data); | |
}) | |
.catch((err) => { | |
console.log(MSG_FETCH_ERROR, err); | |
}); | |
}; | |
const onRefresh = () => { | |
fetchChargingData("Online", setOnlineChargingData); | |
fetchChargingData("Offline", setOfflineChargingData); | |
fetchChargingRecord(); | |
setCurrentTime(new Date()); | |
}; | |
useEffect(() => { | |
onRefresh(); | |
const id = setInterval(() => { | |
onRefresh(); | |
}, 10000); | |
return () => clearInterval(id); | |
}, []); | |
return { onlineChargingData, offlineChargingData, chargingRecord }; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is a button to manually refresh, onRefresh()
can't be wrapped.
Rebase #39 and re-design frontend, see https://hackmd.io/MBX9nCDNRniF5mBDnLI3pg