From f46290abf63d3322336eeb4623f17d0a0e4bdd3f Mon Sep 17 00:00:00 2001 From: Sai Sudheer Date: Fri, 9 Dec 2022 17:33:06 +0530 Subject: [PATCH] new changes --- assets/js/base.js | 22 ++-- assets/js/forgotpassword.js | 237 ++++++++++++++++++------------------ assets/js/home.js | 25 +--- assets/js/list.index.js | 189 ++++++++++++++++++++-------- assets/js/login.js | 186 ++++++++++++++-------------- assets/js/setting.js | 3 + authentication/index.html | 11 +- login/index.html | 7 +- 8 files changed, 385 insertions(+), 295 deletions(-) create mode 100644 assets/js/setting.js diff --git a/assets/js/base.js b/assets/js/base.js index 7016a2b..07de321 100644 --- a/assets/js/base.js +++ b/assets/js/base.js @@ -1,7 +1,13 @@ -const serverUrl = 'http://localhost:1188/'; -let _baseUserInfo = atob(document.cookie.split('=')[1]); -let baseUserInfo = 'JSON.parse(_baseUserInfo).result'; -let baseSessionId = 'baseUserInfo.sessionId'; +import { + decrypt +} from "./cookiehelper.js"; +import { + _serverUrl +} from "./setting.js"; + +let serverUrl = _serverUrl(); +let baseUserInfo = decrypt(document.cookie.split('=')[1]); +let baseSessionId = baseUserInfo.sessionId; export function getData(url) { var datastr = null; @@ -16,9 +22,9 @@ export function getData(url) { cache: true, jsonp: false, data: datastr, - beforeSend: function (xhr) { + beforeSend: function(xhr) { if (baseUserInfo != undefined && baseUserInfo != null) { - xhr.setRequestHeader("Authorization", "Basic " + baseSessionId); + xhr.setRequestHeader("Authorization", "Basic " + JSON.parse(baseUserInfo).sessionId); xhr.setRequestHeader('geoposition', 0 + ':' + 0); } } @@ -36,9 +42,9 @@ export function getDataObj(url, data, async, type) { //url, data, true, "POST" traditional: true, crossDomain: true, async: async, - beforeSend: function (xhr) { + beforeSend: function(xhr) { if (baseUserInfo != undefined && baseUserInfo != null) { - xhr.setRequestHeader('Authorization', 'Basic ' + baseSessionId); + xhr.setRequestHeader('Authorization', 'Basic ' + JSON.parse(baseUserInfo).sessionId); xhr.setRequestHeader('geoposition', 0 + ':' + 0); } } diff --git a/assets/js/forgotpassword.js b/assets/js/forgotpassword.js index 788a028..674da5e 100644 --- a/assets/js/forgotpassword.js +++ b/assets/js/forgotpassword.js @@ -1,147 +1,142 @@ -const serverUrl = 'http://localhost:3088/'; +const serverUrl = 'http://localhost:3086/'; let otpid; let sendotp; let unibaseid; async function showOtpBox() { let inputdetails = document.getElementById('txt_PhoneorMail').value; - - let sendnumber = await fetch(serverUrl + 'account/getuserbyphoneormail/'+inputdetails+'/'+inputdetails) - let textdata = await sendnumber.json(); - if(textdata.result != null){ - unibaseid = textdata.result.unibaseId; - var myHeaders = new Headers(); - myHeaders.append("Content-Type", "application/json"); - - var raw = JSON.stringify({ - "FirstName": "", - "LastName": "", - "ContactNumber": "", - "Email": "", - "TenantName": "", - "ContactOrEmail": inputdetails, - "IsSignup": false, - "IsRegisterUser": false, - "IsForgotPswd": true, - "UnibaseId": unibaseid, - "OtpId": 0, - "UserOtp": "" - }); - - var requestOptions = { - method: 'POST', - headers: myHeaders, - body: raw, - redirect: 'follow' - }; - - fetch(serverUrl + 'account/sendotp', requestOptions) - .then(response => response.text()) - .then(function(result){ - optid = result; - document.getElementById('div_ForgotPswd').style.display = 'none'; - document.getElementById('modal_Otp').style.display = 'block'; + + let sendnumber = await fetch(serverUrl + 'account/getuserbyphoneormail/' + inputdetails + '/' + inputdetails) + let textdata = await sendnumber.json(); + if (textdata.result != null) { + unibaseid = textdata.result.unibaseId; + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + + var raw = JSON.stringify({ + "FirstName": "", + "LastName": "", + "ContactNumber": "", + "Email": "", + "TenantName": "", + "ContactOrEmail": inputdetails, + "IsSignup": false, + "IsRegisterUser": false, + "IsForgotPswd": true, + "UnibaseId": unibaseid, + "OtpId": 0, + "UserOtp": "" + }); + + var requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' + }; + + fetch(serverUrl + 'account/sendotp', requestOptions) + .then(response => response.text()) + .then(function(result) { + optid = result; + document.getElementById('div_ForgotPswd').style.display = 'none'; + document.getElementById('modal_Otp').style.display = 'block'; + document.getElementById('div_ValidationSummary').innerHTML = ""; + }) + .catch(error => console.log('error', error)); + } else { + let html = '
Error ! Email/Phonenumber does not exist
'; document.getElementById('div_ValidationSummary').innerHTML = ""; - }) - .catch(error => console.log('error', error)); - } - else{ - let html = '
Error ! Email/Phonenumber does not exist
' ; - document.getElementById('div_ValidationSummary').innerHTML = ""; - let error = document.getElementById('div_ValidationSummary'); - error.insertAdjacentHTML('beforeend',html); + let error = document.getElementById('div_ValidationSummary'); + error.insertAdjacentHTML('beforeend', html); } } /*verify otp*/ - async function showPasswordBox() { - let inputdetails = document.getElementById('txt_Code').value; - if(inputdetails.length > 0){ +async function showPasswordBox() { + let inputdetails = document.getElementById('txt_Code').value; + if (inputdetails.length > 0) { var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); var raw = JSON.stringify({ - "FirstName": "", - "LastName": "", - "ContactNumber": "", - "Email": "", - "TenantName": "", - "ContactOrEmail": "", - "IsForgotPswd": false, - "IsRegisterUser": false, - "IsSignup": true, - "UnibaseId": "", - "OtpId": optid, - "UserOtp": inputdetails + "FirstName": "", + "LastName": "", + "ContactNumber": "", + "Email": "", + "TenantName": "", + "ContactOrEmail": "", + "IsForgotPswd": false, + "IsRegisterUser": false, + "IsSignup": true, + "UnibaseId": "", + "OtpId": optid, + "UserOtp": inputdetails }); - + var requestOptions = { - method: 'POST', - headers: myHeaders, - body: raw, - redirect: 'follow' + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' }; - + fetch(serverUrl + 'account/verifyotp', requestOptions) - .then(response => response.text()) - .then(function(result){ - let data = JSON.parse(result); - if(data.result.contactConfirmed == true){ - document.getElementById('modal_Otp').style.display = 'none'; - document.getElementById('div_ResetPswd').style.display = 'block'; - document.getElementById('div_ValidationSummary').innerHTML = ""; - }else{ - let html = '
Error ! Enter Valid OTP
' ; - document.getElementById('div_ValidationSummary').innerHTML = ""; - let error = document.getElementById('div_ValidationSummary'); - error.insertAdjacentHTML('beforeend',html); - } - }) - .catch(error => console.log('error', error)); - }else{ + .then(response => response.text()) + .then(function(result) { + let data = JSON.parse(result); + if (data.result.contactConfirmed == true) { + document.getElementById('modal_Otp').style.display = 'none'; + document.getElementById('div_ResetPswd').style.display = 'block'; + document.getElementById('div_ValidationSummary').innerHTML = ""; + } else { + let html = '
Error ! Enter Valid OTP
'; + document.getElementById('div_ValidationSummary').innerHTML = ""; + let error = document.getElementById('div_ValidationSummary'); + error.insertAdjacentHTML('beforeend', html); + } + }) + .catch(error => console.log('error', error)); + } else { } - + } + function showSuccessBox() { - let txt_NewPassword = document.getElementById('txt_NewPassword').value; - let txt_ConfirmPassword = document.getElementById('txt_ConfirmPassword').value; - if(txt_NewPassword == txt_ConfirmPassword){ - var myHeaders = new Headers(); -myHeaders.append("Content-Type", "application/json"); -var raw = JSON.stringify({ - "Password": txt_NewPassword, - "UserName": unibaseid -}); -var requestOptions = { - method: 'POST', - headers: myHeaders, - body: raw, - redirect: 'follow' -}; -fetch(serverUrl + 'account/updatepassword', requestOptions) - .then(response => response.text()) - .then(function(result){ - let updatepassword = JSON.parse(result); - let message = updatepassword.message; - if(message == 'Password Updated Successfully'){ + let txt_NewPassword = document.getElementById('txt_NewPassword').value; + let txt_ConfirmPassword = document.getElementById('txt_ConfirmPassword').value; + if (txt_NewPassword == txt_ConfirmPassword) { + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + var raw = JSON.stringify({ + "Password": txt_NewPassword, + "UserName": unibaseid + }); + var requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' + }; + fetch(serverUrl + 'account/updatepassword', requestOptions) + .then(response => response.text()) + .then(function(result) { + let updatepassword = JSON.parse(result); + let message = updatepassword.message; + if (message == 'Password Updated Successfully') { + document.getElementById('div_ValidationSummary').innerHTML = ""; + document.getElementById('div_ResetPswd').style.display = 'none'; + document.getElementById('div_SuccessMsg').style.display = 'block'; + } + }) + .catch(error => console.log('error', error)); + + } else { + let html = '
Error ! Password Does not Match
'; document.getElementById('div_ValidationSummary').innerHTML = ""; - document.getElementById('div_ResetPswd').style.display = 'none'; - document.getElementById('div_SuccessMsg').style.display = 'block'; + let error = document.getElementById('div_ValidationSummary'); + error.insertAdjacentHTML('beforeend', html); } - } - ) - .catch(error => console.log('error', error)); - - }else{ - let html = '
Error ! Password Does not Match
' ; - document.getElementById('div_ValidationSummary').innerHTML = ""; - let error = document.getElementById('div_ValidationSummary'); - error.insertAdjacentHTML('beforeend',html); - } - -} - - - +} \ No newline at end of file diff --git a/assets/js/home.js b/assets/js/home.js index 7c19c89..62f92a9 100644 --- a/assets/js/home.js +++ b/assets/js/home.js @@ -1,22 +1,9 @@ -import { getCookie } from "./cookiehelper.js"; -import { initListIndex } from "./list.index.js"; +import { + getCookie +} from "./cookiehelper.js"; +import { + initListIndex +} from "./list.index.js"; initListIndex(); -$('#detailBtn').click(function () { - $('.bdy-ul').addClass('d-none'); - // Unibase.Themes.Compact.Components.Notification.Instance().loadReminderDetails(105013010001972,105010260000090,'Details','null',6,0,null) - const cookie = getCookie('_idty'); - if (cookie) { - const { - unibaseId, - tenantId, - userId - } = JSON.parse(cookie); - debugger; - $('#detailIframe').html( - `` - ); - } - -}); \ No newline at end of file diff --git a/assets/js/list.index.js b/assets/js/list.index.js index 4cfe177..dc7d2ea 100644 --- a/assets/js/list.index.js +++ b/assets/js/list.index.js @@ -1,53 +1,94 @@ /*Data loading start here*/ +import { + getCookie +} from "./cookiehelper.js"; -import { getData, getDataObj } from "./base.js"; - - +import { + getData, + getDataObj +} from "./base.js"; function loadData() { - getData('apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/6/PageSize/20').then(function (result) { + getData( + "apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/6/PageSize/20" + ).then(function(result) { let response = JSON.parse(result.result); - if (response.length != 0) { // Notifcations + if (response.length != 0) { + // Notifcations let bdyUI = '
'; for (var i = 0; i < response.length; i++) { - bdyUI += `
  • -
    -
  • +
    + -
    -
    +
    +
  • `; } - bdyUI += '
    ' - $('.bdy-ul').append(bdyUI); - $('.notifiListItms').on('click', function () { - let _this = $(this).parents('.item-li'); - let obj = { "FromDate": "2022/11/30", "InstalledAppId": Number($(_this).attr('data-installedAppId')), "RecordId": Number($(_this).attr('data-ref')), "ToDate": "2022/11/30" }; + bdyUI += ""; + $(".bdy-ul").append(bdyUI); + + $(".notifiListItms").on("click", function() { + let _this = $(this).parents(".item-li"); + let obj = { + FromDate: "2022/11/30", + InstalledAppId: Number($(_this).attr("data-installedAppId")), + RecordId: Number($(_this).attr("data-ref")), + ToDate: "2022/11/30", + }; //let obj = { "FromDate": "2022/11/30", "InstalledAppId": 102530270000109, "RecordId": 102533490346298, "ToDate": "2022/11/30" }; - getDataObj('apis/v4/unibase/platform/widgets/getdefaultwidget', obj, true, "POST").then(function (response) { + getDataObj( + "apis/v4/unibase/platform/widgets/getdefaultwidget", + obj, + true, + "POST" + ).then(function(response) { let res = JSON.parse(response.result), - html = ''; - if (response.message == '200' && response.errors == null) { + html = ""; + if (response.message == "200" && response.errors == null) { html = `' + html += ""; } else { html += ``; } - html += ``; + html += `
  • Details-Page
  • `; } else { html += `` + `; } - $(_this).find('.accordion-body').html(html); + $(_this).find(".accordion-body").html(html); + detailClick(); }); - }) + }); } - }) - getData('apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/1/PageSize/20').then(function (tskResp) { - let response = JSON.parse(tskResp.result) + }); + getData( + "apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/1/PageSize/20" + ).then(function(tskResp) { + let response = JSON.parse(tskResp.result); if (response.length != 0) { let _tskhtml = '
    '; for (var i = 0; i < response.length; i++) { - _tskhtml += `
  • -
    -
  • +
    + -
    -
    +
    +
    • Confirm
    • Reject
    • Close
    • +
    • Details-Page
  • `; } - _tskhtml += '
    ' - $('.bdy-ul').append(_tskhtml); + _tskhtml += ""; + $(".bdy-ul").append(_tskhtml); + detailClick() } }); } - - - - +export function detailClick(){ + $('.detailBtn').click(function() { + $('.bdy-ul').addClass('d-none'); + let installedAppId = +$(this).attr('data-appId'); + let recordId = +$(this).attr('data-recordId') + // Unibase.Themes.Compact.Components.Notification.Instance().loadReminderDetails(105013010001972,105010260000090,'Details','null',6,0,null) + const cookie = getCookie('_idty'); + if (cookie) { + const { + unibaseId, + tenantId, + userId + } = JSON.parse(cookie); + debugger; + $('#detailIframe').html( + `` + ); + + } + + }); +} export function initListIndex() { - let _userInfo = atob(document.cookie.split('=')[1]); - let userInfo = ' JSON.parse(_userInfo).result'; - let sessionId = 'userInfo.sessionId'; + let _userInfo = atob(document.cookie.split("=")[1]); + let userInfo = " JSON.parse(_userInfo).result"; + let sessionId = "userInfo.sessionId"; let usrinfoHTML = `
  • ${userInfo.name}
  • Cloud Settings
  • Help
  • Logoff
  • `; - $('.icn-circle').text(userInfo?.name?.charAt(0)?.toUpperCase()) - $('.uindtls').html(usrinfoHTML) + $(".icn-circle").text(userInfo?.name?.charAt(0)?.toUpperCase()); + $(".uindtls").html(usrinfoHTML); // List Page loading /*Data loading start here*/ - $('.mnNvIcn').click(function () { - $('.lft-nav-bar').toggleClass('lft-nav-bar-Wrap'); - $('.ctr-lst-pge').toggleClass('lft-nav-bar-Wrap'); + $(".mnNvIcn").click(function() { + $(".lft-nav-bar").toggleClass("lft-nav-bar-Wrap"); + $(".ctr-lst-pge").toggleClass("lft-nav-bar-Wrap"); }); loadData(); } \ No newline at end of file diff --git a/assets/js/login.js b/assets/js/login.js index e67f998..2dc0be7 100644 --- a/assets/js/login.js +++ b/assets/js/login.js @@ -1,6 +1,14 @@ -import { setCookie } from "./cookiehelper.js"; +import { + setCookie +} from "./cookiehelper.js"; +import { + _serverUrl +} from "./setting.js"; + + +const serverUrl = _serverUrl(); + -const serverUrl = 'http://localhost:1188/'; const emailInputEl = document.getElementById('email'); const passwordInputEl = document.getElementById('password'); const emailErrEl = document.getElementById('emailErrMsg'); @@ -16,124 +24,124 @@ passwordContainerEl.style.display = 'none'; emailInputEl.focus(); function showPasswordBox() { - const email = emailInputEl.value; - if (validateEmailOrPhone()) { - emailContainerEl.style.display = 'none'; - passwordContainerEl.style.display = 'block'; - document.getElementById('entered-email').innerHTML = email; - passwordInputEl.focus(); - emailInputEl.classList.remove('error'); - emailErrEl.innerText = ''; - } else { - emailInputEl.classList.add('error'); - emailErrEl.innerText = 'Please enter valid email or phone'; - } + const email = emailInputEl.value; + if (validateEmailOrPhone()) { + emailContainerEl.style.display = 'none'; + passwordContainerEl.style.display = 'block'; + document.getElementById('entered-email').innerHTML = email; + passwordInputEl.focus(); + emailInputEl.classList.remove('error'); + emailErrEl.innerText = ''; + } else { + emailInputEl.classList.add('error'); + emailErrEl.innerText = 'Please enter valid email or phone'; + } } function validateEmailOrPhone() { - const value = emailInputEl.value.trim(); - const regx = /^[6-9]\d{9}$/; - if (value.includes('@') || regx.test(value)) { - return true; - } - return false; + const value = emailInputEl.value.trim(); + const regx = /^[6-9]\d{9}$/; + if (value.includes('@') || regx.test(value)) { + return true; + } + return false; } function togglePassword() { - const ele = document.getElementById('showPassword'); - const password = passwordInputEl; + const ele = document.getElementById('showPassword'); + const password = passwordInputEl; - if (password.value.length > 0) { - passwordInputEl.value = password.value; - password.focus(); - if (ele.checked) { - password.setAttribute('type', 'text'); - } else { - password.setAttribute('type', 'password'); + if (password.value.length > 0) { + passwordInputEl.value = password.value; + password.focus(); + if (ele.checked) { + password.setAttribute('type', 'text'); + } else { + password.setAttribute('type', 'password'); + } } - } } function onPasswordFocusOut() { - const passwordLabel = document.getElementById('passwordLabel'); - if (passwordInputEl.value.length > 0) { - passwordLabel.classList.add('password-fixed'); - } else { - passwordLabel.classList.remove('password-fixed'); - } + const passwordLabel = document.getElementById('passwordLabel'); + if (passwordInputEl.value.length > 0) { + passwordLabel.classList.add('password-fixed'); + } else { + passwordLabel.classList.remove('password-fixed'); + } } function onEmailFocusOut() { - const emailLabel = document.getElementById('emailLabel'); - if (emailInputEl.value.trim()) { - emailLabel.classList.add('password-fixed'); - } else { - emailLabel.classList.remove('password-fixed'); - } + const emailLabel = document.getElementById('emailLabel'); + if (emailInputEl.value.trim()) { + emailLabel.classList.add('password-fixed'); + } else { + emailLabel.classList.remove('password-fixed'); + } } function loginUser(email, password) { - const postData = JSON.stringify({ - UserName: email, - Password: password, - UnibaseId: '', - RememberMe: false, - }); - - const requestOptions = { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: postData, - redirect: 'follow', - }; - - fetch(serverUrl + 'account/login', requestOptions) - .then((response) => response.text()) - .then((result) => { - const data = JSON.parse(result); - if (data.status === 0) { - setCookie('_idty', JSON.stringify(data.result), 1); - window.location = '../authentication'; - } else { - passwordErrEl.innerText = data.message; - } - }) - .catch((error) => { - passwordErrEl.innerText = error; + const postData = JSON.stringify({ + UserName: email, + Password: password, + UnibaseId: '', + RememberMe: false, }); + + const requestOptions = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: postData, + redirect: 'follow', + }; + + fetch(serverUrl + 'account/login', requestOptions) + .then((response) => response.text()) + .then((result) => { + const data = JSON.parse(result); + if (data.status === 0) { + setCookie('_idty', JSON.stringify(data.result), 1); + window.location = '../authentication'; + } else { + passwordErrEl.innerText = data.message; + } + }) + .catch((error) => { + passwordErrEl.innerText = error; + }); } function validateLogin() { - const email = emailInputEl.value; - const password = passwordInputEl.value; - if (password.trim().length !== 0) { - loginUser(email, password); - } else { - passwordInputEl.classList.add('error'); - passwordErrEl.innerText = 'Please enter valid password'; - } + const email = emailInputEl.value; + const password = passwordInputEl.value; + if (password.trim().length !== 0) { + loginUser(email, password); + } else { + passwordInputEl.classList.add('error'); + passwordErrEl.innerText = 'Please enter valid password'; + } } function reEnterEmailClickHandler() { - emailContainerEl.style.display = 'block'; - passwordContainerEl.style.display = 'none'; - emailInputEl.focus(); + emailContainerEl.style.display = 'block'; + passwordContainerEl.style.display = 'none'; + emailInputEl.focus(); } function initializeEventListeners() { - emailNextBtn.addEventListener('click', showPasswordBox); + emailNextBtn.addEventListener('click', showPasswordBox); - showPasswordChk.addEventListener('click', togglePassword); + showPasswordChk.addEventListener('click', togglePassword); - passwordInputEl.addEventListener('focusout', onPasswordFocusOut); + passwordInputEl.addEventListener('focusout', onPasswordFocusOut); - emailInputEl.addEventListener('focusout', onEmailFocusOut); + emailInputEl.addEventListener('focusout', onEmailFocusOut); - loginSubmitBtn.addEventListener('click', validateLogin); + loginSubmitBtn.addEventListener('click', validateLogin); - renterEmailLink.addEventListener('click', reEnterEmailClickHandler); + renterEmailLink.addEventListener('click', reEnterEmailClickHandler); } -initializeEventListeners(); +initializeEventListeners(); \ No newline at end of file diff --git a/assets/js/setting.js b/assets/js/setting.js new file mode 100644 index 0000000..3719d50 --- /dev/null +++ b/assets/js/setting.js @@ -0,0 +1,3 @@ +export function _serverUrl() { + return 'http://localhost:3086/'; +} \ No newline at end of file diff --git a/authentication/index.html b/authentication/index.html index 68bb19e..83af26a 100644 --- a/authentication/index.html +++ b/authentication/index.html @@ -30,7 +30,7 @@
  • - +
  • @@ -92,6 +92,13 @@ - + \ No newline at end of file diff --git a/login/index.html b/login/index.html index 44011d9..e906733 100644 --- a/login/index.html +++ b/login/index.html @@ -25,7 +25,7 @@
    - +
    @@ -53,14 +53,13 @@
    - +