Skip to content

Commit a4a2ef0

Browse files
committed
chore: wip
1 parent f144362 commit a4a2ef0

File tree

1 file changed

+56
-30
lines changed
  • storage/framework/defaults/views/dashboard/models

1 file changed

+56
-30
lines changed

storage/framework/defaults/views/dashboard/models/index.vue

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ const createDiagram = () => {
406406
if (!diagramContainer.value) return
407407
408408
const width = diagramContainer.value.clientWidth
409-
const height = 800 // Increased height for better spacing
409+
const height = 1200 // Further increased height for better vertical spacing
410410
const cardWidth = 310 // Card width defined here for consistent reference
411411
412412
// Clear existing visualization
@@ -487,35 +487,29 @@ const createDiagram = () => {
487487
const g = svg.append('g')
488488
489489
// Apply initial zoom to see all content
490-
const initialScale = 0.7 // Reduced scale to see more content
491-
svg.call(zoom.transform, d3.zoomIdentity.translate(width/2 - width*initialScale/2, 20).scale(initialScale))
490+
const initialScale = 0.55 // Further reduced scale to see more content
491+
svg.call(zoom.transform, d3.zoomIdentity.translate(width/2 - width*initialScale/2, 10).scale(initialScale))
492492
493493
// Set initial positions for models based on the reference image layout
494494
const initialPositions: Record<string, {x: number, y: number}> = {
495-
// Top row
496-
'team': { x: width * 0.25, y: 150 },
495+
// Top row - more evenly spaced
496+
'team': { x: width * 0.2, y: 150 },
497497
'user': { x: width * 0.5, y: 150 },
498-
'post': { x: width * 0.75, y: 150 },
498+
'post': { x: width * 0.8, y: 150 },
499499
500-
// Second row
501-
'accessToken': { x: width * 0.25, y: 450 },
500+
// Second row - better distributed
501+
'accessToken': { x: width * 0.2, y: 450 },
502+
'subscriber': { x: width * 0.8, y: 450 },
502503
503-
// Third row - left side
504-
'project': { x: width * 0.25, y: 700 },
504+
// Third row - more evenly spaced
505+
'project': { x: width * 0.2, y: 750 },
506+
'order': { x: width * 0.5, y: 750 },
507+
'subscriberEmail': { x: width * 0.8, y: 750 },
505508
506-
// Fourth row - left side
507-
'deployment': { x: width * 0.1, y: 900 },
508-
'release': { x: width * 0.4, y: 900 },
509-
510-
// Second row - right side
511-
'subscriber': { x: width * 0.75, y: 450 },
512-
513-
// Third row - right side
514-
'subscriberEmail': { x: width * 0.75, y: 700 },
515-
'order': { x: width * 0.5, y: 700 },
516-
517-
// Fourth row - right side
518-
'orderItem': { x: width * 0.5, y: 900 }
509+
// Fourth row - better distributed with more horizontal spacing
510+
'deployment': { x: width * 0.1, y: 1050 },
511+
'release': { x: width * 0.35, y: 1050 },
512+
'orderItem': { x: width * 0.65, y: 1050 }
519513
}
520514
521515
// Apply initial positions to models and store them for dragging
@@ -782,11 +776,14 @@ const createDiagram = () => {
782776
// Calculate control points for the curve
783777
const dx = targetModel.posX - sourceModel.posX
784778
const dy = targetModel.posY - sourceModel.posY
785-
const dr = Math.sqrt(dx * dx + dy * dy) * 1.5 // Increased curve factor for better arcs
779+
const distance = Math.sqrt(dx * dx + dy * dy)
780+
781+
// Adjust curve factor based on distance between nodes
782+
const curveFactor = distance > 500 ? 1.5 : 2.5
783+
const dr = distance * curveFactor
786784
787785
// Determine if we need a clockwise or counter-clockwise arc
788-
const sweep = (sourceId === 'user' && targetId === 'team') ||
789-
(sourceId === 'team' && targetId === 'user') ? 0 : 1;
786+
const sweep = determineArcSweep(sourceId, targetId);
790787
791788
// Create curved path
792789
linkGroup.append('path')
@@ -860,6 +857,32 @@ const createDiagram = () => {
860857
.alphaDecay(0.02) // Slower decay for smoother animation
861858
}
862859
860+
// Helper function to determine arc sweep direction
861+
function determineArcSweep(sourceId: string, targetId: string): number {
862+
// Define specific pairs that should use counter-clockwise arcs
863+
const counterClockwisePairs = [
864+
['user', 'team'],
865+
['team', 'user'],
866+
['user', 'post'],
867+
['user', 'subscriber'],
868+
['user', 'deployment'],
869+
['project', 'deployment'],
870+
['project', 'release'],
871+
['subscriber', 'subscriberEmail'],
872+
['order', 'orderItem']
873+
];
874+
875+
// Check if this pair should use counter-clockwise arc
876+
for (const pair of counterClockwisePairs) {
877+
if ((sourceId === pair[0] && targetId === pair[1]) ||
878+
(sourceId === pair[1] && targetId === pair[0])) {
879+
return 0; // Counter-clockwise
880+
}
881+
}
882+
883+
return 1; // Default to clockwise
884+
}
885+
863886
// Function to update links after dragging
864887
function updateLinks() {
865888
if (!diagramContainer.value) return
@@ -882,11 +905,14 @@ function updateLinks() {
882905
// Calculate control points for the curve
883906
const dx = targetModel.posX - sourceModel.posX
884907
const dy = targetModel.posY - sourceModel.posY
885-
const dr = Math.sqrt(dx * dx + dy * dy) * 1.5 // Increased curve factor for better arcs
908+
const distance = Math.sqrt(dx * dx + dy * dy)
909+
910+
// Adjust curve factor based on distance between nodes
911+
const curveFactor = distance > 500 ? 1.5 : 2.5
912+
const dr = distance * curveFactor
886913
887914
// Determine if we need a clockwise or counter-clockwise arc
888-
const sweep = (sourceId === 'user' && targetId === 'team') ||
889-
(sourceId === 'team' && targetId === 'user') ? 0 : 1;
915+
const sweep = determineArcSweep(sourceId, targetId);
890916
891917
// Create curved path
892918
linkGroup.append('path')
@@ -971,7 +997,7 @@ onUnmounted(() => {
971997
</button>
972998
</div>
973999
</div>
974-
<div ref="diagramContainer" class="w-full h-[800px] bg-gray-50 dark:bg-blue-gray-800 rounded-lg"></div>
1000+
<div ref="diagramContainer" class="w-full h-[1200px] bg-gray-50 dark:bg-blue-gray-800 rounded-lg"></div>
9751001
</div>
9761002
</div>
9771003
</div>

0 commit comments

Comments
 (0)