-
Notifications
You must be signed in to change notification settings - Fork 10
Adminpanel #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
horaanchal
wants to merge
18
commits into
cybergroupdevs:master
Choose a base branch
from
horaanchal:Adminpanel
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adminpanel #33
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4b2baca
panel code
horaanchal d94a6a1
Merge branch 'master' of https://github.com/horaanchal/BootcampJan202…
horaanchal 9829f54
Db And VS Code added with modifications in UI
horaanchal 50b2253
Add on functionalities
horaanchal 4df63c4
new features
horaanchal a9b634c
UI improvise
horaanchal e51d957
update, delete by admin functionality added
horaanchal c4610bb
.gitignore added
horaanchal 82a5751
gitignore
horaanchal 6e0c6a7
Revert "gitignore"
horaanchal a912b05
naming convention followed
horaanchal 57cc990
Jwt functionality added
horaanchal 2a94458
WebApplicationPanel.DbModels removed
horaanchal 369974b
extra files added in gitignore
horaanchal 0a30582
Revert "extra files added in gitignore"
horaanchal 1732f6c
file deleted
horaanchal 4df4421
deleted .swp file
horaanchal d25cd1b
deleted not required gitignore file
horaanchal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added
BIN
+4 KB
Anchal_Hora/CRUD_Operation/.vs/ConsoleApp1/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file added
BIN
+32 KB
Anchal_Hora/CRUD_Operation/.vs/ConsoleApp1/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file added
BIN
+933 KB
Anchal_Hora/CRUD_Operation/.vs/ConsoleApp1/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added
BIN
+1.93 MB
Anchal_Hora/panel/.vs/WebApplicationPanel/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file added
BIN
+32 KB
Anchal_Hora/panel/.vs/WebApplicationPanel/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file added
BIN
+1.78 MB
Anchal_Hora/panel/.vs/WebApplicationPanel/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| CREATE TABLE EmpInformation(SNo int primary key, Projectid VARCHAR(200) , name VARCHAR(500) ,email VARCHAR(200) UNIQUE , [PASSWORD] VARCHAR(200) , [ROLE] VARCHAR(500), ContactNo bigint, ProjectName VARCHAR(200) ); | ||
|
|
||
| INSERT INTO EmpInformation VALUES ('1', 'P1', 'Anchal','horaanchal@gmail.com', 'anchal', 'User1', '6656676878', 'Web development'); | ||
| INSERT INTO EmpInformation VALUES ('2', 'P1', 'Anjali','horaanjali@gmail.com', 'anjali', 'User2', '7867665676', 'Web development'); | ||
| INSERT INTO EmpInformation VALUES ('3', 'P2', 'Ankush','horaankush@gmail.com', 'ankush', 'User3', '6656566766', 'AI'); | ||
| INSERT INTO EmpInformation VALUES ('4', 'P2', 'Resham','horaresham@gmail.com', 'resham', 'User4', '8990876774','AI'); | ||
| INSERT INTO EmpInformation VALUES ('5', 'P1', 'Ansh','horaansh@gmail.com', 'ansh', 'Reporting Manager1', '7545347667', 'Web development'); | ||
| INSERT INTO EmpInformation VALUES ('6', 'P2', 'Aditya','horaaditya@gmail.com', 'aditya', 'Reporting Manager2', '6378656789', 'AI'); | ||
| INSERT INTO EmpInformation VALUES ('7','', 'Raghav','horaraghavl@gmail.com', 'raghav', 'Admin', '5653424789',''); | ||
|
|
||
| SELECT * from EmpInformation ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| function func(){ | ||
| console.log("Hello Bhai lpg"); | ||
| window.location.href = "./admin/index.html"; | ||
| console.log("Hello Bhai b ehen"); | ||
| } | ||
| //document.getElementById("button").addEventListener("click",Gettoken) | ||
| function Gettoken(){ | ||
|
|
||
| var Sno=parseInt(document.getElementById("inputid").value); | ||
| var Username=document.getElementById("inputName").value; | ||
| var Email=document.getElementById("inputEmail").value; | ||
| var Password=document.getElementById("inputPassword").value; | ||
|
|
||
|
|
||
| var get = { | ||
| "Sno":Sno, | ||
| "Name":Username, | ||
| "Email":Email, | ||
| "Password":Password | ||
| }; | ||
| console.log(get); | ||
| //sendHTTPReq('POST', "http://localhost:51391/api/Panel", json).then(x => func() ); | ||
| var xhr= new XMLHttpRequest(); | ||
| var url="http://localhost:51391/api/Login"; | ||
| xhr.open('POST', url,true); | ||
| xhr.responseType='json'; | ||
| xhr.setRequestHeader('Content-type','application/json'); | ||
| console.log(JSON.stringify(get)); | ||
| xhr.onload = () => { | ||
| console.log(xhr.status); | ||
| //var jwtToken = xhr.response.token; | ||
|
|
||
| }; | ||
| xhr.send(JSON.stringify(get)); | ||
| } | ||
|
|
||
| // //console.log("Plain Object -- "+ get); | ||
| // apiRequest(get) | ||
|
|
||
| // } | ||
| // function apiRequest(get){ | ||
| // let getObject = get; | ||
| // //console.log("object in apirequest getObject); | ||
| // const xhr= new XMLHttpRequest(); | ||
| // const url="http://localhost:51391/api/Login"; | ||
| // xhr.open('POST', url); | ||
| // xhr.responseType='json'; | ||
| // xhr.setRequestHeader('Content-type','application/json'); | ||
| // //console.log(JSON.stringify(getObject)); | ||
| // debugger; | ||
| // xhr.onload = () => { | ||
| // console.log(xhr.status); | ||
| // //var jwtToken = xhr.response.token; | ||
|
|
||
| // }; | ||
| // xhr.send(JSON.stringify(json)); | ||
| // } | ||
| // // let jToken = {}; | ||
| // // jToken = xhr.response.token; | ||
| // // //console.log(xhr.response.token); | ||
| // // console.log(xhr.status); | ||
| // // //console.log(xhr.response); | ||
| // // console.log(jToken); | ||
| // // // var jwtToken = xhr.response.token; | ||
|
|
||
| // // }; | ||
| // // //console.log("object in apiRequest"+JSON.stringify(get)); | ||
| // // debugger; | ||
| // // xhr.send(JSON.stringify(get)); | ||
| // // } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio 15 | ||
| VisualStudioVersion = 15.0.28307.1000 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplicationPanel", "WebApplicationPanel\WebApplicationPanel.csproj", "{EC1659EB-707D-416C-8BD0-AD72DD2CCE40}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {6291CE64-2D3B-4B27-BB96-989FDEF68E3B} | ||
| EndGlobalSection | ||
| EndGlobal |
94 changes: 94 additions & 0 deletions
94
Anchal_Hora/panel/WebApplicationPanel/Controllers/LoginController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IdentityModel.Tokens.Jwt; | ||
| using System.Linq; | ||
| using System.Security.Claims; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.IdentityModel.Tokens; | ||
| using WebApplicationPanel.DbModels; | ||
|
|
||
| // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 | ||
|
|
||
| namespace WebappAPItype.Controllers | ||
| { | ||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
|
|
||
| public class LoginController : Controller | ||
| { | ||
| private panelContext _panelcontext; | ||
| private IConfiguration _config; | ||
| private panelContext _panelContext; | ||
|
|
||
| public LoginController(IConfiguration config, panelContext panelcontext) | ||
|
|
||
| { | ||
| _panelcontext = panelcontext; | ||
| _config = config; | ||
| } | ||
|
|
||
| [HttpPost] | ||
| public IActionResult Login([FromBody] WebApplicationPanel.DbModels.EmpInformation login) | ||
|
horaanchal marked this conversation as resolved.
Outdated
|
||
| { | ||
| IActionResult response = Unauthorized(); | ||
| var user = AuthenticateUser(login); | ||
|
|
||
| if (user != null) | ||
| { | ||
| var tokenString = GenerateJSONWebToken(user); | ||
| response = Ok(new { token = tokenString }); | ||
| } | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
| //private object AuthenticateUser(EmpInformation login) | ||
| //{ | ||
| // throw new NotImplementedException(); | ||
| //} | ||
|
|
||
| private object GenerateJSONWebToken(object user) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| //private object AuthenticateUser(DbModels.UserInformation login) | ||
| //{ | ||
| // throw new NotImplementedException(); | ||
| //} | ||
|
|
||
| private string GenerateJSONWebToken(EmpInformation userInfo) | ||
| { | ||
| var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); | ||
| var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); | ||
| var claims = new[] { | ||
| new Claim("Name", userInfo.Name), | ||
| new Claim("Email", userInfo.Email), | ||
| new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) | ||
| }; | ||
|
|
||
|
|
||
| var token = new JwtSecurityToken(_config["Jwt:Issuer"], | ||
| _config["Jwt:Issuer"], | ||
| claims, | ||
| expires: DateTime.Now.AddMinutes(120), | ||
| signingCredentials: credentials); | ||
|
|
||
| return new JwtSecurityTokenHandler().WriteToken(token); | ||
| } | ||
|
|
||
| private WebApplicationPanel.DbModels.EmpInformation AuthenticateUser(WebApplicationPanel.DbModels.EmpInformation login) | ||
| { | ||
| EmpInformation user = _panelcontext.EmpInformation.Where(u => u.Sno == login.Sno && u.Password == login.Password).FirstOrDefault(); | ||
| if (user != null) | ||
| { | ||
| user = new WebApplicationPanel.DbModels.EmpInformation { Email = user.Email, Name=user.Name }; | ||
| } | ||
| return user; | ||
| } | ||
| } | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
Anchal_Hora/panel/WebApplicationPanel/Controllers/Panel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace WebApplicationPanel.Controllers | ||
| { | ||
| internal class Panel | ||
| { | ||
| public int Sno { get; internal set; } | ||
| public int Username { get; internal set; } | ||
| public string Emailid { get; internal set; } | ||
| public string Password { get; internal set; } | ||
| } | ||
| } |
83 changes: 83 additions & 0 deletions
83
Anchal_Hora/panel/WebApplicationPanel/Controllers/PanelController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Http; | ||
| using System.Configuration; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using WebApplicationPanel.DbModels; | ||
| using WebappAPItype.CustomModels; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| namespace WebApplicationPanel.Controllers | ||
| { | ||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
|
|
||
|
horaanchal marked this conversation as resolved.
|
||
|
|
||
| public class PanelController : ControllerBase | ||
| { | ||
| panelContext _panelContext; | ||
|
|
||
| //private object panelContext; | ||
| //private object panel; | ||
|
|
||
| public PanelController(panelContext panelContext) | ||
| { | ||
| _panelContext = panelContext; | ||
| } | ||
|
|
||
| // [HttpGet] | ||
| //public IActionResult heyAanchal() | ||
| //{ | ||
|
horaanchal marked this conversation as resolved.
Outdated
|
||
| // return Ok("Yipeee-Ke-Yay"); | ||
| //} | ||
|
|
||
|
|
||
| [HttpPost] | ||
| public IActionResult Createpanel([FromBody]PanelRequest panelRequest) | ||
| { | ||
| EmpInformation panel = new EmpInformation(); | ||
| panel.Sno = panelRequest.Sno; | ||
| panel.Name = panelRequest.Name; | ||
| panel.Email = panelRequest.Email; | ||
| panel.Password = panelRequest.Password; | ||
|
|
||
| _panelContext.EmpInformation.Add(panel); | ||
| _panelContext.SaveChanges(); | ||
| return Ok("Employee Added"); | ||
|
|
||
| } | ||
|
|
||
| [HttpPut("{id}")] | ||
|
|
||
| public ActionResult Put(int id, [FromBody]PanelRequest panelRequest) | ||
| { | ||
| EmpInformation panel = _panelContext.EmpInformation.Find(id); | ||
| panel.Email = panelRequest.Email; | ||
| panel.Name = panelRequest.Name; | ||
| panel.Password = panelRequest.Password; | ||
| // _panelContext.EmpInformation.Update(panel); | ||
| _panelContext.SaveChanges(); | ||
| return Ok("Employee updated"); | ||
|
|
||
| } | ||
|
|
||
| [HttpDelete("{id}")] | ||
|
|
||
| public ActionResult<string> Delete(int id) | ||
| { | ||
| EmpInformation output = _panelContext.EmpInformation.Where(x => x.Sno == id).FirstOrDefault(); | ||
| if (output == null) | ||
| { | ||
| return NotFound(); | ||
| } | ||
| //EmpInformation e = new EmpInformation { Sno = id }; | ||
|
|
||
| _panelContext.EmpInformation.Remove(output); | ||
| _panelContext.SaveChanges(); | ||
| return Ok("Employee Deleted"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
20 changes: 20 additions & 0 deletions
20
Anchal_Hora/panel/WebApplicationPanel/CustomModels/PanelRequest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace WebappAPItype.CustomModels | ||
| { | ||
| public class PanelRequest | ||
| { | ||
| public int Sno { get; set; } | ||
| public string Projectid { get; set; } | ||
| public string Name { get; set; } | ||
| public string Email { get; set; } | ||
| public string Password { get; set; } | ||
| public string Role { get; set; } | ||
| public long? ContactNo { get; set; } | ||
| public string ProjectName { get; set; } | ||
|
|
||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
Anchal_Hora/panel/WebApplicationPanel/DbModels/EmpInformation.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace WebApplicationPanel.DbModels | ||
| { | ||
| public partial class EmpInformation | ||
| { | ||
| public int Sno { get; set; } | ||
| public string Projectid { get; set; } | ||
| public string Name { get; set; } | ||
| public string Email { get; set; } | ||
| public string Password { get; set; } | ||
| public string Role { get; set; } | ||
| public long? ContactNo { get; set; } | ||
| public string ProjectName { get; set; } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.