Commit 8e848331 by Takumi Imai

Merge branch 'feature/1.0_check_web_dev_kdh_2' into 'feature/1.0_check_web_dev'

check login information in window.sessionStorage

See merge request !64
parents 8f132c6a deff63f5
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
height: 100vh; height: 100vh;
width: 100vw; width: 100vw;
display: block; display: block;
background: rgb(255,255,255,.5); background: rgb(255, 255, 255);
background-position: center; background-position: center;
background-image: url("../img/loading.gif"); background-image: url("../img/loading.gif");
background-repeat: no-repeat; background-repeat: no-repeat;
......
...@@ -13,8 +13,34 @@ ...@@ -13,8 +13,34 @@
*/ */
var COMMON = {}; 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 * page transition without outputting a warning message
* @param {*} url * @param {*} url
...@@ -648,13 +674,17 @@ var UserSession = function () { ...@@ -648,13 +674,17 @@ var UserSession = function () {
*/ */
UserSession.prototype.init = function (option) { UserSession.prototype.init = function (option) {
this.available = false; this.available = false;
console.log("kdh check userSession init option : " + option);
if (option == 'restore') { if (option == 'restore') {
var value = null; var value = null;
try { try {
value = this._get('init'); value = this._get('init');
console.log("kdh check userSession init value : " + value);
} catch (e) { } catch (e) {
value = null; value = null;
console.log("kdh check userSession init catch : " + e);
} finally { } finally {
console.log("kdh check userSession init final : " + value);
if (value) { if (value) {
this.available = true; this.available = true;
} }
...@@ -691,6 +721,7 @@ UserSession.prototype.set = function (key, value) { ...@@ -691,6 +721,7 @@ UserSession.prototype.set = function (key, value) {
* @returns * @returns
*/ */
UserSession.prototype.get = function (key) { UserSession.prototype.get = function (key) {
console.log("kdh check userSession get");
var value = null; var value = null;
if (this.available) { if (this.available) {
value = this._get(key); value = this._get(key);
...@@ -836,13 +867,16 @@ COMMON.setErrorState = function () { ...@@ -836,13 +867,16 @@ COMMON.setErrorState = function () {
/* get user session object */ /* get user session object */
COMMON.userSession = function () { COMMON.userSession = function () {
if (!COMMON.userSessionObj) { if (!COMMON.userSessionObj) {
console.log("kdh check userSession : COMMON.userSessionObj null");
var obj = new UserSession(); var obj = new UserSession();
obj.init('restore'); obj.init('restore');
if (obj.available) { if (obj.available) {
console.log("kdh check userSession : COMMON.userSessionObj available");
COMMON.userSessionObj = obj; COMMON.userSessionObj = obj;
return COMMON.userSessionObj; return COMMON.userSessionObj;
} else { } else {
return null; console.log("kdh check userSession : COMMON.userSessionObj unavailable");
return CO;
} }
} }
return COMMON.userSessionObj; return COMMON.userSessionObj;
...@@ -884,6 +918,7 @@ var SessionStorageUtils = { ...@@ -884,6 +918,7 @@ var SessionStorageUtils = {
} }
}, },
get: function (strKey) { get: function (strKey) {
console.log("kdh check SessionStorageUtils get : " + strKey);
return COMMON.userSession().get(strKey); return COMMON.userSession().get(strKey);
}, },
set: function (strKey, objValue) { set: function (strKey, objValue) {
...@@ -1053,6 +1088,56 @@ COMMON.currentTime = function () { ...@@ -1053,6 +1088,56 @@ COMMON.currentTime = function () {
return Date.now(); 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 ] * Operations for session storage [ end ]
*/ */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"pushPageCount" : 5, "pushPageCount" : 5,
"pushTimePeriod" : 60, "pushTimePeriod" : 60,
"debug" : true, "debug" : true,
"loginPage" : "index.html", "loginPage" : "login.html",
"anonymousLoginFlg" : false, "anonymousLoginFlg" : false,
"anonymousLoginPath" : "test", "anonymousLoginPath" : "test",
"anonymousLoginId" : "nologin", "anonymousLoginId" : "nologin",
......
...@@ -42,20 +42,7 @@ ...@@ -42,20 +42,7 @@
<div id="includedHeader"></div> <div id="includedHeader"></div>
<!-- title --> <!-- title -->
<div id="main-ttl"> <div id="includedMainTitle"></div>
<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>
<!-- ↓↓↓ ここから共通HTML ↓↓↓ --> <!-- ↓↓↓ ここから共通HTML ↓↓↓ -->
<div class="container-wrap mb-5" id="pdfPrintDiv" ></div> <div class="container-wrap mb-5" id="pdfPrintDiv" ></div>
......
...@@ -35,7 +35,7 @@ SETTINGS.getToken = function () { ...@@ -35,7 +35,7 @@ SETTINGS.getToken = function () {
if (data.errorMessage) { if (data.errorMessage) {
COMMON.displayAlert(data.errorMessage); COMMON.displayAlert(data.errorMessage);
} else { } else {
COMMON.displayAlert('msgPwdChangeOK'); COMMON.displayAlert('msgPwdChangeNG');
} }
}); });
}; };
......
...@@ -32,7 +32,7 @@ modify_api() ...@@ -32,7 +32,7 @@ modify_api()
"pushPageCount" : 5, "pushPageCount" : 5,
"pushTimePeriod" : 60, "pushTimePeriod" : 60,
"debug" : false, "debug" : false,
"loginPage" : "index.html", "loginPage" : "login.html",
"anonymousLoginFlg" : false, "anonymousLoginFlg" : false,
"anonymousLoginPath" : "test", "anonymousLoginPath" : "test",
"anonymousLoginId" : "nologin", "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