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 ]
then
cp /opt/local/fifo-cerberus/config/config.js.example /opt/local/fifo-cerberus/config/config.js
else
echo "This upgrade requires changes to your config."
echo "Please check your config against the example located in:"
echo "/opt/local/fifo-cerberus/config"
fi
;;
esac
......@@ -9,7 +9,7 @@ var Config = {
*/
/*
* datasets source
* datasets sources as a list
*/
datasets: "https://datasets.at/images"
datasets: ["https://datasets.project-fifo.net/images/", "http://datasets.at/images"]
};
......@@ -10,8 +10,6 @@
(def root :datasets)
(def server (global/get "datasets" "http://datasets.at/images"))
(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]
[cerberus.global :as global]
[cerberus.fields :as fields]
......@@ -49,11 +51,24 @@
om/IWillMount
(will-mount [_]
(datasets/list data)
(go
(let [resp (<! (http/get (global/get "datasets" "http://datasets.at/images") {:with-credentials? false :headers {"Accept" "application/json"}}))]
(if (:success resp)
(om/transact! data :remote-datasets (constantly (:body resp)))
(dbg/error "[datasets/import] error: " resp)))))
(doseq
; 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" ["https://datasets.project-fifo.net/images"]))
(global/get "datasets" ["https://datasets.project-fifo.net/images"])
["https://datasets.project-fifo.net/images"])]
(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))))))
om/IRenderState
(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"))
(d/tbody
(map
(fn [{uuid :uuid :as e}]
(d/tr
{: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])))))
datasets)))))))
(for [source datasets]
(for [dataset (second source)]
(let [uuid (:uuid dataset)
source (first source)]
(d/tr
{: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))
(d/td
(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