feat: server member count
This commit is contained in:
@@ -14,6 +14,9 @@ export const serverApi = createApi({
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
getMetrics: builder.query({
|
||||||
|
query: () => ({ url: `/admin/system/metrics` }),
|
||||||
|
}),
|
||||||
getFirebaseConfig: builder.query({
|
getFirebaseConfig: builder.query({
|
||||||
query: () => ({ url: `admin/fcm/config` }),
|
query: () => ({ url: `admin/fcm/config` }),
|
||||||
}),
|
}),
|
||||||
@@ -72,6 +75,7 @@ export const {
|
|||||||
useGetAgoraConfigQuery,
|
useGetAgoraConfigQuery,
|
||||||
useUpdateAgoraConfigMutation,
|
useUpdateAgoraConfigMutation,
|
||||||
useGetServerQuery,
|
useGetServerQuery,
|
||||||
|
useLazyGetMetricsQuery,
|
||||||
useLazyGetServerQuery,
|
useLazyGetServerQuery,
|
||||||
useUpdateServerMutation,
|
useUpdateServerMutation,
|
||||||
useUpdateLogoMutation,
|
useUpdateLogoMutation,
|
||||||
|
|||||||
@@ -16,33 +16,46 @@ const StyledWrapper = styled.div`
|
|||||||
.server {
|
.server {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 10px;
|
||||||
.logo {
|
.logo {
|
||||||
width: 24px;
|
width: 28px;
|
||||||
height: 24px;
|
height: 28px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
.title {
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 100%;
|
||||||
|
color: #374151;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
.count {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 18px;
|
line-height: 100%;
|
||||||
color: #1c1c1e;
|
color: #78787c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
export default function ServerDropList({ data, expand = true }) {
|
export default function ServerDropList({ data, memberCount, expand = true }) {
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
return (
|
return (
|
||||||
<StyledWrapper className={expand ? "expand" : ""}>
|
<StyledWrapper className={expand ? "expand" : ""}>
|
||||||
<div className="server">
|
<div className="server">
|
||||||
<img className="logo" src={data.logo} alt="logo" />
|
<img className="logo" src={data.logo} alt="logo" />
|
||||||
{expand && (
|
{expand && (
|
||||||
|
<div className="info">
|
||||||
<h2 className="title animate__animated animate__fadeIn">
|
<h2 className="title animate__animated animate__fadeIn">
|
||||||
{data.name}
|
{data.name}
|
||||||
</h2>
|
</h2>
|
||||||
|
<span className="count">{memberCount} members</span>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</StyledWrapper>
|
</StyledWrapper>
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ export default function HomePage() {
|
|||||||
{ready ? (
|
{ready ? (
|
||||||
<StyledWrapper>
|
<StyledWrapper>
|
||||||
<div className={`col left ${menuExpand ? "expand" : ""}`}>
|
<div className={`col left ${menuExpand ? "expand" : ""}`}>
|
||||||
<ServerDropList data={data?.server} expand={menuExpand} />
|
<ServerDropList
|
||||||
|
data={data?.server}
|
||||||
|
memberCount={data?.metrics?.user_count}
|
||||||
|
expand={menuExpand}
|
||||||
|
/>
|
||||||
<nav className="nav">
|
<nav className="nav">
|
||||||
<NavLink className="link" to={"/chat"}>
|
<NavLink className="link" to={"/chat"}>
|
||||||
<img src={ChatIcon} alt="chat icon" />{" "}
|
<img src={ChatIcon} alt="chat icon" />{" "}
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import { clearAuthData, setUserData } from "../../app/slices/auth.data";
|
|||||||
import { setContacts } from "../../app/slices/contacts";
|
import { setContacts } from "../../app/slices/contacts";
|
||||||
|
|
||||||
// import { useGetChannelsQuery } from "../../app/services/channel";
|
// import { useGetChannelsQuery } from "../../app/services/channel";
|
||||||
import { useLazyGetServerQuery } from "../../app/services/server";
|
import {
|
||||||
|
useLazyGetServerQuery,
|
||||||
|
useLazyGetMetricsQuery,
|
||||||
|
} from "../../app/services/server";
|
||||||
import { KEY_UID } from "../../app/config";
|
import { KEY_UID } from "../../app/config";
|
||||||
// pollingInterval: 0,
|
// pollingInterval: 0,
|
||||||
// const querySetting = {
|
// const querySetting = {
|
||||||
@@ -36,6 +39,15 @@ export default function usePreload() {
|
|||||||
data: server,
|
data: server,
|
||||||
},
|
},
|
||||||
] = useLazyGetServerQuery();
|
] = useLazyGetServerQuery();
|
||||||
|
const [
|
||||||
|
getMetrics,
|
||||||
|
{
|
||||||
|
isLoading: metricsLoading,
|
||||||
|
isSuccess: metricsSuccess,
|
||||||
|
isError: metricsError,
|
||||||
|
data: metrics,
|
||||||
|
},
|
||||||
|
] = useLazyGetMetricsQuery();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initCache();
|
initCache();
|
||||||
rehydrate();
|
rehydrate();
|
||||||
@@ -43,6 +55,7 @@ export default function usePreload() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getContacts();
|
getContacts();
|
||||||
getServer();
|
getServer();
|
||||||
|
getMetrics();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -64,12 +77,18 @@ export default function usePreload() {
|
|||||||
}
|
}
|
||||||
}, [contacts]);
|
}, [contacts]);
|
||||||
return {
|
return {
|
||||||
loading: contactsLoading || serverLoading || !checked || !cacheFirst,
|
loading:
|
||||||
error: contactsError && serverError,
|
contactsLoading ||
|
||||||
success: contactsSuccess && serverSuccess,
|
serverLoading ||
|
||||||
|
metricsLoading ||
|
||||||
|
!checked ||
|
||||||
|
!cacheFirst,
|
||||||
|
error: contactsError && serverError && metricsError,
|
||||||
|
success: contactsSuccess && serverSuccess && metricsSuccess,
|
||||||
data: {
|
data: {
|
||||||
contacts,
|
contacts,
|
||||||
server,
|
server,
|
||||||
|
metrics,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user