Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Admin/Dashboard.vue
<template> | <template> | ||||
<div v-if="!$root.isLoading" class="container" dusk="dashboard-component"> | <div class="container" dusk="dashboard-component"> | ||||
<div id="search-box" class="card"> | <div id="search-box" class="card"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<form @submit.prevent="searchUser" class="row justify-content-center"> | <form @submit.prevent="searchUser" class="row justify-content-center"> | ||||
<div class="input-group col-sm-8"> | <div class="input-group col-sm-8"> | ||||
<input class="form-control" type="text" placeholder="User ID, email or domain" v-model="search"> | <input class="form-control" type="text" placeholder="User ID, email or domain" v-model="search"> | ||||
<div class="input-group-append"> | <div class="input-group-append"> | ||||
<button type="submit" class="btn btn-primary"><svg-icon icon="search"></svg-icon> Search</button> | <button type="submit" class="btn btn-primary"><svg-icon icon="search"></svg-icon> Search</button> | ||||
</div> | </div> | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | <script> | ||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
search: '', | search: '', | ||||
users: [] | users: [] | ||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
const authInfo = this.$store.state.isLoggedIn ? this.$store.state.authInfo : null | |||||
if (authInfo) { | |||||
$('#search-box input').focus() | $('#search-box input').focus() | ||||
} else { | |||||
this.$root.startLoading() | |||||
axios.get('/api/auth/info') | |||||
.then(response => { | |||||
this.$store.state.authInfo = response.data | |||||
this.$root.stopLoading() | |||||
setTimeout(() => { $('#search-box input').focus() }, 10) | |||||
}) | |||||
.catch(this.$root.errorHandler) | |||||
} | |||||
}, | }, | ||||
methods: { | methods: { | ||||
searchUser() { | searchUser() { | ||||
this.users = [] | this.users = [] | ||||
axios.get('/api/v4/users', { params: { search: this.search } }) | axios.get('/api/v4/users', { params: { search: this.search } }) | ||||
.then(response => { | .then(response => { | ||||
if (response.data.count == 1 && !response.data.list[0].isDeleted) { | if (response.data.count == 1 && !response.data.list[0].isDeleted) { | ||||
Show All 20 Lines |