new visualisation namespace

integration-tests
Josha von Gizycki 6 years ago
parent df90b486af
commit eaeca7f8c3

@ -60,13 +60,19 @@
"header-content__link")])] "header-content__link")])]
[:nav [:nav
(when authed? (when authed?
(list
[:section.schemas [:section.schemas
[:h2 [:span.__icon "▤"] "Schemas"] [:h2 [:span.__icon "▤"] "Schemas"]
[:ul [:ul
(for [schema (:schemas session)] (for [schema (:schemas session)]
[:li [:a {:href (path :instance-list [:li [:a {:href (path :instance-list
{:schema-uuid (:uuid schema)})} {:schema-uuid (:uuid schema)})}
(h (:name schema))]])]])] (h (:name schema))]])]]
[:section
[:h2 [:span.__icon "▤"] "Visualisation"]
[:ul
[:li [:a {:href ""}
"All Instances"]]]]))]
(into [:main (into [:main
(for [msg (:flash request)] (for [msg (:flash request)]
(flash-error msg))] (flash-error msg))]

@ -12,6 +12,7 @@
[wanijo.user.routes :as user-routes] [wanijo.user.routes :as user-routes]
[wanijo.attribute.routes :as attr-routes] [wanijo.attribute.routes :as attr-routes]
[wanijo.instance.routes :as instance-routes] [wanijo.instance.routes :as instance-routes]
[wanijo.visualisation.routes :as vis-routes]
[wanijo.framework.auth :as auth] [wanijo.framework.auth :as auth]
[wanijo.framework.devmode :as devmode] [wanijo.framework.devmode :as devmode]
[wanijo.framework.routing :refer [path]])) [wanijo.framework.routing :refer [path]]))
@ -29,7 +30,8 @@
schema-routes/routes schema-routes/routes
user-routes/routes user-routes/routes
attr-routes/routes attr-routes/routes
instance-routes/routes)) instance-routes/routes
vis-routes/routes))
(route/not-found "Not Found")) (route/not-found "Not Found"))
(def app (def app

@ -6,8 +6,7 @@
[wanijo.instance [wanijo.instance
[view :as view] [view :as view]
[domain :as domain] [domain :as domain]
[forms :as forms-inst] [forms :as forms-inst]]
[viz :as viz]]
[wanijo.schema [wanijo.schema
[domain :as domain-schema] [domain :as domain-schema]
[middleware :as middleware-schema]] [middleware :as middleware-schema]]
@ -119,11 +118,6 @@
(DELETE (register! :instance-delete "/instance/:uuid") (DELETE (register! :instance-delete "/instance/:uuid")
[uuid :as req] [uuid :as req]
(delete! uuid req)) (delete! uuid req))
(GET (register! :instance-link-viz
"/instance/:uuid/link/viz")
[uuid :as req]
{:body (viz/as-svg (instance! uuid))
:headers {"Content-Type" "image/svg+xml"}})
(GET (register! :instance-link-selection (GET (register! :instance-link-selection
"/instance/:uuid/link/:schema-uuid") "/instance/:uuid/link/:schema-uuid")
[uuid schema-uuid :as req] [uuid schema-uuid :as req]

@ -71,7 +71,7 @@
(seq (:links-in instance))) (seq (:links-in instance)))
[:section.visualisation [:section.visualisation
[:h2 "Visualisation"] [:h2 "Visualisation"]
[:image {:src (path :instance-link-viz instance) [:image {:src (path :vis-single-instance instance)
:alt "SVG Visualisation"}]]) :alt "SVG Visualisation"}]])
(when (seq (:links-out instance)) (when (seq (:links-out instance))
[:section.links-out [:section.links-out

@ -0,0 +1,14 @@
(ns wanijo.visualisation.routes
(:require [compojure.core :refer [defroutes wrap-routes
GET POST DELETE]]
[ring.util.response :as resp]
[wanijo.framework.routing :refer [register! path]]
[wanijo.instance.domain :as domain-instance]
[wanijo.visualisation.viz :as viz]))
(defroutes routes
(GET (register! :vis-single-instance "/visualisation/instance/:uuid")
[uuid]
{:body (viz/single-instance
(domain-instance/full-instance-by-uuid! uuid))
:headers {"Content-Type" "image/svg+xml"}}))

@ -1,9 +1,9 @@
(ns wanijo.instance.viz (ns wanijo.visualisation.viz
(:require [dorothy (:require [dorothy
[core :as dot] [core :as dot]
[jvm :as doro-jvm]])) [jvm :as doro-jvm]]))
(defn as-svg [instance] (defn single-instance [instance]
(let [out-nodes (map #(vector (-> % :target :uuid) (let [out-nodes (map #(vector (-> % :target :uuid)
{:label (-> % :target :name)}) {:label (-> % :target :name)})
(:links-out instance)) (:links-out instance))
Loading…
Cancel
Save