mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-12 02:00:47 +01:00
1 line
10 KiB
Plaintext
1 line
10 KiB
Plaintext
|
{"version":3,"file":"AccessLogViewer-DhKO22h5.js","sources":["../../../resources/js/components/AccessLogViewer.vue"],"sourcesContent":["<script setup>\n import SearchBox from '@/components/SearchBox.vue'\n import userService from '@/services/userService'\n import Spinner from '@/components/Spinner.vue'\n import { useNotifyStore } from '@/stores/notify'\n import { FontAwesomeLayers } from '@fortawesome/vue-fontawesome'\n import { UseColorMode } from '@vueuse/components'\n\n const notify = useNotifyStore()\n const $2fauth = inject('2fauth')\n\n const props = defineProps({\n userId: [Number, String],\n lastOnly: Boolean,\n showSearch: Boolean,\n period: {\n type: [Number, String],\n default: 12\n },\n })\n\n const periods = {\n aMonth: 1,\n threeMonths: 3,\n halfYear: 6,\n aYear: 12\n }\n\n const authentications = ref([])\n const isFetching = ref(false)\n const searched = ref('')\n const period = ref(props.period)\n const orderIsDesc = ref(true)\n\n const emit = defineEmits(['has-more-entries'])\n\n const visibleAuthentications = computed(() => {\n return authentications.value.filter(authentication => {\n return JSON.stringify(authentication)\n .toString()\n .toLowerCase()\n .includes(searched.value);\n })\n })\n\n onMounted(() => {\n getAuthentications()\n })\n\n /**\n * Sets the visible time span\n * \n * @param {int} duration \n */\n function setPeriod(duration) {\n period.value = duration\n getAuthentications()\n }\n\n /**\n * Set sort order to ASC\n */\n function setAsc() {\n orderIsDesc.value = false\n sortAsc()\n }\n \n /**\n * Sorts entries ascending\n */\n function sortAsc() {\n authentications.value.sort((a, b) => a.id > b.id ? 1 : -1)\n }\n\n /**\n * Set sort order to DESC\n */\n function setDesc() {\n orderIsDesc.value = true\n sortDesc()\n }\n\n /**\n * Sorts entries descending\n */\n function sortDesc() {\n authentications.value.sort((a, b) => a.id < b.id ? 1 : -1)\n }\n\n /**\n * Gets user authentication logs\n */\n function getAuthentications() {\n isFetching.value = true\n let limit = props.lastOnly ? 4 : false\n\n userService.getauthentications(props.userId, period.value, limit, {returnError: true})\n .then(response => {\n authentications.value = response.data\n\n if (authentications.value.length > 3 && props.lastOnly) {\n emit('has-more-entries')\n authentications.value.pop()\n }\n \n orderIsDesc.value == true ? sortDesc() : sortAsc()\n })\n .catch(error => {\n notify.error(error)\n })\n .finally(() => {\n isFetching.value = false\n })\n }\n\n const deviceIcon = (device) => {\n switch (device) {\n case \"phone\":\n return 'mobile-screen'\n case \"tablet\":\n return 'tablet-screen-button'\n default:\n return 'display'\n }\n }\n\n const isSuccessfulLogin = (authentication) => {\n return authentication.login_successful && authentication.login_at\n }\n\n const isSuccessfulLogout = (authentication) => {\n return !authentication.login_at && authentication.logout_at\n }\n\n const isFailedEntry = (authentication) => {\n return !authentication.login_successful && !authentication.logout_at\n }\n</script>\n\n<template>\n <SearchBox v-if=\"props.showSearch\" v-model:keyword=\"searched\" :hasNoBackground=\"true\" />\n <nav v-if=\"props.showSearch\" class=\"level is-mobile mb-2\">\n <div class=\"level-item has-text-centered\">\n <div class=\"buttons\"> \n <button id=\"btnShowOneMonth\" :title=\"$t(
|