Skip to content
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

Merged
merged 64 commits into from
Mar 3, 2024
Merged

Charging #58

merged 64 commits into from
Mar 3, 2024

Conversation

brianchennn
Copy link
Contributor

@brianchennn brianchennn commented Aug 29, 2023

Rebase #39 and re-design frontend, see https://hackmd.io/MBX9nCDNRniF5mBDnLI3pg

.golangci.yml Outdated Show resolved Hide resolved
config/webuicfg.yaml Outdated Show resolved Hide resolved
@tim-ywliu
Copy link
Collaborator

rebase and resolve conflicts

@@ -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:
Copy link
Collaborator

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

@brianchennn brianchennn force-pushed the charging branch 3 times, most recently from 7684d0a to 74f2951 Compare September 21, 2023 07:08
@ianchen0119
Copy link
Contributor

Hi @brianchennn

Please also remember to replace all of the qfis shown in PCF PR.

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>
@ianchen0119
Copy link
Contributor

Hi @yccodr

Please help to review this PR (especially the Front End part).
Thanks.

.gitignore Outdated Show resolved Hide resolved
Copy link
Collaborator

@yccodr yccodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE reviewed

frontend/src/axios.tsx Outdated Show resolved Hide resolved
Comment on lines +15 to +60
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);
}, []);
Copy link
Collaborator

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.

Suggested change
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 };
}

Copy link
Collaborator

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.

frontend/src/pages/Charging/OfflineChargingList.tsx Outdated Show resolved Hide resolved
frontend/src/pages/Charging/OnlineChargingList.tsx Outdated Show resolved Hide resolved
frontend/src/pages/StatusRead.tsx Outdated Show resolved Hide resolved
frontend/src/pages/SubscriberCreate.tsx Outdated Show resolved Hide resolved
@andy89923 andy89923 requested a review from yccodr March 3, 2024 12:18
@tim-ywliu tim-ywliu merged commit d13a12a into free5gc:main Mar 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants