* @brief Plan a workspace: list compatible (group, widgetType) options for tile placement. */
| 252 | * @brief Plan a workspace: list compatible (group, widgetType) options for tile placement. |
| 253 | */ |
| 254 | API::CommandResponse API::Handlers::AssistantHandler::workspacePlan(const QString& id, |
| 255 | const QJsonObject& params) |
| 256 | { |
| 257 | const auto wsResp = workspaceResolve(QStringLiteral("inner"), params); |
| 258 | if (!wsResp.success) |
| 259 | return rewrap(id, wsResp); |
| 260 | |
| 261 | const auto groupListResp = |
| 262 | forward(QStringLiteral("project.group.list"), QStringLiteral("inner"), QJsonObject()); |
| 263 | if (!groupListResp.success) |
| 264 | return rewrap(id, groupListResp); |
| 265 | |
| 266 | QString widgetFilterSlug; |
| 267 | if (params.contains(QStringLiteral("widgetType"))) { |
| 268 | const auto v = params.value(QStringLiteral("widgetType")); |
| 269 | if (v.isString()) |
| 270 | widgetFilterSlug = v.toString(); |
| 271 | else |
| 272 | widgetFilterSlug = API::EnumLabels::dashboardWidgetSlug(v.toInt()); |
| 273 | } |
| 274 | |
| 275 | const auto groups = groupsFromListResponse(groupListResp); |
| 276 | const auto rows = buildPlanRows(groups, widgetFilterSlug); |
| 277 | |
| 278 | QJsonObject result; |
| 279 | result[QStringLiteral("workspace")] = wsResp.result.value(QStringLiteral("workspace")); |
| 280 | result[QStringLiteral("options")] = rows; |
| 281 | result[QStringLiteral("count")] = rows.size(); |
| 282 | if (!widgetFilterSlug.isEmpty()) |
| 283 | result[QStringLiteral("widgetType")] = widgetFilterSlug; |
| 284 | |
| 285 | if (rows.isEmpty() && !widgetFilterSlug.isEmpty()) |
| 286 | result[QStringLiteral("hint")] = |
| 287 | QStringLiteral( |
| 288 | "No group currently exposes widgetType '%1'. Flip the matching dataset option " |
| 289 | "(project.dataset.setOptions / .setOption / .update {graph|fft|led|waterfall}) " |
| 290 | "on a dataset in the target group, then re-plan.") |
| 291 | .arg(widgetFilterSlug); |
| 292 | |
| 293 | return CommandResponse::makeSuccess(id, result); |
| 294 | } |
| 295 | |
| 296 | //-------------------------------------------------------------------------------------------------- |
| 297 | // assistant.script.dryRun / assistant.script.apply: kind-routed |
nothing calls this directly
no test coverage detected