From 903d8d899e23a73d1ddcf4c9c35dd6bb4f1784f3 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Thu, 15 Jun 2023 14:26:08 +0800 Subject: [PATCH 1/2] fix: .js files are required by dashboard as static revert parts of 8c1334c421c4099e403771f648b72305cd9564e5 --- apps/emqx_dashboard/src/emqx_dashboard.erl | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/emqx_dashboard/src/emqx_dashboard.erl b/apps/emqx_dashboard/src/emqx_dashboard.erl index 8786e869f..6299ec96b 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard.erl @@ -68,19 +68,13 @@ start_listeners(Listeners) -> } } }, - Dispatch = [ - {"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}, - {"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}}, - {emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []}, - {'_', emqx_dashboard_not_found, []} - ], BaseMinirest = #{ base_path => emqx_dashboard_swagger:base_path(), modules => minirest_api:find_api_modules(apps()), authorization => Authorization, security => [#{'basicAuth' => []}, #{'bearerAuth' => []}], swagger_global_spec => GlobalSpec, - dispatch => Dispatch, + dispatch => dispatch(), middlewares => [?EMQX_MIDDLE, cowboy_router, cowboy_handler] }, {OkListeners, ErrListeners} = @@ -259,3 +253,20 @@ ensure_ssl_cert(Listeners = #{https := Https0}) -> Listeners#{https => maps:from_list(Https1)}; ensure_ssl_cert(Listeners) -> Listeners. + +dispatch() -> + static_dispatch() ++ dynamic_dispatch(). + +static_dispatch() -> + StaticFiles = ["/editor.worker.js", "/json.worker.js", "/version"], + [ + {"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}, + {"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}} + ] ++ + [{Path, cowboy_static, {priv_file, emqx_dashboard, "www" ++ Path}} || Path <- StaticFiles]. + +dynamic_dispatch() -> + [ + {emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []}, + {'_', emqx_dashboard_not_found, []} + ]. From 611fc6c53ce44bae1776ac6782da324e0c448b06 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Thu, 15 Jun 2023 14:45:12 +0800 Subject: [PATCH 2/2] chore: rm unused hocon file --- rel/i18n/emqx_connector_api.hocon | 46 ------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 rel/i18n/emqx_connector_api.hocon diff --git a/rel/i18n/emqx_connector_api.hocon b/rel/i18n/emqx_connector_api.hocon deleted file mode 100644 index 4942ce981..000000000 --- a/rel/i18n/emqx_connector_api.hocon +++ /dev/null @@ -1,46 +0,0 @@ -emqx_connector_api { - -conn_get.desc: -"""List all connectors""" - -conn_get.label: -"""List All Connectors""" - -conn_id_delete.desc: -"""Delete a connector by ID""" - -conn_id_delete.label: -"""Delete Connector""" - -conn_id_get.desc: -"""Get the connector by ID""" - -conn_id_get.label: -"""Get Connector""" - -conn_id_put.desc: -"""Update an existing connector by ID""" - -conn_id_put.label: -"""Update Connector""" - -conn_post.desc: -"""Create a new connector""" - -conn_post.label: -"""Create Connector""" - -conn_test_post.desc: -"""Test creating a new connector by given ID
-The ID must be of format '{type}:{name}'""" - -conn_test_post.label: -"""Create Test Connector""" - -id.desc: -"""The connector ID. Must be of format {type}:{name}""" - -id.label: -"""Connector ID""" - -}