table

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDistributionStatus

func GetDistributionStatus(str string) string

func IsNodeLabelInBlacklist added in v1.4.0

func IsNodeLabelInBlacklist(node data.Object) bool

func IsNodeOffline added in v1.4.0

func IsNodeOffline(node data.Object) bool

func SortByDistribution

func SortByDistribution(data []RowItem, sortColumn string, asc bool)

SortByDistribution sort by percent

func SortByNode

func SortByNode(data []RowItem, _ string, asc bool)

SortByNode sort by node struct

func SortByStatus

func SortByStatus(data []RowItem, _ string, asc bool)

SortByStatus sort by percent

func SortByString

func SortByString(data []RowItem, sortColumn string, asc bool)

SortByString sort by string value

Types

type BatchOperation

type BatchOperation struct {
	Key       string   `json:"key,omitempty"`
	Text      string   `json:"text,omitempty"`
	Reload    bool     `json:"reload,omitempty"`
	ShowIndex []string `json:"showIndex,omitempty"`
}

type Columns

type Columns struct {
	Title     string `json:"title,omitempty"`
	DataIndex string `json:"dataIndex,omitempty"`
	Width     int    `json:"width,omitempty"`
	Sortable  bool   `json:"sorter,omitempty"`
	Fixed     string `json:"fixed,omitempty"`
	TitleTip  string `json:"titleTip"`
}

type Command

type Command struct {
	Key     string       `json:"key,omitempty"`
	Command CommandState `json:"state,omitempty"`
	Target  string       `json:"target,omitempty"`
	JumpOut bool         `json:"jumpOut,omitempty"`
}

type CommandState

type CommandState struct {
	Params   Params                 `json:"params,omitempty"`
	Visible  bool                   `json:"visible,omitempty"`
	FormData FormData               `json:"formData,omitempty"`
	Query    map[string]interface{} `json:"query,omitempty"`
}

type Distribution

type Distribution struct {
	RenderType string `json:"renderType,omitempty"`
	//Value      DistributionValue `json:"value,omitempty"`
	Value  string `json:"value"`
	Status string `json:"status,omitempty"`
	Tip    string `json:"tip,omitempty"`
}

type DistributionValue

type DistributionValue struct {
	Text    string `json:"text"`
	Percent string `json:"percent"`
}

type FormData

type FormData struct {
	RecordId string `json:"recordId,omitempty"`
}

type GetRowItem

type GetRowItem interface {
	GetRowItems(c []data.Object, resName TableType, requests map[string]cmp.AllocatedRes) ([]RowItem, error)
}

type Labels

type Labels struct {
	RenderType string               `json:"renderType,omitempty"`
	Value      []label.Label        `json:"value,omitempty"`
	Operations map[string]Operation `json:"operations,omitempty"`
}

type LabelsValue

type LabelsValue struct {
	Label string `json:"label"`
	Group string `json:"group"`
}

type Meta

type Meta struct {
	Id       int    `json:"id,omitempty"`
	PageSize int    `json:"pageSize,omitempty"`
	PageNo   int    `json:"pageNo,omitempty"`
	Sorter   Sorter `json:"sorter,omitempty"`
}

type Node

type Node struct {
	RenderType string        `json:"renderType,omitempty"`
	Renders    []interface{} `json:"renders,omitempty"`
}
type NodeLink struct {
	RenderType string               `json:"renderType,omitempty"`
	Value      string               `json:"value,omitempty"`
	Operations map[string]Operation `json:"operations,omitempty"`
	Reload     bool                 `json:"reload"`
}

type NodeTags

type NodeTags struct {
	RenderType string               `json:"renderType,omitempty"`
	Value      []label.Label        `json:"value,omitempty"`
	Operation  map[string]Operation `json:"operation,omitempty"`
}

type Operate

type Operate struct {
	RenderType string               `json:"renderType,omitempty"`
	Operations map[string]Operation `json:"operations,omitempty"`
}

type Operation

type Operation struct {
	Key           string      `json:"key,omitempty"`
	Reload        bool        `json:"reload"`
	FillMeta      string      `json:"fillMeta,omitempty"`
	Confirm       string      `json:"confirm"`
	Target        string      `json:"target,omitempty"`
	Meta          interface{} `json:"meta,omitempty"`
	ClickableKeys interface{} `json:"clickableKeys,omitempty"`
	Text          string      `json:"text,omitempty"`
	Command       *Command    `json:"command,omitempty"`
}

type Params

type Params struct {
	NodeId string `json:"nodeId,omitempty"`
	NodeIP string `json:"nodeIP,omitempty"`
}

type RowItem

