From 32821eb02c84d143d9d9078a17faaf1183e5b04b Mon Sep 17 00:00:00 2001 From: sachinganesh Date: Fri, 2 Dec 2022 18:05:35 +0530 Subject: [PATCH] module import and export --- assets/js/base.js | 16 +-- assets/js/cookiehelper.js | 10 +- assets/js/list.index.js | 242 ++++++++++++++++++++------------------ assets/js/login.js | 4 +- authentication/index.html | 32 ++--- index.html | 7 +- login/index.html | 8 +- 7 files changed, 163 insertions(+), 156 deletions(-) diff --git a/assets/js/base.js b/assets/js/base.js index d59d3d6..7016a2b 100644 --- a/assets/js/base.js +++ b/assets/js/base.js @@ -1,9 +1,9 @@ -const serverUrl = 'https://c01.bizgaze.app/'; +const serverUrl = 'http://localhost:1188/'; let _baseUserInfo = atob(document.cookie.split('=')[1]); -let baseUserInfo = JSON.parse(_baseUserInfo).result; -let baseSessionId = baseUserInfo.sessionId; +let baseUserInfo = 'JSON.parse(_baseUserInfo).result'; +let baseSessionId = 'baseUserInfo.sessionId'; -function getData(url) { +export function getData(url) { var datastr = null; var method = "GET"; let serviceurl = serverUrl + url; @@ -16,7 +16,7 @@ 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('geoposition', 0 + ':' + 0); @@ -25,7 +25,7 @@ function getData(url) { }); } -function getDataObj(url, data, async, type) { //url, data, true, "POST" +export function getDataObj(url, data, async, type) { //url, data, true, "POST" let serviceurl = serverUrl + url; return $.ajax({ @@ -36,7 +36,7 @@ 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('geoposition', 0 + ':' + 0); @@ -45,7 +45,7 @@ function getDataObj(url, data, async, type) { //url, data, true, "POST" }); } -function formatLocal(dateTime) { +export function formatLocal(dateTime) { var hou = new Date(dateTime).getHours(), sec, min, day, month, years; if (hou < 24) { diff --git a/assets/js/cookiehelper.js b/assets/js/cookiehelper.js index 1e0e0f1..ef926a6 100644 --- a/assets/js/cookiehelper.js +++ b/assets/js/cookiehelper.js @@ -2,17 +2,17 @@ const cryptoProvider = window['CryptoJS']; const cryptoAlgorithm = window['CryptoJS'].AES; const _secretKey = 'unibase'; -function encrypt(content) { +export function encrypt(content) { return cryptoAlgorithm.encrypt(content, _secretKey).toString(); } -function decrypt(encoded) { +export function decrypt(encoded) { return cryptoAlgorithm .decrypt(encoded, _secretKey) .toString(cryptoProvider.enc.Utf8); } -function setCookie(cname, cvalue, exdays) { +export function setCookie(cname, cvalue, exdays) { let _cookievalue = ''; if (cvalue) { _cookievalue = encrypt(cvalue); @@ -29,7 +29,7 @@ function setCookie(cname, cvalue, exdays) { ';path=/;samesite=none;secure=true'; } -function getCookie(cname) { +export function getCookie(cname) { var name = cname + '='; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); @@ -48,7 +48,7 @@ function getCookie(cname) { return ''; } -function isAuthenticated() { +export function isAuthenticated() { if (getCookie('_idty')) { return true; } diff --git a/assets/js/list.index.js b/assets/js/list.index.js index a5a3cb8..4cfe177 100644 --- a/assets/js/list.index.js +++ b/assets/js/list.index.js @@ -1,108 +1,18 @@ /*Data loading start here*/ -let _userInfo = atob(document.cookie.split('=')[1]); -let userInfo = JSON.parse(_userInfo).result; -let sessionId = userInfo.sessionId; +import { getData, getDataObj } from "./base.js"; -let usrinfoHTML = `
  • ${userInfo.name}
  • -
  • Cloud Settings
  • -
  • Help
  • -
  • Logoff
  • `; -$('.icn-circle').text(userInfo.name.charAt(0).toUpperCase()) -$('.uindtls').html(usrinfoHTML) -// List Page loading -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 - 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" }; - //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) { - let res = JSON.parse(response.result), - html = ''; - if (response.message == '200' && response.errors == null) { - html = ``; - } else { - html += `` - } - $(_this).find('.accordion-body').html(html); - }); - }) - } -}) -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 += `
  • + +function loadData() { + 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 + 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" }; + //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) { + let res = JSON.parse(response.result), + html = ''; + if (response.message == '200' && response.errors == null) { + html = ``; + } else { + html += `` + } + $(_this).find('.accordion-body').html(html); + }); + }) } - _tskhtml += '' - $('.bdy-ul').append(_tskhtml); - } -}); + }) + 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
    • +
    +
    +
    +
    +
  • `; + } + _tskhtml += '
    ' + $('.bdy-ul').append(_tskhtml); + } + }); +} -/*Data loading start here*/ -$('.mnNvIcn').click(function() { - $('.lft-nav-bar').toggleClass('lft-nav-bar-Wrap'); - $('.ctr-lst-pge').toggleClass('lft-nav-bar-Wrap'); -}); \ No newline at end of file + + + + +export function initListIndex() { + 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) + + // 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'); + }); + loadData(); +} \ No newline at end of file diff --git a/assets/js/login.js b/assets/js/login.js index ae0deca..e67f998 100644 --- a/assets/js/login.js +++ b/assets/js/login.js @@ -1,4 +1,6 @@ -const serverUrl = 'https://test.bizgaze.app/'; +import { setCookie } from "./cookiehelper.js"; + +const serverUrl = 'http://localhost:1188/'; const emailInputEl = document.getElementById('email'); const passwordInputEl = document.getElementById('password'); const emailErrEl = document.getElementById('emailErrMsg'); diff --git a/authentication/index.html b/authentication/index.html index 2d2686f..68bb19e 100644 --- a/authentication/index.html +++ b/authentication/index.html @@ -9,6 +9,14 @@ List Page + + + + + + + + @@ -72,6 +80,7 @@ +
    @@ -83,29 +92,6 @@
    - - - - - \ No newline at end of file diff --git a/index.html b/index.html index 15f3b8c..80cf74b 100644 --- a/index.html +++ b/index.html @@ -6,17 +6,20 @@ Bizgaze + + - + helo + \ No newline at end of file diff --git a/login/index.html b/login/index.html index 4d6c614..44011d9 100644 --- a/login/index.html +++ b/login/index.html @@ -7,6 +7,10 @@ Login + + + + @@ -71,9 +75,7 @@ - - - + \ No newline at end of file