From 6d7587aeac336f78dfb75f10a64ca2bb27e4dbc4 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Mon, 9 Aug 2021 22:19:40 +0200 Subject: [PATCH] view-progress-log end-point returns a self-contained HTML --- Handler/ShowChallenge.hs | 28 ++++++++++++++++++++++++++++ Handler/Swagger.hs | 2 ++ 2 files changed, 30 insertions(+) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 938a9e6..8497be6 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -1688,3 +1688,31 @@ viewProgressWithWebSockets :: Swagger viewProgressWithWebSockets = spec & definitions .~ defs where (defs, spec) = runDeclare declareViewProgressWithWebSocketsSwagger mempty + + +declareViewProgressLogSwagger :: Declare (Definitions Schema) Swagger +declareViewProgressLogSwagger = do + let numberSchema = toParamSchema (Proxy :: Proxy Int) + + numberResponse <- declareResponse (Proxy :: Proxy Int) + + return $ mempty + & paths .~ + fromList [ ("/api/view-progress-log/{jobId}", + mempty & DS.get ?~ (mempty + & parameters .~ [ Inline $ mempty + & name .~ "jobId" + & description ?~ "The ID for the job to be shown" + & required ?~ True + & schema .~ ParamOther (mempty + & in_ .~ ParamPath + & paramSchema .~ numberSchema)] + & produces ?~ MimeList ["text/html"] + & description ?~ "Returns HTML code with embedded JS script for showing logs via web sockets" + & at 200 ?~ Inline numberResponse)) + ] + +viewProgressLog :: Swagger +viewProgressLog = spec & definitions .~ defs + where + (defs, spec) = runDeclare declareViewProgressLogSwagger mempty diff --git a/Handler/Swagger.hs b/Handler/Swagger.hs index dc1da35..5705013 100644 --- a/Handler/Swagger.hs +++ b/Handler/Swagger.hs @@ -33,6 +33,8 @@ apiDescription = generalApi <> challengeRepoApi <> testProgressApi <> viewProgressWithWebSockets + <> viewProgressLog + generalApi :: Swagger generalApi = (mempty :: Swagger)