first commit + add fe component vue accone
This commit is contained in:
100
apps/components/oneFooter.vue-170123
Normal file
100
apps/components/oneFooter.vue-170123
Normal file
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<v-footer color="blue lighten-2" app>
|
||||
<one-clock></one-clock>
|
||||
<v-spacer></v-spacer>
|
||||
<span class="one-footer white--text"><code class="mb-0">Auto logged out in <span id="SecondsUntilExpire"></span> seconds</code></span>
|
||||
|
||||
</v-footer>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
span.one-footer {
|
||||
margin-right:30px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
module.exports = {
|
||||
mounted() {
|
||||
var IDLE_TIMEOUT = 5*60; //seconds
|
||||
if(localStorage.getItem("user")){
|
||||
var retrievedObject = localStorage.getItem('user')
|
||||
var dtuser = JSON.parse(retrievedObject)
|
||||
if(dtuser.time_autologout && parseInt(dtuser.time_autologout) > 0)
|
||||
IDLE_TIMEOUT = parseInt(dtuser.time_autologout) * 60
|
||||
}
|
||||
var _idleSecondsTimer = null;
|
||||
var _idleSecondsCounter = 0;
|
||||
|
||||
document.onclick = function() {
|
||||
_idleSecondsCounter = 0;
|
||||
};
|
||||
|
||||
document.onmousemove = function() {
|
||||
_idleSecondsCounter = 0;
|
||||
};
|
||||
|
||||
document.onkeypress = function() {
|
||||
_idleSecondsCounter = 0;
|
||||
};
|
||||
|
||||
_idleSecondsTimer = window.setInterval(CheckIdleTime, 1000);
|
||||
|
||||
function CheckIdleTime() {
|
||||
_idleSecondsCounter++;
|
||||
//this.show_autologout = false
|
||||
|
||||
var oPanel = document.getElementById("SecondsUntilExpire");
|
||||
if (oPanel)
|
||||
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
|
||||
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
|
||||
window.clearInterval(_idleSecondsTimer);
|
||||
window.one_logout('/one-ui/test/vuex/one-login')
|
||||
}
|
||||
}
|
||||
},
|
||||
components: {
|
||||
'one-clock' : httpVueLoader('./oneTanggal.vue')
|
||||
}
|
||||
}
|
||||
function one_verif() {
|
||||
let url_redir = "/one-ui/";
|
||||
let verif = async function (token) {
|
||||
try {
|
||||
var resp = await axios.post("/one-api/v1/system/verify/do", {
|
||||
token: token,
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText,
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let x = async () => {
|
||||
let url_redir = "/one-ui/";
|
||||
try {
|
||||
let resp = await verif(window.one_token());
|
||||
console.log('Response',resp);
|
||||
return;
|
||||
|
||||
if (resp.status != "OK") {
|
||||
window.localStorage.removeItem("token");
|
||||
window.localStorage.removeItem("user");
|
||||
location.replace(url_redir);
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
x();
|
||||
}
|
||||
|
||||
//one_verif();
|
||||
</script>
|
||||
Reference in New Issue
Block a user