display modules

Josha von Gizycki 4 years ago
parent 506bee914b
commit 5902dcdcfa

@ -23,6 +23,7 @@ body {
.navbar {
padding: 0;
background-color: rgba(254, 254, 254, .5);
}
.navbar-brand {
@ -32,7 +33,6 @@ body {
}
.navbar__logo {
background: white;
height: var(--height-navbar);
padding: 1rem;
}
@ -101,7 +101,7 @@ body {
background: rgba(250, 250, 250, 0.8);
border-radius: 2rem;
border: 1px solid #ccc;
font-family: 'jetbrains-mono';
font-family: 'jetbrains-mono', monospace;
}
.breadcrumb img {
@ -127,6 +127,10 @@ body {
border: 1px solid #ccc;
}
.main > h2 {
margin-top: 3rem;
}
h1 {
font-weight: bold;
color: var(--ci-primary);
@ -179,5 +183,35 @@ table [data-sort="desc"]::after {
table [data-sort="asc"]::after {
content: "⇧";
diplay: inline;
display: inline;
}
.module-desc {
margin-top: 3rem;
padding-left: 1rem;
}
.module-desc h1 {
font-size: 2rem;
margin-left: -1rem;
}
.module-desc h1::before {
display: inline-block;
content: " ";
background-image: url('../img/klammer.svg');
width: .5rem;
height: 1.8rem;
background-size: contain;
background-repeat: no-repeat;
background-position: bottom;
margin-right: .5rem;
}
.module-desc h2 {
font-size: 1.7rem;
}
.module-desc h3 {
font-size: 1.5rem;
}

@ -134,7 +134,7 @@ document.addEventListener('DOMContentLoaded', function () {
input.classList.add('search')
input.classList.add('form-control')
input.type = 'search'
input.placeholder = 'search...'
input.placeholder = '🔍...'
return input
}

@ -13,6 +13,10 @@
:component (or (System/getenv "SCHEMA_COMPONENT")
"439856be-85be-49c1-b58b-4594741f37b3")})
(def attribute-uuids
{:module-desc (or (System/getenv "ATTR_MODULE_DESC")
"0924be5a-9680-44e3-986f-54b5b59631ba")})
(def coc-instance-uuids
{"dev" (or (System/getenv "INST_DEV")
"6348f1ab-1771-4bef-b101-eb76ec236646")
@ -63,12 +67,29 @@
(neo4j/defquery instance
"MATCH (i:instance {uuid:{uuid}})
RETURN i")
OPTIONAL MATCH
(p:property)-[:of]->(i),
(a:attribute)<-[:of]-(p)
RETURN i, p, a")
(defn instance! [uuid]
(-> (neo4j/exec-query! instance
{:uuid uuid})
first
:i))
(let [res (neo4j/exec-query! instance
{:uuid uuid})
instance (-> res
first
:i
(assoc :properties []))]
(reduce (fn [instance row]
(if-let [prop (:p row)]
(update instance
:properties
conj (assoc prop :attr
(:a row)))
instance))
instance
res)))
(comment
(instance! "0b30521a-0727-4a6b-b69e-6f3c554a81b2")
(instance! "fbe4375b-6518-45bb-a692-e58dccd8f658"))
(neo4j/defquery modules-with-comps
"MATCH (level:instance {uuid:{level_uuid}}),
@ -118,3 +139,28 @@
(comment
(modules-and-levels! "d97628f4-477d-49d7-a1c1-2fd643a0ee65")
(instance! "d97628f4-477d-49d7-a1c1-2fd643a0ee65"))
(neo4j/defquery components-of-module
"MATCH (module:instance {uuid:{uuid}}),
(cschema:schema {uuid:{compschema_uuid}}),
(comp:instance)-[:of]->(schema),
(module)--(:link)--(comp)
RETURN comp
ORDER BY comp.name")
(defn module! [uuid]
(let [i (instance! uuid)
desc (->> (:properties i)
(filter #(= (:module-desc attribute-uuids)
(-> % :attr :uuid)))
first
:value)
comps (->> {:uuid uuid
:compschema_uuid (:component schema-uuids)}
(neo4j/exec-query! components-of-module)
(map :comp))]
(assoc i
:desc desc
:components comps)))
(comment
(module! "0b30521a-0727-4a6b-b69e-6f3c554a81b2"))

@ -23,6 +23,11 @@
(db-public/instance! role-uuid)
(db-public/modules-and-levels! role-uuid)))
(defn show-module [coc-key module-uuid]
(view-public/show-module
(db-public/coc! coc-key)
(db-public/module! module-uuid)))
(defroutes routes
(GET (register! :public-index "/public") [] (index))
(GET (register! :public-coc "/public/:coc")
@ -33,4 +38,7 @@
(show-level coc level))
(GET (register! :public-role "/public/:coc/role/:role")
[coc role]
(show-role coc role)))
(show-role coc role))
(GET (register! :public-module "/public/:coc/module/:module")
[coc module]
(show-module coc module)))

@ -1,6 +1,7 @@
(ns wanijo.public.view
(:require [hiccup.page :refer [html5 include-js include-css]]
[hiccup.core :refer [h]]
[markdown.core :as md]
[wanijo.infrastructure.routing :refer [path]]))
(defn breadcrumb [& links]
@ -117,7 +118,10 @@
(list
[:tr
[:td {:rowspan (max 1 (count comps))}
(h (:name module))]
[:a {:href (path :public-module
{:coc (:key coc)
:module (:uuid module)})}
(h (:name module))]]
[:td (h (:name compo))]]
(for [compo (rest comps)]
[:tr
@ -143,7 +147,11 @@
[:tbody
(for [{:keys [module level]} modules-and-levels]
[:tr
[:td (h (:name module))]
[:td
[:a {:href (path :public-module
{:coc (:key coc)
:module (:uuid module)})}
(h (:name module))]]
[:td
[:a {:href (path :public-level
{:coc (:key coc)
@ -154,3 +162,27 @@
[:a {:href (path :public-coc {:coc (:key coc)})}
(h (:name coc))]]
[:li.breadcrumb-item.active (h (:name role))])]))
(defn show-module [coc module]
(layout
(h (:name module))
[[:main.main
[:h1 "Modul " (h (:name module))]
[:div.module-desc
(md/md-to-html-string (:desc module))]
[:h2 "Komponenten"]
[:table.table
[:thead
[:tr
[:th "Name"]]]
[:tbody
(for [comp (:components module)]
[:tr
[:td (h (:name comp))]])]]]
(breadcrumb
[:li.breadcrumb-item
[:a {:href (path :public-coc {:coc (:key coc)})}
(h (:name coc))]]
;; link to role not possible
;; multiple roles could use this module
[:li.breadcrumb-item.active (h (:name module))])]))

Loading…
Cancel
Save