type RowItem struct {
	ID      string      `json:"id,omitempty"`
	IP      string      `json:"IP,omitempty"`
	Status  SteveStatus `json:"Status,omitempty"`
	Node    Node        `json:"Node,omitempty"`
	NodeID  string      `json:"nodeId,omitempty"`
	Role    string      `json:"Role,omitempty"`
	Version string      `json:"Version,omitempty"`
	//
	Distribution Distribution `json:"Distribution,omitempty"`
	Usage        Distribution `json:"Usage,omitempty"`
	UnusedRate   Distribution `json:"UnusedRate,omitempty"`
	Operate      Operate      `json:"Operate,omitempty"`
	// batchOperations for json
	BatchOperations []string `json:"batchOperations,omitempty"`
}

type Scroll

type Scroll struct {
	X int `json:"x,omitempty"`
	Y int `json:"y,omitempty"`
}

type Sorter

type Sorter struct {
	Field string `json:"field,omitempty"`
	Order string `json:"order,omitempty"`
}

type State

type State struct {
	//PageNo          int           `json:"pageNo,omitempty"`
	//PageSize        int           `json:"pageSize,omitempty"`
	//Left           int           `json:"total,omitempty"`
	SelectedRowKeys []string      `json:"selectedRowKeys,omitempty"`
	Sorter          Sorter        `json:"sorterData,omitempty"`
	Values          filter.Values `json:"values"`
}

type SteveStatus

type SteveStatus struct {
	Value      string `json:"value,omitempty"`
	RenderType string `json:"renderType"`
	Status     string `json:"status"`
}

type Table

type Table struct {
	TableComponent GetRowItem
	base.DefaultProvider
	SDK        *cptype.SDK
	Ctx        context.Context
	Metrics    metrics.Interface
	Server     cmp.SteveServer
	Type       string                 `json:"type"`
	Props      map[string]interface{} `json:"props"`
	Operations map[string]interface{} `json:"operations"`
	State      State                  `json:"state"`
}

func (*Table) CordonNode

func (t *Table) CordonNode(ctx context.Context, nodeNames []string) error

func (*Table) GetDistributionValue

func (t *Table) GetDistributionValue(req, total float64, resourceType TableType) DistributionValue

func (*Table) GetIp

func (t *Table) GetIp(node data.Object) string

func (*Table) GetItemStatus

func (t *Table) GetItemStatus(node data.Object) (*SteveStatus, error)

func (*Table) GetLabelGroupAndDisplayName

func (t *Table) GetLabelGroupAndDisplayName(label string) (string, string)

func (*Table) GetLabelOperation

func (t *Table) GetLabelOperation(rowId string) map[string]Operation

func (*Table) GetMetrics added in v1.4.0

func (t *Table) GetMetrics(ctx context.Context)

func (*Table) GetNodeAddress

func (t *Table) GetNodeAddress(addrs []v1.NodeAddress) string

func (*Table) GetNodeLabels

func (t *Table) GetNodeLabels(labels data.Object) []label.Label

func (*Table) GetNodes

func (t *Table) GetNodes(ctx context.Context, gs *cptype.GlobalStateData) ([]data.Object, error)

func (*Table) GetOperate

func (t *Table) GetOperate(id string) Operate

func (*Table) GetPods

func (t *Table) GetPods(ctx context.Context) (map[string][]data.Object, error)

func (*Table) GetRenders

func (t *Table) GetRenders(id string, labelMap data.Object) []interface{}

func (*Table) GetScaleValue

func (t *Table) GetScaleValue(a, b float64, Type TableType) string

func (*Table) GetTableOperation

func (t *Table) GetTableOperation() map[string]interface{}

func (*Table) GetUnusedRate

func (t *Table) GetUnusedRate(unallocate, request float64, resourceType TableType) DistributionValue

func (*Table) GetUsageValue

func (t *Table) GetUsageValue(used, total float64, resourceType TableType) DistributionValue

func (*Table) RenderList

func (t *Table) RenderList(component *cptype.Component, tableType TableType, gs *cptype.GlobalStateData) error

func (*Table) SetComponentValue

func (t *Table) SetComponentValue(c *cptype.Component) error

SetComponentValue mapping properties to Component

func (*Table) SetData

func (t *Table) SetData(nodes []data.Object, tableType TableType, requests map[string]cmp.AllocatedRes) ([]RowItem, error)

SetData assemble rowItem of table

func (*Table) UncordonNode

func (t *Table) UncordonNode(ctx context.Context, nodeNames []string) error

type TableType

type TableType string
const (
	DefaultPageSize = 10
	DefaultPageNo   = 1

	Pod    TableType = "pod"
	Memory TableType = "memory"
	Cpu    TableType = "cpu"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL