diff --git a/project.clj b/project.clj index e83c559..9ce81bc 100644 --- a/project.clj +++ b/project.clj @@ -14,6 +14,7 @@ ring/ring-codec commons-io commons-codec]] + [ring/ring-json "0.4.0"] [hiccup "1.0.5"] [joshavg/formulare "0.4.0-SNAPSHOT"] diff --git a/src/frontend/viz.elm b/src/frontend/Explore.elm similarity index 90% rename from src/frontend/viz.elm rename to src/frontend/Explore.elm index 401f267..3c60976 100644 --- a/src/frontend/viz.elm +++ b/src/frontend/Explore.elm @@ -1,4 +1,4 @@ -module Main exposing (Msg(..), main, update, view) +module Explore exposing (Msg(..), main, update, view) import Browser import Html exposing (Html, button, div, text) diff --git a/src/wanijo/handler.clj b/src/wanijo/handler.clj index 7949210..2af6139 100644 --- a/src/wanijo/handler.clj +++ b/src/wanijo/handler.clj @@ -6,6 +6,7 @@ :refer [wrap-defaults site-defaults]] [ring.util.response :as rur] [ring.middleware.session.cookie :as session-cookie] + [ring.middleware.json :as ring-json] [wanijo.home.routes :as home-routes] [wanijo.schema [routes :as schema-routes] @@ -46,6 +47,7 @@ (-> app-routes devmode/wrap-devmode schema-middleware/wrap-user-schemas + ring-json/wrap-json-response (wrap-defaults (assoc-in site-defaults [:session :store] diff --git a/src/wanijo/visualisation/routes.clj b/src/wanijo/visualisation/routes.clj index 06f8867..6e8dae7 100644 --- a/src/wanijo/visualisation/routes.clj +++ b/src/wanijo/visualisation/routes.clj @@ -5,6 +5,7 @@ [wanijo.framework.routing :refer [register! path]] [wanijo.framework.view :as view] [wanijo.instance.domain :as domain-instance] + [wanijo.schema.domain :as domain-schema] [wanijo.visualisation [domain :as vis-domain] [viz :as viz] @@ -17,10 +18,17 @@ [[:h1 "All Instances"] (viz/all-instances (vis-domain/all-instance-connections!))])) +(defn all-schemas [req] + {:content-type "text/json" + :body (domain-schema/accessible-schemas! (-> req :session :uuid))}) + (defroutes routes (GET (register! :vis-index "/visualisation/index") [:as req] (vis-view/index req)) (GET (register! :vis-all-instances "/visualisation/all-instances") [:as req] - (all-instances req))) + (all-instances req)) + (GET (register! :vis-all-schemas "/api/visualisation/schemas") + [:as req] + (all-schemas req)))