Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Anchal_Hora/nodejs/Login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
function login(){
window.location.href = "./admin/index.html";
}
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 json= {
"Sno":Sno,
"Name":Username,
"Email":Email,
"Password":Password
};
console.log(json);
//sendHTTPReq('POST', "http://localhost:3000/employees/login", json).then(x => func() );
var xhr= new XMLHttpRequest();
var url="http://localhost:3000/employees/login";
xhr.open('POST', url,true);
xhr.responseType='json';
xhr.setRequestHeader('Content-type','application/json');
console.log(JSON.stringify(json));
xhr.onload = () => {
console.log(xhr.status);
//var jwtToken = xhr.response.token;

};
xhr.send(JSON.stringify(json));
}
//saving token in local storage
function saveToken(token){
if(typeof Storage !=="undefined"){
localStorage.setItem("JWTtoken",token);
}
else{
console.log("Browser doesn't support");
}
decodeToken(token);
}

//for decoding the token

function decodeToken (token) {
var base64Url = token.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);
return JSON.parse(jsonPayload);
}

82 changes: 82 additions & 0 deletions Anchal_Hora/nodejs/UI/admin/create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://kit.fontawesome.com/222eef09a0.js" crossorigin="anonymous"></script>

<link href="https://fonts.googleapis.com/css?family=Lora&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../admin/styles/style.css">
<link rel="stylesheet" href="../admin/styles/admin.css">
<title>Manage admin</title>
</head>
<body>
<header>
<div class="logo">
<h1 class="logo-text"><span>Cyber</span>Group</h1>
</div>

<ul class="nav">
<li>
<a href="#">
<i class="fa fa-user"></i>
CyberGroup
<i class="fa fa-chevron-down" style="font-size: .8rem;"></i>
</a>
<ul>
<li><a href="index.html" class="logout">Dashboard</a></li>
<li><a href="../index.html" class="logout">Logout</a></li>
</ul>
</li>
</ul>
</header>

<div class="admin-wrapper">
<div class="left-sidebar">
<ul>
<li><a href="index.html">Manage admin</a></li>
<li><a href="../admin/index.html">Manage users</a></li>
<li><a href="../manager/index.html">Manage managers</a></li>
</ul>
</div>
<div class="admin-content">
<div class="button-group">
<a href="create.html" type="button" class="btn btn-big">Add user</a>
<a href="index.html" type="button" class="btn btn-big">Manage user</a>
</div>
<div class="content">
<h2 class="page-title">Add users</h2>
<form action="create.html" method="user">
<div>
<label>Sno</label>
<input type="int" name="sno" id="inputSno" class="text-input">
</div>
<div>
<label>Username</label>
<input type="text" name="title" id="inputName" class="text-input">
</div>
<div>
<label>Email</label>
<input type="email" name="email" id="inputEmail" class="text-input">
</div>
<div>
<label>Password</label>
<input type="password" name="password" id="inputPassword" class="text-input">
</div>

<div>
<button type="submit" class="btn btn-big" id="buttonsignup">Add user</button>
</div>
</form>

</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
<!-- <script src="../admin/js/scripts.js"></script> -->
<script src="../admin/js/post.js"></script>

</body>
</html>
79 changes: 79 additions & 0 deletions Anchal_Hora/nodejs/UI/admin/delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://kit.fontawesome.com/222eef09a0.js" crossorigin="anonymous"></script>

<link href="https://fonts.googleapis.com/css?family=Lora&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../admin/styles/style.css">
<link rel="stylesheet" href="../admin/styles/admin.css">
<title>Manage user</title>
</head>
<body>
<header>
<div class="logo">
<h1 class="logo-text"><span>Cyber</span>Group</h1>
</div>

<ul class="nav">
<li>
<a href="#">
<i class="fa fa-user"></i>
CyberGroup
<i class="fa fa-chevron-down" style="font-size: .8rem;"></i>
</a>
<ul>
<li><a href="index.html" class="logout">Dashboard</a></li>
<li><a href="../index.html" class="logout">Logout</a></li>
</ul>
</li>
</ul>
</header>

<div class="admin-wrapper">
<div class="left-sidebar">
<ul>
<li><a href="../user/index.html">Manage admin</a></li>
<li><a href="index.html">Manage users</a></li>
<li><a href="../manager/index.html">Manage managers</a></li>
</ul>
</div>
<div class="admin-content">
<div class="button-group">

<a href="index.html" type="button" class="btn btn-big">Manage user</a>
</div>

