Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nisum-scorecard
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
Venkaiah Naidu Singamchetty
nisum-scorecard
Commits
8ef594ee
Commit
8ef594ee
authored
Mar 25, 2024
by
Venkaiah Naidu Singamchetty
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'initailSetup' into 'master'
Initail setup See merge request
!93
parents
efa06946
37c33fa0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
13 deletions
+100
-13
package.json
package.json
+2
-0
index.jsx
src/components/sidebar/index.jsx
+5
-4
index.css
src/index.css
+20
-0
index.jsx
src/pages/reportexport/index.jsx
+69
-8
exporttableslice.js
src/redux/reducers/exporttableslice.js
+4
-1
No files found.
package.json
View file @
8ef594ee
...
...
@@ -10,6 +10,8 @@
"
axios
"
:
"^1.6.7"
,
"
cors
"
:
"^2.8.5"
,
"
express
"
:
"^4.18.3"
,
"
jspdf
"
:
"^2.5.1"
,
"
jspdf-autotable
"
:
"^3.8.2"
,
"
lodash
"
:
"^4.17.21"
,
"
moment
"
:
"^2.30.1"
,
"
mongodb
"
:
"^6.5.0"
,
...
...
src/components/sidebar/index.jsx
View file @
8ef594ee
...
...
@@ -5,13 +5,14 @@ import DashboardIcon from '../../assets/icons/dashboardIcon';
import
ReportsIcon
from
'../../assets/icons/reportsIcon'
;
const
menus
=
[
{
title
:
"Dashboard"
,
path
:
'/dashboard'
,
icon
:
<
DashboardIcon
/>
},
{
title
:
"Reports"
,
path
:
'/reportees'
,
icon
:
<
ReportsIcon
/>}
{
title
:
"Dashboard"
,
path
:
'/dashboard'
,
selectPaths
:
[
'dashboard'
,
'viewreportee'
],
icon
:
<
DashboardIcon
/>
},
{
title
:
"Reports"
,
path
:
'/reportees'
,
selectPaths
:[
'reportees'
],
icon
:
<
ReportsIcon
/>}
]
function
Sidebar
()
{
const
url
=
window
.
location
.
href
;
const
[
windowWidth
,
windowHeight
]
=
SetWindowSize
();
const
selected
=
url
.
split
(
'/'
).
at
(
-
1
)
return
(
<
div
className=
"w-[20%] flex items-center flex-col overflow-auto"
style=
{
{
height
:
`calc(${windowHeight}px - 87px)`
}
}
>
...
...
@@ -24,7 +25,7 @@ function Sidebar() {
menus
.
map
((
menu
)
=>
(
<
li
key=
{
menu
.
path
}
>
<
Link
className=
{
`flex items-center ${
url.includes(menu.path
) && 'bg-gray-100'} gap-x-3.5 py-2 px-2.5 text-sm text-slate-700 rounded-lg hover:bg-gray-100 `
}
className=
{
`flex items-center ${
menu.selectPaths.includes(selected
) && 'bg-gray-100'} gap-x-3.5 py-2 px-2.5 text-sm text-slate-700 rounded-lg hover:bg-gray-100 `
}
to=
{
menu
.
path
}
>
<
span
>
{
menu
.
icon
}
</
span
>
...
...
@@ -33,7 +34,7 @@ function Sidebar() {
</
li
>
))
}
</
ul
>
</
nav
>
</
div
>
...
...
src/index.css
View file @
8ef594ee
...
...
@@ -23,3 +23,23 @@ code {
display
:
inline-block
;
}
.loading
{
width
:
100%
;
height
:
100%
;
content
:
''
;
top
:
50%
;
left
:
50%
;
width
:
20px
;
height
:
20px
;
border
:
3px
solid
#fff
;
border-radius
:
50%
;
border-top-color
:
transparent
;
animation
:
spin
1s
linear
infinite
;
}
@keyframes
spin
{
to
{
transform
:
rotate
(
360deg
);
}
}
\ No newline at end of file
src/pages/reportexport/index.jsx
View file @
8ef594ee
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
axios
from
"axios"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
fetchReportstableData
,
fetchReportesActivitiesData
,
}
from
"../../redux/reducers/exporttableslice"
;
import
{
fetchReportesActivitiesData
,
resetReporteesTableData
,
resetActivitiesData
}
from
"../../redux/reducers/exporttableslice"
;
import
{
fetchReportees
}
from
"../../redux/reducers/reporteesSlice"
;
import
{
convertUTCToLocal
}
from
"../../utils/commonFunctions"
;
import
Table
from
"../../components/table"
;
import
{
base_url
}
from
"../../utils/constants"
;
import
jsPDF
from
'jspdf'
;
import
'jspdf-autotable'
;
function
Exporttable
()
{
const
dispatch
=
useDispatch
();
...
...
@@ -20,6 +21,8 @@ function Exporttable() {
const
[
fromDate
,
setFromDate
]
=
useState
(
""
);
const
[
toDate
,
setToDate
]
=
useState
(
""
);
const
[
inputValue
,
setInputValue
]
=
useState
(
''
);
const
[
pdfData
,
setPdfData
]
=
useState
([]);
const
[
pdfLoading
,
setPdfLoading
]
=
useState
(
false
);
const
calculateDateRange
=
(
monthsAgo
)
=>
{
const
toDate
=
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
...
...
@@ -65,8 +68,17 @@ function Exporttable() {
};
dispatch
(
fetchReportees
(
data
));
}
return
(()
=>
{
dispatch
(
resetReporteesTableData
())
})
},
[
user
]);
useEffect
(()
=>
{
if
(
activitiesData
.
length
>
0
)
{
dispatch
(
resetActivitiesData
())
}
},
[
selectedEmployee
,
toDate
,
fromDate
])
const
headers
=
[
{
title
:
"Activity Name"
,
id
:
"aName"
},
{
...
...
@@ -96,6 +108,52 @@ function Exporttable() {
];
// Function to convert table to PDF
const
convertTableToPDF
=
(
data
)
=>
{
const
doc
=
new
jsPDF
({
orientation
:
'portrait'
,
format
:
'a4'
});
const
headerParams
=
{
align
:
'justify'
,
fillStyle
:
'FD'
}
const
tableData
=
data
.
map
(
item
=>
[
item
.
aName
,
item
.
ratedBy
,
item
.
score
,
item
.
comments
]);
// Add header to the PDF
doc
.
text
(
'Score card reports'
,
15
,
10
,
headerParams
);
doc
.
autoTable
({
head
:
[[
'Activity Name'
,
'Rated By'
,
'Score'
,
'Comments'
]],
// Extract header row
body
:
tableData
,
// Extract data rows
startY
:
20
,
// Start y-position of the table
theme
:
'striped'
,
// Table theme: 'plain', 'grid', 'striped', 'striped' (default is 'striped')
styles
:
{
overflow
:
'linebreak'
},
// Styles for table cells
columnStyles
:
{
2
:
{
fontStyle
:
'bold'
}
},
// Styles for specific columns
});
// Save PDF
doc
.
save
(
'ActivitiesList.pdf'
);
};
const
getPdfList
=
async
(
type
)
=>
{
try
{
setPdfLoading
(
true
);
let
data
=
{
empId
:
Number
(
selectedEmployee
),
fromDate
:
fromDate
,
toDate
:
toDate
,
};
const
response
=
await
axios
.
post
(
`
${
base_url
}
/getActivities`
,
data
).
then
((
res
)
=>
res
.
data
.
activities
);
if
(
response
.
length
>
0
)
convertTableToPDF
(
response
);
}
catch
{
setPdfLoading
(
false
);
}
finally
{
setPdfLoading
(
false
);
}
}
if
(
reportees
?.
length
>
0
)
{
return
(
<
div
>
...
...
@@ -159,18 +217,21 @@ function Exporttable() {
</
div
>
<
div
className=
"flex"
>
<
button
className=
"px-8 py-2 ml-5 w-[100px] h-[40px] bg-blue-500 text-white font-semibold rounded-md"
disabled=
{
!
fromDate
||
!
selectedEmployee
||
!
toDate
}
className=
"px-8 py-2 ml-5 w-[100px] h-[40px] bg-blue-500 text-white font-semibold rounded-md disabled:bg-gray-400"
onClick=
{
(
e
)
=>
handleView
(
e
)
}
>
View
</
button
>
<
button
disabled=
{
true
}
onClick=
{
getPdfList
}
disabled=
{
pdfLoading
||
!
fromDate
||
!
selectedEmployee
||
!
toDate
}
type=
"button"
className=
"px-3 py-2 ml-5
w-[100px] h-[40px] bg-gray-500 font-semibold text-white rounded-md
"
className=
"px-3 py-2 ml-5
min-w-[100px] disabled:bg-gray-400 h-[40px] bg-blue-500 font-semibold text-white rounded-md flex items-center justify-center
"
>
Download
<
span
>
{
pdfLoading
?
"Downloading..."
:
"Download"
}
</
span
>
{
pdfLoading
&&
<
div
className=
"loading ml-2 "
></
div
>
}
</
button
>
</
div
>
</
div
>
...
...
src/redux/reducers/exporttableslice.js
View file @
8ef594ee
...
...
@@ -21,6 +21,9 @@ const exporttableSlice = createSlice({
name
:
"totalReportees"
,
initialState
,
reducers
:
{
resetActivitiesData
:
(
state
)
=>
{
state
.
activitiesData
=
[]
},
resetReporteesTableData
:()
=>
{
return
initialState
},
...
...
@@ -46,6 +49,6 @@ const exporttableSlice = createSlice({
},
});
export
const
{
resetReporteesTableData
}
=
exporttableSlice
.
actions
;
export
const
{
resetReporteesTableData
,
resetActivitiesData
}
=
exporttableSlice
.
actions
;
export
default
exporttableSlice
.
reducer
;
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