66 lines
2.2 KiB
Markdown

# Sage desktop client sample
This directory is an independent Compose Desktop sample app for Sage on top of the
root `bricks-mp` shared module. It is intentionally **not** included from the
root `settings.gradle.kts`, so normal library builds are unchanged.
## Build
From any directory:
```bash
/path/to/bricks-mp/test/sageclient/build.sh
```
The script:
1. resolves its own directory,
2. checks that `java` is available and is JDK 17+,
3. uses the repository Gradle wrapper when present, otherwise system `gradle`,
4. runs `gradle build` for this standalone sample.
Extra Gradle arguments can be appended, for example:
```bash
./test/sageclient/build.sh --info
```
## Run
```bash
cd /path/to/bricks-mp/test/sageclient
../../gradlew run \
-Dsage.baseUrl=http://localhost:8080 \
-Dsage.centerUi=/center.ui
```
Optional properties:
- `sage.baseUrl` defaults to `http://localhost:8080`
- `sage.centerUi` defaults to `/center.ui`
- `sage.loginAction` defaults to `/rbac/user/login`
- `sage.loginUi` defaults to `/rbac/user/login.ui`
- `sage.username` / `sage.password` prefill the login form
- `sage.lang` overrides the default JVM locale tag
## What the sample demonstrates
- Uses the generic `BricksHttp` client from the shared module for Sage login and
`center.ui` loading. Sage-specific bootstrapping lives here, not in the shared
library package.
- Loads `center.ui` via `ActionDispatcher.dispatch(BricksBind(actiontype =
"urlwidget", ...))`, so HTTP handling stays in the shared ActionDispatcher /
BricksHttp flow.
- `BricksHttp` automatically appends the correct WebBricks query parameters for
`.ui` / `.dspy` backend requests:
`_webbricks_`, `_width`, `_height`, `_is_mobile`, `_lang`.
- `BricksHttp` surfaces HTTP 403, 401 and 3xx (including 301) as
`BricksHttpException`. `ActionDispatcher` handles them generically:
- 403 loads the configured login UI (`sage.loginUi`) in a dialog,
- 401 shows the server response as an unauthorized message,
- 3xx follows the `Location` header as a UI navigation target.
The sample is wired as a Gradle composite build through `includeBuild("../..")`
and depends on the root project module using `implementation("com.bricks.mp:shared")`
with dependency substitution to `:shared`.