Commit b5ec0666 authored by ReemyHasan's avatar ReemyHasan

fixing Dashboard

parent 8b7a15fc
...@@ -10,6 +10,7 @@ export default function CardUsers() { ...@@ -10,6 +10,7 @@ export default function CardUsers() {
const Columns = [ const Columns = [
{ title: 'username', dataIndex: 'username', key: 'username' }, { title: 'username', dataIndex: 'username', key: 'username' },
{ title: 'role', dataIndex: 'role', key: 'role' }, { title: 'role', dataIndex: 'role', key: 'role' },
{ title: 'email', dataIndex: 'email', key: 'email' },
]; ];
const { t } = useTranslation(TranslationFiles.COMMON); const { t } = useTranslation(TranslationFiles.COMMON);
const router = useRouter(); const router = useRouter();
......
...@@ -9,7 +9,7 @@ import CardUsers from "./card-users"; ...@@ -9,7 +9,7 @@ import CardUsers from "./card-users";
import CardSocialTraffic from './card-socialTraffics' import CardSocialTraffic from './card-socialTraffics'
import CardStats from './card-stats' import CardStats from './card-stats'
import { getAdminsCount, getUsersCount } from "@/src/services/user-service"; import { getAdminsCount, getUsersCount } from "@/src/services/user-service";
import {getTrapsCount, getErrorTrapCount} from "@/src/services/traps-service"; import {getTrapsCount, getErrorTrapCount, getWarningTrapCount, getInfoTrapCount} from "@/src/services/traps-service";
import { useCookies } from "react-cookie"; import { useCookies } from "react-cookie";
const DashboardComponent = () => { const DashboardComponent = () => {
const { t } = useTranslation(TranslationFiles.COMMON); const { t } = useTranslation(TranslationFiles.COMMON);
...@@ -18,13 +18,15 @@ const DashboardComponent = () => { ...@@ -18,13 +18,15 @@ const DashboardComponent = () => {
const [adminCount, setAdminCount] = useState([]); const [adminCount, setAdminCount] = useState([]);
const [trapCount, setTrapCount] = useState([]); const [trapCount, setTrapCount] = useState([]);
const [errorTrapCount, setErrorTrapCount] = useState([]); const [errorTrapCount, setErrorTrapCount] = useState([]);
const [warnTrapCount, setWarnTrapCount] = useState([]);
const [infoTrapCount, setInfoTrapCount] = useState([]);
useEffect(() => { useEffect(() => {
async function fetchAdminCount() { async function fetchAdminCount() {
try { try {
const response1 = await getAdminsCount(cookies["token"], cookies["role"]); const response1 = await getAdminsCount(cookies["token"], cookies["role"]);
setAdminCount(response1); setAdminCount(response1);
} catch (error) { } catch (error) {
console.log("error"+error); console.log("error:"+error);
} }
} }
async function fetchUserCount() { async function fetchUserCount() {
...@@ -32,7 +34,7 @@ const DashboardComponent = () => { ...@@ -32,7 +34,7 @@ const DashboardComponent = () => {
const response2 = await getUsersCount(cookies["token"], cookies["role"]); const response2 = await getUsersCount(cookies["token"], cookies["role"]);
setUserCount(response2) setUserCount(response2)
} catch (error) { } catch (error) {
console.log("error1"+error); console.log("error:"+error);
} }
} }
async function fetchTrapsCount() { async function fetchTrapsCount() {
...@@ -40,7 +42,7 @@ const DashboardComponent = () => { ...@@ -40,7 +42,7 @@ const DashboardComponent = () => {
const response2 = await getTrapsCount(cookies["token"]); const response2 = await getTrapsCount(cookies["token"]);
setTrapCount(response2) setTrapCount(response2)
} catch (error) { } catch (error) {
console.log("error1"+error); console.log("error:"+error);
} }
} }
async function fetchErrorTrapsCount() { async function fetchErrorTrapsCount() {
...@@ -48,13 +50,32 @@ const DashboardComponent = () => { ...@@ -48,13 +50,32 @@ const DashboardComponent = () => {
const response2 = await getErrorTrapCount(cookies["token"]); const response2 = await getErrorTrapCount(cookies["token"]);
setErrorTrapCount(response2) setErrorTrapCount(response2)
} catch (error) { } catch (error) {
console.log("error1"+error); console.log("error:"+error);
} }
} }
async function fetchWarnignTrapsCount() {
try {
const response2 = await getWarningTrapCount(cookies["token"]);
setWarnTrapCount(response2)
} catch (error) {
console.log("error:"+error);
}
}
async function fetchInfoTrapsCount() {
try {
const response2 = await getInfoTrapCount(cookies["token"]);
setInfoTrapCount(response2)
} catch (error) {
console.log("error:"+error);
}
}
fetchAdminCount(); fetchAdminCount();
fetchUserCount(); fetchUserCount();
fetchTrapsCount(); fetchTrapsCount();
fetchErrorTrapsCount(); fetchErrorTrapsCount();
fetchWarnignTrapsCount();
fetchInfoTrapsCount();
}, []); }, []);
return ( return (
<> <>
...@@ -130,12 +151,10 @@ const DashboardComponent = () => { ...@@ -130,12 +151,10 @@ const DashboardComponent = () => {
</div> </div>
</div> </div>
<div className="flex flex-wrap mt-4"> <div className="flex flex-wrap mt-4">
<div className="w-full xl:w-8/12 mb-12 xl:mb-0 px-4"> {/* <div className="w-full xl:w-8/12 mb-12 xl:mb-0 px-4"> */}
<CardUsers /> <CardUsers />
</div> {/* </div> */}
<div className="w-full xl:w-4/12 px-4">
<CardSocialTraffic />
</div>
</div> </div>
</> </>
); );
......
...@@ -65,4 +65,32 @@ export const getErrorTrapCount = async (token:any) => { ...@@ -65,4 +65,32 @@ export const getErrorTrapCount = async (token:any) => {
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
};
export const getWarningTrapCount = async (token:any) => {
try {
const response = await axios.get(TrapURL+ "/getWarningTrapCount",{
headers: {
Authorization: `Bearer ${token}`,
},
});
// console.log("response: "+response);
return response.data;
} catch (error) {
console.log(error);
}
};
export const getInfoTrapCount = async (token:any) => {
try {
const response = await axios.get(TrapURL+ "/getInfoTrapCount",{
headers: {
Authorization: `Bearer ${token}`,
},
});
// console.log("response: "+response);
return response.data;
} catch (error) {
console.log(error);
}
}; };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment