Class CustomCardsRest
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,BasicUniversalConfig,DefaultConfig,DefaultHtmlConfig
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([
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestServlet
RestServlet.Builder<R extends RestServlet,SELF extends RestServlet.Builder<R, SELF>>, RestServlet.DefaultBuilder<R extends RestServlet> -
Field Summary
Fields inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
PAGE_HEADER, TEMPLATESFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCounts one species' pets by status, for the gauge.page(RestRequest req) The Custom cards page.prices()voidscript(RestResponse res) Serves the page-local script.Methods inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
builder, freemarker, store, twinMethods inherited from class org.apache.juneau.rest.server.servlet.RestServlet
builder, createAuthenticator, destroy, doLog, getContext, getPath, getPaths, getRequest, getResponse, getRestBuilder, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
CustomCardsRest
public CustomCardsRest()
-
-
Method Details
-
page
The Custom cards page.- Parameters:
req- The request;?builderrenders the builder twin.- Returns:
- The page.
-
available
- Returns:
- The kpi card's number: how many pets are available.
-
inventory
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
- Returns:
- One row
{id, price}per pet, by id, for the zoomable prices chart.
-
script
Serves the page-local script.- Parameters:
res- The response.- Throws:
IOException- If the bundled script can't be read.
-