Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webconsole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pqc-free5gc
webconsole
Commits
3997bd11
Unverified
Commit
3997bd11
authored
11 months ago
by
CTFang@WireLab
Browse files
Options
Downloads
Patches
Plain Diff
fix: add back last update time
parent
6db2e47b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/Dashboard.tsx
+15
-8
15 additions, 8 deletions
frontend/src/Dashboard.tsx
frontend/src/pages/Charging/ChargingTable.tsx
+17
-1
17 additions, 1 deletion
frontend/src/pages/Charging/ChargingTable.tsx
with
32 additions
and
9 deletions
frontend/src/Dashboard.tsx
+
15
−
8
View file @
3997bd11
...
...
@@ -85,7 +85,7 @@ function Dashboard(props: DashboardProps) {
const
{
user
,
setUser
}
=
useContext
(
LoginContext
);
const
navigation
=
useNavigate
();
const
[
time
,
setTime
]
=
useState
(
Date
.
now
());
const
[
time
,
setTime
]
=
useState
<
Date
>
(
new
Date
());
const
[
refreshInterval
,
setRefreshInterval
]
=
useState
(
0
);
const
[
refreshString
,
setRefreshString
]
=
useState
(
"
manual
"
);
...
...
@@ -93,20 +93,19 @@ function Dashboard(props: DashboardProps) {
// update the time value every x ms, which triggers refresh (see below)
useEffect
(()
=>
{
if
(
refreshInterval
===
0
)
{
console
.
log
(
"
refreshInterval is 0
"
)
console
.
log
(
"
refreshInterval is 0
"
)
;
return
;
}
const
interval
=
setInterval
(()
=>
setTime
(
Date
.
now
()),
refreshInterval
);
const
interval
=
setInterval
(()
=>
setTime
(
new
Date
()),
refreshInterval
);
return
()
=>
{
console
.
log
(
"
clear refreshInterval
"
)
console
.
log
(
"
clear refreshInterval
"
)
;
clearInterval
(
interval
);
};
},
[
refreshInterval
]);
// refresh every time the 'time' value changes
useEffect
(()
=>
{
console
.
log
(
"
reload page at
"
,
time
);
//setChildKey(prev => prev + 1);
console
.
log
(
"
reload page at
"
,
time
.
toISOString
());
props
.
refreshAction
();
},
[
time
]);
...
...
@@ -189,9 +188,17 @@ function Dashboard(props: DashboardProps) {
borderColor
:
"
white
"
,
}
}
/>
<
SimpleListMenu
title
=
{
`Refresh:
${
refreshString
}
`
}
options
=
{
refreshStrings
}
handleMenuItemClick
=
{
handleRefreshClick
}
/>
<
SimpleListMenu
title
=
{
`Refresh:
${
refreshString
}
`
}
options
=
{
refreshStrings
}
handleMenuItemClick
=
{
handleRefreshClick
}
/>
</
Box
>
<
SimpleListMenu
title
=
{
user
?.
username
}
options
=
{
[
"
Change Password
"
,
"
Logout
"
]
}
handleMenuItemClick
=
{
handleUserNameClick
}
/>
<
SimpleListMenu
title
=
{
user
?.
username
}
options
=
{
[
"
Change Password
"
,
"
Logout
"
]
}
handleMenuItemClick
=
{
handleUserNameClick
}
/>
</
Toolbar
>
</
AppBar
>
<
Drawer
variant
=
"permanent"
open
=
{
open
}
>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/pages/Charging/ChargingTable.tsx
+
17
−
1
View file @
3997bd11
...
...
@@ -10,6 +10,7 @@ import { Button, Grid } from "@mui/material";
export
default
function
ChargingTable
()
{
const
[
expand
,
setExpand
]
=
useState
(
true
);
const
[
refresh
,
setRefresh
]
=
useState
<
boolean
>
(
false
);
const
[
updateTime
,
setUpdateTime
]
=
useState
<
Date
>
(
new
Date
());
const
[
onlineChargingData
,
setOnlineChargingData
]
=
useState
<
ChargingData
[]
>
([]);
const
[
offlineChargingData
,
setOfflineChargingData
]
=
useState
<
ChargingData
[]
>
([]);
...
...
@@ -44,10 +45,10 @@ export default function ChargingTable() {
};
const
onRefresh
=
()
=>
{
console
.
log
(
"
refreshing charging data
"
);
fetchChargingData
(
"
Online
"
,
setOnlineChargingData
);
fetchChargingData
(
"
Offline
"
,
setOfflineChargingData
);
fetchChargingRecord
();
setUpdateTime
(
new
Date
());
};
useEffect
(()
=>
{
...
...
@@ -71,6 +72,21 @@ export default function ChargingTable() {
{
expand
?
"
Fold
"
:
"
Expand
"
}
</
Button
>
</
Grid
>
<
Grid
item
>
<
Button
color
=
"secondary"
variant
=
"contained"
onClick
=
{
()
=>
onRefresh
()
}
sx
=
{
{
m
:
2
,
backgroundColor
:
"
blue
"
,
"
&:hover
"
:
{
backgroundColor
:
"
blue
"
}
}
}
>
Refresh
</
Button
>
</
Grid
>
<
Grid
item
>
<
Button
color
=
"success"
variant
=
"contained"
sx
=
{
{
m
:
2
}
}
disabled
>
Last update:
{
updateTime
.
toISOString
().
slice
(
0
,
19
).
replace
(
"
T
"
,
"
"
)
}
</
Button
>
</
Grid
>
</
Grid
>
<
br
/>
<
ChargingList
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment