All files / src/views HomePage.vue

100% Statements 39/39
91.66% Branches 11/12
100% Functions 7/7
100% Lines 37/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145  10x 1x 1x 1x 1x 1x 1x               1x                           1x 1x 1x 1x       1x             1x 1x 1x 1x               1x     10x     10x               1x 1x 1x   2x       20x                     10x 10x 10x 10x   10x 10x 8x 8x     10x 10x 10x 10x                                                                                      
<template>
  <PageLayout :title="t('navigation.dashboard')" class="dashboard-page">
    <div class="scrollable-content">
      <div class="row">
        <div class="col-md-4 mb-3">
          <div class="card h-100 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">
                <font-awesome-icon
                  icon="fa-solid fa-building"
                  class="me-2"
                  style="color: #689909"
                />
                {{ t('home.currentFlow') }}
              </h5>
              <p class="card-text fs-4">
                <span
                  v-if="loading"
                  class="spinner-border spinner-border-sm text-success"
                  role="status"
                >
                  <span class="visually-hidden">Loading...</span>
                </span>
                <span v-else>{{ currentFlowName }}</span>
              </p>
            </div>
          </div>
        </div>
 
        <div class="col-md-4 mb-3">
          <div class="card h-100 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">
                <font-awesome-icon icon="fa-solid fa-user" class="me-2" style="color: #689909" />
                {{ t('home.welcome') }}
              </h5>
              <p class="card-text">
                {{ authStore.user?.attributes?.name || authStore.user?.username || 'User' }}
              </p>
            </div>
          </div>
        </div>
 
        <div class="col-md-4 mb-3">
          <div class="card h-100 shadow-sm">
            <div class="card-body">
              <h5 class="card-title">
                <font-awesome-icon
                  icon="fa-solid fa-database"
                  class="me-2"
                  style="color: #689909"
                />
                {{ t('home.quickActions') }}
              </h5>
              <div class="d-grid gap-2">
                <router-link to="/entities" class="btn btn-sm btn-success">{{
                  t('navigation.entities')
                }}</router-link>
                <router-link to="/flows" class="btn btn-sm btn-success">{{
                  t('navigation.flows')
                }}</router-link>
              </div>
            </div>
          </div>
        </div>
      </div>
 
      <div v-if="!authStore.currentTenant" class="row mt-4">
        <div class="col-12">
          <div class="alert alert-warning shadow-sm">
            <h5 class="alert-heading">{{ t('flow.noActiveFlow') }}</h5>
            <p>{{ t('flow.selectFlowFirst') }}</p>
            <router-link to="/flows" class="btn btn-success">{{ t('flow.goToFlows') }}</router-link>
          </div>
        </div>
      </div>
    </div>
  </PageLayout>
</template>
 
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import PageLayout from '@/components/PageLayout.vue'
import { useAuthStore } from '@/stores/auth'
import { useTenantsStore } from '@/stores/tenants'
import { useUILanguage } from '@/composables/useUILanguage'
 
const authStore = useAuthStore()
const tenantsStore = useTenantsStore()
const { t } = useUILanguage()
const loading = ref(true)
 
const currentFlowName = computed(() => {
  if (!authStore.currentTenant) return 'None'
  const tenant = tenantsStore.myTenants.find((t) => t.tenantId === authStore.currentTenant)
  return tenant?.tenantName || 'None'
})
 
onMounted(async () => {
  loading.value = true
  await tenantsStore.fetchMyTenants()
  loading.value = false
})
</script>
 
<style scoped>
.dashboard-page :deep(.page-content) {
  padding: 0 !important;
  height: 100%;
  display: flex;
  flex-direction: column;
}
 
.dashboard-page :deep(.page-header) {
  flex-shrink: 0;
  padding: 0 2rem !important;
  margin-bottom: 0;
}
 
.scrollable-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 2rem;
}
 
/* Mobile optimization */
@media (max-width: 767px) {
  .dashboard-page :deep(.page-header) {
    padding: 0 1rem !important;
  }
 
  .scrollable-content {
    padding: 1rem;
  }
 
  .card-title {
    font-size: 1rem;
  }
 
  .fs-4 {
    font-size: 1.25rem !important;
  }
}
</style>