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) {
|
func GetDashboard(owner string) (*Dashboard, error) {
|
||||||
|
if owner == "All" {
|
||||||
|
owner = ""
|
||||||
|
}
|
||||||
|
|
||||||
dashboard := &Dashboard{
|
dashboard := &Dashboard{
|
||||||
OrganizationCounts: make([]int, 31),
|
OrganizationCounts: make([]int, 31),
|
||||||
UserCounts: make([]int, 31),
|
UserCounts: make([]int, 31),
|
||||||
@ -36,14 +40,13 @@ func GetDashboard(owner string) (*Dashboard, error) {
|
|||||||
SubscriptionCounts: make([]int, 31),
|
SubscriptionCounts: make([]int, 31),
|
||||||
}
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
organizations := []Organization{}
|
organizations := []Organization{}
|
||||||
users := []User{}
|
users := []User{}
|
||||||
providers := []Provider{}
|
providers := []Provider{}
|
||||||
applications := []Application{}
|
applications := []Application{}
|
||||||
subscriptions := []Subscription{}
|
subscriptions := []Subscription{}
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
wg.Add(5)
|
wg.Add(5)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
@ -42,11 +42,21 @@ const Dashboard = (props) => {
|
|||||||
}
|
}
|
||||||
}, [props.account]);
|
}, [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(() => {
|
React.useEffect(() => {
|
||||||
if (!Setting.isLocalAdminUser(props.account)) {
|
if (!Setting.isLocalAdminUser(props.account)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DashboardBackend.getDashboard(props.account.owner).then((res) => {
|
|
||||||
|
const organization = getOrganizationName();
|
||||||
|
DashboardBackend.getDashboard(organization).then((res) => {
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
setDashboardData(res.data);
|
setDashboardData(res.data);
|
||||||
} else {
|
} else {
|
||||||
@ -64,9 +74,8 @@ const Dashboard = (props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newOrganization = localStorage.getItem("organization") === "All" ? "" : localStorage.getItem("organization");
|
const organization = getOrganizationName();
|
||||||
|
DashboardBackend.getDashboard(organization).then((res) => {
|
||||||
DashboardBackend.getDashboard(newOrganization).then((res) => {
|
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
setDashboardData(res.data);
|
setDashboardData(res.data);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user