integration-tests
Josha von Gizycki 6 years ago
commit 0fe483e306

2
.gitignore vendored

@ -13,3 +13,5 @@ pom.xml.asc
*.iml *.iml
figwheel_server.log figwheel_server.log
neo4j/* neo4j/*
resources/public/js/out
.rebel_readline_history

@ -0,0 +1,11 @@
(ns user
(:require [figwheel-sidecar.repl-api :as ra]))
(defn start-fw []
(ra/start-figwheel!))
(defn stop-fw []
(ra/stop-figwheel!))
(defn cljs []
(ra/cljs-repl))

@ -0,0 +1,11 @@
(ns ^:figwheel-no-load wanijo.frontend.dev
(:require
[wanijo.frontend.core :as core]
[devtools.core :as devtools]))
(enable-console-print!)
(devtools/install!)
(core/init!)

@ -0,0 +1,8 @@
(ns wanijo.frontend.prod
(:require
[wanijo.frontend.core :as core]))
;;ignore println statements in prod
(set! *print-fn* (fn [& _]))
(core/init!)

@ -3,8 +3,10 @@
:url "http://example.com/FIXME" :url "http://example.com/FIXME"
:min-lein-version "2.0.0" :min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.10.0"] :dependencies [;;clojure core
[org.clojure/clojure "1.10.0"]
;; static site
[compojure "1.6.1"] [compojure "1.6.1"]
[ring/ring-defaults "0.3.2"] [ring/ring-defaults "0.3.2"]
[ring/ring-jetty-adapter "1.7.1" [ring/ring-jetty-adapter "1.7.1"
@ -12,36 +14,59 @@
ring/ring-codec ring/ring-codec
commons-io commons-io
commons-codec]] commons-codec]]
[hiccup "1.0.5"] [hiccup "1.0.5"]
[joshavg/formulare "0.4.0-SNAPSHOT"] [joshavg/formulare "0.4.0-SNAPSHOT"]
;; neo4j
[gorillalabs/neo4j-clj "2.0.1" [gorillalabs/neo4j-clj "2.0.1"
:exclusions [org.bouncycastle/bcprov-jdk15on :exclusions [org.bouncycastle/bcprov-jdk15on
org.bouncycastle/bcpkix-jdk15on org.bouncycastle/bcpkix-jdk15on
com.github.ben-manes.caffeine/caffeine]] com.github.ben-manes.caffeine/caffeine]]
;; additional server side libs
[buddy/buddy-hashers "1.3.0" [buddy/buddy-hashers "1.3.0"
:exclusions [commons-codec]] :exclusions [commons-codec]]
[clj-time "0.15.1"] [clj-time "0.15.1"]
[markdown-clj "1.0.7"] [markdown-clj "1.0.7"]
[dorothy "0.0.7"]] [dorothy "0.0.7"]
:profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"] ;; fancy js fuckup
[org.clojure/clojurescript "1.10.520"]
[reagent "0.8.1"]]
:profiles {:dev {:dependencies [;; webserver stuff
[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"] [ring/ring-mock "0.3.2"]
[ring/ring-devel "1.7.1" [ring/ring-devel "1.7.1"
:exclusions [ring/ring-core :exclusions [ring/ring-core
ring/ring-codec ring/ring-codec
commons-io commons-io
commons-codec]]] commons-codec]]
:plugins [[joshavg/lein-neo4j "0.5.0"]
;; fancy js fuckup
[binaryage/devtools "0.9.10"]
[figwheel-sidecar "0.5.18"]
[nrepl "0.6.0"]
[cider/piggieback "0.4.0"]]
:plugins [;; neo4j db
[joshavg/lein-neo4j "0.4.0"]
;; webserver stuff
[lein-less "1.7.5"] [lein-less "1.7.5"]
[lein-ring "0.12.5"] [lein-ring "0.12.5"]
[lein-ancient "0.6.15"]
;; code quality
[lein-ancient "LATEST"]
[jonase/eastwood "LATEST"] [jonase/eastwood "LATEST"]
[lein-bikeshed "0.5.1"] [lein-bikeshed "0.5.1"]
[lein-cloverage "1.1.0"] [lein-cloverage "1.0.13"]
[lein-kibit "LATEST"]]} [cider/cider-nrepl "LATEST"]
[lein-kibit "LATEST"]
;; fancy js fuckup
[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.18"]]
:source-paths ["src" "env/dev/clj"]}
:uberjar {:aot :all :uberjar {:aot :all
:main wanijo.main}} :main wanijo.main}}
@ -51,4 +76,40 @@
:less {:source-paths ["resources/app/stylesheets"] :less {:source-paths ["resources/app/stylesheets"]
:target-path "resources/public/css"} :target-path "resources/public/css"}
:hiera {:cluster-depth 2} :hiera {:cluster-depth 2}
:eastwood {:namespaces [:source-paths]}) :eastwood {:namespaces [:source-paths]}
:aliases {"package" ["do"
"clean"
["cljsbuild" "once" "release"]
["less" "once"]]}
;;fancy js fuckup
:clean-targets ^{:protect false}
[:target-path
[:cljsbuild :builds :app :compiler :output-dir]
[:cljsbuild :builds :app :compiler :output-to]]
:figwheel {;;:http-server-root "resources"
:nrepl-port 7002
:nrepl-middleware [cider.piggieback/wrap-cljs-repl]
:css-dirs ["resources/public/css"]
:ring-handler wanijo.handler/app}
:cljsbuild {:builds
{:app
{:source-paths ["src" "env/dev/cljs"]
:compiler {:main "wanijo.frontend.dev"
:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/out"
:asset-path "/js/out"
:source-map true
:optimizations :none
:pretty-print true}
:figwheel {:on-jsload "wanijo.frontend.core/mount-root"
:open-urls ["http://localhost:3449/index.html"]}}
:release
{:source-paths ["src" "env/prod/cljs"]
:compiler {:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/out-release"
:optimizations :advanced
:infer-externs true
:pretty-print false}}}})

@ -68,11 +68,9 @@ img, svg {
grid-template-columns: 20% 70% 10%; grid-template-columns: 20% 70% 10%;
grid-template-areas: grid-template-areas:
"header header header" "header header header"
// "nav main sidebar"
"nav main main" "nav main main"
"footer footer footer"; "footer footer footer";
margin: auto; margin: auto;
max-width: 1500px;
header { header {
grid-area: header; grid-area: header;

@ -0,0 +1,11 @@
var CLOSURE_UNCOMPILED_DEFINES = {};
var CLOSURE_NO_DEPS = true;
if(typeof goog == "undefined") document.write('<script src="/js/out/goog/base.js"></script>');
document.write('<script src="/js/out/goog/deps.js"></script>');
document.write('<script src="/js/out/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write('<script>goog.require("figwheel.connect");</script>');
document.write('<script>goog.require("process.env");</script>');
document.write('<script>goog.require("wanijo.frontend.dev");</script>');
document.write("<script>figwheel.connect.start();</script>");

@ -29,7 +29,7 @@
(when (:flash req) [:section.flash (:flash req)]) (when (:flash req) [:section.flash (:flash req)])
;; ;;
(hform/label "uname" "Name") (hform/label "uname" "Name")
(hform/text-field {:required "required"} "uname") (hform/text-field {:required "required" :autofocus true} "uname")
;; ;;
(hform/label "pw" "Password") (hform/label "pw" "Password")
(hform/password-field {:required "required"} "pw") (hform/password-field {:required "required"} "pw")

@ -57,8 +57,3 @@
(time-format/unparse (time-format/unparse
(time-format/formatters :basic-date-time) (time-format/formatters :basic-date-time)
(time-local/local-now))) (time-local/local-now)))
(defn bool [value]
(if value
(.asBoolean value)
false))

@ -3,8 +3,7 @@
[neo4j-clj.core :as db] [neo4j-clj.core :as db]
[wanijo.framework.neo4j :as neo4j])) [wanijo.framework.neo4j :as neo4j]))
(db/defquery (db/defquery create-user
create-user
"CREATE (n:user) "CREATE (n:user)
SET n.ident = {ident} SET n.ident = {ident}
SET n.pw = {pw} SET n.pw = {pw}
@ -16,3 +15,57 @@
{:ident ident {:ident ident
:pw (hashers/derive pw) :pw (hashers/derive pw)
:uuid (neo4j/uuid)})) :uuid (neo4j/uuid)}))
(db/defquery init-config
"MERGE (c:dbconfig)
ON CREATE SET
c.installed_at = {now},
c.db_version = 0")
(db/defquery config
"MATCH (c:dbconfig) RETURN c")
(db/defquery ver-0-schema-uuid
"CREATE CONSTRAINT ON (n:schema)
ASSERT n.uuid IS UNIQUE")
(db/defquery ver-0-attribute-uuid
"CREATE CONSTRAINT ON (n:attribute)
ASSERT n.uuid IS UNIQUE")
(db/defquery ver-0-instance-uuid
"CREATE CONSTRAINT ON (n:instance)
ASSERT n.uuid IS UNIQUE")
(db/defquery ver-0-property-uuid
"CREATE CONSTRAINT ON (n:property)
ASSERT n.uuid IS UNIQUE")
(db/defquery ver-0-user-uuid
"CREATE CONSTRAINT ON (n:user)
ASSERT n.uuid IS UNIQUE")
(db/defquery ver-0-link-uuid
"CREATE CONSTRAINT ON (n:link)
ASSERT n.uuid IS UNIQUE")
(defn init-version-0 []
(neo4j/exec-query! ver-0-schema-uuid {})
(neo4j/exec-query! ver-0-attribute-uuid {})
(neo4j/exec-query! ver-0-instance-uuid {})
(neo4j/exec-query! ver-0-property-uuid {})
(neo4j/exec-query! ver-0-user-uuid {})
(neo4j/exec-query! ver-0-link-uuid {}))
(def migrations
[init-version-0])
(defn run-migrations! []
(neo4j/exec-query! init-config {:now (neo4j/now-str)})
(let [version (-> (neo4j/exec-query! config {})
first
:c
:db_version)]
(if-let [to-run (nthrest migrations version)]
(doseq [mig to-run]
(mig)))))

@ -23,11 +23,13 @@
content]) content])
(defn layout! (defn layout!
[& {:keys [content title session request] [& {:keys [content title session request head bottom]
:or {content [] :or {content []
title nil title nil
request {} request {}
session nil}}] session nil
head nil
bottom nil}}]
(let [session (or session (:session request)) (let [session (or session (:session request))
ident (:ident session) ident (:ident session)
authed? (some? ident) authed? (some? ident)
@ -40,7 +42,8 @@
[:title (str "wan ijo" (when title (str " - " title)))] [:title (str "wan ijo" (when title (str " - " title)))]
(include-css "/css/app.css") (include-css "/css/app.css")
(when devmode? (include-css "/css/devmode.css")) (when devmode? (include-css "/css/devmode.css"))
(include-js "/js/frontend.js")] (include-js "/js/scripts.js")
head]
[:body [:body
[:section.grid [:section.grid
[:header [:header
@ -71,6 +74,8 @@
[:section [:section
[:h2 [:span.__icon "▤"] "Visualisation"] [:h2 [:span.__icon "▤"] "Visualisation"]
[:ul [:ul
[:li [:a {:href (path :vis-index)}
"Custom Visualisation"]]
[:li [:a {:href (path :vis-all-instances)} [:li [:a {:href (path :vis-all-instances)}
"All Instances"]]]]))] "All Instances"]]]]))]
(into [:main (into [:main
@ -78,4 +83,5 @@
(flash-error msg))] (flash-error msg))]
content) content)
[:footer [:footer
[:small "Ilo pali e ijo"]]]]))) [:small "Ilo pali e ijo"]]]
bottom])))

@ -0,0 +1,18 @@
(ns wanijo.frontend.core
(:require
[reagent.core :as r]))
;; -------------------------
;; Views
(defn home-page []
[:div [:h2 "Welcome to Reagent ummf"]])
;; -------------------------
;; Initialize app
(defn mount-root []
(r/render [home-page] (.getElementById js/document "visualisation")))
(defn init! []
(mount-root))

@ -4,4 +4,5 @@
[wanijo.home.view :as home-view])) [wanijo.home.view :as home-view]))
(defroutes routes (defroutes routes
(GET "/index.html" [] home-view/root!)
(GET (register! :home "/") [] home-view/root!)) (GET (register! :home "/") [] home-view/root!))

@ -101,8 +101,8 @@
{:schema_uuid schema-uuid {:schema_uuid schema-uuid
:user_uuid user-uuid :user_uuid user-uuid
:type perm-type})) :type perm-type}))
public? (neo4j/bool (:is_public permissions)) public? (:is_public permissions)
user? (neo4j/bool (:user_has_permission permissions))] user? (:user_has_permission permissions)]
(or public? user?))) (or public? user?)))
(defn has-user-write-permissions? [schema-uuid user-uuid] (defn has-user-write-permissions? [schema-uuid user-uuid]

@ -5,8 +5,10 @@
[wanijo.framework.routing :refer [register! path]] [wanijo.framework.routing :refer [register! path]]
[wanijo.framework.view :as view] [wanijo.framework.view :as view]
[wanijo.instance.domain :as domain-instance] [wanijo.instance.domain :as domain-instance]
[wanijo.visualisation.domain :as vis-domain] [wanijo.visualisation
[wanijo.visualisation.viz :as viz])) [domain :as vis-domain]
[viz :as viz]
[view :as vis-view]]))
(defn all-instances [req] (defn all-instances [req]
(view/layout! (view/layout!
@ -16,6 +18,9 @@
(viz/all-instances (vis-domain/all-instance-connections!))])) (viz/all-instances (vis-domain/all-instance-connections!))]))
(defroutes routes (defroutes routes
(GET (register! :vis-index "/visualisation/index")
[:as req]
(vis-view/index req))
(GET (register! :vis-all-instances "/visualisation/all-instances") (GET (register! :vis-all-instances "/visualisation/all-instances")
[:as req] [:as req]
(all-instances req))) (all-instances req)))

@ -0,0 +1,11 @@
(ns wanijo.visualisation.view
(:require [hiccup.page :refer [include-js]]
[wanijo.framework.view :as view]))
(defn index [req]
(view/layout!
:request req
:bottom (list (include-js "/js/app.js"))
:content
[[:h1 "Visualisation"]
[:div#visualisation]]))
Loading…
Cancel
Save