component page

Josha von Gizycki 5 years ago
parent 810f2ab657
commit ea8eed672c

@ -6,6 +6,7 @@ export SCHEMA_COMPONENT=f229b8c7-3794-4ded-8192-052dd7af3830
export ATTR_MODULE_DESC=0924be5a-9680-44e3-986f-54b5b59631ba export ATTR_MODULE_DESC=0924be5a-9680-44e3-986f-54b5b59631ba
export ATTR_ROLE_DESC=39e467a5-9ed2-496b-bc98-a14e3b52a8d1 export ATTR_ROLE_DESC=39e467a5-9ed2-496b-bc98-a14e3b52a8d1
export ATTR_COMP_DESC=35646a07-5b48-4711-9211-54df9f13e815
export INST_DEV=73f69c1b-5106-44bb-b5e1-90c4f3847037 export INST_DEV=73f69c1b-5106-44bb-b5e1-90c4f3847037
export INST_REQ=1d155970-f211-4699-9b90-21ef748c6afd export INST_REQ=1d155970-f211-4699-9b90-21ef748c6afd

@ -17,7 +17,9 @@
{:module-desc (or (System/getenv "ATTR_MODULE_DESC") {:module-desc (or (System/getenv "ATTR_MODULE_DESC")
"0924be5a-9680-44e3-986f-54b5b59631ba") "0924be5a-9680-44e3-986f-54b5b59631ba")
:role-desc (or (System/getenv "ATTR_ROLE_DESC") :role-desc (or (System/getenv "ATTR_ROLE_DESC")
"39e467a5-9ed2-496b-bc98-a14e3b52a8d1")}) "39e467a5-9ed2-496b-bc98-a14e3b52a8d1")
:comp-desc (or (System/getenv "ATTR_COMP_DESC")
"35646a07-5b48-4711-9211-54df9f13e815")})
(def coc-instance-uuids (def coc-instance-uuids
{"dev" (or (System/getenv "INST_DEV") {"dev" (or (System/getenv "INST_DEV")
@ -150,6 +152,12 @@
(modules-and-levels! "d97628f4-477d-49d7-a1c1-2fd643a0ee65") (modules-and-levels! "d97628f4-477d-49d7-a1c1-2fd643a0ee65")
(instance! "d97628f4-477d-49d7-a1c1-2fd643a0ee65")) (instance! "d97628f4-477d-49d7-a1c1-2fd643a0ee65"))
(defn propery-of-attribute [{:keys [properties]} attr-uuid]
(->> properties
(filter #(= attr-uuid (-> % :attr :uuid)))
first
:value))
(neo4j/defquery components-of-module (neo4j/defquery components-of-module
"MATCH (module:instance {uuid:{uuid}}), "MATCH (module:instance {uuid:{uuid}}),
(cschema:schema {uuid:{compschema_uuid}}), (cschema:schema {uuid:{compschema_uuid}}),
@ -159,30 +167,25 @@
ORDER BY comp.name") ORDER BY comp.name")
(defn module! [uuid] (defn module! [uuid]
(let [i (instance! uuid) (let [i (instance! uuid)
desc (->> (:properties i)
(filter #(= (:module-desc attribute-uuids)
(-> % :attr :uuid)))
first
:value)
comps (->> {:uuid uuid comps (->> {:uuid uuid
:compschema_uuid (:component schema-uuids)} :compschema_uuid (:component schema-uuids)}
(neo4j/exec-query! components-of-module) (neo4j/exec-query! components-of-module)
(map :comp))] (map :comp))]
(assoc i (assoc i
:desc desc :desc (propery-of-attribute i (:module-desc attribute-uuids))
:components comps))) :components comps)))
(comment (comment
(module! "0b30521a-0727-4a6b-b69e-6f3c554a81b2")) (module! "0b30521a-0727-4a6b-b69e-6f3c554a81b2"))
(defn role! [uuid] (defn role! [uuid]
(let [i (instance! uuid) (let [i (instance! uuid)]
desc (->> (:properties i)
(filter #(= (:role-desc attribute-uuids)
(-> % :attr :uuid)))
first
:value)]
(assoc i (assoc i
:desc desc))) :desc (propery-of-attribute i (:role-desc attribute-uuids)))))
(comment (comment
(role! "2c507f67-600d-4add-b648-2ea62d5a4ffc")) (role! "2c507f67-600d-4add-b648-2ea62d5a4ffc"))
(defn comp! [uuid]
(let [i (instance! uuid)]
(assoc i
:desc (propery-of-attribute i (:comp-desc attribute-uuids)))))

@ -28,6 +28,12 @@
(db-public/coc! coc-key) (db-public/coc! coc-key)
(db-public/module! module-uuid))) (db-public/module! module-uuid)))
(defn show-comp [coc-key module-uuid comp-uuid]
(view-public/show-comp
(db-public/coc! coc-key)
(db-public/module! module-uuid)
(db-public/comp! comp-uuid)))
(defroutes routes (defroutes routes
(GET (register! :public-index "/public") [] (index)) (GET (register! :public-index "/public") [] (index))
(GET (register! :public-coc "/public/:coc") (GET (register! :public-coc "/public/:coc")
@ -41,4 +47,7 @@
(show-role coc role)) (show-role coc role))
(GET (register! :public-module "/public/:coc/module/:module") (GET (register! :public-module "/public/:coc/module/:module")
[coc module] [coc module]
(show-module coc module))) (show-module coc module))
(GET (register! :public-comp "/public/:coc/module/:module/comp/:comp")
[coc module comp]
(show-comp coc module comp)))

@ -180,7 +180,12 @@
[:tbody [:tbody
(for [comp (:components module)] (for [comp (:components module)]
[:tr [:tr
[:td (h (:name comp))]])]]] [:td
[:a {:href (path :public-comp
{:coc (:key coc)
:module (:uuid module)
:comp (:uuid comp)})}
(h (:name comp))]]])]]]
(breadcrumb (breadcrumb
[:li.breadcrumb-item [:li.breadcrumb-item
[:a {:href (path :public-coc {:coc (:key coc)})} [:a {:href (path :public-coc {:coc (:key coc)})}
@ -188,3 +193,22 @@
;; link to role not possible ;; link to role not possible
;; multiple roles could use this module ;; multiple roles could use this module
[:li.breadcrumb-item.active (h (:name module))])])) [:li.breadcrumb-item.active (h (:name module))])]))
(defn show-comp [coc module comp]
(layout
(h (:name comp))
[[:main.main
[:h1 "Komponente " (h (:name comp))]
[:div.markdown-content
(md/md-to-html-string (:desc comp))]]
(breadcrumb
[:li.breadcrumb-item
[:a {:href (path :public-coc {:coc (:key coc)})}
(h (:name coc))]]
[:li.breadcrumb-item
[:a {:href (path :public-module
{:coc (:key coc)
:module (:uuid module)})}
(h (:name module))]]
[:li.breadcrumb-item.active (h (:name comp))])]))

Loading…
Cancel
Save