1919--
2020module Main (main ) where
2121
22+ import Control.Monad (sequence_ )
2223import Data.Aeson (FromJSON )
2324import qualified Data.Aeson as J
2425import qualified Data.Aeson.Types as J
@@ -420,9 +421,9 @@ app dynFrag = do
420421
421422 el " hr" blank
422423
423- evCellClick <- reportTableWidget dynRepSum dynQRows dynWorkers dynHist dynInfo
424+ (_, evCellClick) <- runEventWriterT $ reportTableWidget dynRepSum dynQRows dynWorkers dynHist dynInfo
424425
425- dynCellClick <- holdDyn Nothing (Just <$> evCellClick)
426+ dynCellClick <- holdDyn Nothing (Just . _unCellTable <$> evCellClick)
426427
427428 let dynCell' = mergeCellId pn <$> dynCellClick <*> dynIdxSt
428429
@@ -530,7 +531,7 @@ packagesPageWidget dynPackages dynTags dynPkgTags = do
530531 V. filter (tagContained st dpt) pkg
531532
532533
533- reportTableWidget :: forall t m . (SetRoute t FragRoute m , MonadHold t m , PostBuild t m , DomBuilder t m , Reflex t )
534+ reportTableWidget :: forall t w m . (EventWriter t CellTable m , HasCellTable CellTable , SetRoute t FragRoute m , MonadHold t m , PostBuild t m , DomBuilder t m , Reflex t )
534535 => Dynamic t PkgIdxTsReport
535536 -> Dynamic t (Vector QEntryRow )
536537 -> Dynamic t (Vector WorkerRow )
@@ -548,7 +549,8 @@ reportTableWidget dynRepSum dynQRows dynWorkers dynHist dynInfo = joinE =<< go
548549 let activeHcs = [ k | (k,CompilerInfo { ciActive = True }) <- Map. toDescList ciCompilers ]
549550
550551
551- let hcvsLR = computeLR pitrHcversions activeHcs
552+ let (Just defVer) = verFromText " 0"
553+ hcvsLR = computeLR pitrHcversions activeHcs
552554 hcvs = applyLR hcvsLR pitrHcversions activeHcs
553555
554556 let vmap = Map. mergeWithKey (\ _ (t,u) e -> Just (t,u,applyLR hcvsLR e emptyActive)) (fmap (\ (t,u) -> (t,u,emptyHcvs))) (const mempty )
@@ -580,7 +582,8 @@ reportTableWidget dynRepSum dynQRows dynWorkers dynHist dynInfo = joinE =<< go
580582 el " th" (text " released" )
581583 el " th" (text " uploader" )
582584
583- el " tbody" $ do
585+ el " tbody" $ do
586+ sequence_ . snd $ List. mapAccumL (accumTableRow pn' hcvs pitrIdxstate wip inQueue) (defVer, ((PkgIdxTs 0 ), " " , [] )) (Map. toAscList vmap)
584587 evsRows <- forM (Map. toDescList vmap) $ \ (pv,(t,u,cs)) -> do
585588 let tooSoon = t > pitrIdxstate
586589 tooSoonAttr = if tooSoon then (" style" =: " opacity:0.5;" ) else mempty
@@ -607,6 +610,58 @@ reportTableWidget dynRepSum dynQRows dynWorkers dynHist dynInfo = joinE =<< go
607610 pure (leftmost evsRow1)
608611 pure (leftmost evsRows) -- main "return" value
609612
613+ accumTableRow :: forall t w m . (SetRoute t FragRoute m , DomBuilder t m , Reflex t , EventWriter t CellTable m , HasCellTable CellTable )
614+ => Text
615+ -> [CompilerID ]
616+ -> PkgIdxTs
617+ -> [(Ver ,CompilerID )]
618+ -> Bool
619+ -> (Ver , (PkgIdxTs , UserName , [CellReportSummary ]))
620+ -> (Ver , (PkgIdxTs , UserName , [CellReportSummary ]))
621+ -> ((Ver , (PkgIdxTs , UserName , [CellReportSummary ])), m () )
622+ accumTableRow pn' hcvs pkgIdxTs wip inQ prevVer currVer =
623+ let pkgVer = const currVer prevVer
624+ (pcVer, (t, u, cs)) = currVer
625+ (ppVer, _) = prevVer
626+ in (pkgVer, (renderRow pn' hcvs pkgIdxTs wip inQ ppVer pcVer t u cs))
627+
628+ renderRow :: forall t w m . (SetRoute t FragRoute m , DomBuilder t m , Reflex t , EventWriter t CellTable m , HasCellTable CellTable )
629+ => Text
630+ -> [CompilerID ]
631+ -> PkgIdxTs
632+ -> [(Ver ,CompilerID )]
633+ -> Bool
634+ -> (Ver )
635+ -> (Ver )
636+ -> PkgIdxTs
637+ -> UserName
638+ -> [CellReportSummary ]
639+ -> m ()
640+ renderRow pn' hcvs pitrIdxstate wip inQueue ppV pcV t u cs = do
641+ let tooSoon = t > pitrIdxstate
642+ tooSoonAttr = if tooSoon then (" style" =: " opacity:0.5;" ) else mempty
643+ elAttr " tr" tooSoonAttr $ do
644+ elAttr " th" (" style" =: " text-align:left;" ) $
645+ elAttr " a" (" href" =: (mconcat [ " https://hackage.haskell.org/package/" , pn'," -" ,verToText pcV," /" ,pn'," .cabal/edit" ])) $
646+ text (verToText pcV)
647+ evsRow1 <- forM (zip cs hcvs) $ \ (x,hcv) -> do
648+ let (cellAttr,cellText) = case crsT x of
649+ Nothing
650+ | tooSoon -> (" class" =: " stat-unknown" , el " b" (text " " ))
651+ | (pcV,hcv) `elem` wip -> (" class" =: " stat-wip" , el " b" (text " WIP" ))
652+ | inQueue -> (" class" =: " stat-queued" , text " queued" )
653+ _ -> (" class" =: (snd $ fmtCRS x), (text $ fst $ fmtCRS x))
654+
655+ (l,_) <- elAttr' " td" ((" style" =: if tooSoon then " cursor: not-allowed;" else " cursor: cell;" ) <> cellAttr) cellText
656+
657+ pure $ ((CellTable (pcV,hcv)) <$ (if tooSoon then never else domEvent Click l) :: Event t CellTable )
658+
659+ elAttr " th" (" style" =: " text-align:left;" ) (text (verToText pcV))
660+ el " td" $ text (pkgIdxTsToText t)
661+ el " td" $ routeLink False (" #/user/" <> u) (text u)
662+ tellEvent (leftmost evsRow1)
663+ pure () -- (leftmost evsRow1)
664+
610665reportDetailWidget :: (SupportsServantReflex t m , MonadFix m , PostBuild t m , DomBuilder t m , Reflex t , MonadHold t m , Adjustable t m ) => Dynamic t (Maybe (PkgN ,Ver ,CompilerID ,PkgIdxTs )) -> m ()
611666reportDetailWidget dynCellId = do
612667
0 commit comments