Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
FMS_Project_Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bashar.hussein
FMS_Project_Frontend
Commits
b5ec0666
Commit
b5ec0666
authored
Aug 09, 2023
by
ReemyHasan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing Dashboard
parent
8b7a15fc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
10 deletions
+58
-10
card-users.tsx
packages/admin/src/features/dashboard/card-users.tsx
+1
-0
index.tsx
packages/admin/src/features/dashboard/index.tsx
+29
-10
traps-service.tsx
packages/admin/src/services/traps-service.tsx
+28
-0
No files found.
packages/admin/src/features/dashboard/card-users.tsx
View file @
b5ec0666
...
@@ -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
();
...
...
packages/admin/src/features/dashboard/index.tsx
View file @
b5ec0666
...
@@ -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
(
"error
1
"
+
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
(
"error
1
"
+
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
(
"error
1
"
+
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
>
</>
</>
);
);
...
...
packages/admin/src/services/traps-service.tsx
View file @
b5ec0666
...
@@ -66,3 +66,31 @@ export const getErrorTrapCount = async (token:any) => {
...
@@ -66,3 +66,31 @@ export const getErrorTrapCount = async (token:any) => {
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment