Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Students response

  • Loading branch information...
commit 4f574386318730d527944e9e825ac26e5135b80d 1 parent fc87dff
@MasseR authored
Showing with 20 additions and 1 deletion.
  1. +14 −1 code/Main.hs
  2. +6 −0 code/public/js/doThings.js
View
15 code/Main.hs
@@ -130,12 +130,24 @@ userQuery = do
Nothing -> notFound $ toResponse $ notFoundView $
H.p "User is not found"
+fileResponse :: Html -> Html
+fileResponse fun = H.docTypeHtml $ do
+ H.head $
+ H.script ! A.type_ "application/javascript" $
+ ("parent." `mappend` fun `mappend` "()")
+ H.body $ mempty
+
+studentsData :: Mining Response
+studentsData = do
+ s <- gets students
+ ok $ toResponse $ toJSON $ map DatatableStudent s
+
studentsUpload :: Mining Response
studentsUpload = do
(path, _, _) <- lookFile "studentFile"
newStudents <- liftIO $ parseStudents path
modify (\m -> m{students=newStudents})
- undefined
+ ok $ toResponse $ fileResponse "touchStudents"
thesisUpload :: Mining Response
thesisUpload = do
@@ -256,6 +268,7 @@ main = do
nullDir >> ok (toResponse $ mainView students)
, dir "user" $ userQuery
, dirs "student/upload" $ studentsUpload
+ , dirs "student/data" $ studentsData
, dirs "thesis/upload" $ thesisUpload
, dir "static" $ serveDirectory EnableBrowsing [] "public/"
]) state
View
6 code/public/js/doThings.js
@@ -13,6 +13,12 @@ $(document).ready(function() {
{ "sTitle": "Enrollment date"}
]
});
+ window.touchStudents = function() {
+ $.get("/student/data", function(data) {
+ dusers.fnClearTable();
+ dusers.fnAddData(data);
+ });
+ };
var dataClicks = $("#databox").
asEventStream("click", "tr").
Please sign in to comment.
Something went wrong with that request. Please try again.