Documentation ¶
Index ¶
Constants ¶
const ( NameProperty = "name" CreationTimestampProperty = "creationTimestamp" NamespaceProperty = "namespace" StatusProperty = "status" TypeProperty = "type" FirstSeenProperty = "firstSeen" LastSeenProperty = "lastSeen" ReasonProperty = "reason" )
List of all property names supported by the UI.
Variables ¶
var DefaultDataSelect = NewDataSelectQuery(DefaultPagination, NoSort, NoFilter)
DefaultDataSelect downloads first 10 items from page 1 with no sort and no metrics.
var DefaultPagination = NewPaginationQuery(10, 0)
Returns 10 items from page 1
var EmptyPagination = NewPaginationQuery(0, 0)
No items will be returned
var NoFilter = &FilterQuery{ FilterByList: []FilterBy{}, }
var NoPagination = NewPaginationQuery(-1, -1)
By default backend pagination will not be applied.
var NoSort = &SortQuery{ SortByList: []SortBy{}, }
NoSort is as option for no sort.
Functions ¶
This section is empty.
Types ¶
type ComparableValue ¶
type ComparableValue interface { // Compares self with other value. Returns 1 if other value is smaller, 0 if they are the same, -1 if other is larger. Compare(ComparableValue) int // Returns true if self value contains or is equal to other value, false otherwise. Contains(ComparableValue) bool }
ComparableValue hold any value that can be compared to its own kind.
type DataCell ¶
type DataCell interface { // GetPropertyAtIndex returns the property of this data cell. // Value returned has to have Compare method which is required by Sort functionality of DataSelect. GetProperty(PropertyName) ComparableValue }
GenericDataCell describes the interface of the data cell that contains all the necessary methods needed to perform complex data selection GenericDataSelect takes a list of these interfaces and performs selection operation. Therefore as long as the list is composed of GenericDataCells you can perform any data selection!
func GenericDataSelect ¶
func GenericDataSelect(dataList []DataCell, dsQuery *DataSelectQuery) []DataCell
GenericDataSelect takes a list of GenericDataCells and DataSelectQuery and returns selected data as instructed by dsQuery.
func GenericDataSelectWithFilter ¶
func GenericDataSelectWithFilter(dataList []DataCell, dsQuery *DataSelectQuery) ([]DataCell, int)
GenericDataSelectWithFilter 获取 GenericDataCells 和 DataSelectQuery 的列表,并按照 dsQuery 的指示返回选定的数据。
type DataSelectQuery ¶
type DataSelectQuery struct { PaginationQuery *PaginationQuery SortQuery *SortQuery FilterQuery *FilterQuery }
DataSelectQuery is options for GenericDataSelect which takes []GenericDataCell and returns selected data. Can be extended to include any kind of selection - for example filtering. Currently included only Pagination and Sort options.
func NewDataSelectQuery ¶
func NewDataSelectQuery(paginationQuery *PaginationQuery, sortQuery *SortQuery, filterQuery *FilterQuery) *DataSelectQuery
NewDataSelectQuery creates DataSelectQuery object from simpler data select queries.
type DataSelector ¶
type DataSelector struct { // GenericDataList hold generic data cells that are being selected. GenericDataList []DataCell // DataSelectQuery holds instructions for data select. DataSelectQuery *DataSelectQuery }
SelectableData contains all the required data to perform data selection. It implements sort.Interface so its sortable under sort.Sort You can use its Select method to get selected GenericDataCell list.
func (*DataSelector) Filter ¶
func (self *DataSelector) Filter() *DataSelector
Filter the data inside as instructed by DataSelectQuery and returns itself to allow method chaining.
func (DataSelector) Len ¶
func (self DataSelector) Len() int
Len returns the length of data inside SelectableData.
func (DataSelector) Less ¶
func (self DataSelector) Less(i, j int) bool
Less compares 2 indices inside SelectableData and returns true if first index is larger.
func (*DataSelector) Paginate ¶
func (self *DataSelector) Paginate() *DataSelector
Paginates the data inside as instructed by DataSelectQuery and returns itself to allow method chaining.
func (*DataSelector) Sort ¶
func (self *DataSelector) Sort() *DataSelector
Sort sorts the data inside as instructed by DataSelectQuery and returns itself to allow method chaining.
func (DataSelector) Swap ¶
func (self DataSelector) Swap(i, j int)
Swap swaps 2 indices inside SelectableData.
type FilterBy ¶
type FilterBy struct { Property PropertyName Value ComparableValue }
type FilterQuery ¶
type FilterQuery struct {
FilterByList []FilterBy
}
func NewFilterQuery ¶
func NewFilterQuery(filterByListRaw []string) *FilterQuery
NewFilterQuery takes raw filter options list and returns FilterQuery object. For example: ["parameter1", "value1", "parameter2", "value2"] - means that the data should be filtered by parameter1 equals value1 and parameter2 equals value2
type PaginationQuery ¶
type PaginationQuery struct { // How many items per page should be returned ItemsPerPage int // Number of page that should be returned when pagination is applied to the list Page int }
PaginationQuery structure represents pagination settings
func NewPaginationQuery ¶
func NewPaginationQuery(itemsPerPage, page int) *PaginationQuery
NewPaginationQuery return pagination query structure based on given parameters
func (*PaginationQuery) GetPaginationSettings ¶
func (p *PaginationQuery) GetPaginationSettings(itemsCount int) (startIndex int, endIndex int)
GetPaginationSettings based on number of items and pagination query parameters returns start and end index that can be used to return paginated list of items.
func (*PaginationQuery) IsPageAvailable ¶
func (p *PaginationQuery) IsPageAvailable(itemsCount, startingIndex int) bool
IsPageAvailable returns true if at least one element can be placed on page. False otherwise
func (*PaginationQuery) IsValidPagination ¶
func (p *PaginationQuery) IsValidPagination() bool
IsValidPagination returns true if pagination has non negative parameters
type PropertyName ¶
type PropertyName string
PropertyName is used to get the value of certain property of data cell. For example if we want to get the namespace of certain Deployment we can use DeploymentCell.GetProperty(NamespaceProperty)
type SortBy ¶
type SortBy struct { Property PropertyName Ascending bool }
SortBy holds the name of the property that should be sorted and whether order should be ascending or descending.
type SortQuery ¶
type SortQuery struct {
SortByList []SortBy
}
SortQuery holds options for sort functionality of data select.
func NewSortQuery ¶
NewSortQuery takes raw sort options list and returns SortQuery object. For example: ["a", "parameter1", "d", "parameter2"] - means that the data should be sorted by parameter1 (ascending) and later - for results that return equal under parameter 1 sort - by parameter2 (descending)
type StdComparableString ¶
type StdComparableString string
func (StdComparableString) Compare ¶
func (self StdComparableString) Compare(otherV ComparableValue) int
func (StdComparableString) Contains ¶
func (self StdComparableString) Contains(otherV ComparableValue) bool
type StdComparableTime ¶
func (StdComparableTime) Compare ¶
func (self StdComparableTime) Compare(otherV ComparableValue) int
func (StdComparableTime) Contains ¶
func (self StdComparableTime) Contains(otherV ComparableValue) bool