Commit 024eb0a3 authored by Kamalavelan's avatar Kamalavelan 💬

interim commit

Signed-off-by: Kamalavelan's avatarKamalavelan <sskamalavelan@gmail.com>
parent b1c89a43
(ns pprg.db.mothers
(ns pprg.db.visits
(:require [hugsql.core :as hugsql]))
(hugsql/def-db-fns "pprg/db/sql/mothers.sql")
(hugsql/def-db-fns "pprg/db/sql/visits.sql")
......@@ -17,6 +17,11 @@ where worker = :worker
select * from mothers
where center = :center
-- :name mothers-by-id :? :1
-- :doc Get a mother by id
select * from mothers
where id = :id
-- :name mothers-by-date :? :*
-- :doc Get mothers by date
select * from mothers
......
-- :name mothers-insert :! :n
-- :name questions-insert :! :n
-- :doc Insert a single user returning affected row count
insert into mothers
values (:type, :name, :age, :blood_group, :mobile, :street_name, :area, :city, :pin_code, :delivery_date, :child_weight, :child_gender, :center, :worker, :current_visit)
......
......@@ -17,6 +17,8 @@
[pprg.site.centers :as site.centers]
[pprg.site.mothers :as site.mothers]
[pprg.site.auth :as site.auth]
[pprg.site.questions :as site.questions]
[pprg.site.visits :as site.visits]
;; [mount.core :refer defstate]
))
......@@ -120,9 +122,12 @@
;; URLs for individual users
["/user/:user-id" :get (conj json-interceptors `site.users/user-record-page) :route-name :user-record-page]
["/user/:user-id/update" :post (conj json-interceptors `site.users/user-record-update) :route-name :user-record-update]
["/user/:user-id/edit" :get (conj common-interceptors `site.users/user-record-page) :route-name :user-record-edit]
["/user/:user-id/mothers/all" :get (conj json-interceptors `site.mothers/mothers-by-worker) :route-name :mothers-all-by-worker]
["/user/:user-id/mothers/create" :get (conj common-interceptors `site.mothers/create-mother-page) :route-name :mother-create-get]
["/user/:user-id/mothers/create" :post (conj common-interceptors `site.mothers/create-mother-post) :route-name :mother-create-post] ;; ["/centers" :get (conj json-interceptors `site.users/user-all)]
["/center/:center-id/mothers/create" :get (conj common-interceptors `site.mothers/create-mother-page) :route-name :mother-create-get]
["/center/:center-id/mothers/create" :post (conj common-interceptors `site.mothers/create-mother-post) :route-name :mother-create-post] ;; ["/centers" :get (conj json-interceptors `site.users/user-all)]
["/center/:center-id" :get (conj common-interceptors `site.centers/center-overview-page) :route-name :center-overview-page]
......@@ -134,6 +139,19 @@
["/mother/:mother-id" :get (conj common-interceptors `site.mothers/mother-record-page) :route-name :mother-record-page]
["/mother/:mother-id/update" :post (conj common-interceptors `site.mothers/mother-record-update) :route-name :mother-record-update-post]
["/mother/:mother-id/edit" :get (conj common-interceptors `site.mothers/mother-record-page) :route-name :mother-record-edit]
["/configure" :get (conj common-interceptors `site.centers/configure-page) :route-name :configure-page]
["/questions" :get (conj common-interceptors `site.questions/questions-list-page) :route-name :questions-list-page]
["/questions/add" :get (conj common-interceptors `site.questions/add-questions-page) :route-name :questions-list-add]
["/visits/add" :get (conj common-interceptors `site.visits/visit-add-page) :route-name :visit-add-page]
["/visits/add" :post (conj common-interceptors `site.visits/visit-add-post) :route-name :visit-add-post]
["/visits/:visit-id" :get (conj common-interceptors `site.visits/visit-page) :route-name :visit-page]
;; ["/mother/:mother-id/edit" :get (conj common-interceptors `site.mothers/mother-record-page) :route-name :mother-record-page]
;; ["/mothers/:mother-id/visits/create" :get (conj common-interceptors `site.mothers/create-mother-page) :route-name :mother-create-get]
;; ["/mothers/:mother-id/visits/create" :post (conj common-interceptors `site.mothers/create-mother-post) :route-name :mother-create-post]
})
......
......@@ -12,53 +12,54 @@
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
[:link {:rel "icon" :type "image/png" :href "/img/favicon.png"}]
[:title title]
(include-css "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css")]
;; (include-css "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css")]
(include-css "/css/bulma.min.css")]
[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/fork-awesome@1.1.7/css/fork-awesome.min.css" :integrity "sha256-gsmEoJAws/Kd3CjuOQzLie5Q3yshhvmo7YNtBG7aaEY=" :crossorigin "anonymous"}] [:body {:style "background-color:fafafa"} content]))
(defn form-control
"Default form control for dynamic deployment"
[text & value]
[:div.field [:label.label text] [:div.control [:input.input {:type "text" :placeholder text :name value}]]
[text param-name & value]
[:div.field [:label.label text] [:div.control [:input.input {:type "text" :placeholder text :name param-name :value value}]]
;;[:p.help "This is a help text"]
])
(defn form-control-textarea
"Default form control for dynamic deployment"
[text & value]
[:div.field [:label.label text] [:div.control [:textarea.textarea {:type "text" :placeholder text :name value}]]
[text param-name & value]
[:div.field [:label.label text] [:div.control [:textarea.textarea {:type "text" :placeholder text :name param-name :value value}]]
;;[:p.help "This is a help text"]
])
(defn form-control-email
"Default form control for dynamic deployment"
[text & value]
[:div.field [:label.label text] [:div.control [:input.input {:type "email" :placeholder text :name value}]]
[text param-name & value]
[:div.field [:label.label text] [:div.control [:input.input {:type "email" :placeholder text :name param-name :value value}]]
;;[:p.help "This is a help text"]
])
(defn form-control-date
"Default form control for dynamic deployment"
[text & value]
[text param-name & value]
[:div.field [:label.label text] [:div.control
[:input.input {:type "date" :name value}]]
[:input.input {:type "date" :name param-name :value value}]]
[:p.help "Click to choose a date"]])
(defn form-control-password
"Password form control for dynamic deployment"
[text & value]
[:div.field [:label.label text] [:div.control [:input.input {:type "password" :placeholder text :name value}]]
[text param-name & value]
[:div.field [:label.label text] [:div.control [:input.input {:type "password" :placeholder text :name param-name :value value}]]
;;[:p.help "This is a help text"]
])
(defn form-control-checkbox
"Checkbox form control for dynamic deployment"
[text & value]
[:div.field [:label.checkbox text] [:div.control [:input {:type "checkbox" :placeholder text :name value}]]])
[text param-name & value]
[:div.field [:label.checkbox text] [:div.control [:input {:type "checkbox" :placeholder text :name param-name :value value}]]])
(defn form-hidden-value
"Default form control for dynamic deployment"
[text & value]
[:div.control [:input {:type "hidden" :name text :value value}]])
[text param-name & value]
[:div.control [:input {:type "hidden" :name param-name :value value}]])
(defn form-control-dropdown
"Dropdown form control for dynamic deployment. Accepts label name, form value name and value pairs for each option."
......@@ -90,7 +91,7 @@
[:aside.menu
[:ul.menu-list [:li [:a {:href "/"} "Home"]]]
[:p.menu-label "Settings"] [:ul.menu-list [:li [:a "Profile"]] [:li [:a "About"]]]
[:p.menu-label "Settings"] [:ul.menu-list [:li [:a {:href "/configure"} "Configure"]] [:li [:a "About"]]]
[:p.menu-label "Centers"]
[:ul.menu-list
(for [x (db.centers/centers-all db/jdbc)] [:li [:a {:href (str "/center/" (:id x))} (:name x)]
......
......@@ -46,7 +46,10 @@
[:i.fa.fa-cog.fa-2x {:aria-hidden "true"}]
[:hr]
[:div
;;[:h2.is-size-5 (:name user)] [:a.button {:href (str "/user/" (:id user) "/mothers/create")} "Add mother"]
[:h2.is-size-3 "Upcoming visits"]
[:hr]
[:h2.is-size-3 "Past visits"]
;;[:h2.is-size-5 (:name user)] [:a.button {:href (str "/user/" (:id user) "/mothers/create")} "Add mother"]
]))))
(defn users-all-page [request]
......@@ -59,12 +62,12 @@
(:name center)
[:div.columns
[:div.column.is-half
[:p.is-size-5 "Workers"]
[:p.is-size-5 "Workers"] [:a.button.is-primary {:href "/create/user"} "Add new worker"]
[:table.table.is-hoverable.is-fullwidth.is-striped [:thead [:tr [:th "Worker Name"] [:th "Area"] [:th "Next Visit"] [:th "Mothers"] [:th "Edit"] [:th "Delete"]]]
[:tbody
(for [user users]
[:tr [:td (:name user)] [:td (:name center)] [:td ""] [:td ""]
[:td [:i.fa.fa-pencil {:aria-hidden "true"}]]
[:tr [:td (:name user)] [:td (:name center)] [:td (:id user)] [:td ""]
[:td [:a {:href (str "/user/" (:id user) "/edit")} [:i.fa.fa-pencil {:aria-hidden "true"}]]]
[:td [:i.fa.fa-trash {:aria-hidden "true"}]]])]]
;; [:div.column.is-half [:a.button {:href (str "/user/" (:id user) "/mothers/create")} "Add mother"]]]
]]))))
......@@ -73,18 +76,35 @@
(let
[center-id (Integer/parseInt (:center-id (:path-params request)))
center (db.centers/centers-by-id db/jdbc {:id center-id})
users (db.users/users-by-center db/jdbc {:center center-id})]
mothers (db.mothers/mothers-by-center db/jdbc {:center center-id})]
(ring-resp/response
(site/admin-template
(:name center)
[:div.columns
[:div.column.is-half
[:p.is-size-5 "Mothers"]
[:table.table.is-hoverable.is-fullwidth.is-striped [:thead [:tr [:th "Worker Name"] [:th "Area"] [:th "Next Visit"] [:th "Mothers"] [:th "Edit"] [:th "Delete"]]]
[:div.column
[:p.is-size-5 "Mothers"] [:a.button.is-primary {:href (str "/center/" center-id "/mothers/create")} "Add new mother"]
[:table.table.is-hoverable.is-fullwidth.is-striped [:thead [:tr [:th "Mother Name"] [:th "Next Visit"] [:th "Age"] [:th "Worker"] [:th "Baby DOB"] [:th "Baby Sex"] [:th "Edit"] [:th "Delete"]]]
[:tbody
(for [user users]
[:tr [:td (:name user)] [:td (:name center)] [:td ""] [:td ""]
[:td [:i.fa.fa-pencil {:aria-hidden "true"}]]
(for [mother mothers]
[:tr [:td (:name mother)] [:td (:name center)] [:td ""] [:td ""] [:td ""] [:td ""]
[:td [:a {:href (str "/mother/" (:id mother))} [:i.fa.fa-pencil {:aria-hidden "true"}]]]
[:td [:i.fa.fa-trash {:aria-hidden "true"}]]])]]
;; [:div.column.is-half [:a.button {:href (str "/user/" (:id user) "/mothers/create")} "Add mother"]]]
;;[:div.column.is-half [:a.button {:href (str "/user/" (:id user) "/mothers/create")} "Add mother"]]]
]]))))
(defn configure-page [request]
(ring-resp/response
(site/admin-template
"Configure"
[:div.columns
;; [:div.column
;; [:h1.title.is-size-3 "Visits"]]
[:div.column.is-one-third
[:h1.title.is-size-3 "Configure"]
[:a.button.is-primary {:href "/create/center"} "Add new center"] [:hr]
[:a.button.is-primary {:href "/visits/add"} "Add new visit"] [:hr]
;;[:a.button.is-primary {:href "/create/user"} "Add new worker"] [:hr]
]
[:div.column
[:h1.title.is-size-3 "Visits"]]])))
......@@ -16,14 +16,17 @@
(let [centers (db.centers/centers-all db/jdbc)]
[:div.columns
(for [center centers]
[:div.column.is-3 [:div.card [:header.card-header [:p.card-header-title (:name center)] [:a.card-header-icon {:href "#" :aria-label "more options"} [:span.icon [:i.fa.fa-angle-down {:aria-hidden "true"}]]]]
[:div.column.is-3 [:div.card [:header.card-header [:p.card-header-title (:name center)]
;; [:a.card-header-icon {:href "#" :aria-label "more options"} [:span.icon [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
]
[:div.card-content
[:div.content "Health worker" [:br]]]
[:div.card-content
[:div.content "Trips" [:br]]]
[:div.card-content
[:div.content "Mothers" [:br]]]
[:footer.card-footer [:a.card-footer-item {:href "#"} "Add new"]]]])]))
;;[:footer.card-footer [:a.card-footer-item {:href "#"} "Add new"]]
]])]))
(defn display-home-page [])
......
......@@ -52,7 +52,7 @@
]))
(defn create-mother-page "HTML page for creating a new mother record" [request]
(let [user-id (Integer/parseInt (:user-id (:path-params request)))
(let [user-id (Integer/parseInt (:center-id (:path-params request)))
user (db.users/users-by-id db/jdbc {:id user-id})]
(ring-resp/response (create-mother-html-form user))))
......@@ -74,12 +74,20 @@
(let [user-id (Integer/parseInt (:user-id (:path-params request)))
user (db.users/users-by-id db/jdbc {:id user-id})
mothers (db.mothers/mother-by-worker db/jdbc {:worker (:email user)})]
(ring-resp/response
(for [mother mothers]
(assoc mother :visits
(db.visits/visits-by-mother db/jdbc {:mother (:id mother)}))))))
(defn mother-record-page [request])
(defn mother-record-page [request]
(ring-resp/response
(site/admin-template "New mother"
(let
[mother-id (Integer/parseInt (:mother-id (:path-params request)))
mother (db.mothers/mothers-by-id db/jdbc {:id mother-id})]
;;mothers (db.mothers/mother-by-worker db/jdbc {:worker (:email user)})]
[:form {:method "POST" :action (str "/user/" "/mothers/create")}
[:div.column
[:h2.title.is-size-3 (:name mother)]]]))))
(defn mother-record-update [request])
......@@ -13,8 +13,6 @@
(defn create-user-html-form []
[:div.column.is-one-fifth.is-offset-one-third
[:h1.title.has-text-centered "New User"]
;; [:h2.has-size-3 "Hello"]
;; [:h2.has-size-3 "Kek"]
[:form {:method "POST" :action "/create/user"}
(site/form-control "Name" "name")
(site/form-control-email "Email" "email")
......@@ -60,6 +58,24 @@
[request]
())
(defn user-record-page [request])
(defn user-record-page [request]
(ring-resp/response
(site/admin-template "User"
(let
[user-id {:id (Integer/parseInt (:user-id (:path-params request)))}
user (db.users/users-by-id db/jdbc user-id)]
[:div.column.is-one-quarter.is-offset-one-quarter
[:h1.title.has-text-centered "Edit User"]
;; [:h2.has-size-3 "Hello"]
;; [:h2.has-size-3 "Kek"]
[:form {:method "POST" :action "/create/user"}
(site/form-control "Name" "name" (:name user))
(site/form-control-email "Email" "email" (:email user))
(site/form-control-password "Password" "password")
(site/form-control "Mobile" "mobile" (:mobile user))
(site.centers/centers-html-dropdown)
(site/form-control-checkbox "Admin?" "officer")
(site/form-control-button "Submit")]]))))
(defn user-record-update [request])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment