发布

  • v1408 99c78f512c

    feat(homecore-ui iter 5): Call Service from Services page

    frostbyte_neo 发布于 2026-05-26 19:27:48 +00:00

    CRUD increment 5/6. Each service pill on the Services page now has
    a ▶ Call button that opens a modal letting the operator POST a
    JSON service_data payload to /api/services// and
    inspect the round-tripped response.

    Modal contents:

    • heading "Call ."
    • target URL displayed as code (POST /api/services/...)
    • service_data JSON textarea (default {}, live-validated as
      JSON object — same rules as EntityForm.attributes)
    • response
       block: green border on 2xx, red on non-2xx,
      pretty-printed JSON when parseable
    • Close + Call buttons in footer; Call disabled on invalid JSON
      or while pending; renders "Calling…" briefly during the POST

    Reuses <hc-modal> from iter 1. No new components — all of iter 5
    lives in frontend/src/pages/Services.ts (~140 LOC delta).

    Browser-verified end-to-end against homecore-server (13 services
    seeded across 6 domains):

    • 13/13 service pills have a ▶ Call button
    • Modal opens with correct heading and target URL
    • Live validation: [1,2,3] → red "must be a JSON object";
      {broken json: → red "JSON parse: …"; valid → green ✓
    • Call button disabled on invalid input
    • Successful call: green-bordered response containing
      {"called":"switch.turn_on", "acknowledged":true,
      "service_data":{"entity_id":"light.kitchen_ceiling","brightness":200}}
    • Toast "Called switch.turn_on → 200"
    • homecore.ping with empty body (default {}) succeeds too
    • 0 console errors related to this flow

    Co-Authored-By: claude-flow ruv@ruv.net

    下载附件