mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-12 02:00:47 +01:00
1 line
9.7 KiB
Plaintext
1 line
9.7 KiB
Plaintext
|
{"version":3,"file":"Users-Cjm1JjIX.js","sources":["../../../resources/js/views/admin/Users.vue"],"sourcesContent":["<script setup>\n import AdminTabs from '@/layouts/AdminTabs.vue'\n import userService from '@/services/userService'\n import { useNotifyStore } from '@/stores/notify'\n import { UseColorMode } from '@vueuse/components'\n import Spinner from '@/components/Spinner.vue'\n import SearchBox from '@/components/SearchBox.vue'\n\n const $2fauth = inject('2fauth')\n const notify = useNotifyStore()\n const returnTo = useStorage($2fauth.prefix + 'returnTo', 'accounts')\n\n const users = ref([])\n const searched = ref('')\n const isFetching = ref(false)\n\n const visibleUsers = computed(() => {\n return users.value.filter(\n user => {\n let ret = user.name.toLowerCase().includes(searchedObj.value.keywords)\n || user.email.toLowerCase().includes(searchedObj.value.keywords)\n\n if (searchedObj.value.admin != undefined) {\n ret = ret && user.is_admin == searchedObj.value.admin\n }\n if (searchedObj.value.oauth != undefined) {\n ret = ret && user.oauth_provider == searchedObj.value.oauth\n }\n\n return ret\n }\n )\n })\n\n const searchedObj = computed(() => {\n const obj = {\n admin: undefined,\n oauth: undefined,\n keywords: searched.value.toLowerCase()\n }\n const searchedChunks = searched.value.toLowerCase().split(' ')\n const regexAdmin = /admin:([01])/\n const regexOAuth = /oauth:([a-zA-Z0-9])/\n\n searchedChunks.forEach(chunk => {\n if (chunk.match(regexAdmin)) {\n obj.admin = parseInt(chunk.replace(regexAdmin, '$1'))\n obj.keywords = obj.keywords.replace(chunk, '').trim()\n }\n if (chunk.match(regexOAuth)) {\n obj.oauth = chunk.replace(regexOAuth, '$1')\n obj.keywords = obj.keywords.replace(chunk, '').trim()\n }\n })\n\n return obj\n })\n\n onMounted(() => {\n fetchUsers()\n })\n\n /**\n * \n * @param {*} filter \n */\n function addFilter(filter) {\n const regexAdmin = /admin:([01])/\n const regexOAuth = /oauth:([a-zA-Z0-9]*)/\n\n if (searched.value.match(regexAdmin) && filter.match(regexAdmin)) {\n searched.value = searched.value.replace(regexAdmin, filter)\n }\n else if (searchedObj.value.oauth != undefined && filter.match(regexOAuth)) {\n searched.value = searched.value.replace(regexOAuth, filter)\n }\n else searched.value = searched.value ? searched.value + ' ' + filter : filter\n }\n\n /**\n * Gets all users from backend\n */\n function fetchUsers() {\n isFetching.value = true\n\n userService.getAll({returnError: true})\n .then(response => {\n users.value = response.data\n })\n .catch(error => {\n notify.error(error)\n })\n .finally(() => {\n isFetching.value = false\n })\n }\n\n onBeforeRouteLeave((to) => {\n if (! to.name.startsWith('admin.')) {\n notify.clear()\n }\n })\n\n</script>\n\n<template>\n <div>\n <AdminTabs activeTab=\"admin.users\" />\n <div class=\"options-tabs\">\n <FormWrapper>\n <h4 class=\"title is-4 has-text-grey-light\">{{ $t('admin.users') }}</h4>\n <div class=\"is-size-7-mobile\">\n {{ $t('admin.users_legend')}}\n </div>\n <div class=\"mb-6 mt-3\">\n <RouterLink class=\"is-link mt-5\" :to=\"{ name: 'admin.createUser' }\">\n <FontAwesomeIcon :icon=\"['fas', 'plus-circle']\" /> {{ $t('admin.create_new_user') }}\n </RouterLink>\n </div>\n <!-
|