visit API, is_admin badge API, is_active badge API,

This commit is contained in:
Cindy Chang
2024-06-25 12:53:50 +08:00
parent 6d11849dae
commit 5d5730fc29
3 changed files with 40 additions and 29 deletions

View File

@@ -6,7 +6,8 @@ export default defineStore('acctMgmtStore', {
allUserAccoutList: [], allUserAccoutList: [],
isAcctMenuOpen: false, isAcctMenuOpen: false,
currentViewingUser: { currentViewingUser: {
detail: null, username: "",
detail: {},
}, },
response: { response: {
deleteAccount: null, deleteAccount: null,
@@ -58,7 +59,6 @@ export default defineStore('acctMgmtStore', {
const response = await this.$axios.get(apiGetUserList); const response = await this.$axios.get(apiGetUserList);
const customizedResponseData = await this.customizeAllUserList(response.data); const customizedResponseData = await this.customizeAllUserList(response.data);
this.allUserAccoutList = customizedResponseData; this.allUserAccoutList = customizedResponseData;
console.log('getAllUserAccounts success');
} catch(error) { } catch(error) {
apiError(error, 'Failed to get all users.'); apiError(error, 'Failed to get all users.');
} }
@@ -110,7 +110,6 @@ export default defineStore('acctMgmtStore', {
} }
} }
catch(error) { catch(error) {
console.log('error', error, error.status, error.code);
apiError(error, 'Failed to delete the account.'); apiError(error, 'Failed to delete the account.');
return false; return false;
}; };
@@ -124,7 +123,10 @@ export default defineStore('acctMgmtStore', {
try{ try{
const response = await this.$axios.get(apiUserDetail); const response = await this.$axios.get(apiUserDetail);
this.currentViewingUser.detail = response.data; this.currentViewingUser = {
...this.currentViewingUser,
detail: response.data,
}
if(response.status === 200) { if(response.status === 200) {
return true; return true;
} }

View File

@@ -16,7 +16,7 @@
<template #body="slotProps"> <template #body="slotProps">
<div class="row-container flex-w-full-hoverable w-full" @mouseenter="handleRowMouseOver(slotProps.data.username)" <div class="row-container flex-w-full-hoverable w-full" @mouseenter="handleRowMouseOver(slotProps.data.username)"
@mouseout="handleRowMouseOut(slotProps.data.username)"> @mouseout="handleRowMouseOut(slotProps.data.username)">
<div @dblclick="onAcctDoubleClick()" class="cursor-pointer"> <div @dblclick="onAcctDoubleClick(slotProps.data.username)" class="cursor-pointer">
{{ slotProps.data.username }} {{ slotProps.data.username }}
</div> </div>
</div> </div>
@@ -178,13 +178,17 @@ export default {
modalStore.openModal(MODAL_CREATE_NEW); modalStore.openModal(MODAL_CREATE_NEW);
}; };
const onAcctDoubleClick = (username) => {
acctMgmtStore.setCurrentViewingUser(username);
modalStore.openModal(MODAL_ACCT_INFO);
}
const getFirstPageUserData = async() => { const getFirstPageUserData = async() => {
await acctMgmtStore.getAllUserAccounts(); await acctMgmtStore.getAllUserAccounts();
infiniteAcctData.value = allUserAccoutList.value.slice(0, ONCE_RENDER_NUM_OF_DATA) infiniteAcctData.value = allUserAccoutList.value.slice(0, ONCE_RENDER_NUM_OF_DATA)
}; };
const isInfiniteFinish = ref(true);
const handleDeleteMouseOver = (username) => { const handleDeleteMouseOver = (username) => {
acctMgmtStore.changeIsDeleteHoveredByUser(username, true); acctMgmtStore.changeIsDeleteHoveredByUser(username, true);
}; };
@@ -276,6 +280,7 @@ export default {
loginUserData, loginUserData,
infiniteAcctData, infiniteAcctData,
onCreateNewClick, onCreateNewClick,
onAcctDoubleClick,
handleScroll, handleScroll,
getRowClass, getRowClass,
onDeleteBtnClick, onDeleteBtnClick,
@@ -312,9 +317,6 @@ export default {
...mapState(useAcctMgmtStore, ['allUserAccoutList']), ...mapState(useAcctMgmtStore, ['allUserAccoutList']),
}, },
methods: { methods: {
onAcctDoubleClick(){
},
onAdminRightsBtnClick(isOn){ onAdminRightsBtnClick(isOn){
}, },

View File

@@ -5,11 +5,13 @@
<main class="flex main-part flex-col px-6 mt-6"> <main class="flex main-part flex-col px-6 mt-6">
<h1 id="acct_info_user_name" class="text-[32px] leading-[64px] font-medium">{{ fullName }}</h1> <h1 id="acct_info_user_name" class="text-[32px] leading-[64px] font-medium">{{ fullName }}</h1>
<div class="status-container"> <div class="status-container">
<Badge displayText="Admin" isActivated/> <Badge displayText="Admin" :isActivated="is_admin"/>
<Badge displayText="Suspended" :isActivated="false"/> <Badge displayText="Suspended" :isActivated="is_active"/>
</div> </div>
<div id="account_visit_info" class="border-b border-b-[#CBD5E1] border-b-[1px] pb-4"> <div id="account_visit_info" class="border-b border-b-[#CBD5E1] border-b-[1px] pb-4">
Account: <span class="text-[#0099FF]">{{ account }}</span>, total visits <span class="text-[#0099FF]">{{ visitTiime }}</span> times. Account: <span class="text-[#0099FF]">{{ username }}</span>, total visits <span class="text-[#0099FF]">
{{ visitTime }}
</span> times.
</div> </div>
</main> </main>
<main class="flex main-part flex-col px-6 py-4"> <main class="flex main-part flex-col px-6 py-4">
@@ -24,6 +26,7 @@
</template> </template>
<script> <script>
import { onBeforeMount, computed, ref } from 'vue';
import i18next from '@/i18n/i18n.js'; import i18next from '@/i18n/i18n.js';
import useAcctMgmtStore from '@/stores/acctMgmt.js'; import useAcctMgmtStore from '@/stores/acctMgmt.js';
import ModalHeader from './ModalHeader.vue'; import ModalHeader from './ModalHeader.vue';
@@ -32,25 +35,29 @@ import Badge from '../../components/Badge.vue';
export default { export default {
setup(){ setup(){
const acctMgmtStore = useAcctMgmtStore(); const acctMgmtStore = useAcctMgmtStore();
const visitTiime = 23; const visitTime = ref(0);
const { currentViewingUser } = acctMgmtStore; const currentViewingUser = computed(() => acctMgmtStore.currentViewingUser);
const { const {
id, username,
account, name,
fullName, is_admin,
adminRights, is_active,
accountActivation, is_sso,
detail has_data,
} = currentViewingUser; } = currentViewingUser.value;
onBeforeMount(async() => {
await acctMgmtStore.getUserDetail(currentViewingUser.value.username);
visitTime.value = currentViewingUser.value.detail.visits;
});
return { return {
i18next, i18next,
visitTiime, username,
id, name,
account, is_admin,
fullName, is_active,
adminRights, visitTime,
accountActivation,
detail
}; };
}, },
components: { components: {