aboutsummaryrefslogtreecommitdiff
path: root/apps/dreki_web/src/ui/dreki_web_ui_tasks.erl
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dreki_web/src/ui/dreki_web_ui_tasks.erl')
-rw-r--r--apps/dreki_web/src/ui/dreki_web_ui_tasks.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/apps/dreki_web/src/ui/dreki_web_ui_tasks.erl b/apps/dreki_web/src/ui/dreki_web_ui_tasks.erl
new file mode 100644
index 0000000..e9748b8
--- /dev/null
+++ b/apps/dreki_web/src/ui/dreki_web_ui_tasks.erl
@@ -0,0 +1,14 @@
+-module(dreki_web_ui_tasks).
+-behaviour(cowboy_handler).
+-export([init/2]).
+
+init(Req = #{method := <<"GET">>}, State) ->
+ Local = maps:fold(fun
+ (Ln, #{mod := Mod, path := Path}, Acc) ->
+ [#{name => Ln, mod => Mod, path => Path, url => <<"/api/admin/tasks/", Path>>} | Acc]
+ end, [], dreki_tasks:local_stores()),
+ Html = dreki_web_ui:render(Req, tasks_dtl, [{"page_title", "Tasks"}, {"stores", Local}, {"tasks", []}]),
+ {ok, dreki_web_ui:reply_html(Req, 200, Html), State};
+init(Req, _) ->
+ dreki_web_ui_error:init(Req, #{code => 400, status => "Bad request"}).
+