Documentation

Reference

View component Description Example
component.Text Displays a string newtext
component.Timestamp Displays Unix time in a human-readable form. Hover to see full datetime. timestamp
component.Table Create a table with rows and columns table
component.Summary Create a summary containing a header and content summary
component.Link Create a link to an object link
component.Quadrant Create a quadrant consisting of fours strings and a title. quadrant
component.Labels Create a label from a key-value pair of strings. labels

JSON Response Reference

For plugins written in languages besides Go, view components will need to be constructed before marshaling. Below is a reference of common components and equivalent format in JSON.

component.Text

component.NewText("component text")
{  
   "metadata":{  
      "type":"text"
   },
   "config":{  
      "value":"component text"
   }
}

component.Timestamp

component.NewTimestamp(time.Unix(1559734098, 0))

{  
   "metadata":{  
      "type":"timestamp"
   },
   "config":{  
      "timestamp":1559734098
   }
}

component.Table

tableCols := component.NewTableCols("Name", "Ready", "Phase", "Restarts", "Node", "Age")
component.NewTableWithRows("Pods", tableCols, []component.TableRow{
    {
        "Name":     component.NewLink("", "pod name", "/pod"),
        "Age":      component.NewTimestamp(time.Unix(1559734098, 0)),
        "Ready":    component.NewText("0/0"),
        "Restarts": component.NewText("0"),
        "Phase":    component.NewText(""),
        "Node":     component.NewText(""),
    },
})
{  
   "metadata":{  
      "type":"table",
      "title":[  
         {  
            "metadata":{  
               "type":"text"
            },
            "config":{  
               "value":"Pods"
            }
         }
      ]
   },
   "config":{  
      "columns":[  
         {  
            "name":"Name",
            "accessor":"Name"
         },
         {  
            "name":"Ready",
            "accessor":"Ready"
         },
         {  
            "name":"Phase",
            "accessor":"Phase"
         },
         {  
            "name":"Restarts",
            "accessor":"Restarts"
         },
         {  
            "name":"Node",
            "accessor":"Node"
         },
         {  
            "name":"Age",
            "accessor":"Age"
         }
      ],
      "rows":[  
         {  
            "Age":{  
               "metadata":{  
                  "type":"timestamp"
               },
               "config":{  
                  "timestamp":1559734098
               }
            },
            "Name":{  
               "metadata":{  
                  "type":"link",
                  "title":[  
                     {  
                        "metadata":{  
                           "type":"text"
                        },
                        "config":{  
                           "value":""
                        }
                     }
                  ]
               },
               "config":{  
                  "value":"pod name",
                  "ref":"/pod"
               }
            },
            "Node":{  
               "metadata":{  
                  "type":"text"
               },
               "config":{  
                  "value":""
               }
            },
            "Phase":{  
               "metadata":{  
                  "type":"text"
               },
               "config":{  
                  "value":""
               }
            },
            "Ready":{  
               "metadata":{  
                  "type":"text"
               },
               "config":{  
                  "value":"0/0"
               }
            },
            "Restarts":{  
               "metadata":{  
                  "type":"text"
               },
               "config":{  
                  "value":"0"
               }
            }
         }
      ],
      "emptyContent":""
   }
}

component.Summary

sections := component.SummarySections{
    {Header: "header", Content: component.NewText("text component")},
}
component.NewSummary("summary title", sections...)
{  
   "metadata":{  
      "type":"summary",
      "title":[  
         {  
            "metadata":{  
               "type":"text"
            },
            "config":{  
               "value":"summary title"
            }
         }
      ]
   },
   "config":{  
      "sections":[  
         {  
            "header":"header",
            "content":{  
               "metadata":{  
                  "type":"text"
               },
               "config":{  
                  "value":"text component"
               }
            }
         }
      ]
   }
}
component.NewLink("link title", "pod name", "/pod")
{  
   "metadata":{  
      "type":"link",
      "title":[  
         {  
            "metadata":{  
               "type":"text"
            },
            "config":{  
               "value":"link title"
            }
         }
      ]
   },
   "config":{  
      "value":"pod name",
      "ref":"/pod"
   }
}

component.Quadrant

quadrant := component.NewQuadrant("quadrant title")
quadrant.Set(component.QuadNW, "NW", "0")
quadrant.Set(component.QuadNE, "NE", "1")
quadrant.Set(component.QuadSE, "SE", "2")
quadrant.Set(component.QuadSW, "SW", "3")
{  
   "metadata":{  
      "type":"quadrant",
      "title":[  
         {  
            "metadata":{  
               "type":"text"
            },
            "config":{  
               "value":"quadrant title"
            }
         }
      ]
   },
   "config":{  
      "nw":{  
         "value":"0",
         "label":"NW"
      },
      "ne":{  
         "value":"1",
         "label":"NE"
      },
      "se":{  
         "value":"2",
         "label":"SE"
      },
      "sw":{  
         "value":"3",
         "label":"SW"
      }
   }
}

component.Labels

component.NewLabels(map[string]string{"label key": "label value"})
{  
   "metadata":{  
      "type":"labels"
   },
   "config":{  
      "labels":{  
         "label key":"label value"
      }
   }
}
Getting Started

To help you get started, see the documentation.