listing roles

Josha von Gizycki 5 years ago
parent 627dc678a9
commit 0024f99fe9

@ -83,7 +83,12 @@
[:h2 "Visualisation"] [:h2 "Visualisation"]
[:ul [:ul
[:li [:a {:href (path :vis-all-instances)} [:li [:a {:href (path :vis-all-instances)}
"All Instances"]]]]))] "All Instances"]]]]
[:section
[:h2 "Triology"]
[:ul
[:li [:a {:href (path :public-index)}
"Public"]]]]))]
(into [:main (into [:main
(for [msg (:flash request)] (for [msg (:flash request)]
(flash-error msg))] (flash-error msg))]

@ -1,10 +1,26 @@
(ns wanijo.public.db (ns wanijo.public.db
(:require [wanijo.infrastructure.neo4j :as neo4j])) (:require [wanijo.infrastructure.neo4j :as neo4j]))
(def key-mapping (def schema-uuids
{"dev" "Development" {:coc "4f7b561c-51d2-4332-895f-cd583946dcab"
"req" "Projekte" :role "f87b5810-b8c2-4420-91ae-87f0e02af88a"
"prk" "Requirements Engineering"}) :level "4ce60c8f-3864-4528-9e63-7c862cb8644a"
:module "574b1813-5366-4e48-9034-9c1bce52d455"
:component "439856be-85be-49c1-b58b-4594741f37b3"})
(neo4j/defquery roles (def coc-instance-uuids
"MATCH (i:instance {name:{name}})") {"dev" "6348f1ab-1771-4bef-b101-eb76ec236646"
"req" "44b02979-7e78-491c-8631-fc49a47b799d"
"prk" "318ee72d-8a8b-42c5-aa90-d5efc1787d22"})
(neo4j/defquery roles-of-coc
"MATCH (coc:instance {uuid:{coc_uuid}}),
(coc)--(:link)--(role:instance),
(role)-[:of]->(rschema:schema {uuid:{roleschema_uuid}})
RETURN role
ORDER BY role.name")
(defn roles-of-coc! [coc-key]
(map :role
(neo4j/exec-query! roles-of-coc
{:coc_uuid (get coc-instance-uuids coc-key)
:roleschema_uuid (:role schema-uuids)})))

@ -1,13 +1,15 @@
(ns wanijo.public.routes (ns wanijo.public.routes
(:require [compojure.core :refer [defroutes wrap-routes GET]] (:require [compojure.core :refer [defroutes wrap-routes GET]]
[wanijo.infrastructure.routing :refer [register!]] [wanijo.infrastructure.routing :refer [register!]]
[wanijo.public.db :as db-public]
[wanijo.public.view :as view-public])) [wanijo.public.view :as view-public]))
(defn index [] (defn index []
(view-public/index)) (view-public/index))
(defn show-coc [coc] (defn show-coc [coc]
(view-public/show-coc coc)) (view-public/show-coc coc
(db-public/roles-of-coc! coc)))
(defroutes routes (defroutes routes
(GET (register! :public-index "/public") [] (index)) (GET (register! :public-index "/public") [] (index))

@ -1,5 +1,6 @@
(ns wanijo.public.view (ns wanijo.public.view
(:require [hiccup.page :refer [html5 include-js include-css]] (:require [hiccup.page :refer [html5 include-js include-css]]
[hiccup.core :refer [h]]
[wanijo.infrastructure.routing :refer [path]])) [wanijo.infrastructure.routing :refer [path]]))
(defn layout [content] (defn layout [content]
@ -49,6 +50,14 @@
"Dann gestalte selbst deinen Weg bei der TRIO und sprich" "Dann gestalte selbst deinen Weg bei der TRIO und sprich"
"deinen Vorgesetzten an"]])) "deinen Vorgesetzten an"]]))
(defn show-coc [coc] (defn show-coc [coc roles]
(layout (layout
[[:h1 "CoC " coc]])) [[:h1 "CoC " coc]
[:table.table
[:thead
[:tr
[:th "Name"]]]
[:tbody
(for [role roles]
[:tr
[:td (h (:name role))]])]]]))

Loading…
Cancel
Save