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
37dd1624
Commit
37dd1624
authored
Aug 09, 2023
by
ReemyHasan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing dashboard
parent
4ff55782
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
165 additions
and
134 deletions
+165
-134
app-constant.tsx
packages/admin/src/data/constant/app-constant.tsx
+1
-1
card-lineChart.tsx
packages/admin/src/features/dashboard/card-lineChart.tsx
+117
-107
card-users.tsx
packages/admin/src/features/dashboard/card-users.tsx
+24
-22
index.tsx
packages/admin/src/features/show-users/index.tsx
+0
-1
traps-service.tsx
packages/admin/src/services/traps-service.tsx
+14
-1
globals.css
packages/shared-library/globals.css
+3
-0
fms-table.tsx
packages/shared-library/src/tables/fms-table.tsx
+6
-2
No files found.
packages/admin/src/data/constant/app-constant.tsx
View file @
37dd1624
// export const AUTH_TOKEN: string = "token";
// export const AUTH_TOKEN: string = "token";
export
const
Default_Language
:
string
=
"app-language"
;
export
const
Default_Language
:
string
=
"app-language"
;
export
const
ApiGatewayURL
:
string
=
`http://localhost:6644`
;
export
const
ApiGatewayURL
:
string
=
`http://localhost:6644`
;
export
const
TrapURL
:
string
=
`http://localhost:6644/api/rethink
/data
`
;
export
const
TrapURL
:
string
=
`http://localhost:6644/api/rethink`
;
export
const
SettingURL
:
string
=
`http://localhost:6644/api/about`
;
export
const
SettingURL
:
string
=
`http://localhost:6644/api/about`
;
export
const
AuthURL
:
string
=
"http://localhost:6644/auth/"
;
export
const
AuthURL
:
string
=
"http://localhost:6644/auth/"
;
export
const
UserURL
:
string
=
`http://localhost:6644/users/`
;
export
const
UserURL
:
string
=
`http://localhost:6644/users/`
;
...
...
packages/admin/src/features/dashboard/card-lineChart.tsx
View file @
37dd1624
import
React
,
{
Component
}
from
"react"
;
import
React
,
{
Component
,
useEffect
,
useState
}
from
"react"
;
import
Chart
from
"chart.js/auto"
;
import
Chart
from
"chart.js/auto"
;
import
{
useCookies
}
from
"react-cookie"
;
import
{
getSeverityStatistics
}
from
"../../services/traps-service"
;
export
default
function
CardLineChart
()
{
export
default
function
CardLineChart
()
{
React
.
useEffect
(()
=>
{
const
[
data
,
setData
]
=
useState
([]);
var
config
=
{
const
[
cookies
]
=
useCookies
([]);
type
:
"line"
,
data
:
{
useEffect
(()
=>
{
labels
:
[
const
fetchData
=
async
()
=>
{
"January"
,
try
{
"February"
,
const
response
=
await
getSeverityStatistics
(
cookies
[
"token"
]);
"March"
,
console
.
log
(
response
);
"April"
,
setData
(
response
);
"May"
,
}
catch
(
error
)
{
"June"
,
console
.
error
(
"Error fetching data:"
,
error
);
"July"
,
}
],
};
datasets
:
[
{
fetchData
();
label
:
"WARNING"
,
},
[]);
backgroundColor
:
"#fadb14"
,
useEffect
(()
=>
{
borderColor
:
"#fadb14"
,
const
severityColors
:
any
=
{
data
:
[
65
,
78
,
66
,
44
,
56
,
67
,
75
],
WARNING
:
"#fadb14"
,
fill
:
false
,
INFO
:
"#10B981"
,
},
ERROR
:
"#EF4444"
,
{
};
label
:
"INFO"
,
if
(
window
.
myLine
)
{
backgroundColor
:
"#10B981"
,
window
.
myLine
.
destroy
();
borderColor
:
"#10B981"
,
}
data
:
[
65
,
78
,
76
,
34
,
46
,
67
,
85
],
// Check if data has been fetched and is not an empty object
fill
:
false
,
if
(
Object
.
keys
(
data
).
length
>
0
)
{
},
const
labels
=
Object
.
keys
(
data
).
sort
();
// Use the sorted timestamps as labels
{
label
:
"ERROR"
,
const
datasets
=
Object
.
keys
(
severityColors
).
map
((
severity
)
=>
({
fill
:
false
,
label
:
severity
,
backgroundColor
:
"#EF4444"
,
backgroundColor
:
severityColors
[
severity
],
borderColor
:
"#EF4444"
,
borderColor
:
severityColors
[
severity
],
data
:
[
40
,
68
,
86
,
74
,
56
,
60
,
87
],
data
:
labels
.
map
((
timestamp
)
=>
data
[
timestamp
][
severity
]
||
0
),
},
fill
:
false
,
],
}));
},
var
config
=
{
options
:
{
type
:
"line"
,
maintainAspectRatio
:
false
,
data
:
{
responsive
:
true
,
labels
:
labels
.
map
((
timestamp
)
=>
title
:
{
new
Date
(
timestamp
).
toLocaleTimeString
()
display
:
false
,
),
text
:
"Severity traps Charts"
,
datasets
:
datasets
,
fontColor
:
"white"
,
},
},
legend
:
{
options
:
{
labels
:
{
maintainAspectRatio
:
false
,
responsive
:
true
,
title
:
{
display
:
false
,
text
:
"Severity traps Charts"
,
fontColor
:
"white"
,
fontColor
:
"white"
,
},
},
align
:
"end"
,
legend
:
{
position
:
"bottom"
,
labels
:
{
},
fontColor
:
"white"
,
tooltips
:
{
mode
:
"index"
,
intersect
:
false
,
},
hover
:
{
mode
:
"nearest"
,
intersect
:
true
,
},
scales
:
{
xAxes
:
[
{
ticks
:
{
fontColor
:
"rgba(255,255,255,.7)"
,
},
display
:
true
,
scaleLabel
:
{
display
:
false
,
labelString
:
"Month"
,
fontColor
:
"white"
,
},
gridLines
:
{
display
:
false
,
borderDash
:
[
2
],
borderDashOffset
:
[
2
],
color
:
"rgba(33, 37, 41, 0.3)"
,
zeroLineColor
:
"rgba(0, 0, 0, 0)"
,
zeroLineBorderDash
:
[
2
],
zeroLineBorderDashOffset
:
[
2
],
},
},
},
],
align
:
"end"
,
yAxes
:
[
position
:
"bottom"
,
{
},
ticks
:
{
tooltips
:
{
fontColor
:
"rgba(255,255,255,.7)"
,
mode
:
"index"
,
},
intersect
:
false
,
display
:
true
,
},
scaleLabel
:
{
hover
:
{
display
:
false
,
mode
:
"nearest"
,
labelString
:
"Value"
,
intersect
:
true
,
fontColor
:
"white"
,
},
scales
:
{
xAxes
:
[
{
ticks
:
{
fontColor
:
"rgba(255,255,255,.7)"
,
},
display
:
true
,
scaleLabel
:
{
display
:
false
,
labelString
:
"Month"
,
fontColor
:
"white"
,
},
gridLines
:
{
display
:
false
,
borderDash
:
[
2
],
borderDashOffset
:
[
2
],
color
:
"rgba(33, 37, 41, 0.3)"
,
zeroLineColor
:
"rgba(0, 0, 0, 0)"
,
zeroLineBorderDash
:
[
2
],
zeroLineBorderDashOffset
:
[
2
],
},
},
},
gridLines
:
{
],
borderDash
:
[
3
],
yAxes
:
[
borderDashOffset
:
[
3
],
{
drawBorder
:
false
,
ticks
:
{
color
:
"rgba(255, 255, 255, 0.15)"
,
fontColor
:
"rgba(255,255,255,.7)"
,
zeroLineColor
:
"rgba(33, 37, 41, 0)"
,
},
zeroLineBorderDash
:
[
2
],
display
:
true
,
zeroLineBorderDashOffset
:
[
2
],
scaleLabel
:
{
display
:
false
,
labelString
:
"Value"
,
fontColor
:
"white"
,
},
gridLines
:
{
borderDash
:
[
3
],
borderDashOffset
:
[
3
],
drawBorder
:
false
,
color
:
"rgba(255, 255, 255, 0.15)"
,
zeroLineColor
:
"rgba(33, 37, 41, 0)"
,
zeroLineBorderDash
:
[
2
],
zeroLineBorderDashOffset
:
[
2
],
},
},
},
}
,
]
,
]
,
}
,
},
},
}
,
}
;
}
;
}
var
ctx
=
document
.
getElementById
(
"line-chart"
).
getContext
(
"2d"
);
var
ctx
=
document
.
getElementById
(
"line-chart"
).
getContext
(
"2d"
);
window
.
myLine
=
new
Chart
(
ctx
,
config
);
window
.
myLine
=
new
Chart
(
ctx
,
config
);
},
[]);
},
[
data
]);
return
(
return
(
<>
<>
<
div
className=
"relative flex flex-col min-w-0 break-words w-full mb-6 shadow-lg rounded primary-blue-600"
>
<
div
className=
"relative flex flex-col min-w-0 break-words w-full mb-6 shadow-lg rounded primary-blue-600"
>
...
@@ -123,12 +132,13 @@ export default function CardLineChart() {
...
@@ -123,12 +132,13 @@ export default function CardLineChart() {
<
h6
className=
"uppercase text-blueGray-100 mb-1 text-xs font-semibold"
>
<
h6
className=
"uppercase text-blueGray-100 mb-1 text-xs font-semibold"
>
Overview
Overview
</
h6
>
</
h6
>
<
h2
className=
"text-white text-xl font-semibold"
>
Severity traps Charts
</
h2
>
<
h2
className=
"text-white text-xl font-semibold"
>
Severity traps Charts
</
h2
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
className=
"p-4 flex-auto"
>
<
div
className=
"p-4 flex-auto"
>
{
/* Chart */
}
<
div
className=
"relative h-350-px"
>
<
div
className=
"relative h-350-px"
>
<
canvas
id=
"line-chart"
></
canvas
>
<
canvas
id=
"line-chart"
></
canvas
>
</
div
>
</
div
>
...
@@ -136,4 +146,4 @@ export default function CardLineChart() {
...
@@ -136,4 +146,4 @@ export default function CardLineChart() {
</
div
>
</
div
>
</>
</>
);
);
}
}
\ No newline at end of file
packages/admin/src/features/dashboard/card-users.tsx
View file @
37dd1624
import
React
from
"react"
;
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
FmsTable
from
"../../../../shared-library/src/tables/fms-table"
;
import
FmsTable
from
"../../../../shared-library/src/tables/fms-table"
;
// import { DataSource } from "../show-users/data-source";
import
useTranslation
from
"next-translate/useTranslation"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
FmsButton
from
"../../../../shared-library/src/buttons/fms-button"
;
import
FmsButton
from
"../../../../shared-library/src/buttons/fms-button"
;
import
{
useRouter
}
from
"next/router"
;
import
{
useRouter
}
from
"next/router"
;
// components
import
{
getAllUsers
,
deleteUser
}
from
"@/src/services/user-service"
;
import
{
useCookies
}
from
"react-cookie"
;
export
default
function
CardUsers
()
{
export
default
function
CardUsers
()
{
const
Columns
=
[
const
Columns
=
[
{
title
:
'
Name'
,
dataIndex
:
'name'
,
key
:
'
name'
},
{
title
:
'
username'
,
dataIndex
:
'username'
,
key
:
'user
name'
},
{
title
:
'
Age'
,
dataIndex
:
'age'
,
key
:
'ag
e'
},
{
title
:
'
role'
,
dataIndex
:
'role'
,
key
:
'rol
e'
},
];
];
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
router
=
useRouter
();
const
router
=
useRouter
();
const
[
data
,
setData
]
=
useState
([]);
const
[
cookies
]
=
useCookies
([]);
useEffect
(()
=>
{
const
fetchData
=
async
()
=>
{
try
{
const
response
=
await
getAllUsers
(
cookies
[
"token"
],
cookies
[
"role"
]);
setData
(
response
);
}
catch
(
error
)
{
console
.
error
(
"Error fetching data:"
,
error
);
}
};
fetchData
();
},
[]);
return
(
return
(
<>
<>
<
div
className=
"relative flex flex-col min-w-0 break-words bg-white w-full mb-6 shadow-lg rounded"
>
<
div
className=
"relative flex flex-col min-w-0 break-words bg-white w-full mb-6 shadow-lg rounded"
>
{
/* <div className="rounded-t mb-0 px-4 py-3 border-0"> */
}
{
/* <div className="flex flex-wrap items-center"> */
}
{
/* <div className="relative w-full px-4 max-w-full flex-grow flex-1">
<h3 className="font-semibold text-base text-blueGray-700">
Page visits
</h3>
</div> */
}
{
/* </div> */
}
{
/* </div> */
}
<
div
className=
"block w-full overflow-x-auto"
>
<
div
className=
"block w-full overflow-x-auto"
>
<
div
className=
" w-full px-4 max-w-full flex-grow flex-1 text-right"
>
<
div
className=
" w-full px-4 max-w-full flex-grow flex-1 text-right"
>
<
FmsButton
<
FmsButton
...
@@ -40,16 +43,15 @@ export default function CardUsers() {
...
@@ -40,16 +43,15 @@ export default function CardUsers() {
{
"See all"
.
toUpperCase
()
}
{
"See all"
.
toUpperCase
()
}
</
FmsButton
>
</
FmsButton
>
</
div
>
</
div
>
{
/*
<FmsTable
<
FmsTable
title=
{
"users"
}
title=
{
"users"
}
columns=
{
Columns
}
columns=
{
Columns
}
data={
DataSource
}
data=
{
data
}
pageSizeOptions=
{
[
"3"
,
"5"
,
"7"
]
}
pageSizeOptions=
{
[
"3"
,
"5"
,
"7"
]
}
defaultPageSize=
{
3
}
defaultPageSize=
{
3
}
// t={t}
className=
{
"dash-table"
}
// setData={setData}
scroll=
{
{
x
:
false
}
}
// setColumns={setColumns}
/>
/> */
}
</
div
>
</
div
>
</
div
>
</
div
>
</>
</>
...
...
packages/admin/src/features/show-users/index.tsx
View file @
37dd1624
...
@@ -18,7 +18,6 @@ const [modalProps, setModalProps] = useState({
...
@@ -18,7 +18,6 @@ const [modalProps, setModalProps] = useState({
const
[
data
,
setData
]
=
useState
([]);
const
[
data
,
setData
]
=
useState
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
string
[]
>
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
string
[]
>
([]);
const
[
cookies
]
=
useCookies
([]);
const
[
cookies
]
=
useCookies
([]);
// Fetch data when the component mounts using useEffect
useEffect
(()
=>
{
useEffect
(()
=>
{
const
fetchData
=
async
()
=>
{
const
fetchData
=
async
()
=>
{
try
{
try
{
...
...
packages/admin/src/services/traps-service.tsx
View file @
37dd1624
...
@@ -2,7 +2,7 @@ import axios from "axios";
...
@@ -2,7 +2,7 @@ import axios from "axios";
import
{
TrapURL
}
from
"../data/constant/app-constant"
;
import
{
TrapURL
}
from
"../data/constant/app-constant"
;
export
const
fetchData
=
async
(
token
:
any
)
=>
{
export
const
fetchData
=
async
(
token
:
any
)
=>
{
try
{
try
{
const
response
=
await
axios
.
get
(
TrapURL
,{
const
response
=
await
axios
.
get
(
TrapURL
+
"/data"
,{
headers
:
{
headers
:
{
Authorization
:
`Bearer
${
token
}
`
,
Authorization
:
`Bearer
${
token
}
`
,
},
},
...
@@ -24,4 +24,17 @@ export const fetchData = async (token:any) => {
...
@@ -24,4 +24,17 @@ export const fetchData = async (token:any) => {
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
}
}
};
export
const
getSeverityStatistics
=
async
(
token
:
any
)
=>
{
try
{
const
response
=
await
axios
.
get
(
TrapURL
+
"/severity-statistics"
,{
headers
:
{
Authorization
:
`Bearer
${
token
}
`
,
},
});
// console.log("response: "+response);
return
response
.
data
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
};
\ No newline at end of file
packages/shared-library/globals.css
View file @
37dd1624
...
@@ -134,3 +134,6 @@
...
@@ -134,3 +134,6 @@
line-height
:
20px
!important
;
line-height
:
20px
!important
;
color
:
var
(
--primary-gray-600
)
!important
;
color
:
var
(
--primary-gray-600
)
!important
;
}
}
.dash-table
{
width
:
fit-content
;
}
\ No newline at end of file
packages/shared-library/src/tables/fms-table.tsx
View file @
37dd1624
...
@@ -15,6 +15,8 @@ interface fmsTableProps {
...
@@ -15,6 +15,8 @@ interface fmsTableProps {
rowSelection
:
any
;
rowSelection
:
any
;
pageSizeOptions
:
Array
<
string
>
;
pageSizeOptions
:
Array
<
string
>
;
defaultPageSize
:
any
;
defaultPageSize
:
any
;
className
?:
string
;
scroll
?:
any
;
}
}
const
FmsTable
:
FunctionComponent
<
fmsTableProps
>
=
({
const
FmsTable
:
FunctionComponent
<
fmsTableProps
>
=
({
title
,
title
,
...
@@ -26,8 +28,10 @@ const FmsTable: FunctionComponent<fmsTableProps> = ({
...
@@ -26,8 +28,10 @@ const FmsTable: FunctionComponent<fmsTableProps> = ({
rowSelection
,
rowSelection
,
pageSizeOptions
,
pageSizeOptions
,
defaultPageSize
,
defaultPageSize
,
className
,
scroll
})
=>
{
})
=>
{
const
combinedClassName
=
`fms-table
${
className
||
""
}
`
;
return
(
return
(
<
div
data
-
testid=
"fms-table"
>
<
div
data
-
testid=
"fms-table"
>
<
div
className=
{
classes
.
tableTitleContainer
}
>
<
div
className=
{
classes
.
tableTitleContainer
}
>
...
@@ -46,7 +50,7 @@ const FmsTable: FunctionComponent<fmsTableProps> = ({
...
@@ -46,7 +50,7 @@ const FmsTable: FunctionComponent<fmsTableProps> = ({
dataSource=
{
data
}
dataSource=
{
data
}
rowSelection
=
{
rowSelection
}
rowSelection
=
{
rowSelection
}
bordered
bordered
scroll=
{
{
x
:
1000
}
}
scroll=
{
{
x
:
scroll
}
}
pagination=
{
{
position
:
[
'bottomLeft'
],
pagination=
{
{
position
:
[
'bottomLeft'
],
pageSizeOptions
:
pageSizeOptions
,
pageSizeOptions
:
pageSizeOptions
,
showSizeChanger
:
true
,
locale
:
{
items_per_page
:
""
},
showSizeChanger
:
true
,
locale
:
{
items_per_page
:
""
},
...
...
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