From a005e05e71b7960b26ece0fd3ef754617bb28ed3 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Mon, 3 Feb 2020 17:14:02 +0100 Subject: [PATCH] modules and components --- src/wanijo/public/db.clj | 46 +++++++++++++++++++++++++++-- src/wanijo/public/routes.clj | 13 +++++++-- src/wanijo/public/view.clj | 56 ++++++++++++++++++++++++++++++------ 3 files changed, 103 insertions(+), 12 deletions(-) diff --git a/src/wanijo/public/db.clj b/src/wanijo/public/db.clj index 9ecea5f..f501ef8 100644 --- a/src/wanijo/public/db.clj +++ b/src/wanijo/public/db.clj @@ -25,7 +25,7 @@ "MATCH (coc:instance {uuid:{coc_uuid}}), (rschema:schema {uuid:{roleschema_uuid}}), (role:instance)-[:of]->(rschema), - (coc)--(:link)--(role:instance) + (coc)--(:link)--(role) OPTIONAL MATCH (lschema:schema {uuid:{levelschema_uuid}}), (level:instance)-[:of]->(lschema), @@ -39,7 +39,10 @@ (group-by :role) (map (fn [[role rows]] {:role role - :levels (filter some? (map :level rows))})))) + :levels (->> (map :level rows) + (filter some?) + (sort-by :name))})) + (sort-by #(-> % :role :name)))) (comment (roles-with-levels-of-coc! "dev") @@ -57,3 +60,42 @@ first :coc (assoc :key coc-key))) + +(neo4j/defquery level + "MATCH (level:instance {uuid:{uuid}}) + RETURN level") +(defn level! [uuid] + (-> (neo4j/exec-query! level + {:uuid uuid}) + first + :level)) + +(neo4j/defquery modules-with-comps + "MATCH (level:instance {uuid:{level_uuid}}), + (mschema:schema {uuid:{moduleschema_uuid}}), + (module:instance)-[:of]->(mschema), + (level)--(:link)--(module) + OPTIONAL MATCH + (cschema:schema {uuid:{compschema_uuid}}), + (comp:instance)-[:of]->(cschema), + (module)--(:link)--(comp) + RETURN module, comp") +(defn modules-with-comps! [level-uuid] + (->> (neo4j/exec-query! modules-with-comps + {:level_uuid level-uuid + :moduleschema_uuid (:module schema-uuids) + :compschema_uuid (:component schema-uuids)}) + (group-by :module) + (map (fn [[module rows]] + {:module module + :comps (->> (map :comp rows) + (filter some?) + (sort-by :name))})) + (sort-by #(-> % :module :name)))) + +(comment + (modules-with-comps! "140962fb-f55e-45ab-87fc-680c012bd8dc") + (neo4j/exec-query! modules-with-comps + {:level_uuid "140962fb-f55e-45ab-87fc-680c012bd8dc" + :moduleschema_uuid (:module schema-uuids) + :compschema_uuid (:component schema-uuids)})) diff --git a/src/wanijo/public/routes.clj b/src/wanijo/public/routes.clj index b930a85..be421be 100644 --- a/src/wanijo/public/routes.clj +++ b/src/wanijo/public/routes.clj @@ -7,10 +7,19 @@ (defn index [] (view-public/index)) -(defn show-roles [coc-key] +(defn show-coc [coc-key] (view-public/show-coc (db-public/coc! coc-key) (db-public/roles-with-levels-of-coc! coc-key))) +(defn show-modules [coc-key level-uuid] + (view-public/show-modules + (db-public/coc! coc-key) + (db-public/level! level-uuid) + (db-public/modules-with-comps! level-uuid))) + (defroutes routes (GET (register! :public-index "/public") [] (index)) - (GET (register! :public-coc "/public/:coc") [coc] (show-roles coc))) + (GET (register! :public-coc-roles "/public/:coc") [coc] (show-coc coc)) + (GET (register! :public-role-modules "/public/:coc/:level") + [coc level] + (show-modules coc level))) diff --git a/src/wanijo/public/view.clj b/src/wanijo/public/view.clj index da4ccd2..a9729c7 100644 --- a/src/wanijo/public/view.clj +++ b/src/wanijo/public/view.clj @@ -30,13 +30,13 @@ [:menu.global-nav [:ol.global-nav__card-nav [:li.global-nav__card-nav-item - [:a.global-nav__link {:href (path :public-coc {:coc "dev"})} + [:a.global-nav__link {:href (path :public-coc-roles {:coc "dev"})} "Development"]] [:li.global-nav__card-nav-item - [:a.global-nav__link {:href (path :public-coc {:coc "prk"})} + [:a.global-nav__link {:href (path :public-coc-roles {:coc "prk"})} "Projekte"]] [:li.global-nav__card-nav-item - [:a.global-nav__link {:href (path :public-coc {:coc "req"})} + [:a.global-nav__link {:href (path :public-coc-roles {:coc "req"})} "Req. Eng."]]]] (into [:div.content] content)]])) @@ -64,16 +64,56 @@ [:tbody (for [row roles-with-levels :let [{:keys [role levels]} row - rest-levels (rest levels)]] + level (first levels)]] (list [:tr - [:td {:rowspan (max 1 (count levels))} (h (:name role))] - [:td (h (-> levels first :name))]] - (for [level rest-levels] + [:td {:rowspan (max 1 (count levels))} + (h (:name role))] + [:td + [:a {:href (path :public-role-modules + {:coc (:key coc) + :level (:uuid level)})} + (h (:name level))]]] + (for [level (rest levels)] [:tr - [:td (h (:name level))]])))]]]] + [:td [:a {:href (path :public-role-modules + {:coc (:key coc) + :level (:uuid level)})} + (h (:name level))]]])))]]]] [:nav [:ol.breadcrumb [:li.breadcrumb-item [:a {:href (path :public-index)} "Start"]] [:li.breadcrumb-item.active (h (:name coc))]]]])) + +(defn show-modules [coc level modules-with-comps] + (layout + [[:main.main + [:h1 "Erfahrungsstufe " (h (:name level))] + [:div.table-responsive + [:table.table + [:thead + [:tr + [:th "Modul"] + [:th "Komponente"]]] + [:tbody + (for [row modules-with-comps + :let [{:keys [module comps]} row + compo (first comps)]] + (list + [:tr + [:td {:rowspan (max 1 (count comps))} + (h (:name module))] + [:td (h (:name compo))]] + (for [compo (rest comps)] + [:tr + [:td (h (:name compo))]])))]]]] + [:nav + [:ol.breadcrumb + [:li.breadcrumb-item + [:a {:href (path :public-index)} "Start"]] + [:li.breadcrumb-item + [:a {:href (path :public-coc-roles + {:coc (:key coc)})} + (h (:name coc))]] + [:li.breadcrumb-item.active (h (:name level))]]]]))