diff --git a/Faizan_Akhtar/employeeManagement/admin.html b/Faizan_Akhtar/employeeManagement/admin.html new file mode 100644 index 0000000..9b941e3 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/admin.html @@ -0,0 +1,92 @@ + + + + + + + Admin Dashboard + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#EmpIDUsernameFirstNameLastNameDesignationProjectManagerSalaryEDIT
1104faizan.akhtarFaizanAkhtarInternBootcampVishal20000 + +
2104faizan.akhtarFaizanAkhtarInternBootcampVishal20000 + +
+ +
+
+ + + + \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/api/AdminController.cs b/Faizan_Akhtar/employeeManagement/api/AdminController.cs new file mode 100644 index 0000000..417a707 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/api/AdminController.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using EmployeeManagement.Custom_Models; +using EmployeeManagement.DbModels; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace EmployeeManagement.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class AdminController : ControllerBase + { + + EmployeeDBContext _employeeDBContext; + public AdminController(EmployeeDBContext employeeDBContext) + { + _employeeDBContext = employeeDBContext; + } + + [HttpGet] + public ActionResult GetEmployee() + { + // List studentName = _cSharpAdvContext.TStudent.ToList(); + List employee = _employeeDBContext.TEmployee.ToList(); + return Ok(employee); + } + + [HttpDelete] + public IActionResult DeleteStudent(CustomEmployee customEmployee) + { + TEmployee employee = _employeeDBContext.TEmployee.FirstOrDefault(); + _employeeDBContext.TEmployee.Remove(employee); + _employeeDBContext.SaveChanges(); + return Ok("Deleted"); + } + } +} \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/api/CustomEmployee.cs b/Faizan_Akhtar/employeeManagement/api/CustomEmployee.cs new file mode 100644 index 0000000..33800a4 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/api/CustomEmployee.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace EmployeeManagement.Custom_Models +{ + public class CustomEmployee + { + + public int EmpId { get; set; } + public string FName { get; set; } + public string Lname { get; set; } + public string Email { get; set; } + public string Passwrd { get; set; } + public string Designation { get; set; } + public string Project { get; set; } + public string Manager { get; set; } + public int? Salary { get; set; } + } +} diff --git a/Faizan_Akhtar/employeeManagement/api/EmployeeDBContext.cs b/Faizan_Akhtar/employeeManagement/api/EmployeeDBContext.cs new file mode 100644 index 0000000..dc83737 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/api/EmployeeDBContext.cs @@ -0,0 +1,71 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; + +namespace EmployeeManagement.DbModels +{ + public partial class EmployeeDBContext : DbContext + { + + public EmployeeDBContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet TEmployee { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.EmpId); + + entity.ToTable("tEmployee"); + + entity.Property(e => e.EmpId).HasColumnName("EmpID"); + + entity.Property(e => e.Designation) + .HasColumnName("designation") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.Email) + .HasColumnName("email") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.FName) + .HasColumnName("fName") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.Lname) + .HasColumnName("LName") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.Manager) + .HasColumnName("manager") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.Passwrd) + .HasColumnName("passwrd") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.Project) + .HasColumnName("project") + .HasMaxLength(200) + .IsUnicode(false); + + entity.Property(e => e.Salary).HasColumnName("salary"); + }); + } + } +} diff --git a/Faizan_Akhtar/employeeManagement/api/LoginController.cs b/Faizan_Akhtar/employeeManagement/api/LoginController.cs new file mode 100644 index 0000000..9256a58 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/api/LoginController.cs @@ -0,0 +1,81 @@ +using System; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Text; +using EmployeeManagement.Custom_Models; +using EmployeeManagement.DbModels; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.IdentityModel.Tokens; +using System.Security.Claims; + +namespace EmployeeManagement.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class LoginController : ControllerBase + { + private IConfiguration _config; + private EmployeeDBContext _employeeDBContext; + + public LoginController(IConfiguration config, EmployeeDBContext employeeDBcontext) + { + _config = config; + _employeeDBContext = employeeDBcontext; + } + [AllowAnonymous] + [HttpPost] + public IActionResult Login([FromBody]CustomEmployee customEmployee) + { + IActionResult response = Unauthorized(); + var user = AuthenticateUser(customEmployee); + + if (user != null) + { + var tokenString = GenerateJSONWebToken(user); + response = Ok(new { token = tokenString }); + } + + return response; + } + + private string GenerateJSONWebToken(CustomEmployee customEmployee) + { + var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); + var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); + + + var claims = new[] + { + + new Claim("FName", customEmployee.FName ), + new Claim("Lname", customEmployee.Lname), + new Claim("Email", customEmployee.Email) + }; + + var token = new JwtSecurityToken(_config["Jwt:Issuer"], + _config["Jwt:Issuer"], + claims, + expires: DateTime.Now.AddMinutes(2400), + signingCredentials: credentials); + + return new JwtSecurityTokenHandler().WriteToken(token); + } + + private CustomEmployee AuthenticateUser(CustomEmployee customEmployee) + { + CustomEmployee user = null; + + //Validate the User Credentials + //Demo Purpose, I have Passed HardCoded User Information + TEmployee employee = _employeeDBContext.TEmployee.Where(x => x.Email == customEmployee.Email && x.Passwrd == customEmployee.Passwrd).FirstOrDefault(); + + if (employee != null) + { + user = new CustomEmployee { FName = employee.FName, Lname = employee.Lname, Email = employee.Email}; + } + return user; + } + } +} \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/api/SignupController.cs b/Faizan_Akhtar/employeeManagement/api/SignupController.cs new file mode 100644 index 0000000..d627d4c --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/api/SignupController.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EmployeeManagement.Custom_Models; +using EmployeeManagement.DbModels; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.IdentityModel.Tokens; + +namespace EmployeeManagement.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class SignupController : ControllerBase + { + EmployeeDBContext _employeeDBContext; + public SignupController(EmployeeDBContext employeeDBContext) + { + _employeeDBContext = employeeDBContext; + } + + [HttpPost] + public IActionResult CreateEmployee([FromBody]CustomEmployee customEmployee) + { + TEmployee employee = new TEmployee() + { + FName =customEmployee.FName, + Lname = customEmployee.Lname, + Email = customEmployee.Email, + Passwrd = customEmployee.Passwrd + + }; + _employeeDBContext.TEmployee.Add(employee); + _employeeDBContext.SaveChanges(); + return Ok("Employee Added"); + } + } +} + diff --git a/Faizan_Akhtar/employeeManagement/api/TEmployee.cs b/Faizan_Akhtar/employeeManagement/api/TEmployee.cs new file mode 100644 index 0000000..a605fb0 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/api/TEmployee.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace EmployeeManagement.DbModels +{ + public partial class TEmployee + { + public int EmpId { get; set; } + public string FName { get; set; } + public string Lname { get; set; } + public string Email { get; set; } + public string Passwrd { get; set; } + public string Designation { get; set; } + public string Project { get; set; } + public string Manager { get; set; } + public int? Salary { get; set; } + } +} diff --git a/Faizan_Akhtar/employeeManagement/assets/scripts/admin.js b/Faizan_Akhtar/employeeManagement/assets/scripts/admin.js new file mode 100644 index 0000000..fd2b990 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/assets/scripts/admin.js @@ -0,0 +1,57 @@ +function tryFunction() { + api(); +} + +function parseJwt (jwtToken) { + var base64Url = jwtToken.split('.')[1]; + var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); + var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }).join('')); + + return JSON.parse(jsonPayload); + +}; + +function api(){ + const xhr = new XMLHttpRequest(); + const url = "http://localhost:61496/api/Admin"; + xhr.open('GET', url); + xhr.responseType = 'json'; + + xhr.onload = () => { + let empDetail = xhr.response; + console.log(empDetail); + console.log(typeof(empDetail)); + printTable(empDetail); + }; + xhr.onerror = (err) =>{ + console.log(err); + }; + xhr.send(); +} + +function printTable(empDetail){ + + var columnLength = 10; + for(let j=0; j { + if (typeof(Storage) !== "undefined") { + localStorage.removeItem("JwtTOKEN"); + window.location.href = "./index.html"; + } else { + alert("Error - Browser Support"); + } + } +} \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/assets/scripts/login.js b/Faizan_Akhtar/employeeManagement/assets/scripts/login.js new file mode 100644 index 0000000..1dc1410 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/assets/scripts/login.js @@ -0,0 +1,58 @@ +function loginSubmit(){ + var email = document.getElementById("uname").value; + var passwrd = document.getElementById("pwd").value; + + var empLogin = { + email: email, + passwrd: passwrd, + }; + console.log("Plain object"+empLogin); + api(empLogin); + window.location.href = "./admin.html"; +} + +function parseJwt (jwtToken) { + var base64Url = jwtToken.split('.')[1]; + var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); + var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }).join('')); + + console.log(jsonPayload); + printToken(JSON.parse(jsonPayload)); + return JSON.parse(jsonPayload); + +}; + +function api(empLogin){ + let empObject = empLogin; + const xhr = new XMLHttpRequest(); + const url = "http://localhost:61496/api/Login"; + xhr.open('POST', url); + xhr.responseType = 'json'; + xhr.setRequestHeader("Content-Type", "application/json"); + console.log(JSON.stringify(empObject)); + xhr.onload = () => { + + let jwtToken = {}; + jwtToken = xhr.response.token; + console.log("Response----"+jwtToken); + parseJwt(jwtToken); + saveToken(jwtToken) + }; + xhr.onerror = (err) =>{ + console.log(err); + }; + xhr.send(JSON.stringify(empObject)); +} + +function printToken(jsonPayload){ + console.log(jsonPayload); +} +function saveToken(jwtToken){ + if(typeof(Storage) != "undefined"){ + localStorage.setItem("JwtToken", jwtToken); + } else { + console.log("Local Storage not found") + } +} \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/assets/scripts/signup.js b/Faizan_Akhtar/employeeManagement/assets/scripts/signup.js new file mode 100644 index 0000000..710fb86 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/assets/scripts/signup.js @@ -0,0 +1,28 @@ +function signupSubmit(){ + var fName = document.getElementById("fName").value; + var lName = document.getElementById("lName").value; + var email = document.getElementById("email").value; + var passwrd = document.getElementById("pwd").value; + + var emp = { + fName: fName, + lName: lName, + email: email, + passwrd: passwrd, + }; + console.log(emp); + api(emp); + window.location.href = "./admin.html"; +} + +function api(emp){ + let empObject = emp; + const xhr = new XMLHttpRequest(); + const url = "http://localhost:61496/api/Signup"; + xhr.open('POST', url); + xhr.responseType = 'json'; + xhr.setRequestHeader("Content-Type", "application/json"); + console.log(empObject); + console.log(JSON.stringify(empObject)); + xhr.send(JSON.stringify(empObject)); +} \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/assets/styles/main.css b/Faizan_Akhtar/employeeManagement/assets/styles/main.css new file mode 100644 index 0000000..8b1d834 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/assets/styles/main.css @@ -0,0 +1,55 @@ +#bodyID{ + background-image: linear-gradient(315deg, #7f53ac 0%, #647dee 74%); + height: 100vh; + width: 100vw; + display: flex; + align-items: center; + justify-content: center; +} + +#mainBox{ + height: 70%; + width: 80%; + background:white; + border-radius: 2rem; + display: flex; + align-items: center; + justify-content: center; +} + +#dashboardBody{ + background-image: linear-gradient(315deg, #7f53ac 0%, #647dee 74%); + height: 100vh; + width: 100vw; + display: flex; + align-items: center; + justify-content: center; +} + +#dashboardDiv{ + height: 90%; + width: 90%; + background:white; + border-radius: 2rem; + +} + +#formID{ + width: 70%; + height: 70%; +} +.nameDiv{ + display: flex; +} +#lastNameDiv{ + margin-left: 3rem; +} +#navbar { + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; + margin: 0; +} +.table{ + margin: 2rem 0rem; +} diff --git a/Faizan_Akhtar/employeeManagement/index.html b/Faizan_Akhtar/employeeManagement/index.html new file mode 100644 index 0000000..d657dad --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/index.html @@ -0,0 +1,30 @@ + + + + + + + Login Web App + + + + + +
+
+
+ + +
+
+ + +
+
+ +

+ Signup +
+
+ + \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/manager.html b/Faizan_Akhtar/employeeManagement/manager.html new file mode 100644 index 0000000..65cf365 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/manager.html @@ -0,0 +1,84 @@ + + + + + + + Manager Dashboard + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#EmpIDUsernameFirstNameLastNameDesignationProjectManagerRemove
1104faizan.akhtarFaizanAkhtarInternBootcampVishal + +
2104faizan.akhtarFaizanAkhtarInternBootcampVishal + +
+ +
+
+ + + + \ No newline at end of file diff --git a/Faizan_Akhtar/employeeManagement/signup.html b/Faizan_Akhtar/employeeManagement/signup.html new file mode 100644 index 0000000..e391146 --- /dev/null +++ b/Faizan_Akhtar/employeeManagement/signup.html @@ -0,0 +1,40 @@ + + + + + + + Signup Web App + + + + + +
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ + +
+ +

+ Login +
+
+ + \ No newline at end of file diff --git a/Faizan_Akhtar/profile-page/assets/styles/profile-page.css b/Faizan_Akhtar/profile-page/assets/styles/profile-page.css index 16d5425..07f3eeb 100644 --- a/Faizan_Akhtar/profile-page/assets/styles/profile-page.css +++ b/Faizan_Akhtar/profile-page/assets/styles/profile-page.css @@ -1,9 +1,40 @@ .jumbotron{ background-image: linear-gradient(to right, #fe5858, #ee9617); + } -#nameTitle{ - color:white; +h1{ + color:white !important; } p{ color: white; } +.overlay { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + height: 100%; + width: 100%; + opacity: 0; + transition: 2s ease; + border-radius: 1rem; + background-image: linear-gradient(to right, #fe5858, #ee9617); + } + + .thumbnail:hover .overlay { + opacity: 1; + } + + .text { + color: white; + font-size: 20px; + position: absolute; + top: 50%; + left: 50%; + -webkit-transform: translate(-50%, -50%); + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + text-align: center; + } + diff --git a/Faizan_Akhtar/profile-page/profile-page.html b/Faizan_Akhtar/profile-page/index.html similarity index 60% rename from Faizan_Akhtar/profile-page/profile-page.html rename to Faizan_Akhtar/profile-page/index.html index 027cca8..c8c28d2 100644 --- a/Faizan_Akhtar/profile-page/profile-page.html +++ b/Faizan_Akhtar/profile-page/index.html @@ -12,38 +12,59 @@
-

Faizan Akhtar

+

Faizan Akhtar

Undergrad from Sharda University

+
+
Hey! I am Faizan Akhtar. Undergrad from Sharda University
+
+
+
+ Technology that I have worked on are: Android Application Development, Java, Flutter +
+
+
+
Contact Me: 9910980327, 38faizan@gmail.com
+
+
+
Gaming and Gardening are my favourite past time. Road Rash, IGI, NFS, PUBG are ❤
+
+
+
Intrested in : JavaScript, C# .Net, Angular, AWS +
+
+
+
Projects: AQI Monitoring, Smart Policing App, School ERP System
+
diff --git a/Faizan_Akhtar/project1-tic-tac-toe/assets/scripts/tic-tac-toe.js b/Faizan_Akhtar/project1-tic-tac-toe/assets/scripts/tic-tac-toe.js index 6d64cf0..ae72261 100644 --- a/Faizan_Akhtar/project1-tic-tac-toe/assets/scripts/tic-tac-toe.js +++ b/Faizan_Akhtar/project1-tic-tac-toe/assets/scripts/tic-tac-toe.js @@ -16,9 +16,9 @@ function btnDisable(){ } } function setButton(button, gameSymbol){ - var btn = document.getElementById("btn"+button); - btn.innerHTML = gameSymbol; - btn.disabled = true; + var btn = document.getElementById("btn"+button); + btn.innerHTML = gameSymbol; + btn.disabled = true; checker(); } function gameFinished(box1, box2, box3){ diff --git a/Faizan_Akhtar/project1-tic-tac-toe/tic-tac-toe.html b/Faizan_Akhtar/project1-tic-tac-toe/index.html similarity index 100% rename from Faizan_Akhtar/project1-tic-tac-toe/tic-tac-toe.html rename to Faizan_Akhtar/project1-tic-tac-toe/index.html