change login btn : suseendhiran
This commit is contained in:
parent
59165504b8
commit
65ea397989
@ -6,7 +6,8 @@ require('dotenv').config();
|
||||
let dropdown = [];
|
||||
let column_name;
|
||||
let doc;
|
||||
const tempData = [];
|
||||
// use in addRow and getRow api
|
||||
let tempData = [];
|
||||
|
||||
|
||||
|
||||
@ -45,10 +46,14 @@ exports.getRow = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// console.log(req.query.email);
|
||||
email = "ajay@gmail.com"
|
||||
// req.query.email;
|
||||
// arr for ejs
|
||||
const empData = [];
|
||||
// clear array
|
||||
tempData = [];
|
||||
// clear temp data
|
||||
tempData = [];
|
||||
await doc.loadInfo();
|
||||
// Index of the sheet
|
||||
let sheet = doc.sheetsByIndex[0];
|
||||
@ -94,7 +99,7 @@ exports.getRow = async (req, res) =>
|
||||
"milan_shaka" : [...new Set(milan_shaka)],
|
||||
"poruppu" : [...new Set(poruppu)],
|
||||
"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
|
||||
}
|
||||
for (let index = 0; index < rows.length; index++) {
|
||||
@ -111,18 +116,25 @@ exports.getRow = async (req, res) =>
|
||||
tempData.push(obj);
|
||||
}
|
||||
};
|
||||
for (let index = 0; index < rows.length; index++) {
|
||||
const row = rows[index];
|
||||
if (row.email == email || row.Gatnayak == tempData[0]['email'] ) {
|
||||
var obj = {}
|
||||
for (let i = 0; i < column_name.length; i++){
|
||||
// get email position in dynamic array
|
||||
Object.assign( obj , { [column_name[i]] : row[column_name[i]] });
|
||||
}
|
||||
empData.push(obj);
|
||||
}
|
||||
};
|
||||
res.render( 'displaydata' , { "data" : empData , "dropdown" : dropdown} , function (err, html ) { res.send(html) });
|
||||
if (tempData.length > 0)
|
||||
{
|
||||
for (let index = 0; index < rows.length; index++) {
|
||||
const row = rows[index];
|
||||
if (row.email == email || row.Gatnayak == tempData[0]['email'] ) {
|
||||
var obj = {}
|
||||
for (let i = 0; i < column_name.length; i++){
|
||||
// get email position in dynamic array
|
||||
Object.assign( obj , { [column_name[i]] : row[column_name[i]] });
|
||||
}
|
||||
empData.push(obj);
|
||||
}
|
||||
};
|
||||
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) {
|
||||
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" });
|
||||
} //end of try catch
|
||||
@ -136,7 +148,6 @@ exports.addRow = async (req, res) =>
|
||||
try
|
||||
{
|
||||
newData = req.body.data;
|
||||
const empData = [];
|
||||
// key value mapping
|
||||
var obj = {}
|
||||
for (let i = 0; i < column_name.length; i++){
|
||||
|
||||
@ -818,10 +818,6 @@ select , option {
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// console.log(window.location.host);
|
||||
// console.log(window.location.protocol);
|
||||
// console.log(window.location.origin);
|
||||
|
||||
let oldValue = [];let newValue = [];let pos = [];
|
||||
|
||||
@ -851,7 +847,7 @@ $(document).on("click", "#add-new", function(){
|
||||
// add data in googlesheet using ajax
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/api/addRow",
|
||||
url: ''+ window.location.origin +'/gsheet/api/addRow',
|
||||
data: { data : newValue },
|
||||
success: function(response) {
|
||||
if (response.status == 200 && response.statusCode == 1) {
|
||||
@ -906,7 +902,7 @@ $(document).on("click", "#up", function(){
|
||||
// update data in googlesheet using ajax
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: ''+ window.location.origin +'/api/updateRow',
|
||||
url: ''+ window.location.origin +'/gsheet/api/updateRow',
|
||||
data: { Old : oldValue , New : newValue },
|
||||
success: function(response) {
|
||||
if (response.status == 200) { alert("updated") }
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
function handleCredentialResponse(response) {
|
||||
const responsePayload = JSON.parse(atob(response.credential.split('.')[1]));
|
||||
// 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 () {
|
||||
@ -87,7 +87,7 @@ img {
|
||||
.form {
|
||||
background-color: #455a64;
|
||||
width: 100%;
|
||||
height: 1100px;
|
||||
height: 1500px;
|
||||
margin: 0px auto 10px auto;
|
||||
padding: 30px;
|
||||
/* border-radius: 8px; */
|
||||
@ -104,8 +104,8 @@ h3{
|
||||
}
|
||||
#buttonDiv{
|
||||
top: 150px;
|
||||
margin-left: 49%;
|
||||
transform: scale(2.5);
|
||||
margin-left: 35%;
|
||||
transform: scale(1.5);
|
||||
position: relative;
|
||||
}
|
||||
p{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user