Files
panel/resources/js/pages/dashboards/demo.vue

126 lines
3.4 KiB
Vue
Raw Normal View History

2025-08-04 16:33:07 +03:30
<script setup>
2025-09-03 17:28:04 +03:30
import { onMounted, nextTick, ref } from 'vue'
2025-08-04 16:33:07 +03:30
import { GridStack } from 'gridstack'
import ProjectActivityBarChart from "@/components/ProjectActivityBarChart.vue";
import AnalysisCard from "@/components/AnalysisCard.vue";
import CostOverview from "@/components/CostOverview.vue";
import GeneratedLeadsCard from "@/views/dashboards/ecommerce/EcommerceGeneratedLeads.vue";
2025-09-03 17:28:04 +03:30
import AgGridTable from '@/views/demos/forms/tables/data-table/AgGridTable.vue';
2025-09-08 10:45:29 +03:30
const ganttColumns = ref([])
const generateColumnsFromData = (data) => {
if (!data || data.length === 0) return []
const firstItem = data[0]
const columns = Object.keys(firstItem).map(key => {
const column = {
field: key,
headerName: key.charAt(0).toUpperCase() + key.slice(1).replace(/([A-Z])/g, ' $1'),
sortable: true,
filter: true,
flex: 1
}
if (key === 'id') {
column.width = 80
column.flex = undefined
}
if (key === 'completed' && typeof firstItem[key] === 'boolean') {
column.width = 120
column.flex = undefined
column.cellRenderer = (params) => {
return params.value ? '<span style="color: green; font-weight: bold;">✓ Completed</span>' : '<span style="color: orange; font-weight: bold;">⏳ Pending</span>'
}
}
if (key === 'userId') {
column.width = 100
column.flex = undefined
2025-09-03 17:28:04 +03:30
}
2025-09-08 10:45:29 +03:30
return column
})
return columns
}
2025-09-03 17:28:04 +03:30
const processAPIData = (response) => {
2025-09-08 10:45:29 +03:30
const data = response.todos || response
ganttColumns.value = generateColumnsFromData(data)
return data
2025-09-03 17:28:04 +03:30
}
2025-08-04 16:33:07 +03:30
onMounted(async () => {
const grid = GridStack.init({
column: 12,
2025-09-08 10:45:29 +03:30
cellHeight: '105',
2025-08-04 16:33:07 +03:30
float: true,
draggable: { handle: '.grid-stack-item-content' },
resizable: true,
maxRow: 20,
2025-08-04 16:33:07 +03:30
})
await nextTick()
})
</script>
2025-08-04 16:33:07 +03:30
<template>
<div class="grid-stack">
2025-09-08 10:45:29 +03:30
<div class="grid-stack-item" gs-w="4" gs-min-h="2" gs-max-h="2">
2025-08-04 16:33:07 +03:30
<div class="grid-stack-item-content">
<GeneratedLeadsCard :progress="32" />
2025-08-04 16:33:07 +03:30
</div>
</div>
<div class="grid-stack-item" gs-min-w="4" gs-h="2" gs-max-h="2">
2025-08-04 16:33:07 +03:30
<div class="grid-stack-item-content">
<GeneratedLeadsCard :donut-colors="['primary']" :progress="71" />
2025-08-04 16:33:07 +03:30
</div>
</div>
<div class="grid-stack-item" gs-min-w="4" gs-h="2" gs-max-h="2">
2025-08-04 16:33:07 +03:30
<div class="grid-stack-item-content">
<GeneratedLeadsCard :donut-colors="['warning']" :progress="32" />
2025-08-04 16:33:07 +03:30
</div>
</div>
<div class="grid-stack-item" gs-w="8" gs-h="7" gs-max-h="7">
2025-08-04 16:33:07 +03:30
<div class="grid-stack-item-content">
<ProjectActivityBarChart />
2025-08-04 16:33:07 +03:30
</div>
</div>
<div class="grid-stack-item" gs-w="4" gs-h="7" gs-max-h="7">
2025-08-04 16:33:07 +03:30
<div class="grid-stack-item-content">
<AnalysisCard />
2025-08-04 16:33:07 +03:30
</div>
</div>
2025-09-08 10:45:29 +03:30
<div class="grid-stack-item" gs-w="12" gs-h="6" gs-max-h="6">
2025-08-04 16:33:07 +03:30
<div class="grid-stack-item-content">
2025-09-03 17:28:04 +03:30
<AgGridTable :columns="ganttColumns" api-url="https://dummyjson.com/todos"
:data-processor="processAPIData" :enable-export="true" :enable-edit="true" :enable-delete="true"
:enable-search="true" height="500px" />
2025-08-04 16:33:07 +03:30
</div>
</div>
</div>
</template>
2025-08-04 16:33:07 +03:30
<style>
.grid-stack-item-content {
height: 100%;
display: flex;
flex-direction: column;
}
2025-08-04 16:33:07 +03:30
.grid-stack-item-content>* {
flex: 1;
margin-bottom: 3.2rem;
}
2025-08-04 16:33:07 +03:30
2025-09-03 17:28:04 +03:30
.grid-stack-item:has(AgGridTable) {
height: 100vh !important;
}
2025-08-04 16:33:07 +03:30
2025-09-03 17:28:04 +03:30
.grid-stack-item:has(AgGridTable) .grid-stack-item-content {
height: 100vh;
}
</style>