<div class="content">
<h2 class="page-title"> User Information</h2>
<form action="create.html" method="user">
<div>
<label>Sno</label>
<input type="int" name="Sno" class="text-input">
</div>
<div>
<label>Username</label>
<input type="text" name="username" class="text-input">
</div>
<div>
<label>Email</label>
<input type="email" name="email" class="text-input">
</div>
<div>
<label>Password</label>
<input type="password" name="password" class="text-input">
</div>

<div>
<button type="submit" class="btn btn-big" id="buttondelete">Delete Information</button>
</div>

</form>

</div>
</div>
</div>
<script src="../admin/js/delete.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</body>
</html>
74 changes: 74 additions & 0 deletions Anchal_Hora/nodejs/UI/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://kit.fontawesome.com/222eef09a0.js" crossorigin="anonymous"></script>

<link href="https://fonts.googleapis.com/css?family=Lora&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../admin/styles/style.css">
<link rel="stylesheet" href="../admin/styles/admin.css">
<title>Manage admin</title>
</head>
<body>
<header>
<div class="logo">
<h1 class="logo-text"><span>Cyber</span>Group</h1>
</div>

<ul class="nav">
<li>
<a href="#">
<i class="fa fa-user"></i>
CyberGroup
<i class="fa fa-chevron-down" style="font-size: .8rem;"></i>
</a>
<ul>
<li><a href="index.html" class="Dashboard">Dashboard</a></li>
<li><a href="../index.html" class="logout">Logout</a></li>
</ul>
</li>
</ul>
</header>

<div class="admin-wrapper">
<div class="left-sidebar">
<ul>
<li><a href="index.html">Manage admin</a></li>
<li><a href="../admin/index.html">Manage users</a></li>
<li><a href="../manager/index.html">Manage managers</a></li>
</ul>
</div>
<div class="admin-content">
<div class="button-group">
<a href="create.html" type="button" class="btn btn-big">Add user</a>
<a href="index.html" type="button" class="btn btn-big">Manage user</a>
<a href="view.html" type="button" class="btn btn-big">View user</a>
</div>

<div class="content">
<h2 class="page-title">Manage users</h2>
<table>
<thead>
<th>SNo.</th>
<th>User name</th>
<th colspan="2">Action</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Anchal</td>
<td><a href="update.html" class="update">update</a></td>
<td><a href="delete.html" class="delete">delete</a></td>
</tr>


</tbody>
</table>
</div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions Anchal_Hora/nodejs/UI/admin/js/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
document.getElementById("buttondelete").addEventListener("click",adminDeletedata)
function adminDeletedata(){

let id = document.getElementById("id").value;
console.log(id.value);

// Creating a XHR object
var xhr = new XMLHttpRequest();
let url = "https://localhost:3000/employees/"+id;


// open a connection
xhr.open("DELETE", url, true);

// Set the request header i.e. which type of content you are sending
xhr.setRequestHeader("Content-Type", "application/json");

// Create a state change callback
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
alert("deleted user")
console.log(url);
}
else{
alert("no user with such ID");
}
};

// Converting JSON data to string
var data = JSON.stringify({ "id": id.value});

// Sending data with the request
xhr.send(data);
}
27 changes: 27 additions & 0 deletions Anchal_Hora/nodejs/UI/admin/js/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function adminGet(){}

fetch('https://localhost:3000/employees')
.then(function (response) {
return response.json();
})
.then(function (data) {
appendData(data);
})
.catch(function (err) {
console.log(err);
});

function appendData(data)
{
var users = document.getElementById("users");
console.log(users);

for (var i = 0; i < data.length; i++) {
var div = document.createElement("div");
div.innerHTML = 'Name: ' + data[i].name + "Email :" + data[i].email + "Password :" + data[i].password + "ContactNo :" + data[i].contactno;
users.appendChild(div);
}
}



28 changes: 28 additions & 0 deletions Anchal_Hora/nodejs/UI/admin/js/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
document.getElementById("buttonsignup").addEventListener("click",adminPostdata);
function adminPostdata(){
var Sno=document.getElementById("inputSno").value;
var Username=document.getElementById("inputName").value;
var Email=document.getElementById("inputEmail").value;
var Password=document.getElementById("inputPassword").value;

var format={
"Sno":Sno,
"Name":Username,
"Email":Email,
"Password":Password
};
console.log(format);
//sendHTTPReq('POST', "http://localhost:3000/employees", json).then(x => func() );
var xhr= new XMLHttpRequest();
var url="http://localhost:3000/employees";
xhr.open('POST', url,true);
xhr.responseType='json';
xhr.setRequestHeader('Content-type','application/json');
console.log(JSON.stringify(format));
xhr.onload = () => {
console.log(xhr.status);
//var jwtToken = xhr.response.token;

};
xhr.send(JSON.stringify(format));
}
Loading