From e9991dca02aa37e7620b8e8b61bca5c1fef60d04 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 30 Sep 2021 09:27:21 +0200 Subject: [PATCH] chore(dashboard): Allow test mode of the dashboard --- apps/emqx_dashboard/src/emqx_dashboard.erl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/emqx_dashboard/src/emqx_dashboard.erl b/apps/emqx_dashboard/src/emqx_dashboard.erl index 2868ae4fd..f1f5ab133 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard.erl @@ -47,13 +47,17 @@ start_listeners() -> type => apiKey, name => "authorization", in => header}}}}, - %% TODO: open dashboard after beta 1 - %% Dispatch = [ - %% {"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}, - %% {"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}}, - %% {'_', cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}} - %% ], - Dispatch = [], + %% TODO: make it permanent when it's ready to release + Dispatch = + case os:getenv("_EMQX_ENABLE_DASHBOARD") of + V when V =:= "true" orelse V =:= "1" -> + [{"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}, + {"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}}, + {'_', cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}} + ]; + _ -> + [] + end, BaseMinirest = #{ base_path => ?BASE_PATH, modules => minirest_api:find_api_modules(apps()),