All files / src/views HomePage.vue

100% Statements 48/48
85.71% Branches 12/14
100% Functions 8/8
100% Lines 46/46

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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178  10x 1x 1x 1x 1x 1x 1x               1x                           1x 1x 1x 1x       1x                 1x 1x 1x 1x               1x     10x     10x             1x 1x 1x 1x 1x       1x                                 1x 1x 1x   2x       20x                     10x 10x 10x 10x   10x 10x 8x 8x     10x 10x     10x 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">
                <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?.attributes?.email || '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 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-book" class="me-2" style="color: #689909" />
                {{ t('home.apiDocs') }}
              </h5>
              <div class="d-grid">
                <a
                  :href="apiDocsUrl"
                  target="_blank"
                  rel="noopener"
                  class="btn btn-sm btn-outline-success"
                >
                  <font-awesome-icon icon="fa-solid fa-up-right-from-square" class="me-1" />
                  Swagger UI
                </a>
              </div>
            </div>
          </div>
        </div>
      </div>
 
      <div v-if="!authStore.currentFlow" 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 { useFlowsStore } from '@/stores/flows'
import { useUILanguage } from '@/composables/useUILanguage'
 
const authStore = useAuthStore()
const flowsStore = useFlowsStore()
const { t } = useUILanguage()
const loading = ref(true)
 
const currentFlowName = computed(() => {
  if (!authStore.currentFlow) return 'None'
  const flow = flowsStore.myFlows.find((t) => t.flowId === authStore.currentFlow)
  return flow?.flowName || 'None'
})
 
const apiDocsUrl = computed(
  () => `${import.meta.env.VITE_API_URL || 'https://api.flows.browsway.com'}/v1/docs`
)
 
onMounted(async () => {
  loading.value = true
  try {
    await flowsStore.fetchMyFlows()
  } finally {
    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>