first commit + add fe component vue accone
This commit is contained in:
109
apps/components/oneFooter.vue
Normal file
109
apps/components/oneFooter.vue
Normal file
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<v-footer style="color: white!important" color="grey darken-3 " app>
|
||||
<one-clock></one-clock>
|
||||
<v-spacer></v-spacer>
|
||||
<span class="one-footer"
|
||||
><p class="mb-0" style="color: white!important"
|
||||
>Auto logged out in <span id="SecondsUntilExpire"></span> seconds</p
|
||||
></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;
|
||||
if (localStorage.getItem("autologout") === null) {
|
||||
localStorage.setItem("autologout", 0);
|
||||
}
|
||||
|
||||
document.onclick = function () {
|
||||
localStorage.setItem("autologout", 0);
|
||||
};
|
||||
|
||||
document.onmousemove = function () {
|
||||
localStorage.setItem("autologout", 0);
|
||||
};
|
||||
|
||||
document.onkeypress = function () {
|
||||
localStorage.setItem("autologout", 0);
|
||||
};
|
||||
|
||||
_idleSecondsTimer = window.setInterval(CheckIdleTime, 1000);
|
||||
|
||||
function CheckIdleTime() {
|
||||
let xcounter = parseInt(localStorage.getItem("autologout"));
|
||||
xcounter++;
|
||||
localStorage.setItem("autologout", xcounter);
|
||||
//this.show_autologout = false
|
||||
|
||||
var oPanel = document.getElementById("SecondsUntilExpire");
|
||||
if (oPanel)
|
||||
oPanel.innerHTML =
|
||||
IDLE_TIMEOUT - parseInt(localStorage.getItem("autologout")) + "";
|
||||
if (parseInt(localStorage.getItem("autologout")) >= IDLE_TIMEOUT) {
|
||||
window.clearInterval(_idleSecondsTimer);
|
||||
localStorage.removeItem("autologout");
|
||||
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