forked from filipg/gonito
add "folder" icon
This commit is contained in:
parent
8fc0b659c9
commit
961b767b74
@ -3,6 +3,7 @@
|
|||||||
module Handler.Tables where
|
module Handler.Tables where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import Handler.Shared
|
||||||
|
|
||||||
import qualified Yesod.Table as Table
|
import qualified Yesod.Table as Table
|
||||||
import Yesod.Table (Table)
|
import Yesod.Table (Table)
|
||||||
@ -29,23 +30,23 @@ data LeaderboardEntry = LeaderboardEntry {
|
|||||||
leaderboardNumberOfSubmissions :: Int
|
leaderboardNumberOfSubmissions :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
submissionsTable :: [Entity Test] -> Table App ((Entity Submission, Entity User, Map (Key Test) Evaluation), Maybe UserId)
|
submissionsTable :: Text -> [Entity Test] -> Table App ((Entity Submission, Entity User, Map (Key Test) Evaluation), Maybe UserId)
|
||||||
submissionsTable tests = mempty
|
submissionsTable challengeName tests = mempty
|
||||||
++ Table.text "submitter" (formatSubmitter . (\(_, Entity _ submitter, _) -> submitter) . fst)
|
++ Table.text "submitter" (formatSubmitter . (\(_, Entity _ submitter, _) -> submitter) . fst)
|
||||||
++ timestampCell "when" (submissionStamp . (\(Entity _ s, _, _) -> s) . fst)
|
++ timestampCell "when" (submissionStamp . (\(Entity _ s, _, _) -> s) . fst)
|
||||||
++ Table.text "description" (submissionDescription . (\(Entity _ s, _, _) -> s) . fst)
|
++ Table.text "description" (submissionDescription . (\(Entity _ s, _, _) -> s) . fst)
|
||||||
++ mconcat (map (\(Entity k t) -> Table.string (testName t) ((submissionScore k) . fst)) tests)
|
++ mconcat (map (\(Entity k t) -> Table.string (testName t) ((submissionScore k) . fst)) tests)
|
||||||
++ statusCell (\((Entity submissionId submission, Entity userId _, _), mauthId) -> (submissionId, submission, userId, mauthId))
|
++ statusCell challengeName (\((Entity submissionId submission, Entity userId _, _), mauthId) -> (submissionId, submission, userId, mauthId))
|
||||||
|
|
||||||
leaderboardTable :: Table App ((Int, LeaderboardEntry), Maybe UserId)
|
leaderboardTable :: Text -> Table App ((Int, LeaderboardEntry), Maybe UserId)
|
||||||
leaderboardTable = mempty
|
leaderboardTable challengeName = mempty
|
||||||
++ Table.int "#" (fst . fst)
|
++ Table.int "#" (fst . fst)
|
||||||
++ Table.text "submitter" (formatSubmitter . leaderboardUser . snd . fst)
|
++ Table.text "submitter" (formatSubmitter . leaderboardUser . snd . fst)
|
||||||
++ timestampCell "when" (submissionStamp . leaderboardBestSubmission . snd . fst)
|
++ timestampCell "when" (submissionStamp . leaderboardBestSubmission . snd . fst)
|
||||||
++ Table.text "description" (submissionDescription . leaderboardBestSubmission . snd . fst)
|
++ Table.text "description" (submissionDescription . leaderboardBestSubmission . snd . fst)
|
||||||
++ Table.string "result" (presentScore . leaderboardEvaluation . snd . fst)
|
++ Table.string "result" (presentScore . leaderboardEvaluation . snd . fst)
|
||||||
++ Table.int "×" (leaderboardNumberOfSubmissions . snd . fst)
|
++ Table.int "×" (leaderboardNumberOfSubmissions . snd . fst)
|
||||||
++ statusCell (\((_, e), mauthId) -> (leaderboardBestSubmissionId e,
|
++ statusCell challengeName (\((_, e), mauthId) -> (leaderboardBestSubmissionId e,
|
||||||
leaderboardBestSubmission e,
|
leaderboardBestSubmission e,
|
||||||
leaderboardUserId e,
|
leaderboardUserId e,
|
||||||
mauthId))
|
mauthId))
|
||||||
@ -59,14 +60,20 @@ timestampCell :: Text -> (a -> UTCTime) -> Table site a
|
|||||||
timestampCell h timestampFun = hoverTextCell h (Data.Text.pack . shorterFormat . timestampFun) (Data.Text.pack . show . timestampFun)
|
timestampCell h timestampFun = hoverTextCell h (Data.Text.pack . shorterFormat . timestampFun) (Data.Text.pack . show . timestampFun)
|
||||||
where shorterFormat = formatTime defaultTimeLocale "%Y-%m-%d %H:%M"
|
where shorterFormat = formatTime defaultTimeLocale "%Y-%m-%d %H:%M"
|
||||||
|
|
||||||
statusCell :: (a -> (SubmissionId, Submission, UserId, Maybe UserId)) -> Table App a
|
statusCell :: Text -> (a -> (SubmissionId, Submission, UserId, Maybe UserId)) -> Table App a
|
||||||
statusCell fun = Table.widget "" (statusCellWidget . fun)
|
statusCell challengeName fun = Table.widget "" (statusCellWidget challengeName . fun)
|
||||||
|
|
||||||
statusCellWidget (submissionId, submission, userId, mauthId) = $(widgetFile "submission-status")
|
statusCellWidget challengeName (submissionId, submission, userId, mauthId) = $(widgetFile "submission-status")
|
||||||
where commitHash = fromSHA1ToText $ submissionCommit submission
|
where commitHash = fromSHA1ToText $ submissionCommit submission
|
||||||
isPublic = submissionIsPublic submission
|
isPublic = submissionIsPublic submission
|
||||||
isOwner = (mauthId == Just userId)
|
isOwner = (mauthId == Just userId)
|
||||||
isVisible = isPublic || isOwner
|
isVisible = isPublic || isOwner
|
||||||
|
publicSubmissionBranch = getPublicSubmissionBranch submissionId
|
||||||
|
maybeBrowsableUrl = if isPublic
|
||||||
|
then
|
||||||
|
Just $ browsableGitRepoBranch challengeName publicSubmissionBranch
|
||||||
|
else
|
||||||
|
Nothing
|
||||||
|
|
||||||
getMainTest :: [Entity Test] -> Entity Test
|
getMainTest :: [Entity Test] -> Entity Test
|
||||||
getMainTest tests = DL.maximumBy (\(Entity _ a) (Entity _ b) -> ((testName a) `compare` (testName b))) tests
|
getMainTest tests = DL.maximumBy (\(Entity _ a) (Entity _ b) -> ((testName a) `compare` (testName b))) tests
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="alert alert-info" role="alert">
|
<div class="alert alert-info" role="alert">
|
||||||
<p>This is a long list of all submissions, if you want to see only the best, click <a href="@{ShowChallengeR (challengeName challenge)}">leaderboard</a>.
|
<p>This is a long list of all submissions, if you want to see only the best, click <a href="@{ShowChallengeR (challengeName challenge)}">leaderboard</a>.
|
||||||
|
|
||||||
^{Table.buildBootstrap (submissionsTable tests) submissionsWithCurrentUser}
|
^{Table.buildBootstrap (submissionsTable (challengeName challenge) tests) submissionsWithCurrentUser}
|
||||||
|
|
||||||
<div id="graph-container">
|
<div id="graph-container">
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ $nothing
|
|||||||
|
|
||||||
<h2>Leaderboard
|
<h2>Leaderboard
|
||||||
|
|
||||||
^{Table.buildBootstrap leaderboardTable leaderboardWithRanksAndCurrentUser}
|
^{Table.buildBootstrap (leaderboardTable (challengeName challenge)) leaderboardWithRanksAndCurrentUser}
|
||||||
|
|
||||||
<div id="graph-container">
|
<div id="graph-container">
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
$if isVisible
|
$if isVisible
|
||||||
<a href="@{QueryResultsR commitHash}">
|
<a href="@{QueryResultsR commitHash}">
|
||||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true">
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true">
|
||||||
|
$maybe browsableUrl <- maybeBrowsableUrl
|
||||||
|
<a href="#{browsableUrl}">
|
||||||
|
<span class="glyphicon glyphicon-folder-open" aria-hidden="true">
|
||||||
|
Loading…
Reference in New Issue
Block a user