deleting schemas - again!

neo4j-4
Josha von Gizycki 5 years ago
parent e52de87cbb
commit 723f7fd09b

@ -10,6 +10,32 @@
[markdown.core :as md] [markdown.core :as md]
[wanijo.visualisation.viz :as viz])) [wanijo.visualisation.viz :as viz]))
(defn links-table [heading direction instance]
[:section.links-in
[:h2 (h heading)]
[:table
[:thead
[:tr
[:th "Name"]
[:th "Instance"]
[:th "Schema"]
[:th "Created"]]]
[:tbody
(for [{:keys [link source schema target] :as row} (direction instance)
:let [name (:name link)
empty (empty? name)
name (if empty [:i "empty"] (h name))
other (or source target)]]
[:tr
[:td name
(view-instance/tags-for-search row)]
[:td [:a {:href (path :instance-show other)}
(h (:name other))]]
[:td [:a {:href (path :instance-list
{:schema-uuid (:uuid schema)})}
(h (:name schema))]]
[:td (prettify-dt (:created_at link))]])]]])
(defn show [instance schemas req] (defn show [instance schemas req]
(view/layout (view/layout
:request req :request req
@ -61,55 +87,9 @@
[:h2 "Visualisation"] [:h2 "Visualisation"]
[:p (viz/single-instance instance)]]) [:p (viz/single-instance instance)]])
(when (seq (:links-out instance)) (when (seq (:links-out instance))
[:section.links-out (links-table "Outgoing links" :links-out instance))
[:h2 "Outgoing Links"]
[:table
[:thead
[:tr
[:th "Name"]
[:th "Instance"]
[:th "Schema"]
[:th "Created"]]]
[:tbody
(for [{:keys [link target schema] :as row} (:links-out instance)
:let [name (:name link)
empty (empty? name)
name (if empty [:i "empty"] (h name))]]
[:tr
[:td
name
(view-instance/tags-for-search row)]
[:td [:a {:href (path :instance-show target)}
(h (:name target))]]
[:td [:a {:href (path :instance-list
{:schema-uuid (:uuid schema)})}
(h (:name schema))]]
[:td (prettify-dt (:created_at link))]])]]])
(when (seq (:links-in instance)) (when (seq (:links-in instance))
[:section.links-in (links-table "Incoming links" :links-in instance))
[:h2 "Incoming Links"]
[:table
[:thead
[:tr
[:th "Name"]
[:th "Instance"]
[:th "Schema"]
[:th "Created"]]]
[:tbody
(for [{:keys [link source schema] :as row} (:links-in instance)
:let [name (:name link)
empty (empty? name)
name (if empty [:i "empty"] (h name))]]
[:tr
[:td
name
(view-instance/tags-for-search row)]
[:td [:a {:href (path :instance-show source)}
(h (:name source))]]
[:td [:a {:href (path :instance-list
{:schema-uuid (:uuid schema)})}
(h (:name schema))]]
[:td (prettify-dt (:created_at link))]])]]])
[:section.quick-edits [:section.quick-edits
[:h2 "Quick edits"] [:h2 "Quick edits"]
[:section.link-instance [:section.link-instance

@ -6,10 +6,9 @@
(defonce server (atom nil)) (defonce server (atom nil))
(defn start-server! (defn start-server!
[& {:keys [port join? handler] [& {:keys [port join?]
:or {port 3080 :or {port 3080
join? true join? true}}]
handler wanijo-handler/standalone-app}}]
(reset! server (reset! server
(run-jetty wanijo-handler/standalone-app (run-jetty wanijo-handler/standalone-app
{:port port {:port port

@ -93,10 +93,10 @@
{:user_uuid user-uuid}))) {:user_uuid user-uuid})))
(neo4j/defquery delete (neo4j/defquery delete
"MATCH (s:schema) "MATCH (s:schema {uuid:{uuid}})
WHERE s.uuid = {uuid} WITH s
OPTIONAL MATCH (s)--(a:attribute) OPTIONAL MATCH (s)--(a:attribute)-[cb:created_by]-(:user)
DELETE a DELETE cb, a
WITH s WITH s
MATCH (s)-[c]-() MATCH (s)-[c]-()
DELETE c, s") DELETE c, s")

Loading…
Cancel
Save