edit
This commit is contained in:
parent
db408bb2db
commit
95db83ab3e
22
Areas/OTcalculate/Controllers/HodDashboardController.cs
Normal file
22
Areas/OTcalculate/Controllers/HodDashboardController.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PSTW_CentralSystem.Areas.OTcalculate.Models;
|
||||||
|
using PSTW_CentralSystem.DBContext;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PSTW_CentralSystem.Areas.OTcalculate.Controllers
|
||||||
|
{
|
||||||
|
[Area("OTcalculate")]
|
||||||
|
[Authorize]
|
||||||
|
public class HodDashboardController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult HodApproval()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PSTW_CentralSystem.Areas.OTcalculate.Models;
|
using PSTW_CentralSystem.Areas.OTcalculate.Models;
|
||||||
using PSTW_CentralSystem.DBContext;
|
using PSTW_CentralSystem.DBContext;
|
||||||
@ -10,6 +11,7 @@ using System.Threading.Tasks;
|
|||||||
namespace PSTW_CentralSystem.Areas.OTcalculate.Controllers
|
namespace PSTW_CentralSystem.Areas.OTcalculate.Controllers
|
||||||
{
|
{
|
||||||
[Area("OTcalculate")]
|
[Area("OTcalculate")]
|
||||||
|
[Authorize]
|
||||||
|
|
||||||
public class HrDashboardController : Controller
|
public class HrDashboardController : Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace PSTW_CentralSystem.Areas.OTcalculate.Controllers
|
namespace PSTW_CentralSystem.Areas.OTcalculate.Controllers
|
||||||
{
|
{
|
||||||
[Area("OTcalculate")]
|
[Area("OTcalculate")]
|
||||||
|
[Authorize]
|
||||||
public class OvertimeController : Controller
|
public class OvertimeController : Controller
|
||||||
{
|
{
|
||||||
public IActionResult OtRegister()
|
public IActionResult OtRegister()
|
||||||
|
|||||||
7
Areas/OTcalculate/Models/OtRecordsModel.cs
Normal file
7
Areas/OTcalculate/Models/OtRecordsModel.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace PSTW_CentralSystem.Areas.OTcalculate.Models
|
||||||
|
{
|
||||||
|
public class OtRecordsModel
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -28,6 +28,7 @@ namespace PSTW_CentralSystem.Areas.OTcalculate.Models
|
|||||||
public string OtDescription { get; set; }
|
public string OtDescription { get; set; }
|
||||||
public string OtDays { get; set; }
|
public string OtDays { get; set; }
|
||||||
public required string PDFBase64 { get; set; }
|
public required string PDFBase64 { get; set; }
|
||||||
|
public required string IvBase64 { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|||||||
17
Areas/OTcalculate/Views/HodDashboard/HodApproval.cshtml
Normal file
17
Areas/OTcalculate/Views/HodDashboard/HodApproval.cshtml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Overtime Approval";
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-6 col-md-6 col-lg-3">
|
||||||
|
<div class="card card-hover">
|
||||||
|
|
||||||
|
<h6 class="text-white">Rate</h6>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -244,6 +244,33 @@
|
|||||||
reader.onload = async (event) => {
|
reader.onload = async (event) => {
|
||||||
const base64String = event.target.result.split(',')[1];
|
const base64String = event.target.result.split(',')[1];
|
||||||
|
|
||||||
|
// Generate a crypto key
|
||||||
|
const key = await crypto.subtle.generateKey(
|
||||||
|
{ name: "AES-GCM", length: 256 },
|
||||||
|
true,
|
||||||
|
["encrypt", "decrypt"]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Export the key (for sending to backend if needed or for testing)
|
||||||
|
const exportedKey = await crypto.subtle.exportKey("jwk", key);
|
||||||
|
|
||||||
|
// Generate a random IV
|
||||||
|
const iv = crypto.getRandomValues(new Uint8Array(12));
|
||||||
|
|
||||||
|
// Encode data
|
||||||
|
const encoded = new TextEncoder().encode(base64String);
|
||||||
|
|
||||||
|
// Encrypt the data
|
||||||
|
const encrypted = await crypto.subtle.encrypt(
|
||||||
|
{ name: "AES-GCM", iv: iv },
|
||||||
|
key,
|
||||||
|
encoded
|
||||||
|
);
|
||||||
|
|
||||||
|
// Convert encrypted data to base64
|
||||||
|
const encryptedBase64 = btoa(String.fromCharCode(...new Uint8Array(encrypted)));
|
||||||
|
const ivBase64 = btoa(String.fromCharCode(...iv));
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
otDate: this.selectedDate,
|
otDate: this.selectedDate,
|
||||||
officeFrom: this.formatTime(this.officeFrom) || null,
|
officeFrom: this.formatTime(this.officeFrom) || null,
|
||||||
@ -255,11 +282,13 @@
|
|||||||
stationId: this.selectedAirStation,
|
stationId: this.selectedAirStation,
|
||||||
otDescription: this.otDescription,
|
otDescription: this.otDescription,
|
||||||
otDays: this.selectedDayType,
|
otDays: this.selectedDayType,
|
||||||
pdfBase64: base64String,
|
pdfBase64: encryptedBase64,
|
||||||
|
ivBase64: ivBase64, // store this too
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
|
encryptionKey: exportedKey.k, // only if you're doing a simple demo; ideally don't send this from frontend
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
// Send to backend
|
||||||
const response = await fetch(`${window.location.origin}/OvertimeAPI/AddOvertime`, {
|
const response = await fetch(`${window.location.origin}/OvertimeAPI/AddOvertime`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
@ -274,12 +303,9 @@
|
|||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
alert(result.message);
|
alert(result.message);
|
||||||
this.clearForm();
|
this.clearForm();
|
||||||
} catch (error) {
|
|
||||||
console.error("Error adding overtime:", error);
|
|
||||||
alert("Failed to save overtime. Please check the console for errors.");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
reader.onerror = () => {
|
reader.onerror = () => {
|
||||||
console.error("Error reading file");
|
console.error("Error reading file");
|
||||||
alert("Error reading the uploaded file.");
|
alert("Error reading the uploaded file.");
|
||||||
|
|||||||
@ -539,6 +539,21 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a class="sidebar-link has-arrow waves-effect waves-dark"
|
||||||
|
href="javascript:void(0)"
|
||||||
|
aria-expanded="false">
|
||||||
|
<i class="mdi mdi-receipt"></i><span class="hide-menu">HoD Dashboard</span>
|
||||||
|
</a>
|
||||||
|
<ul aria-expanded="false" class="collapse first-level">
|
||||||
|
<li class="sidebar-item">
|
||||||
|
<a class="sidebar-link waves-effect waves-dark sidebar-link" asp-area="OTcalculate" asp-controller="HodDashboard" asp-action="HodApproval" aria-expanded="false">
|
||||||
|
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">OT Approval</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<!-- <li class="sidebar-item">
|
<!-- <li class="sidebar-item">
|
||||||
<a class="sidebar-link waves-effect waves-dark sidebar-link"
|
<a class="sidebar-link waves-effect waves-dark sidebar-link"
|
||||||
href="charts.html"
|
href="charts.html"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user