Class DataSourceController

java.lang.Object
io.micronaut.controlpanel.panels.datasource.DataSourceController

@Controller("${micronaut.control-panel.path:/control-panel}/datasource-control-panel-controller") @ExecuteOn("blocking") @Internal public final class DataSourceController extends Object
REST controller to execute SQL queries against a specific DataSource for the Control Panel. Designed to return paged query results for the Control Panel table renderer.
Since:
2.0.0
Author:
Álvaro Sánchez-Mariscal
  • Constructor Details

    • DataSourceController

      public DataSourceController(io.micronaut.context.BeanLocator locator, io.micronaut.json.JsonMapper jsonMapper)
  • Method Details

    • schemaJs

      @Get(value="/{dataSource}/schema.js", produces="application/javascript") public io.micronaut.http.HttpResponse<String> schemaJs(String dataSource)

      Build CodeMirror SQLNamespace with normalized lowercase keys for matching.

      { "schema": { "table": { self: {label:"EMP", type:"table"}, children: [{label:"EMPNO", type:"column"}, ...] } } }
      
      Parameters:
      dataSource - The name of the datasource
      Returns:
      HttpResponse containing the generated schema.js JavaScript
    • tables

      @Get(value="/{dataSource}/tables", produces="text/html") public io.micronaut.http.HttpResponse<Object> tables(String dataSource, @QueryValue @Nullable Integer page, @QueryValue @Nullable Integer size, @QueryValue @Nullable String schema, @QueryValue @Nullable String search)
      Renders one page of datasource tables as an HTML fragment.
      Parameters:
      dataSource - The name of the datasource
      page - The 1-based page number
      size - The number of tables per page
      schema - The schema to filter by, or null for all schemas
      search - The table search term, or null for all table names
      Returns:
      A server-rendered HTML fragment containing one table page
    • tableDetail

      @Get(value="/{dataSource}/tables/detail", produces="text/html") public io.micronaut.http.HttpResponse<Object> tableDetail(String dataSource, @QueryValue @Nullable String schema, @QueryValue("table") String tableName)
      Renders a single datasource table detail as an HTML fragment.
      Parameters:
      dataSource - The name of the datasource
      schema - The table schema
      tableName - The table name
      Returns:
      A server-rendered HTML fragment for the selected table
    • poolStatus

      @Get(value="/{dataSource}/pool/status", produces="text/html") public io.micronaut.http.HttpResponse<Object> poolStatus(String dataSource)
      Renders current datasource pool status as an HTML fragment.
      Parameters:
      dataSource - The name of the datasource
      Returns:
      A server-rendered HTML fragment for the current pool status
    • query

      @Post(value="/{dataSource}/query", produces="application/json") public io.micronaut.http.HttpResponse<DataSourceController.QueryResponse> query(String dataSource, @Body DataSourceController.QueryRequest body)
      Execute a SQL query against the specified datasource.
      Parameters:
      dataSource - The name of the datasource (path parameter)
      body - The query request containing SQL and pagination parameters
      Returns:
      The query results as a HttpResponse containing DataSourceController.QueryResponse, or an error response if the query fails