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
048ae270
Commit
048ae270
authored
Jul 17, 2023
by
ReemyHasan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add setting page
parent
ad0cca50
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1621 additions
and
629 deletions
+1621
-629
_app.tsx
packages/admin/pages/_app.tsx
+10
-0
index.tsx
packages/admin/pages/setup/index.tsx
+6
-1
index.tsx
packages/admin/pages/setup/setting-about-content/index.tsx
+22
-0
index.tsx
packages/admin/pages/setup/setting-profile-content/index.tsx
+22
-0
index.tsx
packages/admin/pages/user/index.tsx
+0
-0
app-constant.tsx
packages/admin/src/data/constant/app-constant.tsx
+2
-0
footer.tsx
packages/admin/src/features/about/footer.tsx
+7
-7
index.tsx
packages/admin/src/features/about/index.tsx
+401
-495
index.tsx
packages/admin/src/features/edit-user/index.tsx
+0
-31
index.tsx
packages/admin/src/features/login/index.tsx
+6
-0
index.tsx
packages/admin/src/features/profile/index.tsx
+5
-2
index.tsx
packages/admin/src/features/setting/index.tsx
+44
-0
setting-about-content.tsx
...ages/admin/src/features/setting/setting-about-content.tsx
+668
-0
setting-profile.tsx
packages/admin/src/features/setting/setting-profile.tsx
+195
-0
index.tsx
packages/admin/src/features/show-traps/index.tsx
+54
-69
columns.tsx
packages/admin/src/features/show-users/columns.tsx
+9
-14
edit-user-popup.tsx
packages/admin/src/features/show-users/edit-user-popup.tsx
+49
-0
index.tsx
packages/admin/src/features/show-users/index.tsx
+10
-5
setting-service.tsx
packages/admin/src/services/setting-service.tsx
+57
-0
traps-service.tsx
packages/admin/src/services/traps-service.tsx
+23
-0
global.less
packages/admin/src/styles/global.less
+31
-5
No files found.
packages/admin/pages/_app.tsx
View file @
048ae270
...
...
@@ -40,6 +40,16 @@ export default function App({ Component, pageProps }: AppProps) {
if
(
loader
)
loader
.
remove
();
}
},
[]);
useEffect
(()
=>
{
if
(
!
websocket
)
{
return
;
}
return
()
=>
{
if
(
websocket
)
{
websocket
.
close
();
}
};
},
[]);
return
(
<
Fragment
>
...
...
packages/admin/pages/setup/index.tsx
View file @
048ae270
...
...
@@ -4,6 +4,7 @@ import AppLayout from "@/src/components/layout";
import
{
Fragment
}
from
"react"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
Setting
from
"@/src/features/setting"
;
export
default
function
Setup
()
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
return
(
...
...
@@ -12,7 +13,11 @@ export default function Setup() {
<
title
>
{
t
(
"setup"
)
}
</
title
>
</
Head
>
<
AppLayout
>
<
main
className=
{
`app-main-container`
}
>
{
t
(
"setup"
)
}
</
main
>
<
main
className=
{
`app-main-container`
}
>
<
div
className=
" w-full px-4 max-w-full flex-grow flex-1"
>
<
Setting
/>
</
div
>
</
main
>
</
AppLayout
>
</
Fragment
>
);
...
...
packages/admin/pages/setup/setting-about-content/index.tsx
0 → 100644
View file @
048ae270
import
*
as
React
from
"react"
;
import
Head
from
"next/head"
;
import
AppLayout
from
"@/src/components/layout"
;
import
{
Fragment
}
from
"react"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
SettingAboutContent
from
"../../../src/features/setting/setting-about-content"
;
export
default
function
Setup
()
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
return
(
<
Fragment
>
<
Head
>
<
title
>
{
t
(
"setup"
)
}
</
title
>
</
Head
>
<
AppLayout
>
<
main
className=
{
`app-main-container`
}
>
<
SettingAboutContent
/>
</
main
>
</
AppLayout
>
</
Fragment
>
);
}
packages/admin/pages/setup/setting-profile-content/index.tsx
0 → 100644
View file @
048ae270
import
*
as
React
from
"react"
;
import
Head
from
"next/head"
;
import
AppLayout
from
"@/src/components/layout"
;
import
{
Fragment
}
from
"react"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
SettingProfileContent
from
"../../../src/features/setting/setting-profile"
;
export
default
function
Setup
()
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
return
(
<
Fragment
>
<
Head
>
<
title
>
{
t
(
"setup"
)
}
</
title
>
</
Head
>
<
AppLayout
>
<
main
className=
{
`app-main-container`
}
>
<
SettingProfileContent
/>
</
main
>
</
AppLayout
>
</
Fragment
>
);
}
packages/admin/pages/user/index.tsx
0 → 100644
View file @
048ae270
packages/admin/src/data/constant/app-constant.tsx
View file @
048ae270
export
const
AUTH_TOKEN
:
string
=
"app-auth-token"
;
export
const
Default_Language
:
string
=
"app-language"
;
export
const
TrapURL
:
string
=
"http://localhost:6647/api/rethink/data"
;
export
const
SettingURL
:
string
=
"http://localhost:6647/api/about"
;
packages/admin/src/features/about/footer.tsx
View file @
048ae270
...
...
@@ -2,7 +2,7 @@ import { GithubOutlined, MailOutlined } from "@ant-design/icons";
import
React
,
{
useState
}
from
"react"
;
export
default
function
Footer
()
{
const
[
showEmail
,
setShowEmail
]
=
useState
(
false
);
const
email
=
"example@example.com"
;
const
email
=
<
span
>
{
"example@example.com "
}
</
span
>
;
const
handleButtonClick
=
()
=>
{
setShowEmail
(
!
showEmail
);
...
...
@@ -32,12 +32,12 @@ export default function Footer() {
<
div
className=
"container mx-auto px-4"
>
<
div
className=
"flex flex-wrap text-center lg:text-left"
>
<
div
className=
"w-full lg:w-6/12 px-4"
>
<
h4
className=
"text-3xl font-semibold"
>
Let's keep in touch!
</
h4
>
{
/*
<h4 className="text-3xl font-semibold">Let's keep in touch!</h4>
<h5 className="text-lg mt-0 mb-2 text-blueGray-600">
Find us on any of these platform.
</
h5
>
</h5>
*/
}
<
div
className=
"mt-6 lg:mb-0 mb-6"
>
<
button
{
/*
<button
className="bg-white text-lightBlue-400 shadow-lg font-normal h-10 w-10 items-center justify-center align-center rounded-full outline-none focus:outline-none mr-2"
type="button"
onClick={handleButtonClick}
...
...
@@ -59,13 +59,13 @@ export default function Footer() {
style={{ fontSize: "19px", color: "#000f24" }}
className={"ExclamationCircleOutlined "}
/>
</
button
>
</button>
*/
}
</
div
>
</
div
>
<
div
className=
"w-full lg:w-6/12 px-4"
>
<
div
className=
"flex flex-wrap items-top mb-6"
>
<
div
className=
"w-full lg:w-4/12 px-4 ml-auto"
>
<
span
className=
"block uppercase text-blueGray-500 text-sm font-semibold mb-2"
>
{
/*
<span className="block uppercase text-blueGray-500 text-sm font-semibold mb-2">
Useful Links
</span>
<ul className="list-unstyled">
...
...
@@ -77,7 +77,7 @@ export default function Footer() {
Contact Us
</a>
</li>
</
ul
>
</ul>
*/
}
</
div
>
</
div
>
</
div
>
...
...
packages/admin/src/features/about/index.tsx
View file @
048ae270
This diff is collapsed.
Click to expand it.
packages/admin/src/features/edit-user/index.tsx
deleted
100644 → 0
View file @
ad0cca50
import
{
useEffect
,
useState
}
from
'react'
;
import
{
DynamicFormTypes
}
from
"@/src/components/dynamic-form/dtos/dynamic-form.dto"
;
import
DynamicForm
from
"@/src/components/dynamic-form"
;
import
{
formItems
}
from
"./add-user-data"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
const
EditForm
=
({
id
})
=>
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
[
initialValues
,
setInitialValues
]
=
useState
({});
useEffect
(()
=>
{
// Fetch user data from API or database
// const fetchUser = async () => {
// const response = await fetch(`/api/users/${id}`);
// const data = await response.json();
// setInitialValues(data);
// };
// fetchUser();
},
[
id
]);
return
(
<
div
data
-
testid=
"new-stock-form"
>
<
DynamicForm
type=
{
DynamicFormTypes
.
Update
}
title=
{
t
(
"edit-user"
)
}
initialValues=
{
{}
}
onFinish=
{
(
values
)
=>
console
.
log
({
values
})
}
formCol=
{
formItems
(
t
)
}
/>
</
div
>
);
};
export
default
EditForm
;
packages/admin/src/features/login/index.tsx
View file @
048ae270
...
...
@@ -13,8 +13,14 @@ const Login = () => {
const
[
cookies
,
setCookies
]
=
useCookies
([
AUTH_TOKEN
]);
const
onFinishSend
=
(
values
:
any
)
=>
{
if
(
values
.
email
==
"admin@f.com"
){
setCookies
(
AUTH_TOKEN
,
values
.
email
);
router
.
push
(
"/"
);
}
else
if
(
values
.
email
==
"user@f.com"
){
setCookies
(
AUTH_TOKEN
,
values
.
email
);
router
.
push
(
"/user"
);
}
};
return
(
<
div
data
-
testid=
"login-component"
>
...
...
packages/admin/src/features/profile/index.tsx
View file @
048ae270
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
FmsButton
from
"../../../../shared-library/src/buttons/fms-button"
;
import
{
useRouter
}
from
"next/router"
;
const
ProfileForm
=
()
=>
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
router
=
useRouter
();
return
(
<>
<
main
className=
"profile-page"
>
...
...
@@ -60,7 +61,9 @@ const ProfileForm = () => {
className=
"bg-blueGray-700 active:bg-blueGray-600 uppercase text-white font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150"
type=
"primary"
borderRadius=
"32"
onClick=
{
()
=>
{
router
.
push
(
"/setup/setting-profile-content"
);
}
}
>
{
t
(
"edit"
)
}
</
FmsButton
>
...
...
packages/admin/src/features/setting/index.tsx
0 → 100644
View file @
048ae270
import
React
from
"react"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
FmsButton
from
"../../../../shared-library/src/buttons/fms-button"
;
import
{
useRouter
}
from
"next/router"
;
import
{
Col
,
Divider
,
Row
}
from
"antd"
;
const
Setting
=
()
=>
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
router
=
useRouter
();
return
(
<>
<
Divider
orientation=
"left"
>
{
t
(
"setting-pages"
)
}
</
Divider
>
<
Col
span=
{
24
}
className=
{
"pd"
}
>
<
FmsButton
type=
"move"
size=
{
"large"
}
borderRadius=
"8"
onClick=
{
()
=>
{
router
.
push
(
"/setup/setting-about-content"
);
}
}
>
{
t
(
"About-page-setting"
).
toUpperCase
()
}
</
FmsButton
>
</
Col
>
<
Divider
orientation=
"left"
></
Divider
>
<
Col
span=
{
12
}
className=
{
"pd"
}
>
<
FmsButton
type=
"move"
size=
{
"large"
}
borderRadius=
"8"
onClick=
{
()
=>
{
router
.
push
(
"/setup/setting-profile-content"
);
}
}
>
{
t
(
"profile-page-setting"
).
toUpperCase
()
}
</
FmsButton
>
</
Col
>
</>
);
};
export
default
Setting
;
packages/admin/src/features/setting/setting-about-content.tsx
0 → 100644
View file @
048ae270
This diff is collapsed.
Click to expand it.
packages/admin/src/features/setting/setting-profile.tsx
0 → 100644
View file @
048ae270
import
{
useState
}
from
"react"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
FmsButton
from
"../../../../shared-library/src/buttons/fms-button"
;
import
{
DatePicker
,
Input
,
Select
}
from
"antd"
;
import
{
FileAddOutlined
,
UploadOutlined
}
from
"@ant-design/icons"
;
const
SettingProfileContent
=
()
=>
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
[
imageSrc
,
setImageSrc
]
=
useState
(
"/images/Reem.jpg"
);
const
handleImageUpload
=
(
e
)
=>
{
const
file
=
e
.
target
.
files
[
0
];
const
reader
=
new
FileReader
();
reader
.
onloadend
=
()
=>
{
setImageSrc
(
reader
.
result
);
};
reader
.
readAsDataURL
(
file
);
};
return
(
<>
<
main
className=
"profile-page"
>
<
section
className=
"relative block h-500-px"
>
<
div
className=
"absolute top-0 w-full h-full bg-center bg-cover"
style=
{
{
backgroundImage
:
"url('https://images.unsplash.com/photo-1499336315816-097655dcfbda?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2710&q=80')"
,
}
}
>
<
span
id=
"blackOverlay"
className=
"w-full h-full absolute opacity-50 bg-black"
></
span
>
</
div
>
<
div
className=
"top-auto bottom-0 left-0 right-0 w-full absolute pointer-events-none overflow-hidden h-16"
style=
{
{
transform
:
"translateZ(0)"
}
}
>
<
svg
className=
"absolute bottom-0 overflow-hidden"
xmlns=
"http://www.w3.org/2000/svg"
preserveAspectRatio=
"none"
version=
"1.1"
viewBox=
"0 0 2560 100"
x=
"0"
y=
"0"
>
<
polygon
className=
"text-blueGray-200 fill-current"
points=
"2560 0 2560 100 0 100"
></
polygon
>
</
svg
>
</
div
>
</
section
>
<
section
className=
"relative py-16 bg-blueGray-200"
>
<
div
className=
"container mx-auto px-4"
>
<
div
className=
"relative flex flex-col min-w-0 break-words bg-white w-full mb-6 shadow-xl rounded-lg -mt-64"
>
<
div
className=
"px-6"
>
<
div
className=
"flex flex-wrap justify-center"
>
<
div
className=
"w-full lg:w-3/12 px-4 lg:order-2 flex justify-center"
>
<
div
className=
"relative"
>
<
label
htmlFor=
"image-upload"
className=
"file-input-label"
>
<
img
alt=
"..."
src=
{
imageSrc
}
className=
"shadow-xl rounded-full h-auto align-middle border-none absolute -m-16 -ml-20 lg:-ml-16 max-w-150-px"
/>
<
div
className=
"add-image-button pd-top"
>
<
FmsButton
type=
{
"secondary"
}
className=
{
"pd-top"
}
size=
{
"large"
}
borderRadius=
{
8
}
onclick=
{
handleImageUpload
}
>
<
input
type=
"file"
id=
"image-upload"
accept=
".jpg,.jpeg,.png"
onChange=
{
handleImageUpload
}
// className="hidden"
/>
</
FmsButton
>
</
div
>
</
label
>
</
div
>
</
div
>
<
div
className=
"w-full lg:w-4/12 px-4 lg:order-3 lg:text-right lg:self-center"
>
<
div
className=
"py-6 px-3 mt-32 sm:mt-0"
>
<
FmsButton
className=
"bg-blueGray-700 active:bg-blueGray-600 uppercase text-white font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150"
type=
"primary"
borderRadius=
"32"
>
{
t
(
"save"
)
}
</
FmsButton
>
</
div
>
</
div
>
<
div
className=
"w-full lg:w-4/12 px-4 lg:order-1"
>
<
div
className=
"flex justify-center py-4 lg:pt-4 pt-8"
>
<
div
className=
"mr-4 p-3 text-center"
>
<
span
className=
"text-xl font-bold block uppercase tracking-wide text-blueGray-600"
>
</
span
>
<
span
className=
"text-sm text-blueGray-400"
>
</
span
>
</
div
>
<
div
className=
"pd-top mr-4 p-3 text-center"
>
<
span
className=
" text-xl font-bold block uppercase tracking-wide text-blueGray-600"
>
<
Select
placeholder=
{
t
(
"gender"
)
}
// value={""}
onChange=
{
(
e
:
any
)
=>
{}
}
/>
</
span
>
</
div
>
<
div
className=
"pd-top lg:mr-4 p-3 text-center"
>
<
span
className=
"text-xl font-bold block uppercase tracking-wide text-blueGray-600"
>
<
DatePicker
placeholder=
{
t
(
"start-working-date"
)
}
// value={""}
onChange=
{
(
e
:
any
)
=>
{}
}
/>
</
span
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
className=
"text-center mt-12"
>
<
h3
className=
"text-4xl font-semibold leading-normal mb-2 text-blueGray-700 mb-2"
>
<
Input
className=
{
"med-size"
}
placeholder=
{
"name"
}
// value={""}
onChange=
{
(
e
:
any
)
=>
{}
}
/>
</
h3
>
<
div
className=
"text-sm leading-normal mt-0 mb-2 text-blueGray-400 font-bold uppercase"
>
<
i
className=
"fas fa-map-marker-alt text-lg text-blueGray-400"
></
i
>
<
Input
className=
{
"med-size"
}
placeholder=
{
"country"
}
// value={""}
onChange=
{
(
e
:
any
)
=>
{}
}
/>
</
div
>
</
div
>
<
div
className=
"mt-10 py-10 border-t border-blueGray-200 text-center"
>
<
div
className=
"flex flex-wrap justify-center"
>
<
div
className=
"w-full lg:w-9/12 px-4"
>
<
p
className=
"mb-4 text-lg leading-relaxed text-blueGray-700"
>
<
Input
placeholder=
{
"role"
}
// value={""}
onChange=
{
(
e
:
any
)
=>
{}
}
/>
</
p
>
<
div
className=
"mb-2 text-lightBlue-500 mt-10"
>
<
i
className=
"fas fa-briefcase mr-2 text-lg text-blueGray-400"
></
i
>
{
t
(
"description"
)
}
</
div
>
<
div
className=
"mb-2 text-lightBlue-500"
>
<
i
className=
"fas fa-university mr-2 text-lg "
></
i
>
<
Input
.
TextArea
placeholder=
{
"description"
}
// value={""}
onChange=
{
(
e
:
any
)
=>
{}
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
section
>
</
main
>
</>
);
};
export
default
SettingProfileContent
;
packages/admin/src/features/show-traps/index.tsx
View file @
048ae270
...
...
@@ -9,6 +9,7 @@ import { DataSource } from "./data-source";
import
ShowDetailsPopup
from
"./show-details-popup"
;
import
axios
from
"axios"
;
import
{
Spin
}
from
"antd"
;
import
{
fetchData
}
from
"@/src/services/traps-service"
;
export
default
function
ShowTraps
()
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
...
...
@@ -21,80 +22,64 @@ export default function ShowTraps() {
const
[
loading
,
setLoading
]
=
useState
(
false
);
useEffect
(()
=>
{
setLoading
(
true
);
const
fetchData
=
async
()
=>
{
axios
.
get
(
"http://192.168.93.198:6647/api/rethink/data"
)
.
then
((
res
:
any
)
=>
{
if
(
res
.
data
)
{
// console.log(res.data);
const
transformedData
=
res
.
data
.
map
((
item
:
any
)
=>
({
id
:
item
.
id
,
timestamp
:
item
.
timestamp
,
agentAddress
:
item
.
agentAddress
,
severity
:
item
.
severity
,
specificTrap
:
item
.
specificTrap
,
genericTrap
:
item
.
genericTrap
,
variableBindings
:
item
.
variableBindings
,
}));
setData1
(
transformedData
);
// console.log(data1);
if
(
new_val
!=
null
){
if
(
new_val
.
flag
==
'0'
)
{
// const transformedData2 =data.map((newData:any)=>({
// id: newData.id,
// timestamp: newData.timestamp,
// agentAddress: newData.agentAddress,
// severity: newData.severity,
// specificTrap: newData.specificTrap,
// genericTrap: newData.genericTrap,
// variableBindings: newData.variableBindings,
// }))
console
.
log
(
new_val
);
setData1
((
prevData
:
any
)
=>
[...
prevData
,
new_val
]);
setNewVal
(
null
);
// transformedData2.forEach((item:any) => {
// setData1((prevData:any) => [...prevData, item]);
// });
}
else
if
(
new_val
.
flag
==-
1
){
setData1
((
prevData
:
any
)
=>
prevData
.
filter
((
item
:
any
)
=>
item
.
id
!==
new_val
.
id
));
}
}
}
else
{
alert
(
"Error"
);
}
})
.
catch
((
err
:
any
)
=>
console
.
log
(
err
));
};
fetchData
();
fetchData
().
then
((
transformedData
)
=>
{
if
(
transformedData
)
setData1
(
transformedData
);
if
(
new_val
!=
null
){
if
(
new_val
.
flag
==
'0'
)
{
console
.
log
(
new_val
);
setData1
((
prevData
:
any
)
=>
[...
prevData
,
new_val
]);
setNewVal
(
null
);
}
else
if
(
new_val
.
flag
==-
1
){
setData1
((
prevData
:
any
)
=>
prevData
.
filter
((
item
:
any
)
=>
item
.
id
!==
new_val
.
id
));
}
}
});
setLoading
(
false
);
},
[
new_val
]);
// useEffect(() => {
// if (!websocket) {
// return;
// }
// websocket.onmessage = function (event) {
// const message = JSON.parse(event.data);
// const newData = message.new_val;
// const transformedData = {
// id: newData.id,
// agentAddress: newData.agentAddress,
// timestamp: newData.timestamp,
// severity: newData.severity,
// specificTrap: newData.specificTrap,
// genericTrap: newData.genericTrap,
// variableBindings: newData.variableBindings,
// };
// setData((prevData: any) => [...prevData, transformedData]);
// setLoading(true);
// const fetchData = async () => {
// axios
// .get("http://192.168.93.198:6647/api/rethink/data")
// .then((res: any) => {
// if (res.data) {
// const transformedData = res.data.map((item: any) => ({
// id: item.id,
// timestamp: item.timestamp,
// agentAddress: item.agentAddress,
// severity: item.severity,
// specificTrap: item.specificTrap,
// genericTrap: item.genericTrap,
// variableBindings: item.variableBindings,
// }));
// setData1(transformedData);
// if(new_val!=null){
// if (new_val.flag == '0') {
// console.log(new_val);
// setData1((prevData:any) => [...prevData, new_val]);
// setNewVal(null);
// }
// else if (new_val.flag==-1){
// setData1((prevData:any) => prevData.filter((item:any) => item.id !== new_val.id));
// }
// }
// }
// else {
// alert("Error");
// }
// })
// .catch((err: any) => console.log(err));
// };
// fetchData();
// setLoading(false);
// }, [new_val]);
// }, [websocket]);
return
(
<
div
>
<
Spin
spinning=
{
loading
}
>
...
...
packages/admin/src/features/show-users/columns.tsx
View file @
048ae270
import
{
useRouter
}
from
"next/router"
;
import
FmsButton
from
"../../../../shared-library/src/buttons/fms-button"
;
export
const
Columns
=
[
export
function
getColumns
(
setModalProps
:
any
)
{
return
[
{
title
:
"Name"
,
dataIndex
:
"name"
,
...
...
@@ -19,20 +20,14 @@ export const Columns = [
{
title
:
"Actions"
,
key
:
"actions"
,
render
:
(
text
:
any
,
record
:
any
)
=>
(
<
span
>
<
EditButton
id=
{
record
.
id
}
/>
</
span
>
render
:
(
text
:
any
,
record
:
any
)
=>
(
<
FmsButton
type=
"primary"
onClick=
{
()
=>
setModalProps
({
isOpen
:
true
,
data
:
null
})
}
>
{
"edit"
}
</
FmsButton
>
),
},
];
const
EditButton
=
({
id
})
=>
{
const
router
=
useRouter
();
// Get the router object from useRouter
const
handleEditClick
=
()
=>
{
router
.
push
(
`/edit-user`
);
// Navigate to the edit page URL
};
return
<
FmsButton
type
=
"
link
"
onClick=
{
handleEditClick
}
>
Edit
</
FmsButton
>;
};
\ No newline at end of file
packages/admin/src/features/show-users/edit-user-popup.tsx
0 → 100644
View file @
048ae270
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
{
Col
,
DatePicker
,
Input
,
Modal
,
Row
,
Select
}
from
"antd"
;
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
interface
Props
{
modalProps
:
any
;
setModalProps
:
any
;
}
export
default
function
EditUserPopup
({
modalProps
,
setModalProps
}:
Props
)
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
const
handleCancel
=
()
=>
{
setModalProps
(
false
,
null
);
};
useEffect
(()
=>
{
setIsModalOpen
(
modalProps
.
isOpen
);
},
[
modalProps
])
return
(
<
Modal
title=
"edit-user"
visible=
{
isModalOpen
}
onOk=
{
handleCancel
}
onCancel=
{
handleCancel
}
>
<
Row
gutter=
{
[
12
,
12
]
}
>
<
Col
span=
{
24
}
>
<
Input
/>
</
Col
>
<
Col
span=
{
24
}
>
<
Input
/>
</
Col
>
<
Col
span=
{
24
}
>
<
Select
/>
</
Col
>
<
Col
span=
{
24
}
>
<
Select
/>
</
Col
>
<
Col
span=
{
24
}
>
<
Select
/>
</
Col
>
<
Col
span=
{
24
}
>
<
DatePicker
/>
</
Col
>
<
Col
span=
{
24
}
>
<
Input
.
TextArea
/>
</
Col
>
</
Row
>
</
Modal
>
);
}
\ No newline at end of file
packages/admin/src/features/show-users/index.tsx
View file @
048ae270
...
...
@@ -3,29 +3,34 @@ import { useState } from "react";
import
useTranslation
from
"next-translate/useTranslation"
;
import
{
TranslationFiles
}
from
"@/src/data/core"
;
import
FmsTable
from
"../../../../shared-library/src/tables/fms-table"
;
import
{
Columns
}
from
"./columns"
;
import
{
get
Columns
}
from
"./columns"
;
import
{
DataSource
}
from
"./data-source"
;
import
EditUserPopup
from
"./edit-user-popup"
export
default
function
ShowUsers
()
{
const
{
t
}
=
useTranslation
(
TranslationFiles
.
COMMON
);
const
[
columns
,
setColumns
]
=
useState
({
columns
:
Columns
const
[
modalProps
,
setModalProps
]
=
useState
({
isOpen
:
false
,
data
:
null
,
});
const
[
data
,
setData
]
=
useState
(
DataSource
);
return
(
<
div
>
<
FmsTable
title=
{
t
(
"users"
)
}
columns=
{
columns
.
columns
}
columns=
{
getColumns
(
setModalProps
)
}
data=
{
data
}
rowSelection=
{
{
type
:
"checkbox"
,
}
}
t=
{
t
}
setData=
{
setData
}
setColumns=
{
setColumns
}
pageSizeOptions=
{
[
"10"
,
"20"
,
"50"
]
}
defaultPageSize=
{
10
}
/>
<
EditUserPopup
modalProps=
{
modalProps
}
setModalProps=
{
setModalProps
}
/>
</
div
>
);
}
packages/admin/src/services/setting-service.tsx
0 → 100644
View file @
048ae270
import
axios
from
"axios"
;
import
{
SettingURL
}
from
"../data/constant/app-constant"
;
export
const
fetchAboutSettingData
=
async
()
=>
{
try
{
const
response
=
await
axios
.
get
(
SettingURL
+
"/data"
);
if
(
response
.
data
)
{
const
data
=
response
.
data
.
map
((
item
:
any
)
=>
({
id
:
item
.
id
,
key
:
item
.
key
,
value
:
item
.
value
,
}));
return
data
;
}
else
{
alert
(
"Error"
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
export
const
putAboutSettingData
=
async
(
data
:
any
)
=>
{
try
{
const
response
=
await
axios
.
post
(
SettingURL
+
"/post"
,
data
);
console
.
log
(
response
.
data
);
}
catch
(
error
)
{
console
.
error
(
error
);
}
};
export
const
deleteByKeyAboutSettingData
=
async
(
key
:
any
)
=>
{
try
{
const
response
=
await
axios
.
delete
(
SettingURL
+
`/delete/
${
key
}
`
);
console
.
log
(
response
.
data
);
}
catch
(
error
)
{
console
.
error
(
error
);
}
};
export
const
UpdateAboutSettingData
=
async
(
data
:
any
)
=>
{
try
{
const
response
=
await
axios
.
put
(
SettingURL
+
`/update`
,
data
);
console
.
log
(
response
);
return
response
;
}
catch
(
error
)
{
console
.
error
(
error
);
return
error
;
}
};
export
const
sendEmailMessage
=
async
(
data
:
any
)
=>
{
try
{
const
response
=
await
axios
.
post
(
SettingURL
+
`/send-message`
,
data
);
return
response
.
data
;
}
catch
(
error
)
{
return
error
;
}
};
\ No newline at end of file
packages/admin/src/services/traps-service.tsx
0 → 100644
View file @
048ae270
import
axios
from
"axios"
;
import
{
TrapURL
}
from
"../data/constant/app-constant"
;
export
const
fetchData
=
async
()
=>
{
try
{
const
response
=
await
axios
.
get
(
TrapURL
);
if
(
response
.
data
)
{
const
transformedData
=
response
.
data
.
map
((
item
:
any
)
=>
({
id
:
item
.
id
,
timestamp
:
item
.
timestamp
,
agentAddress
:
item
.
agentAddress
,
severity
:
item
.
severity
,
specificTrap
:
item
.
specificTrap
,
genericTrap
:
item
.
genericTrap
,
variableBindings
:
item
.
variableBindings
,
}));
return
transformedData
;
}
else
{
alert
(
"Error"
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
\ No newline at end of file
packages/admin/src/styles/global.less
View file @
048ae270
...
...
@@ -149,21 +149,47 @@ a {
color: #e2d303;
font-weight: 1000;
// font-size: larger;
font-family:
'Times New Roman'
, Times, serif;
font-family:
"Times New Roman"
, Times, serif;
}
.severity-ERROR {
color: #ff2306;
font-weight: 1000;
// font-size: larger;
font-family:
'Times New Roman'
, Times, serif;
// font-size: larger;
font-family:
"Times New Roman"
, Times, serif;
}
.severity-INFO {
color: #06ff83;
font-weight: 1000;
// font-size: larger;
font-family:
'Times New Roman'
, Times, serif;
// font-size: larger;
font-family:
"Times New Roman"
, Times, serif;
}
.ExclamationCircleOutlined {
margin-bottom: 2px;
}
.pd {
margin-bottom: 20px;
}
.pd-top {
margin-top: 20px;
}
.med-size {
width: 20vw;
}
.add-image-button {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
margin: 15px;
margin-top: 40px;
}
.file-input-label input[type="file"] {
// margin: 20px;
cursor: pointer;
}
\ 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