Class StoreRest

All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable, BasicUniversalConfig, DefaultConfig, DefaultHtmlConfig

public class StoreRest extends PetstoreConsolePage
The Store page, the petstore dashboard, and the feeds its charts, tiles and fragments read.

The page is store.ftlh, with a builder twin at ?builder. The feeds are read-only JSON over the live store, and the revenue tile counts days by the store's clock in UTC.

Example:

@RestGet(path="/") public View page() { return FreemarkerView.of("store.ftlh"); }

<@page tab="store" toolkit="views"> <@card id="welcome" title="Welcome to the petstore"><div class="jc-prose">...</div></@card> <@card type="chart" id="by-status" title="Pets by status" src="/console/store/stats/status"> { kind: 'bar', x: { field: 'status' }, series: [ { field: 'count', label: 'Pets' } ] } </@card> </@page>

GET /console/store the page GET /console/store/recent-orders the ten newest orders GET /console/store/stats/daily {day, placed, delivered} for each recent day GET /console/store/kpi/revenue {label, value, unit} for the revenue tile GET /console/store/stats/species {species, count} for each species GET /console/store/stats/status {status, count} for each status GET /console/store/stats/pets {id, name, species, status} for each pet GET /console/store/fragments/hours the opening hours, as markup only

<@badge id="pending" src="/console/pets/changes/pending" href="/console/pets/changes" refreshMs=60000/>

See Also:
  • Constructor Details

  • Method Details

    • page

      public View page(RestRequest req)
      Renders the Store page, with the quick-stat tile values computed from the store.
      Parameters:
      req - The request; ?builder renders the builder twin.
      Returns:
      The page view.
    • recentOrders

      public List<Order> recentOrders()
      Returns:
      The 10 most recent orders, by ship date then id, newest first.
    • daily

      public JsonList daily()
      Returns:
      30 rows {day, placed, delivered} ending today, oldest first; an order counts on its ship date.
    • revenue

      public JsonMap revenue()
      The revenue tile: the summed pet prices of the orders delivered today, by the store clock in UTC.
      Returns:
      {label, value, unit}, with the value rounded to cents.
    • species

      public JsonList species()
      Returns:
      One row {species, count} per species, in enum order, zero counts included; pets with no species are not counted.
    • status

      public JsonList status()
      Returns:
      One row {status, count} per pet status, in enum order.
    • pets

      public JsonList pets()
      Returns:
      One row {id, name, species, status} per pet, by id; the treemap groups them and opens the edit dialog from a tile.
    • hours

      public View hours()
      Returns:
      The store hours as a chrome-free fragment.