light modification
This commit is contained in:
		
							
								
								
									
										45
									
								
								models/workflow/graph/link.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								models/workflow/graph/link.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
package graph
 | 
			
		||||
 | 
			
		||||
// GraphLink is a struct that represents a link between two items in a graph
 | 
			
		||||
type GraphLink struct {
 | 
			
		||||
	Source      Position        `bson:"source" json:"source" validate:"required"`           // Source is the source graphical position of the link
 | 
			
		||||
	Destination Position        `bson:"destination" json:"destination" validate:"required"` // Destination is the destination graphical position of the link
 | 
			
		||||
	Style       *GraphLinkStyle `bson:"style,omitempty" json:"style,omitempty"`             // Style is the graphical style of the link
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// tool function to check if a link is a link between a compute and a resource
 | 
			
		||||
func (l *GraphLink) IsComputeLink(g Graph) (bool, string) {
 | 
			
		||||
	if g.Items == nil {
 | 
			
		||||
		return false, ""
 | 
			
		||||
	}
 | 
			
		||||
	if d, ok := g.Items[l.Source.ID]; ok && d.Compute != nil {
 | 
			
		||||
		return true, d.Compute.UUID
 | 
			
		||||
	}
 | 
			
		||||
	if d, ok := g.Items[l.Destination.ID]; ok && d.Compute != nil {
 | 
			
		||||
		return true, d.Compute.UUID
 | 
			
		||||
	}
 | 
			
		||||
	return false, ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GraphLinkStyle is a struct that represents the style of a link in a graph
 | 
			
		||||
type GraphLinkStyle struct {
 | 
			
		||||
	Color           int64    `bson:"color" json:"color"`                         // Color is the graphical color of the link (int description of a color, can be transpose as hex)
 | 
			
		||||
	Stroke          float64  `bson:"stroke" json:"stroke"`                       // Stroke is the graphical stroke of the link
 | 
			
		||||
	Tension         float64  `bson:"tension" json:"tension"`                     // Tension is the graphical tension of the link
 | 
			
		||||
	HeadRadius      float64  `bson:"head_radius" json:"head_radius"`             // graphical pin radius
 | 
			
		||||
	DashWidth       float64  `bson:"dash_width" json:"dash_width"`               // DashWidth is the graphical dash width of the link
 | 
			
		||||
	DashSpace       float64  `bson:"dash_space" json:"dash_space"`               // DashSpace is the graphical dash space of the link
 | 
			
		||||
	EndArrow        Position `bson:"end_arrow" json:"end_arrow"`                 // EndArrow is the graphical end arrow of the link
 | 
			
		||||
	StartArrow      Position `bson:"start_arrow" json:"start_arrow"`             // StartArrow is the graphical start arrow of the link
 | 
			
		||||
	ArrowStyle      int64    `bson:"arrow_style" json:"arrow_style"`             // ArrowStyle is the graphical arrow style of the link (enum foundable in UI)
 | 
			
		||||
	ArrowDirection  int64    `bson:"arrow_direction" json:"arrow_direction"`     // ArrowDirection is the graphical arrow direction of the link (enum foundable in UI)
 | 
			
		||||
	StartArrowWidth float64  `bson:"start_arrow_width" json:"start_arrow_width"` // StartArrowWidth is the graphical start arrow width of the link
 | 
			
		||||
	EndArrowWidth   float64  `bson:"end_arrow_width" json:"end_arrow_width"`     // EndArrowWidth is the graphical end arrow width of the link
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Position is a struct that represents a graphical position
 | 
			
		||||
type Position struct {
 | 
			
		||||
	ID string  `json:"id" bson:"id"`                   // ID reprents ItemID (optionnal)
 | 
			
		||||
	X  float64 `json:"x" bson:"x" validate:"required"` // X is the graphical x position
 | 
			
		||||
	Y  float64 `json:"y" bson:"y" validate:"required"` // Y is the graphical y position
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user