change login btn : suseendhiran

This commit is contained in:
suseendhiran17 2022-11-29 10:43:37 +05:30
parent 59165504b8
commit 65ea397989
3 changed files with 33 additions and 26 deletions

View File

@ -6,7 +6,8 @@ require('dotenv').config();
let dropdown = []; let dropdown = [];
let column_name; let column_name;
let doc; let doc;
const tempData = []; // use in addRow and getRow api
let tempData = [];
@ -45,10 +46,14 @@ exports.getRow = async (req, res) =>
{ {
try try
{ {
// console.log(req.query.email);
email = "ajay@gmail.com" email = "ajay@gmail.com"
// req.query.email;
// arr for ejs // arr for ejs
const empData = []; const empData = [];
// clear array
tempData = [];
// clear temp data
tempData = [];
await doc.loadInfo(); await doc.loadInfo();
// Index of the sheet // Index of the sheet
let sheet = doc.sheetsByIndex[0]; let sheet = doc.sheetsByIndex[0];
@ -94,7 +99,7 @@ exports.getRow = async (req, res) =>
"milan_shaka" : [...new Set(milan_shaka)], "milan_shaka" : [...new Set(milan_shaka)],
"poruppu" : [...new Set(poruppu)], "poruppu" : [...new Set(poruppu)],
"blood_group" : [...new Set(blood_group)], "blood_group" : [...new Set(blood_group)],
"ganavesh_2w_4w_basg" : ganavesh_2w_4w_basg, "ganavesh_2w_4w_basg" : [...new Set(ganavesh_2w_4w_basg)],
"new_index" : new_index "new_index" : new_index
} }
for (let index = 0; index < rows.length; index++) { for (let index = 0; index < rows.length; index++) {
@ -111,6 +116,8 @@ exports.getRow = async (req, res) =>
tempData.push(obj); tempData.push(obj);
} }
}; };
if (tempData.length > 0)
{
for (let index = 0; index < rows.length; index++) { for (let index = 0; index < rows.length; index++) {
const row = rows[index]; const row = rows[index];
if (row.email == email || row.Gatnayak == tempData[0]['email'] ) { if (row.email == email || row.Gatnayak == tempData[0]['email'] ) {
@ -123,6 +130,11 @@ exports.getRow = async (req, res) =>
} }
}; };
res.render( 'displaydata' , { "data" : empData , "dropdown" : dropdown} , function (err, html ) { res.send(html) }); res.render( 'displaydata' , { "data" : empData , "dropdown" : dropdown} , function (err, html ) { res.send(html) });
}
else
{
res.send('<p style="text-align:center;font-size: 4em;top: 510px;font-style:bold">No Data</p>');
}
} catch(err) { } catch(err) {
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }); res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" });
} //end of try catch } //end of try catch
@ -136,7 +148,6 @@ exports.addRow = async (req, res) =>
try try
{ {
newData = req.body.data; newData = req.body.data;
const empData = [];
// key value mapping // key value mapping
var obj = {} var obj = {}
for (let i = 0; i < column_name.length; i++){ for (let i = 0; i < column_name.length; i++){

View File

@ -819,10 +819,6 @@ select , option {
<script> <script>
// console.log(window.location.host);
// console.log(window.location.protocol);
// console.log(window.location.origin);
let oldValue = [];let newValue = [];let pos = []; let oldValue = [];let newValue = [];let pos = [];
// SI dynamic background-color // SI dynamic background-color
@ -851,7 +847,7 @@ $(document).on("click", "#add-new", function(){
// add data in googlesheet using ajax // add data in googlesheet using ajax
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/api/addRow", url: ''+ window.location.origin +'/gsheet/api/addRow',
data: { data : newValue }, data: { data : newValue },
success: function(response) { success: function(response) {
if (response.status == 200 && response.statusCode == 1) { if (response.status == 200 && response.statusCode == 1) {
@ -906,7 +902,7 @@ $(document).on("click", "#up", function(){
// update data in googlesheet using ajax // update data in googlesheet using ajax
$.ajax({ $.ajax({
type: "post", type: "post",
url: ''+ window.location.origin +'/api/updateRow', url: ''+ window.location.origin +'/gsheet/api/updateRow',
data: { Old : oldValue , New : newValue }, data: { Old : oldValue , New : newValue },
success: function(response) { success: function(response) {
if (response.status == 200) { alert("updated") } if (response.status == 200) { alert("updated") }

View File

@ -12,7 +12,7 @@
function handleCredentialResponse(response) { function handleCredentialResponse(response) {
const responsePayload = JSON.parse(atob(response.credential.split('.')[1])); const responsePayload = JSON.parse(atob(response.credential.split('.')[1]));
// window.location.replace(`http://localhost:8080/api/getRow?email=${responsePayload.email}`); // window.location.replace(`http://localhost:8080/api/getRow?email=${responsePayload.email}`);
window.location = `http://localhost:8080/api/getRow?email=${responsePayload.email}`; window.location = `${ window.location.origin }/api/getRow?email=${responsePayload.email}`;
} }
window.onload = function () { window.onload = function () {
@ -87,7 +87,7 @@ img {
.form { .form {
background-color: #455a64; background-color: #455a64;
width: 100%; width: 100%;
height: 1100px; height: 1500px;
margin: 0px auto 10px auto; margin: 0px auto 10px auto;
padding: 30px; padding: 30px;
/* border-radius: 8px; */ /* border-radius: 8px; */
@ -104,8 +104,8 @@ h3{
} }
#buttonDiv{ #buttonDiv{
top: 150px; top: 150px;
margin-left: 49%; margin-left: 35%;
transform: scale(2.5); transform: scale(1.5);
position: relative; position: relative;
} }
p{ p{