Commit deff63f5 by Kang Donghun

check login information in window.sessionStorage

parent 99c621b6
......@@ -5,7 +5,7 @@
height: 100vh;
width: 100vw;
display: block;
background: rgb(255,255,255,.5);
background: rgb(255, 255, 255);
background-position: center;
background-image: url("../img/loading.gif");
background-repeat: no-repeat;
......
......@@ -13,8 +13,34 @@
*/
var COMMON = {};
COMMON.hasErrorKey = 'AVW_HASERR';
CONSTANT.PAGE_NAME = {
DASHBOARD: 'dashboard',
OPERATION_LIST: 'workList',
REPORT_LIST: 'reportList',
REPORT_FORM: 'reportForm',
MESSAGE_DETAIL: 'pushMessageDetail',
MESSAGE_LIST: 'pushMessageList',
SEND_MESSAGE: 'sendMessage',
SETTING: 'accountSetting',
PICKUP: 'pickup',
PDF_PRINT: 'pdfPrint',
DEFAULT: 'index',
LOGIN: './login.html',
};
COMMON.loginCheckPageList = [CONSTANT.PAGE_NAME.DEFAULT, CONSTANT.PAGE_NAME.DASHBOARD, CONSTANT.PAGE_NAME.REPORT_LIST, CONSTANT.PAGE_NAME.REPORT_FORM,
CONSTANT.PAGE_NAME.MESSAGE_DETAIL, CONSTANT.PAGE_NAME.MESSAGE_LIST, CONSTANT.PAGE_NAME.SEND_MESSAGE, CONSTANT.PAGE_NAME.SETTING,
CONSTANT.PAGE_NAME.PICKUP, CONSTANT.PAGE_NAME.PDF_PRINT];
COMMON.hasErrorKey = 'AVW_HASERR';
$(document).ready(function() {
if (location.href.includes(COMMON.loginCheckPageList)) {
if (!COMMON.checkLogin(CONSTANT.PAGE_NAME.LOGIN)){
return;
}
}
})
/**
* page transition without outputting a warning message
* @param {*} url
......@@ -557,13 +583,17 @@ var UserSession = function () {
*/
UserSession.prototype.init = function (option) {
this.available = false;
console.log("kdh check userSession init option : " + option);
if (option == 'restore') {
var value = null;
try {
value = this._get('init');
console.log("kdh check userSession init value : " + value);
} catch (e) {
value = null;
console.log("kdh check userSession init catch : " + e);
} finally {
console.log("kdh check userSession init final : " + value);
if (value) {
this.available = true;
}
......@@ -600,6 +630,7 @@ UserSession.prototype.set = function (key, value) {
* @returns
*/
UserSession.prototype.get = function (key) {
console.log("kdh check userSession get");
var value = null;
if (this.available) {
value = this._get(key);
......@@ -745,13 +776,16 @@ COMMON.setErrorState = function () {
/* get user session object */
COMMON.userSession = function () {
if (!COMMON.userSessionObj) {
console.log("kdh check userSession : COMMON.userSessionObj null");
var obj = new UserSession();
obj.init('restore');
if (obj.available) {
console.log("kdh check userSession : COMMON.userSessionObj available");
COMMON.userSessionObj = obj;
return COMMON.userSessionObj;
} else {
return null;
console.log("kdh check userSession : COMMON.userSessionObj unavailable");
return CO;
}
}
return COMMON.userSessionObj;
......@@ -793,6 +827,7 @@ var SessionStorageUtils = {
}
},
get: function (strKey) {
console.log("kdh check SessionStorageUtils get : " + strKey);
return COMMON.userSession().get(strKey);
},
set: function (strKey, objValue) {
......@@ -962,6 +997,56 @@ COMMON.currentTime = function () {
return Date.now();
};
/**
* check login information in window.sessionStorage
*
* @returns boolean
*/
COMMON.checkLogin = function (option) {
var userSession = COMMON.userSession();
if(!userSession) {
/* エラー画面を表示 */
var tags = '<div id="avw-auth-error">' +
'<div style="display:table; width:100%; height:100%;">' +
'<div style="display:table-cell; text-align:center; vertical-align:middle;">' +
'<p><h4>Authentication error</h4>Please use it after login.</p>' +
'<div><button id="avw-unauth-ok">OK</button></div>' +
'</div></div></div>';
$('body').prepend(tags);
$('#avw-auth-error').css({
'opacity': 1,
'position': 'fixed',
'top': '0',
'left': '0',
'width': $(window).width(),
'height': $(window).height(),
'zIndex': '10000'
});
// resize error page
$(window).resize(function() {
$('#avw-auth-error').css( {
'width': $(window).width(),
'height': $(window).height()
});
});
var returnPage;
if(option) {
returnPage = option
} else {
var sysSetting = COMMON.sysSetting();
returnPage = sysSetting.loginPage;
}
/* ログイン画面に戻る */
$('#avw-unauth-ok').click(function() {
window.location = returnPage;
});
return false;
}
return true;
}
/*
* Operations for session storage [ end ]
*/
......
......@@ -10,203 +10,9 @@ var HEADER = {};
/**
* init
*/
HEADER.init = function () {
$('#dspLoginId').text(ClientData.userInfo_loginId());
$('#btnLogout').click(HEADER.logoutFunction);
};
/**
* create url tree & show breadcrumbs list
*/
// HEADER.urlTree = function () {
// const pathUrl = location.pathname;
// const htmlName = pathUrl.substring(pathUrl.lastIndexOf('/') + 1);
// let pageName = urlPath.substring(0, urlPath.indexOf(".html"));
// if (pageName == CONSTANT.URL.WEB.OPERATION_LIST) pageName = CONSTANT.PAGE_NAME.OPERATION_LIST;
// // session reset
// if ((htmlName == CONSTANT.URL_TREE_NAME.OPERATION_LIST) || (htmlName == CONSTANT.URL_TREE_NAME.DASHBOARD)) {
// sessionStorage.pickUpParams = null;
// }
// let navs;
// switch (htmlName) {
// case CONSTANT.URL_TREE_NAME.DASHBOARD:
// case CONSTANT.URL_TREE_NAME.OPERATION_LIST:
// if (sessionStorage.urlTree) sessionStorage.urlTree = null;
// if (sessionStorage.pickUpType) sessionStorage.pickUpType = null;
// break;
// case CONSTANT.URL_TREE_NAME.PICKUP :
// navs = [
// {
// titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
// href: CONSTANT.URL_TREE_NAME.DASHBOARD,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.PICKUP,
// },
// ];
// break;
// case CONSTANT.URL_TREE_NAME.REPORT_LIST:
// if (sessionStorage.activeHomePage == CONSTANT.PAGE_TAB.DASHBOARD) {
// if (sessionStorage.pickUpType) {
// if (sessionStorage.pickUpType == CONSTANT.PICK_UP_TYPE.CONTINOUS_WORK) {
// navs = [
// {
// titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
// href: CONSTANT.URL_TREE_NAME.DASHBOARD,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.PICKUP,
// href: CONSTANT.URL_TREE_NAME.PICKUP_CONTINUOS,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
// },
// ]
// } else if (sessionStorage.pickUpType == CONSTANT.PICK_UP_TYPE.WARNING_REPORT) {
// navs = [
// {
// titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
// href: CONSTANT.URL_TREE_NAME.DASHBOARD,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.PICKUP,
// href: CONSTANT.URL_TREE_NAME.PICKUP_WARNING,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
// },
// ]
// } else {
// navs = [
// {
// titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
// href: CONSTANT.URL_TREE_NAME.DASHBOARD,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.PICKUP,
// href: CONSTANT.URL_TREE_NAME.PICKUP_NEW,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
// },
// ]
// }
// } else {
// navs = [
// {
// titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
// href: CONSTANT.URL_TREE_NAME.DASHBOARD,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.PICKUP,
// href: CONSTANT.URL_TREE_NAME.PICKUP,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
// },
// ]
// }
// } else {
// if (sessionStorage.pickUpType) sessionStorage.pickUpType = null;
// navs = [
// {
// titleLang: CONSTANT.PAGE_NAME.OPERATION_LIST,
// href: CONSTANT.URL_TREE_NAME.OPERATION_LIST,
// },
// {
// titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
// },
// ]
// }
// break;
// case CONSTANT.URL_TREE_NAME.REPORT_FORM:
// break;
// }
// CONSTANT.URL_TREE_PASS = {
// 1: [CONSTANT.URL_TREE_NAME.DASHBOARD, CONSTANT.URL_TREE_NAME.PICKUP, CONSTANT.URL_TREE_NAME.REPORT_LIST, CONSTANT.URL_TREE_NAME.REPORT_FORM],
// 2: [CONSTANT.URL_TREE_NAME.DASHBOARD, CONSTANT.URL_TREE_NAME.PICKUP, CONSTANT.URL_TREE_NAME.REPORT_FORM],
// 3: [CONSTANT.URL_TREE_NAME.DASHBOARD, CONSTANT.URL_TREE_NAME.MESSAGE_LIST, CONSTANT.URL_TREE_NAME.MESSAGE_DETAIL],
// 4: [CONSTANT.URL_TREE_NAME.DASHBOARD, CONSTANT.URL_TREE_NAME.SEND_MESSAGE],
// 5: [CONSTANT.URL_TREE_NAME.OPERATION_LIST, CONSTANT.URL_TREE_NAME.REPORT_LIST, CONSTANT.URL_TREE_NAME.REPORT_FORM],
// 6: [CONSTANT.URL_TREE_NAME.OPERATION_LIST, CONSTANT.URL_TREE_NAME.REPORT_LIST, CONSTANT.URL_TREE_NAME.PDF_PRINT],
// };
// //now url tree
// // const urlTree = sessionStorage.urlTree ? JSON.parse(sessionStorage.urlTree) : sessionStorage.urlTree;
// // console.log("kdh check urlTree : " + urlTree);
// // // return;
// // if (urlTree) {
// // urlList: for (var i = 0; i < urlTree.length; i++) {
// // const urlHtmlUrl = urlTree[i].href;
// // const urlHtmlHref = urlHtmlUrl.includes('?') ? urlHtmlUrl.substring(0, urlHtmlUrl.indexOf('?')) : urlHtmlUrl;
// // for (var v in CONSTANT.URL_TREE_PASS) {
// // findUrl: for (var k in CONSTANT.URL_TREE_PASS[v]) {
// // if (urlHtmlHref == CONSTANT.URL_TREE_PASS[v][k]) {
// // if (htmlName == CONSTANT.URL_TREE_PASS[v][k]) {
// // authFlg = true;
// // break urlList;
// // }
// // continue;
// // } else if ((urlHtmlHref != CONSTANT.URL_TREE_PASS[v][k]) && (htmlName == CONSTANT.URL_TREE_PASS[v][k])) {
// // authFlg = true;
// // break urlList;
// // } else {
// // break findUrl;
// // }
// // }
// // }
// // }
// // }
// // if (authFlg) {
// // const urlPath = htmlName + location.search;
// // let pageName = urlPath.substring(0, urlPath.indexOf(".html"));
// // if (pageName == CONSTANT.URL.WEB.OPERATION_LIST) pageName = CONSTANT.PAGE_NAME.OPERATION_LIST;
// // let addReportFlg = "0"
// // if (urlPath.includes(CONSTANT.URL_TREE_NAME.REPORT_FORM) && urlPath.includes("addReport")) {
// // addReportFlg = urlPath.substring(urlPath.indexOf("addReport=") + 10);
// // }
// // let newUrlTree = [];
// // if (urlTree) {
// // let isAdd = false;
// // for (var i = 0; i < urlTree.length; i++) {
// // const sessionUrl = urlTree[i].href.includes('?') ? urlTree[i].href.substring(0, urlTree[i].href.indexOf('?')) : urlTree[i].href;
// // const urlHtmlName = urlPath.includes('?') ? urlPath.substring(0, urlPath.indexOf('?')) : urlPath;
// // if (sessionUrl == urlHtmlName) {
// // if (addReportFlg == "1") {
// // var nav = {titleLang : CONSTANT.PAGE_NAME.REPORT_LIST , href : CONSTANT.URL_TREE_NAME.REPORT_LIST};
// // newUrlTree.push(nav);
// // };
// // var nav = {titleLang : pageName , href : urlPath};
// // newUrlTree.push(nav);
// // isAdd = true;
// // break;
// // } else {
// // newUrlTree.push(urlTree[i]);
// // };
// // };
// // if (!isAdd) {
// // const nav = {titleLang : pageName , href : urlPath};
// // newUrlTree.push(nav);
// // }
// // } else {
// // const nav = {titleLang : pageName , href : urlPath};
// // newUrlTree.push(nav);
// // }
// // sessionStorage.urlTree = JSON.stringify(newUrlTree);
// // } else {
// // console.log("kdh check go index");
// // // COMMON.avwScreenMove('index.html');
// // }
// };
HEADER.init = function() {
$("#dspLoginId").text(ClientData.userInfo_loginId());
HEADER.initLogout();
};
HEADER.initLogout = function() {
......@@ -231,9 +37,11 @@ HEADER.goToHomePage = function (pageId) {
*/
HEADER.logoutFunction = function () {
console.log('clicked logout');
$('#modalTitle').text(I18N.i18nText("confirmation"));
$('#msgModel').text(I18N.i18nText('msgLogoutConfirm'));
$('#confirmYes').show();
$('#confirmYes').click(HEADER.processLogout);
$('#confirmNo').text(I18N.i18nText("confirmNo"));
};
/**
......
......@@ -13,7 +13,7 @@
"pushPageCount" : 5,
"pushTimePeriod" : 60,
"debug" : true,
"loginPage" : "index.html",
"loginPage" : "login.html",
"anonymousLoginFlg" : false,
"anonymousLoginPath" : "test",
"anonymousLoginId" : "nologin",
......
......@@ -42,20 +42,7 @@
<div id="includedHeader"></div>
<!-- title -->
<div id="main-ttl">
<div class="container-wrap">
<!-- breadcrumb -->
<nav aria-label="breadcrumb">
<ol class="breadcrumb px-0 mb-0">
<li class="breadcrumb-item"><a href="task-list.html" class="text-decoration-none text-underline">作業一覧</a></li>
<li class="breadcrumb-item"><a href="report-list.html" class="text-decoration-none text-underline">報告一覧</a></li>
<li class="breadcrumb-item active" aria-current="page"><span>pdf出力</span></li>
</ol>
</nav>
<!-- title -->
<h1 class="fs-14 font-weight-bold pt-sm-4 pt-2 pb-3 mb-0">pdf出力</h1>
</div>
</div>
<div id="includedMainTitle"></div>
<!-- ↓↓↓ ここから共通HTML ↓↓↓ -->
<div class="container-wrap mb-5" id="pdfPrintDiv" ></div>
......
......@@ -35,7 +35,7 @@ SETTINGS.getToken = function () {
if (data.errorMessage) {
COMMON.displayAlert(data.errorMessage);
} else {
COMMON.displayAlert('msgPwdChangeOK');
COMMON.displayAlert('msgPwdChangeNG');
}
});
};
......
......@@ -32,7 +32,7 @@ modify_api()
"pushPageCount" : 5,
"pushTimePeriod" : 60,
"debug" : false,
"loginPage" : "index.html",
"loginPage" : "login.html",
"anonymousLoginFlg" : false,
"anonymousLoginPath" : "test",
"anonymousLoginId" : "nologin",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment