Commit eac9e63a authored by Kevin Meziere's avatar Kevin Meziere

add ability to have multiple dataset sources

parent 5f62f1e9
......@@ -29,7 +29,8 @@
[secretary "1.2.3"]
[clj-http "2.0.0"]
[jarohen/chord "0.6.0"]
[cljs-http "0.1.37"]]
[cljs-http "0.1.37"]
[com.cemerick/url "0.1.1"]]
:plugins [[lein-cljsbuild "1.0.6"]
[lein-environ "1.0.0"]
......@@ -22,6 +22,10 @@ case $2 in
if [ ! -f /opt/local/fifo-cerberus/config/config.js ]
cp /opt/local/fifo-cerberus/config/config.js.example /opt/local/fifo-cerberus/config/config.js
echo "This upgrade requires changes to your config."
echo "Please check your config against the example located in:"
echo "/opt/local/fifo-cerberus/config"
......@@ -9,7 +9,7 @@ var Config = {
* datasets source
* datasets sources as a list
datasets: ""
datasets: ["", ""]
......@@ -10,8 +10,6 @@
(def root :datasets)
(def server (global/get "datasets" ""))
(defn list [data]
(api/list data root))
......@@ -24,8 +22,8 @@
(api/delete data root [uuid]
(alerts "Dataset deleted." "Failed to delete dataset.")))
(defn import [uuid]
(api/post root [] {:url (str server "/" uuid)}
(defn import [url]
(api/post root [] {:url url}
(alerts "Dataset import started." "Dataset import failed.")))
(defn from-vm [vm snapshot name version os desc]
......@@ -4,7 +4,9 @@
[om.core :as om :include-macros true]
[om-tools.dom :as d :include-macros true]
[om-bootstrap.table :refer [table]]
[om-bootstrap.random :as r]
[cljs-http.client :as http]
[cemerick.url :as url]
[cerberus.debug :as dbg]
[ :as global]
[cerberus.fields :as fields]
......@@ -49,11 +51,24 @@
(will-mount [_]
(datasets/list data)
(let [resp (<! (http/get (global/get "datasets" "") {:with-credentials? false :headers {"Accept" "application/json"}}))]
(if (:success resp)
(om/transact! data :remote-datasets (constantly (:body resp)))
(dbg/error "[datasets/import] error: " resp)))))
; This kind of sucks, but we are changing the config data type,
; so at least with this something shows up, and it will be relatively
; easy to debug why the users config changes are not being used.
[f (if (coll? (global/get "datasets" [""]))
(global/get "datasets" [""])
(go (let
[resp (<! (http/get f {:with-credentials? false
:headers {"Accept" "application/json"}}))]
(if (:success resp)
(om/transact! data [:remote-datasets f] (constantly (:body resp)))
(dbg/error "[datasets/import] error: " resp))))))
(render-state [_ datasets]
(let [datasets (:remote-datasets data)
......@@ -68,17 +83,23 @@
(d/td "Version")
(d/td "Type")
(d/td "Published")
(d/td "Source")
(d/td "Size"))
(fn [{uuid :uuid :as e}]
{:on-click #(om/transact! data (partial toggle-dataset uuid))
:class (if (installed? uuid) "installed"
(if (picked? uuid) "selected" "not-selected"))}
(d/td (:name e))
(d/td (:version e))
(d/td (dataset-type e))
(d/td (:published_at e))
(d/td (fields/fmt-bytes :b (get-in e [:files 0 :size])))))
(for [source datasets]
(for [dataset (second source)]
(let [uuid (:uuid dataset)
source (first source)]
{:on-click #(om/transact! data (partial toggle-dataset (str source "/" uuid)))
:class (if (installed? uuid) "installed"
(if (picked? (str source "/" uuid)) "selected" "not-selected"))}
(d/td (:name dataset))
(d/td (:version dataset))
(d/td (dataset-type dataset))
(d/td (:published_at dataset))
(if (= "https" (:protocol (url/url source)))
(r/glyphicon {:glyph "lock"}))
(:host (url/url source)))
(d/td (fields/fmt-bytes :b (get-in dataset [:files 0 :size])))))))))))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment