-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"}).