mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-24 08:20:31 +08:00
feat: fix GetDashboard() page
This commit is contained in:
parent
2cb6ff69ae
commit
88a4736520
@ -28,6 +28,10 @@ type Dashboard struct {
|
||||
}
|
||||
|
||||
func GetDashboard(owner string) (*Dashboard, error) {
|
||||
if owner == "All" {
|
||||
owner = ""
|
||||
}
|
||||
|
||||
dashboard := &Dashboard{
|
||||
OrganizationCounts: make([]int, 31),
|
||||
UserCounts: make([]int, 31),
|
||||
@ -36,14 +40,13 @@ func GetDashboard(owner string) (*Dashboard, error) {
|
||||
SubscriptionCounts: make([]int, 31),
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
organizations := []Organization{}
|
||||
users := []User{}
|
||||
providers := []Provider{}
|
||||
applications := []Application{}
|
||||
subscriptions := []Subscription{}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(5)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
@ -42,11 +42,21 @@ const Dashboard = (props) => {
|
||||
}
|
||||
}, [props.account]);
|
||||
|
||||
const getOrganizationName = () => {
|
||||
let organization = localStorage.getItem("organization") === "All" ? "" : localStorage.getItem("organization");
|
||||
if (!Setting.isAdminUser(props.account) && Setting.isLocalAdminUser(props.account)) {
|
||||
organization = props.account.owner;
|
||||
}
|
||||
return organization;
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!Setting.isLocalAdminUser(props.account)) {
|
||||
return;
|
||||
}
|
||||
DashboardBackend.getDashboard(props.account.owner).then((res) => {
|
||||
|
||||
const organization = getOrganizationName();
|
||||
DashboardBackend.getDashboard(organization).then((res) => {
|
||||
if (res.status === "ok") {
|
||||
setDashboardData(res.data);
|
||||
} else {
|
||||
@ -64,9 +74,8 @@ const Dashboard = (props) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const newOrganization = localStorage.getItem("organization") === "All" ? "" : localStorage.getItem("organization");
|
||||
|
||||
DashboardBackend.getDashboard(newOrganization).then((res) => {
|
||||
const organization = getOrganizationName();
|
||||
DashboardBackend.getDashboard(organization).then((res) => {
|
||||
if (res.status === "ok") {
|
||||
setDashboardData(res.data);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user