Class CustomCardsRest

java.lang.Object
jakarta.servlet.GenericServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable, BasicUniversalConfig, DefaultConfig, DefaultHtmlConfig

The Custom cards page, which shows how an adopter writes a card type, and the feeds its cards read.

The page has a JSON-only card type (kpi), a Java-validated one (inventory-gauge, see InventoryGaugeCardType) and two charts: the stock bands and the zoomable prices.

Both JS handlers live in petstore-cards.js, served beside this class, which also shows the card API (JuneauConsole.refreshCard, JuneauConsole.cardApi) and the juneau:card-mounted event.

Example:

(window.JuneauConsoleCards = window.JuneauConsoleCards || []).push(['kpi', { render(card, el, ctx) { ... } }]);

GET /console/dev/cards the page GET /console/dev/cards/stats/available {label, value} for the kpi card GET /console/dev/cards/inventory?species= {species, available, pending, sold} for the gauge GET /console/dev/cards/inventory/all one gauge row per species, for the stock bands chart GET /console/dev/cards/prices {id, price} per pet, for the prices chart GET /console/dev/cards/petstore-cards.js the page script

See Also:
  • Constructor Details

  • Method Details

    • page

      public View page(RestRequest req)
      The Custom cards page.
      Parameters:
      req - The request; ?builder renders the builder twin.
      Returns:
      The page.
    • available

      public JsonMap available()
      Returns:
      The kpi card's number: how many pets are available.
    • inventory

      public JsonMap inventory(@Query("species") String species)
      Counts one species' pets by status, for the gauge.
      Parameters:
      species - The species name, case-insensitive.
      Returns:
      {species, available, pending, sold}.
      Throws:
      BadRequest - If the species is missing or unknown.
    • inventoryAll

      Returns:
      One inventory(String) row per species, in enum order, for the stock bands chart.
    • prices

      public JsonList prices()
      Returns:
      One row {id, price} per pet, by id, for the zoomable prices chart.
    • script

      public void script(RestResponse res) throws IOException
      Serves the page-local script.
      Parameters:
      res - The response.
      Throws:
      IOException - If the bundled script can't be read.