Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
Hire-Guru
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vigneswaran Shanmugam
Hire-Guru
Commits
d8e24864
Commit
d8e24864
authored
May 26, 2026
by
Aravind RK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat : added file type for uploading
parent
e01f6a70
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
324 additions
and
129 deletions
+324
-129
Backend/server.js
Backend/server.js
+2
-2
Frontend/src/app/pages/admin/user-history/user-history.ts
Frontend/src/app/pages/admin/user-history/user-history.ts
+104
-80
Frontend/src/app/pages/hr/user-history/user-history.ts
Frontend/src/app/pages/hr/user-history/user-history.ts
+154
-30
Frontend/src/app/pages/staff/profile/profile.html
Frontend/src/app/pages/staff/profile/profile.html
+2
-0
Frontend/src/app/pages/staff/profile/profile.ts
Frontend/src/app/pages/staff/profile/profile.ts
+62
-17
No files found.
Backend/server.js
View file @
d8e24864
...
@@ -43,8 +43,8 @@
...
@@ -43,8 +43,8 @@
allowedHeaders
:
[
'
Content-Type
'
,
'
Authorization
'
]
allowedHeaders
:
[
'
Content-Type
'
,
'
Authorization
'
]
}));
}));
app
.
use
(
express
.
json
());
app
.
use
(
express
.
json
(
{
limit
:
'
10mb
'
}
));
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
app
.
use
(
express
.
urlencoded
({
extended
:
true
,
limit
:
'
10mb
'
}));
app
.
use
(
cookieParser
());
app
.
use
(
cookieParser
());
// Serve static files from uploads folder (for resumes, etc)
// Serve static files from uploads folder (for resumes, etc)
...
...
Frontend/src/app/pages/admin/user-history/user-history.ts
View file @
d8e24864
This diff is collapsed.
Click to expand it.
Frontend/src/app/pages/hr/user-history/user-history.ts
View file @
d8e24864
This diff is collapsed.
Click to expand it.
Frontend/src/app/pages/staff/profile/profile.html
View file @
d8e24864
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
<input
type=
"file"
accept=
"image/*"
style=
"display: none;"
(change)=
"uploadSignature($event)"
>
<input
type=
"file"
accept=
"image/*"
style=
"display: none;"
(change)=
"uploadSignature($event)"
>
</label>
</label>
</div>
</div>
<p
style=
"margin-top: 8px; font-size: 12px; color: #666;"
>
Valid formats: JPG, PNG, GIF, WebP (Max 5MB)
</p>
} @else {
} @else {
<div
class=
"empty-state"
style=
"padding: 40px 20px;"
>
<div
class=
"empty-state"
style=
"padding: 40px 20px;"
>
<span
class=
"material-symbols-rounded"
>
draw
</span>
<span
class=
"material-symbols-rounded"
>
draw
</span>
...
@@ -57,6 +58,7 @@
...
@@ -57,6 +58,7 @@
@else {
<span
class=
"material-symbols-rounded"
>
upload
</span>
Upload Signature }
@else {
<span
class=
"material-symbols-rounded"
>
upload
</span>
Upload Signature }
<input
type=
"file"
accept=
"image/*"
style=
"display: none;"
(change)=
"uploadSignature($event)"
>
<input
type=
"file"
accept=
"image/*"
style=
"display: none;"
(change)=
"uploadSignature($event)"
>
</label>
</label>
<p
style=
"margin-top: 8px; font-size: 12px; color: #666;"
>
Valid formats: JPG, PNG, GIF, WebP (Max 5MB)
</p>
</div>
</div>
}
}
</div>
</div>
...
...
Frontend/src/app/pages/staff/profile/profile.ts
View file @
d8e24864
...
@@ -85,27 +85,72 @@ export class StaffProfileComponent implements OnInit {
...
@@ -85,27 +85,72 @@ export class StaffProfileComponent implements OnInit {
const
file
=
event
.
target
.
files
[
0
];
const
file
=
event
.
target
.
files
[
0
];
if
(
!
file
)
return
;
if
(
!
file
)
return
;
// Validate file type
const
allowedTypes
=
[
'
image/jpeg
'
,
'
image/jpg
'
,
'
image/png
'
,
'
image/gif
'
,
'
image/webp
'
];
if
(
!
allowedTypes
.
includes
(
file
.
type
))
{
alert
(
'
Please upload an image file (JPG, PNG, GIF, or WebP)
'
);
return
;
}
// Validate file size (max 5MB before compression)
if
(
file
.
size
>
5
*
1024
*
1024
)
{
alert
(
'
File size must be less than 5MB
'
);
return
;
}
const
reader
=
new
FileReader
();
const
reader
=
new
FileReader
();
reader
.
onload
=
()
=>
{
reader
.
onload
=
(
e
:
any
)
=>
{
const
base64String
=
reader
.
result
as
string
;
const
img
=
new
Image
();
this
.
isUploadingSignature
.
set
(
true
);
img
.
onload
=
()
=>
{
// Resize to signature-appropriate dimensions and compress as JPEG
this
.
authService
.
uploadSignature
({
signature
:
base64String
}).
subscribe
({
const
MAX_WIDTH
=
600
;
next
:
(
res
)
=>
{
const
MAX_HEIGHT
=
200
;
this
.
isUploadingSignature
.
set
(
false
);
let
width
=
img
.
width
;
if
(
res
.
signature
)
{
let
height
=
img
.
height
;
// Update user signal
this
.
user
.
update
(
u
=>
({
...
u
,
signature
:
res
.
signature
}));
// Scale down proportionally if needed
}
if
(
width
>
MAX_WIDTH
)
{
},
height
=
Math
.
round
((
height
*
MAX_WIDTH
)
/
width
);
error
:
(
err
)
=>
{
width
=
MAX_WIDTH
;
this
.
isUploadingSignature
.
set
(
false
);
}
alert
(
err
.
error
?.
message
||
'
Error uploading signature
'
);
if
(
height
>
MAX_HEIGHT
)
{
width
=
Math
.
round
((
width
*
MAX_HEIGHT
)
/
height
);
height
=
MAX_HEIGHT
;
}
}
});
const
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
width
=
width
;
canvas
.
height
=
height
;
const
ctx
=
canvas
.
getContext
(
'
2d
'
)
!
;
// White background so transparent PNGs look clean
ctx
.
fillStyle
=
'
#ffffff
'
;
ctx
.
fillRect
(
0
,
0
,
width
,
height
);
ctx
.
drawImage
(
img
,
0
,
0
,
width
,
height
);
// Export as JPEG at 80% quality (much smaller than raw PNG base64)
const
base64String
=
canvas
.
toDataURL
(
'
image/jpeg
'
,
0.8
);
this
.
isUploadingSignature
.
set
(
true
);
this
.
authService
.
uploadSignature
({
signature
:
base64String
}).
subscribe
({
next
:
(
res
)
=>
{
this
.
isUploadingSignature
.
set
(
false
);
if
(
res
.
signature
)
{
this
.
user
.
update
(
u
=>
({
...
u
,
signature
:
res
.
signature
}));
}
},
error
:
(
err
)
=>
{
this
.
isUploadingSignature
.
set
(
false
);
alert
(
err
.
error
?.
message
||
'
Error uploading signature. Please try again.
'
);
}
});
};
img
.
onerror
=
()
=>
{
alert
(
'
Failed to load image. Please try a different file.
'
);
};
img
.
src
=
e
.
target
.
result
;
};
};
reader
.
onerror
=
()
=>
{
reader
.
onerror
=
()
=>
{
alert
(
'
Failed to read file
'
);
alert
(
'
Failed to read file
. Please try again.
'
);
};
};
reader
.
readAsDataURL
(
file
);
reader
.
readAsDataURL
(
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