deleting schemas - again!

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

@ -10,6 +10,32 @@
[markdown.core :as md]
[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]
(view/layout
:request req
@ -61,55 +87,9 @@
[:h2 "Visualisation"]
[:p (viz/single-instance instance)]])
(when (seq (:links-out instance))
[:section.links-out
[: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))]])]]])
(links-table "Outgoing links" :links-out instance))
(when (seq (:links-in instance))
[:section.links-in
[: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))]])]]])
(links-table "Incoming links" :links-in instance))
[:section.quick-edits
[:h2 "Quick edits"]
[:section.link-instance
@ -118,7 +98,7 @@
(for [schema schemas]
[:li
[:a {:href (path :instance-link-selection
{:uuid (:uuid instance)
{:uuid (:uuid instance)
:schema-uuid (:uuid schema)})}
(h (:name schema))]])]]
[:section.tag-instance

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

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

Loading…
Cancel
Save