Refactor Administration entrypoint

We moved the administration item to the company switcher in the header
This commit is contained in:
Darko Gjorgjijoski
2026-04-04 01:36:28 +02:00
parent 29b3abd317
commit eb0a588164
17 changed files with 295 additions and 30 deletions

View File

@@ -114,6 +114,8 @@ const InvoicePublicPage = () =>
import('@/scripts/components/InvoicePublicPage.vue')
// Administration (Super Admin)
const AdminDashboard = () =>
import('@/scripts/admin/views/administration/AdminDashboard.vue')
const AdminCompaniesIndex = () =>
import('@/scripts/admin/views/administration/companies/Index.vue')
const AdminCompaniesEdit = () =>
@@ -515,6 +517,12 @@ export default [
},
// Administration (Super Admin)
{
path: 'administration/dashboard',
name: 'admin.dashboard',
meta: { isSuperAdmin: true },
component: AdminDashboard,
},
{
path: 'administration/companies',
name: 'admin.companies.index',

View File

@@ -55,12 +55,16 @@ const isAppLoaded = computed(() => {
})
const hasCompany = computed(() => {
return !!companyStore.selectedCompany || !!userStore.currentUser?.is_super_admin
return !!companyStore.selectedCompany || companyStore.isAdminMode
})
onMounted(() => {
globalStore.bootstrap().then((res) => {
if (!res.data.current_company && !res.data.current_user.is_super_admin) {
if (companyStore.isAdminMode) {
return
}
if (!res.data.current_company) {
if (route.name !== 'no.company') {
router.push({ name: 'no.company' })
}

View File

@@ -18,7 +18,7 @@
"
>
<router-link
to="/admin/dashboard"
:to="companyStore.isAdminMode ? '/admin/administration/dashboard' : '/admin/dashboard'"
class="
float-none
text-lg
@@ -61,7 +61,7 @@
<ul class="flex float-right h-8 m-0 list-none md:h-9">
<li
v-if="hasCreateAbilities()"
v-if="hasCreateAbilities() && !companyStore.isAdminMode"
class="relative hidden float-left m-0 md:block"
>
<BaseDropdown width-class="w-48">
@@ -124,7 +124,7 @@
</BaseDropdown>
</li>
<li class="ml-2">
<li v-if="!companyStore.isAdminMode" class="ml-2">
<GlobalSearchBar
v-if="
userStore.currentUser.is_owner ||
@@ -179,6 +179,7 @@ import { computed } from 'vue'
import { useUserStore } from '@/scripts/admin/stores/user'
import { useGlobalStore } from '@/scripts/admin/stores/global'
import { useCompanyStore } from '@/scripts/admin/stores/company'
import CompanySwitcher from '@/scripts/components/CompanySwitcher.vue'
import GlobalSearchBar from '@/scripts/components/GlobalSearchBar.vue'
import MainLogo from '@/scripts/components/icons/MainLogo.vue'
@@ -188,6 +189,7 @@ import abilities from '@/scripts/admin/stub/abilities'
const authStore = useAuthStore()
const userStore = useUserStore()
const globalStore = useGlobalStore()
const companyStore = useCompanyStore()
const router = useRouter()
const previewAvatar = computed(() => {

View File

@@ -14,18 +14,32 @@ export const useCompanyStore = (useWindow = false) => {
selectedCompany: null,
selectedCompanySettings: {},
selectedCompanyCurrency: null,
isAdminMode: window.Ls?.get('isAdminMode') === 'true',
}),
actions: {
setSelectedCompany(data) {
if (data) {
window.Ls.set('selectedCompany', data.id)
window.Ls.remove('isAdminMode')
this.isAdminMode = false
} else {
window.Ls.remove('selectedCompany')
}
this.selectedCompany = data
},
setAdminMode(enabled) {
this.isAdminMode = enabled
if (enabled) {
window.Ls.set('isAdminMode', 'true')
window.Ls.remove('selectedCompany')
this.selectedCompany = null
} else {
window.Ls.remove('isAdminMode')
}
},
fetchBasicMailConfig() {
return new Promise((resolve, reject) => {
http

View File

@@ -47,10 +47,14 @@ export const useGlobalStore = (useWindow = false) => {
actions: {
bootstrap() {
return new Promise((resolve, reject) => {
const companyStore = useCompanyStore()
const url = companyStore.isAdminMode
? '/api/v1/bootstrap?admin_mode=1'
: '/api/v1/bootstrap'
http
.get('/api/v1/bootstrap')
.get(url)
.then(async (response) => {
const companyStore = useCompanyStore()
const userStore = useUserStore()
const moduleStore = useModuleStore()

View File

@@ -0,0 +1,104 @@
<template>
<BasePage>
<BasePageHeader :title="$t('navigation.dashboard')">
<BaseBreadcrumb>
<BaseBreadcrumbItem
:title="$t('navigation.administration')"
to="/admin/administration/dashboard"
active
/>
</BaseBreadcrumb>
</BasePageHeader>
<div v-if="isLoading" class="flex justify-center py-16">
<BaseGlobalLoader />
</div>
<div v-else class="grid grid-cols-1 gap-6 mt-6 md:grid-cols-2 lg:grid-cols-3">
<!-- App Version -->
<BaseCard>
<template #header>
<div class="flex items-center">
<BaseIcon name="ServerIcon" class="w-5 h-5 mr-2 text-gray-400" />
<span class="font-medium text-gray-700">{{ $t('general.app_version') }}</span>
</div>
</template>
<p class="text-2xl font-semibold text-gray-900">
{{ data.app_version }}
</p>
</BaseCard>
<!-- PHP Version -->
<BaseCard>
<template #header>
<div class="flex items-center">
<BaseIcon name="CodeBracketIcon" class="w-5 h-5 mr-2 text-gray-400" />
<span class="font-medium text-gray-700">PHP</span>
</div>
</template>
<p class="text-2xl font-semibold text-gray-900">
{{ data.php_version }}
</p>
</BaseCard>
<!-- Database -->
<BaseCard>
<template #header>
<div class="flex items-center">
<BaseIcon name="CircleStackIcon" class="w-5 h-5 mr-2 text-gray-400" />
<span class="font-medium text-gray-700">{{ $t('general.database') }}</span>
</div>
</template>
<p class="text-2xl font-semibold text-gray-900">
{{ data.database?.driver?.toUpperCase() }}
</p>
<p class="text-sm text-gray-500 mt-1">
{{ data.database?.version }}
</p>
</BaseCard>
<!-- Companies -->
<BaseCard>
<template #header>
<div class="flex items-center">
<BaseIcon name="BuildingOfficeIcon" class="w-5 h-5 mr-2 text-gray-400" />
<span class="font-medium text-gray-700">{{ $t('navigation.companies') }}</span>
</div>
</template>
<p class="text-2xl font-semibold text-gray-900">
{{ data.counts?.companies }}
</p>
</BaseCard>
<!-- Users -->
<BaseCard>
<template #header>
<div class="flex items-center">
<BaseIcon name="UsersIcon" class="w-5 h-5 mr-2 text-gray-400" />
<span class="font-medium text-gray-700">{{ $t('navigation.all_users') }}</span>
</div>
</template>
<p class="text-2xl font-semibold text-gray-900">
{{ data.counts?.users }}
</p>
</BaseCard>
</div>
</BasePage>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import http from '@/scripts/http'
const isLoading = ref(true)
const data = ref({})
onMounted(async () => {
try {
const response = await http.get('/api/v1/super-admin/dashboard')
data.value = response.data
} finally {
isLoading.value = false
}
})
</script>