mirror of
https://github.com/penpot/penpot.git
synced 2025-01-02 04:40:09 -05:00
🔥 Remove a lot of obsolete code
This commit is contained in:
parent
b1b3ad61a5
commit
d349e46cd8
43 changed files with 174 additions and 3689 deletions
|
@ -40,8 +40,7 @@
|
|||
|
||||
;; --- Constants & Helpers
|
||||
|
||||
(def ^:const +images-uuid-ns+ #uuid "3642a582-565f-4070-beba-af797ab27a6a")
|
||||
(def ^:const +icons-uuid-ns+ #uuid "3642a582-565f-4070-beba-af797ab27a6b")
|
||||
(def ^:const +graphics-uuid-ns+ #uuid "3642a582-565f-4070-beba-af797ab27a6a")
|
||||
(def ^:const +colors-uuid-ns+ #uuid "3642a582-565f-4070-beba-af797ab27a6c")
|
||||
|
||||
(s/def ::id ::us/uuid)
|
||||
|
@ -49,16 +48,7 @@
|
|||
(s/def ::path ::us/string)
|
||||
(s/def ::regex #(instance? java.util.regex.Pattern %))
|
||||
|
||||
;; (s/def ::colors
|
||||
;; (s/* (s/cat :name ::us/string :color ::us/color)))
|
||||
;;
|
||||
;; (s/def ::import-item-media
|
||||
;; (s/keys :req-un [::name ::path ::regex]))
|
||||
;;
|
||||
;; (s/def ::import-item-color
|
||||
;; (s/keys :req-un [::name ::id ::colors]))
|
||||
|
||||
(s/def ::import-images
|
||||
(s/def ::import-graphics
|
||||
(s/keys :req-un [::path ::regex]))
|
||||
|
||||
(s/def ::import-color
|
||||
|
@ -68,225 +58,23 @@
|
|||
|
||||
(s/def ::import-library
|
||||
(s/keys :req-un [::name]
|
||||
:opt-un [::import-images ::import-colors]))
|
||||
:opt-un [::import-graphics ::import-colors]))
|
||||
|
||||
(defn exit!
|
||||
([] (exit! 0))
|
||||
([code]
|
||||
(System/exit code)))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;; Icons Libraries Importer
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; (defn- icon-library-exists?
|
||||
;; [conn id]
|
||||
;; (s/assert ::us/uuid id)
|
||||
;; (let [row (db/get-by-id conn :icon-library id)]
|
||||
;; (if row true false)))
|
||||
;;
|
||||
;; (defn- create-icons-library
|
||||
;; [conn {:keys [name] :as item}]
|
||||
;; (let [id (uuid/namespaced +icons-uuid-ns+ name)]
|
||||
;; (log/info "Creating icons library:" name)
|
||||
;; (icons/create-library conn {:team-id uuid/zero
|
||||
;; :id id
|
||||
;; :name name})))
|
||||
;;
|
||||
;; (defn- create-icons-library-if-not-exists
|
||||
;; [conn {:keys [name] :as item}]
|
||||
;; (let [id (uuid/namespaced +icons-uuid-ns+ name)]
|
||||
;; (when-not (icon-library-exists? conn id)
|
||||
;; (create-icons-library conn item))
|
||||
;; id))
|
||||
;;
|
||||
;; (defn- create-icon
|
||||
;; [conn library-id icon-id localpath]
|
||||
;; (s/assert fs/path? localpath)
|
||||
;; (s/assert ::us/uuid library-id)
|
||||
;; (s/assert ::us/uuid icon-id)
|
||||
;; (let [filename (fs/name localpath)
|
||||
;; extension (second (fs/split-ext filename))
|
||||
;; data (svg/parse localpath)
|
||||
;; mdata (select-keys data [:width :height :view-box])]
|
||||
;;
|
||||
;; (log/info "Creating or updating icon" filename icon-id)
|
||||
;; (icons/create-icon conn {:id icon-id
|
||||
;; :library-id library-id
|
||||
;; :name (:name data filename)
|
||||
;; :content (:content data)
|
||||
;; :metadata mdata})))
|
||||
;;
|
||||
;; (defn- icon-exists?
|
||||
;; [conn id]
|
||||
;; (s/assert ::us/uuid id)
|
||||
;; (let [row (db/get-by-id conn :icon id)]
|
||||
;; (if row true false)))
|
||||
;;
|
||||
;; (defn- import-icon-if-not-exists
|
||||
;; [conn library-id fpath]
|
||||
;; (s/assert ::us/uuid library-id)
|
||||
;; (s/assert fs/path? fpath)
|
||||
;; (let [icon-id (uuid/namespaced +icons-uuid-ns+ (str library-id (fs/name fpath)))]
|
||||
;; (when-not (icon-exists? conn icon-id)
|
||||
;; (create-icon conn library-id icon-id fpath))
|
||||
;; icon-id))
|
||||
;;
|
||||
;; (defn- import-icons
|
||||
;; [conn library-id {:keys [path regex] :as item}]
|
||||
;; (run! (fn [fpath]
|
||||
;; (when (re-matches regex (str fpath))
|
||||
;; (import-icon-if-not-exists conn library-id fpath)))
|
||||
;; (->> (fs/list-dir path)
|
||||
;; (filter fs/regular-file?))))
|
||||
;;
|
||||
;; (defn- process-icons-library
|
||||
;; [conn basedir {:keys [path regex] :as item}]
|
||||
;; (s/assert ::import-item-media item)
|
||||
;; (let [library-id (create-icons-library-if-not-exists conn item)]
|
||||
;; (->> (assoc item :path (fs/join basedir path))
|
||||
;; (import-icons conn library-id))))
|
||||
;;
|
||||
;;
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;; --- Images Libraries Importer
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; (defn- image-library-exists?
|
||||
;; [conn id]
|
||||
;; (s/assert ::us/uuid id)
|
||||
;; (let [row (db/get-by-id conn :image-library id)]
|
||||
;; (if row true false)))
|
||||
;;
|
||||
;; (defn- create-images-library
|
||||
;; [conn {:keys [name] :as item}]
|
||||
;; (let [id (uuid/namespaced +images-uuid-ns+ name)]
|
||||
;; (log/info "Creating image library:" name)
|
||||
;; (media/create-library conn {:id id
|
||||
;; :team-id uuid/zero
|
||||
;; :name name})))
|
||||
;;
|
||||
;; (defn- create-images-library-if-not-exists
|
||||
;; [conn {:keys [name] :as item}]
|
||||
;; (let [id (uuid/namespaced +images-uuid-ns+ name)]
|
||||
;; (when-not (image-library-exists? conn id)
|
||||
;; (create-images-library conn item)
|
||||
;; id)))
|
||||
;;
|
||||
;; (defn- create-image
|
||||
;; [conn library-id image-id localpath]
|
||||
;; (s/assert fs/path? localpath)
|
||||
;; (s/assert ::us/uuid library-id)
|
||||
;; (s/assert ::us/uuid image-id)
|
||||
;; (let [filename (fs/name localpath)
|
||||
;; extension (second (fs/split-ext filename))
|
||||
;; file (io/as-file localpath)
|
||||
;; mtype (case extension
|
||||
;; ".jpg" "image/jpeg"
|
||||
;; ".png" "image/png"
|
||||
;; ".webp" "image/webp")]
|
||||
;; (log/info "Creating image" filename image-id)
|
||||
;; (media/create-image conn {:content {:tempfile localpath
|
||||
;; :filename filename
|
||||
;; :content-type mtype
|
||||
;; :size (.length file)}
|
||||
;; :id image-id
|
||||
;; :library-id library-id
|
||||
;; :user uuid/zero
|
||||
;; :name filename})))
|
||||
;;
|
||||
;; (defn- image-exists?
|
||||
;; [conn id]
|
||||
;; (s/assert ::us/uuid id)
|
||||
;; (let [row (db/get-by-id conn :image id)]
|
||||
;; (if row true false)))
|
||||
;;
|
||||
;; (defn- import-image-if-not-exists
|
||||
;; [conn library-id fpath]
|
||||
;; (s/assert ::us/uuid library-id)
|
||||
;; (s/assert fs/path? fpath)
|
||||
;; (let [image-id (uuid/namespaced +images-uuid-ns+ (str library-id (fs/name fpath)))]
|
||||
;; (when-not (image-exists? conn image-id)
|
||||
;; (create-image conn library-id image-id fpath))
|
||||
;; image-id))
|
||||
;;
|
||||
;; (defn- import-images
|
||||
;; [conn library-id {:keys [path regex] :as item}]
|
||||
;; (run! (fn [fpath]
|
||||
;; (when (re-matches regex (str fpath))
|
||||
;; (import-image-if-not-exists conn library-id fpath)))
|
||||
;; (->> (fs/list-dir path)
|
||||
;; (filter fs/regular-file?))))
|
||||
;;
|
||||
;; (defn- process-images-library
|
||||
;; [conn basedir {:keys [path regex] :as item}]
|
||||
;; (s/assert ::import-item-media item)
|
||||
;; (let [library-id (create-images-library-if-not-exists conn item)]
|
||||
;; (->> (assoc item :path (fs/join basedir path))
|
||||
;; (import-images conn library-id))))
|
||||
;;
|
||||
;;
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;; Colors Libraries Importer
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; (defn- color-library-exists?
|
||||
;; [conn id]
|
||||
;; (s/assert ::us/uuid id)
|
||||
;; (let [row (db/get-by-id conn :file id)]
|
||||
;; (if row true false)))
|
||||
;;
|
||||
;; (defn- create-colors-library
|
||||
;; [conn {:keys [name] :as item}]
|
||||
;; (let [id (uuid/namespaced +colors-uuid-ns+ name)]
|
||||
;; (log/info "Creating color library:" name)
|
||||
;; (colors/create-library conn {:id id
|
||||
;; :team-id uuid/zero
|
||||
;; :name name})))
|
||||
;;
|
||||
;;
|
||||
;; (defn- create-colors-library-if-not-exists
|
||||
;; [conn {:keys [name] :as item}]
|
||||
;; (let [id (uuid/namespaced +colors-uuid-ns+ name)]
|
||||
;; (when-not (color-library-exists? conn id)
|
||||
;; (create-colors-library conn item))
|
||||
;; id))
|
||||
;;
|
||||
;; (defn- create-color
|
||||
;; [conn library-id name content]
|
||||
;; (s/assert ::us/uuid library-id)
|
||||
;; (s/assert ::us/color content)
|
||||
;; (let [color-id (uuid/namespaced +colors-uuid-ns+ (str library-id content))]
|
||||
;; (log/info "Creating color" color-id "-" name content)
|
||||
;; (colors/create-color conn {:id color-id
|
||||
;; :library-id library-id
|
||||
;; :name name
|
||||
;; :content content})
|
||||
;; color-id))
|
||||
;;
|
||||
;; (defn- import-colors
|
||||
;; [conn library-id {:keys [colors] :as item}]
|
||||
;; (db/delete! conn :color {:library-id library-id})
|
||||
;; (run! (fn [[name content]]
|
||||
;; (create-color conn library-id name content))
|
||||
;; (partition-all 2 colors)))
|
||||
;;
|
||||
;; (defn- process-colors-library
|
||||
;; [conn {:keys [name id colors] :as item}]
|
||||
;; (us/verify ::import-item-color item)
|
||||
;; (let [library-id (create-colors-library-if-not-exists conn item)]
|
||||
;; (import-colors conn library-id item)))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Images Importer
|
||||
;; Graphics Importer
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- create-image
|
||||
[conn file-id image-id localpath]
|
||||
(defn- create-media-object
|
||||
[conn file-id media-object-id localpath]
|
||||
(s/assert fs/path? localpath)
|
||||
(s/assert ::us/uuid file-id)
|
||||
(s/assert ::us/uuid image-id)
|
||||
(s/assert ::us/uuid media-object-id)
|
||||
(let [filename (fs/name localpath)
|
||||
extension (second (fs/split-ext filename))
|
||||
file (io/as-file localpath)
|
||||
|
@ -295,36 +83,36 @@
|
|||
".png" "image/png"
|
||||
".webp" "image/webp"
|
||||
".svg" "image/svg+xml")]
|
||||
(log/info "Creating image" filename image-id)
|
||||
(log/info "Creating image" filename media-object-id)
|
||||
(media/create-media-object conn {:content {:tempfile localpath
|
||||
:filename filename
|
||||
:content-type mtype
|
||||
:size (.length file)}
|
||||
:id image-id
|
||||
:id media-object-id
|
||||
:file-id file-id
|
||||
:name filename
|
||||
:is-local false})))
|
||||
|
||||
(defn- image-exists?
|
||||
(defn- media-object-exists?
|
||||
[conn id]
|
||||
(s/assert ::us/uuid id)
|
||||
(let [row (db/get-by-id conn :media-object id)]
|
||||
(if row true false)))
|
||||
|
||||
(defn- import-image-if-not-exists
|
||||
(defn- import-media-object-if-not-exists
|
||||
[conn file-id fpath]
|
||||
(s/assert ::us/uuid file-id)
|
||||
(s/assert fs/path? fpath)
|
||||
(let [image-id (uuid/namespaced +images-uuid-ns+ (str file-id (fs/name fpath)))]
|
||||
(when-not (image-exists? conn image-id)
|
||||
(create-image conn file-id image-id fpath))
|
||||
image-id))
|
||||
(let [media-object-id (uuid/namespaced +graphics-uuid-ns+ (str file-id (fs/name fpath)))]
|
||||
(when-not (media-object-exists? conn media-object-id)
|
||||
(create-media-object conn file-id media-object-id fpath))
|
||||
media-object-id))
|
||||
|
||||
(defn- import-images
|
||||
[conn file-id {:keys [path regex] :as images}]
|
||||
(defn- import-graphics
|
||||
[conn file-id {:keys [path regex] :as graphics}]
|
||||
(run! (fn [fpath]
|
||||
(when (re-matches regex (str fpath))
|
||||
(import-image-if-not-exists conn file-id fpath)))
|
||||
(import-media-object-if-not-exists conn file-id fpath)))
|
||||
(->> (fs/list-dir path)
|
||||
(filter fs/regular-file?))))
|
||||
|
||||
|
@ -371,17 +159,17 @@
|
|||
:profile-id uuid/zero
|
||||
:project-id project-id
|
||||
:name name
|
||||
:shared? true})
|
||||
:is-shared true})
|
||||
(files/create-page conn {:file-id id}))
|
||||
id))
|
||||
|
||||
(defn- process-library
|
||||
[conn basedir project-id {:keys [name images colors] :as library}]
|
||||
[conn basedir project-id {:keys [name graphics colors] :as library}]
|
||||
(us/verify ::import-library library)
|
||||
(let [library-file-id (create-library-file-if-not-exists conn project-id library)]
|
||||
(when images
|
||||
(->> (assoc images :path (fs/join basedir (:path images)))
|
||||
(import-images conn library-file-id)))
|
||||
(when graphics
|
||||
(->> (assoc graphics :path (fs/join basedir (:path graphics)))
|
||||
(import-graphics conn library-file-id)))
|
||||
(when colors
|
||||
(import-colors conn library-file-id colors))))
|
||||
|
||||
|
@ -435,15 +223,6 @@
|
|||
[]
|
||||
(mount/stop))
|
||||
|
||||
;; (defn- importer
|
||||
;; [conn basedir data]
|
||||
;; (let [images (:images data)
|
||||
;; icons (:icons data)
|
||||
;; colors (:colors data)]
|
||||
;; (run! #(process-images-library conn basedir %) images)
|
||||
;; (run! #(process-icons-library conn basedir %) icons)
|
||||
;; (run! #(process-colors-library conn %) colors)))
|
||||
|
||||
(defn run
|
||||
[path]
|
||||
(let [[basedir libraries] (read-file path)]
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
(defn- load-query-services
|
||||
[]
|
||||
;; (require 'uxbox.services.queries.icons)
|
||||
(require 'uxbox.services.queries.media)
|
||||
(require 'uxbox.services.queries.colors)
|
||||
(require 'uxbox.services.queries.projects)
|
||||
|
@ -22,20 +21,17 @@
|
|||
(require 'uxbox.services.queries.pages)
|
||||
(require 'uxbox.services.queries.profile)
|
||||
(require 'uxbox.services.queries.recent-files)
|
||||
(require 'uxbox.services.queries.viewer)
|
||||
)
|
||||
(require 'uxbox.services.queries.viewer))
|
||||
|
||||
(defn- load-mutation-services
|
||||
[]
|
||||
(require 'uxbox.services.mutations.demo)
|
||||
;; (require 'uxbox.services.mutations.icons)
|
||||
(require 'uxbox.services.mutations.media)
|
||||
(require 'uxbox.services.mutations.colors)
|
||||
(require 'uxbox.services.mutations.projects)
|
||||
(require 'uxbox.services.mutations.files)
|
||||
(require 'uxbox.services.mutations.pages)
|
||||
(require 'uxbox.services.mutations.profile)
|
||||
)
|
||||
(require 'uxbox.services.mutations.profile))
|
||||
|
||||
(defstate query-services
|
||||
:start (load-query-services))
|
||||
|
|
|
@ -29,91 +29,6 @@
|
|||
(s/def ::library-id ::us/uuid)
|
||||
(s/def ::content ::us/string)
|
||||
|
||||
|
||||
;; ;; --- Mutation: Create Library
|
||||
;;
|
||||
;; (declare create-library)
|
||||
;;
|
||||
;; (s/def ::create-color-library
|
||||
;; (s/keys :req-un [::profile-id ::team-id ::name]
|
||||
;; :opt-un [::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::create-color-library
|
||||
;; [{:keys [profile-id team-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (teams/check-edition-permissions! conn profile-id team-id)
|
||||
;; (create-library conn params)))
|
||||
;;
|
||||
;; (defn create-library
|
||||
;; [conn {:keys [id team-id name]}]
|
||||
;; (let [id (or id (uuid/next))]
|
||||
;; (db/insert! conn :color-library
|
||||
;; {:id id
|
||||
;; :team-id team-id
|
||||
;; :name name})))
|
||||
;;
|
||||
|
||||
;; ;; --- Mutation: Rename Library
|
||||
;;
|
||||
;; (declare select-library-for-update)
|
||||
;; (declare rename-library)
|
||||
;;
|
||||
;; (s/def ::rename-color-library
|
||||
;; (s/keys :req-un [::profile-id ::name ::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::rename-color-library
|
||||
;; [{:keys [id profile-id name] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-library-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;; (rename-library conn id name))))
|
||||
;;
|
||||
;; (def ^:private sql:select-library-for-update
|
||||
;; "select l.*
|
||||
;; from color_library as l
|
||||
;; where l.id = $1
|
||||
;; for update")
|
||||
;;
|
||||
;; (def ^:private sql:rename-library
|
||||
;; "update color_library
|
||||
;; set name = $2
|
||||
;; where id = $1")
|
||||
;;
|
||||
;; (defn- select-library-for-update
|
||||
;; [conn id]
|
||||
;; (db/get-by-id conn :color-library id {:for-update true}))
|
||||
;;
|
||||
;; (defn- rename-library
|
||||
;; [conn id name]
|
||||
;; (db/update! conn :color-library
|
||||
;; {:name name}
|
||||
;; {:id id}))
|
||||
|
||||
|
||||
;; ;; --- Delete Library
|
||||
;;
|
||||
;; (declare delete-library)
|
||||
;;
|
||||
;; (s/def ::delete-color-library
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::delete-color-library
|
||||
;; [{:keys [id profile-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-library-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;;
|
||||
;; ;; Schedule object deletion
|
||||
;; (tasks/submit! conn {:name "delete-object"
|
||||
;; :delay cfg/default-deletion-delay
|
||||
;; :props {:id id :type :color-library}})
|
||||
;;
|
||||
;; (db/update! conn :color-library
|
||||
;; {:deleted-at (dt/now)}
|
||||
;; {:id id})
|
||||
;; nil)))
|
||||
|
||||
|
||||
;; --- Mutation: Create Color
|
||||
|
||||
(declare select-file-for-update)
|
||||
|
|
|
@ -18,10 +18,7 @@
|
|||
[uxbox.common.uuid :as uuid]
|
||||
[uxbox.config :as cfg]
|
||||
[uxbox.db :as db]
|
||||
;; [uxbox.images :as images]
|
||||
;; [uxbox.media :as media]
|
||||
[uxbox.services.mutations :as sm]
|
||||
;; [uxbox.services.mutations.images :as imgs]
|
||||
[uxbox.services.mutations.projects :as proj]
|
||||
[uxbox.services.queries.files :as files]
|
||||
[uxbox.tasks :as tasks]
|
||||
|
@ -152,136 +149,3 @@
|
|||
{:id id})
|
||||
nil)
|
||||
|
||||
|
||||
;; ;; --- Mutations: Create File Image (Upload and create from url)
|
||||
;;
|
||||
;; (declare create-file-image)
|
||||
;;
|
||||
;; (s/def ::file-id ::us/uuid)
|
||||
;; (s/def ::image-id ::us/uuid)
|
||||
;; (s/def ::content ::imgs/upload)
|
||||
;;
|
||||
;; (s/def ::add-file-image-from-url
|
||||
;; (s/keys :req-un [::profile-id ::file-id ::url]
|
||||
;; :opt-un [::id]))
|
||||
;;
|
||||
;; (s/def ::upload-file-image
|
||||
;; (s/keys :req-un [::profile-id ::file-id ::name ::content]
|
||||
;; :opt-un [::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::add-file-image-from-url
|
||||
;; [{:keys [profile-id file-id url] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (files/check-edition-permissions! conn profile-id file-id)
|
||||
;; (let [content (images/download-image url)
|
||||
;; params' (merge params {:content content
|
||||
;; :name (:filename content)})]
|
||||
;; (create-file-image conn params'))))
|
||||
;;
|
||||
;; (sm/defmutation ::upload-file-image
|
||||
;; [{:keys [profile-id file-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (files/check-edition-permissions! conn profile-id file-id)
|
||||
;; (create-file-image conn params)))
|
||||
;;
|
||||
;; (defn- create-file-image
|
||||
;; [conn {:keys [content file-id name] :as params}]
|
||||
;; (when-not (imgs/valid-image-types? (:content-type content))
|
||||
;; (ex/raise :type :validation
|
||||
;; :code :media-type-not-allowed
|
||||
;; :hint "Seems like you are uploading an invalid image."))
|
||||
;;
|
||||
;; (let [info (images/run {:cmd :info :input {:path (:tempfile content)
|
||||
;; :mtype (:content-type content)}})
|
||||
;; path (imgs/persist-image-on-fs content)
|
||||
;; opts (assoc imgs/thumbnail-options
|
||||
;; :input {:mtype (:mtype info)
|
||||
;; :path path})
|
||||
;; thumb (if-not (= (:mtype info) "image/svg+xml")
|
||||
;; (imgs/persist-image-thumbnail-on-fs opts)
|
||||
;; (assoc info
|
||||
;; :path path
|
||||
;; :quality 0))]
|
||||
;;
|
||||
;; (-> (db/insert! conn :file-image
|
||||
;; {:file-id file-id
|
||||
;; :name name
|
||||
;; :path (str path)
|
||||
;; :width (:width info)
|
||||
;; :height (:height info)
|
||||
;; :mtype (:mtype info)
|
||||
;; :thumb-path (str (:path thumb))
|
||||
;; :thumb-width (:width thumb)
|
||||
;; :thumb-height (:height thumb)
|
||||
;; :thumb-quality (:quality thumb)
|
||||
;; :thumb-mtype (:mtype thumb)})
|
||||
;; (images/resolve-urls :path :uri)
|
||||
;; (images/resolve-urls :thumb-path :thumb-uri))))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Delete File Image
|
||||
;;
|
||||
;; (declare mark-file-image-deleted)
|
||||
;;
|
||||
;; (s/def ::delete-file-image
|
||||
;; (s/keys :req-un [::file-id ::image-id ::profile-id]))
|
||||
;;
|
||||
;; (sm/defmutation ::delete-file-image
|
||||
;; [{:keys [file-id image-id profile-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (files/check-edition-permissions! conn profile-id file-id)
|
||||
;;
|
||||
;; ;; Schedule object deletion
|
||||
;; (tasks/submit! conn {:name "delete-object"
|
||||
;; :delay cfg/default-deletion-delay
|
||||
;; :props {:id image-id :type :file-image}})
|
||||
;;
|
||||
;; (mark-file-image-deleted conn params)))
|
||||
;;
|
||||
;; (defn mark-file-image-deleted
|
||||
;; [conn {:keys [image-id] :as params}]
|
||||
;; (db/update! conn :file-image
|
||||
;; {:deleted-at (dt/now)}
|
||||
;; {:id image-id})
|
||||
;; nil)
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Import from collection
|
||||
;;
|
||||
;; (declare copy-image)
|
||||
;; (declare import-image-to-file)
|
||||
;;
|
||||
;; (s/def ::import-image-to-file
|
||||
;; (s/keys :req-un [::image-id ::file-id ::profile-id]))
|
||||
;;
|
||||
;; (sm/defmutation ::import-image-to-file
|
||||
;; [{:keys [image-id file-id profile-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (files/check-edition-permissions! conn profile-id file-id)
|
||||
;; (import-image-to-file conn params)))
|
||||
;;
|
||||
;; (defn- import-image-to-file
|
||||
;; [conn {:keys [image-id file-id] :as params}]
|
||||
;; (let [image (db/get-by-id conn :image image-id)
|
||||
;; image-path (copy-image (:path image))
|
||||
;; thumb-path (copy-image (:thumb-path image))]
|
||||
;;
|
||||
;; (-> (db/insert! conn :file-image
|
||||
;; {:file-id file-id
|
||||
;; :name (:name image)
|
||||
;; :path (str image-path)
|
||||
;; :width (:width image)
|
||||
;; :height (:height image)
|
||||
;; :mtype (:mtype image)
|
||||
;; :thumb-path (str thumb-path)
|
||||
;; :thumb-width (:thumb-width image)
|
||||
;; :thumb-height (:thumb-height image)
|
||||
;; :thumb-quality (:thumb-quality image)
|
||||
;; :thumb-mtype (:thumb-mtype image)})
|
||||
;; (images/resolve-urls :path :uri)
|
||||
;; (images/resolve-urls :thumb-path :thumb-uri))))
|
||||
;;
|
||||
;; (defn- copy-image
|
||||
;; [path]
|
||||
;; (let [image-path (ust/lookup media/media-storage path)]
|
||||
;; (ust/save! media/media-storage (fs/name image-path) image-path)))
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
;; (ns uxbox.services.mutations.icons
|
||||
;; (:require
|
||||
;; [clojure.spec.alpha :as s]
|
||||
;; [uxbox.common.exceptions :as ex]
|
||||
;; [uxbox.common.spec :as us]
|
||||
;; [uxbox.common.uuid :as uuid]
|
||||
;; [uxbox.config :as cfg]
|
||||
;; [uxbox.db :as db]
|
||||
;; [uxbox.services.mutations :as sm]
|
||||
;; [uxbox.services.queries.icons :refer [decode-row]]
|
||||
;; [uxbox.services.queries.teams :as teams]
|
||||
;; [uxbox.tasks :as tasks]
|
||||
;; [uxbox.util.blob :as blob]
|
||||
;; [uxbox.util.time :as dt]))
|
||||
;;
|
||||
;; ;; --- Helpers & Specs
|
||||
;;
|
||||
;; (s/def ::height ::us/integer)
|
||||
;; (s/def ::id ::us/uuid)
|
||||
;; (s/def ::library-id ::us/uuid)
|
||||
;; (s/def ::name ::us/string)
|
||||
;; (s/def ::profile-id ::us/uuid)
|
||||
;; (s/def ::team-id ::us/uuid)
|
||||
;; (s/def ::width ::us/integer)
|
||||
;;
|
||||
;; (s/def ::view-box
|
||||
;; (s/and (s/coll-of number?)
|
||||
;; #(= 4 (count %))
|
||||
;; vector?))
|
||||
;;
|
||||
;; (s/def ::content ::us/string)
|
||||
;; (s/def ::mimetype ::us/string)
|
||||
;;
|
||||
;; (s/def ::metadata
|
||||
;; (s/keys :opt-un [::width ::height ::view-box ::mimetype]))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Create Library
|
||||
;;
|
||||
;; (declare create-library)
|
||||
;;
|
||||
;; (s/def ::create-icon-library
|
||||
;; (s/keys :req-un [::profile-id ::team-id ::name]
|
||||
;; :opt-un [::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::create-icon-library
|
||||
;; [{:keys [profile-id team-id id name] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (teams/check-edition-permissions! conn profile-id team-id)
|
||||
;; (create-library conn params)))
|
||||
;;
|
||||
;; (def ^:private sql:create-library
|
||||
;; "insert into icon_library (id, team_id, name)
|
||||
;; values ($1, $2, $3)
|
||||
;; returning *;")
|
||||
;;
|
||||
;; (defn create-library
|
||||
;; [conn {:keys [team-id id name] :as params}]
|
||||
;; (let [id (or id (uuid/next))]
|
||||
;; (db/insert! conn :icon-library
|
||||
;; {:id id
|
||||
;; :team-id team-id
|
||||
;; :name name})))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Rename Library
|
||||
;;
|
||||
;; (declare select-library-for-update)
|
||||
;; (declare rename-library)
|
||||
;;
|
||||
;; (s/def ::rename-icon-library
|
||||
;; (s/keys :req-un [::profile-id ::name ::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::rename-icon-library
|
||||
;; [{:keys [id profile-id name] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-library-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;; (rename-library conn id name))))
|
||||
;;
|
||||
;; (defn- select-library-for-update
|
||||
;; [conn id]
|
||||
;; (db/get-by-id conn :icon-library id {:for-update true}))
|
||||
;;
|
||||
;; (defn- rename-library
|
||||
;; [conn id name]
|
||||
;; (db/update! conn :icon-library
|
||||
;; {:name name}
|
||||
;; {:id id}))
|
||||
;;
|
||||
;; ;; --- Mutation: Delete Library
|
||||
;;
|
||||
;; (declare delete-library)
|
||||
;;
|
||||
;; (s/def ::delete-icon-library
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::delete-icon-library
|
||||
;; [{:keys [profile-id id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-library-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;;
|
||||
;; ;; Schedule object deletion
|
||||
;; (tasks/submit! conn {:name "delete-object"
|
||||
;; :delay cfg/default-deletion-delay
|
||||
;; :props {:id id :type :icon-library}})
|
||||
;;
|
||||
;; (db/update! conn :icon-library
|
||||
;; {:deleted-at (dt/now)}
|
||||
;; {:id id})
|
||||
;; nil)))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Create Icon (Upload)
|
||||
;;
|
||||
;; (declare create-icon)
|
||||
;;
|
||||
;; (s/def ::create-icon
|
||||
;; (s/keys :req-un [::profile-id ::name ::metadata ::content ::library-id]
|
||||
;; :opt-un [::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::create-icon
|
||||
;; [{:keys [profile-id library-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-library-for-update conn library-id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;; (create-icon conn params))))
|
||||
;;
|
||||
;; (defn create-icon
|
||||
;; [conn {:keys [id name library-id metadata content]}]
|
||||
;; (let [id (or id (uuid/next))]
|
||||
;; (-> (db/insert! conn :icon
|
||||
;; {:id id
|
||||
;; :name name
|
||||
;; :library-id library-id
|
||||
;; :content content
|
||||
;; :metadata (blob/encode metadata)})
|
||||
;; (decode-row))))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Rename Icon
|
||||
;;
|
||||
;; (declare select-icon-for-update)
|
||||
;; (declare rename-icon)
|
||||
;;
|
||||
;; (s/def ::rename-icon
|
||||
;; (s/keys :req-un [::id ::profile-id ::name]))
|
||||
;;
|
||||
;; (sm/defmutation ::rename-icon
|
||||
;; [{:keys [id profile-id name] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [icon (select-icon-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id icon))
|
||||
;; (db/update! conn :icon
|
||||
;; {:name name}
|
||||
;; {:id id}))))
|
||||
;;
|
||||
;; (def ^:private
|
||||
;; sql:select-icon-for-update
|
||||
;; "select i.*,
|
||||
;; lib.team_id as team_id
|
||||
;; from icon as i
|
||||
;; inner join icon_library as lib on (lib.id = i.library_id)
|
||||
;; where i.id = ?
|
||||
;; for update")
|
||||
;;
|
||||
;; (defn- select-icon-for-update
|
||||
;; [conn id]
|
||||
;; (let [row (db/exec-one! conn [sql:select-icon-for-update id])]
|
||||
;; (when-not row
|
||||
;; (ex/raise :type :not-found))
|
||||
;; row))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Mutation: Delete Icon
|
||||
;;
|
||||
;; (declare delete-icon)
|
||||
;;
|
||||
;; (s/def ::delete-icon
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::delete-icon
|
||||
;; [{:keys [id profile-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [icn (select-icon-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id icn))
|
||||
;;
|
||||
;; ;; Schedule object deletion
|
||||
;; (tasks/submit! conn {:name "delete-object"
|
||||
;; :delay cfg/default-deletion-delay
|
||||
;; :props {:id id :type :icon}})
|
||||
;;
|
||||
;; (db/update! conn :icon
|
||||
;; {:deleted-at (dt/now)}
|
||||
;; {:id id})
|
||||
;; nil)))
|
|
@ -37,67 +37,6 @@
|
|||
(s/def ::team-id ::us/uuid)
|
||||
(s/def ::url ::us/url)
|
||||
|
||||
;; ;; --- Create Library
|
||||
;;
|
||||
;; (declare create-library)
|
||||
;;
|
||||
;; (s/def ::create-media-object-library
|
||||
;; (s/keys :req-un [::profile-id ::team-id ::name]
|
||||
;; :opt-un [::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::create-media-object-library
|
||||
;; [{:keys [profile-id team-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (teams/check-edition-permissions! conn profile-id team-id)
|
||||
;; (create-library conn params)))
|
||||
;;
|
||||
;; (defn create-library
|
||||
;; [conn {:keys [id team-id name]}]
|
||||
;; (let [id (or id (uuid/next))]
|
||||
;; (db/insert! conn :media-object-library
|
||||
;; {:id id
|
||||
;; :team-id team-id
|
||||
;; :name name})))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Rename Library
|
||||
;;
|
||||
;; (s/def ::rename-media-object-library
|
||||
;; (s/keys :req-un [::id ::profile-id ::name]))
|
||||
;;
|
||||
;; (sm/defmutation ::rename-media-object-library
|
||||
;; [{:keys [profile-id id name] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-file-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;; (db/update! conn :media-object-library
|
||||
;; {:name name}
|
||||
;; {:id id}))))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Delete Library
|
||||
;;
|
||||
;; (declare delete-library)
|
||||
;;
|
||||
;; (s/def ::delete-media-object-library
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sm/defmutation ::delete-media-object-library
|
||||
;; [{:keys [id profile-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (select-file-for-update conn id)]
|
||||
;; (teams/check-edition-permissions! conn profile-id (:team-id lib))
|
||||
;;
|
||||
;; ;; Schedule object deletion
|
||||
;; (tasks/submit! conn {:name "delete-object"
|
||||
;; :delay cfg/default-deletion-delay
|
||||
;; :props {:id id :type :media-object-library}})
|
||||
;;
|
||||
;; (db/update! conn :media-object-library
|
||||
;; {:deleted-at (dt/now)}
|
||||
;; {:id id})
|
||||
;; nil)))
|
||||
|
||||
|
||||
;; --- Create Media object (Upload and create from url)
|
||||
|
||||
|
|
|
@ -27,55 +27,7 @@
|
|||
(s/def ::profile-id ::us/uuid)
|
||||
(s/def ::team-id ::us/uuid)
|
||||
(s/def ::file-id ::us/uuid)
|
||||
;; (s/def ::library-id (s/nilable ::us/uuid))
|
||||
|
||||
;; ;; --- Query: Colors Libraries
|
||||
;;
|
||||
;; (def ^:private sql:libraries
|
||||
;; "select lib.*,
|
||||
;; (select count(*) from color where library_id = lib.id) as num_colors
|
||||
;; from color_library as lib
|
||||
;; where lib.team_id = ?
|
||||
;; and lib.deleted_at is null
|
||||
;; order by lib.created_at desc")
|
||||
;;
|
||||
;; (s/def ::color-libraries
|
||||
;; (s/keys :req-un [::profile-id ::team-id]))
|
||||
;;
|
||||
;; (sq/defquery ::color-libraries
|
||||
;; [{:keys [profile-id team-id]}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (teams/check-read-permissions! conn profile-id team-id)
|
||||
;; (db/exec! conn [sql:libraries team-id])))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Query: Color Library
|
||||
;;
|
||||
;; (declare retrieve-library)
|
||||
;;
|
||||
;; (s/def ::color-library
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sq/defquery ::color-library
|
||||
;; [{:keys [profile-id id]}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (retrieve-library conn id)]
|
||||
;; (teams/check-read-permissions! conn profile-id (:team-id lib))
|
||||
;; lib)))
|
||||
;;
|
||||
;; (def ^:private sql:single-library
|
||||
;; "select lib.*,
|
||||
;; (select count(*) from color where library_id = lib.id) as num_colors
|
||||
;; from color_library as lib
|
||||
;; where lib.deleted_at is null
|
||||
;; and lib.id = ?")
|
||||
;;
|
||||
;; (defn- retrieve-library
|
||||
;; [conn id]
|
||||
;; (let [row (db/exec-one! conn [sql:single-library id])]
|
||||
;; (when-not row
|
||||
;; (ex/raise :type :not-found))
|
||||
;; row))
|
||||
|
||||
;; --- Query: Colors (by file)
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@
|
|||
(->> (db/exec! db/pool [sql:shared-files])
|
||||
(mapv decode-row)))
|
||||
|
||||
|
||||
;; --- Query: File Permissions
|
||||
|
||||
(def ^:private sql:file-permissions
|
||||
|
@ -220,32 +221,6 @@
|
|||
(ex/raise :type :validation
|
||||
:code :not-authorized))))
|
||||
|
||||
;; ;; --- Query: Images of the File
|
||||
;;
|
||||
;; (declare retrieve-file-images)
|
||||
;;
|
||||
;; (s/def ::file-images
|
||||
;; (s/keys :req-un [::profile-id ::file-id]))
|
||||
;;
|
||||
;; (sq/defquery ::file-images
|
||||
;; [{:keys [profile-id file-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (check-edition-permissions! conn profile-id file-id)
|
||||
;; (retrieve-file-images conn params)))
|
||||
;;
|
||||
;; (def ^:private sql:file-images
|
||||
;; "select fi.*
|
||||
;; from file_image as fi
|
||||
;; where fi.file_id = ?
|
||||
;; and fi.deleted_at is null")
|
||||
;;
|
||||
;; (defn retrieve-file-images
|
||||
;; [conn {:keys [file-id] :as params}]
|
||||
;; (let [sqlv [sql:file-images file-id]
|
||||
;; xf (comp (map #(media/resolve-urls % :path :uri))
|
||||
;; (map #(media/resolve-urls % :thumb-path :thumb-uri)))]
|
||||
;; (->> (db/exec! conn sqlv)
|
||||
;; (into [] xf))))
|
||||
|
||||
;; --- Query: File (By ID)
|
||||
|
||||
|
@ -304,6 +279,7 @@
|
|||
(check-edition-permissions! conn profile-id id)
|
||||
(retrieve-file conn id)))
|
||||
|
||||
|
||||
;; --- Helpers
|
||||
|
||||
(defn decode-row
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
;; ;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; ;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; ;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;; ;;
|
||||
;; ;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; ;; defined by the Mozilla Public License, v. 2.0.
|
||||
;; ;;
|
||||
;; ;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
|
||||
;;
|
||||
;; (ns uxbox.services.queries.icons
|
||||
;; (:require
|
||||
;; [clojure.spec.alpha :as s]
|
||||
;; [uxbox.common.exceptions :as ex]
|
||||
;; [uxbox.common.spec :as us]
|
||||
;; [uxbox.common.uuid :as uuid]
|
||||
;; [uxbox.db :as db]
|
||||
;; [uxbox.images :as images]
|
||||
;; [uxbox.media :as media]
|
||||
;; [uxbox.services.queries :as sq]
|
||||
;; [uxbox.services.queries.teams :as teams]
|
||||
;; [uxbox.util.blob :as blob]
|
||||
;; [uxbox.util.data :as data]))
|
||||
;;
|
||||
;; ;; --- Helpers & Specs
|
||||
;;
|
||||
;; (s/def ::id ::us/uuid)
|
||||
;; (s/def ::name ::us/string)
|
||||
;; (s/def ::profile-id ::us/uuid)
|
||||
;; (s/def ::library-id ::us/uuid)
|
||||
;; (s/def ::team-id ::us/uuid)
|
||||
;;
|
||||
;; (defn decode-row
|
||||
;; [{:keys [metadata] :as row}]
|
||||
;; (when row
|
||||
;; (cond-> row
|
||||
;; metadata (assoc :metadata (blob/decode metadata)))))
|
||||
;;
|
||||
;; ;; --- Query: Icons Librarys
|
||||
;;
|
||||
;; (def ^:private sql:libraries
|
||||
;; "select lib.*,
|
||||
;; (select count(*) from icon where library_id = lib.id) as num_icons
|
||||
;; from icon_library as lib
|
||||
;; where lib.team_id = ?
|
||||
;; and lib.deleted_at is null
|
||||
;; order by lib.created_at desc")
|
||||
;;
|
||||
;; (s/def ::icon-libraries
|
||||
;; (s/keys :req-un [::profile-id ::team-id]))
|
||||
;;
|
||||
;; (sq/defquery ::icon-libraries
|
||||
;; [{:keys [profile-id team-id]}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (teams/check-read-permissions! conn profile-id team-id)
|
||||
;; (db/exec! conn [sql:libraries team-id])))
|
||||
;;
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Query: Icon Library
|
||||
;;
|
||||
;; (declare retrieve-library)
|
||||
;;
|
||||
;; (s/def ::icon-library
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sq/defquery ::icon-library
|
||||
;; [{:keys [profile-id id]}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (retrieve-library conn id)]
|
||||
;; (teams/check-read-permissions! conn profile-id (:team-id lib))
|
||||
;; lib)))
|
||||
;;
|
||||
;; (def ^:private sql:single-library
|
||||
;; "select lib.*,
|
||||
;; (select count(*) from icon where library_id = lib.id) as num_icons
|
||||
;; from icon_library as lib
|
||||
;; where lib.deleted_at is null
|
||||
;; and lib.id = ?")
|
||||
;;
|
||||
;; (defn- retrieve-library
|
||||
;; [conn id]
|
||||
;; (let [row (db/exec-one! conn [sql:single-library id])]
|
||||
;; (when-not row
|
||||
;; (ex/raise :type :not-found))
|
||||
;; row))
|
||||
;;
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Query: Icons (by library)
|
||||
;;
|
||||
;; (declare retrieve-icons)
|
||||
;;
|
||||
;; (s/def ::icons
|
||||
;; (s/keys :req-un [::profile-id ::library-id]))
|
||||
;;
|
||||
;; (sq/defquery ::icons
|
||||
;; [{:keys [profile-id library-id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (retrieve-library conn library-id)]
|
||||
;; (teams/check-read-permissions! conn profile-id (:team-id lib))
|
||||
;; (->> (retrieve-icons conn library-id)
|
||||
;; (mapv decode-row)))))
|
||||
;;
|
||||
;; (def ^:private sql:icons
|
||||
;; "select icon.*
|
||||
;; from icon as icon
|
||||
;; inner join icon_library as lib on (lib.id = icon.library_id)
|
||||
;; where icon.deleted_at is null
|
||||
;; and icon.library_id = ?
|
||||
;; order by created_at desc")
|
||||
;;
|
||||
;; (defn- retrieve-icons
|
||||
;; [conn library-id]
|
||||
;; (db/exec! conn [sql:icons library-id]))
|
||||
;;
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Query: Icon (by ID)
|
||||
;;
|
||||
;; (declare retrieve-icon)
|
||||
;;
|
||||
;; (s/def ::id ::us/uuid)
|
||||
;; (s/def ::icon
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sq/defquery ::icon
|
||||
;; [{:keys [profile-id id] :as params}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [icon (retrieve-icon conn id)]
|
||||
;; (teams/check-read-permissions! conn profile-id (:team-id icon))
|
||||
;; (decode-row icon))))
|
||||
;;
|
||||
;; (def ^:private sql:single-icon
|
||||
;; "select icon.*,
|
||||
;; lib.team_id as team_id
|
||||
;; from icon as icon
|
||||
;; inner join icon_library as lib on (lib.id = icon.library_id)
|
||||
;; where icon.deleted_at is null
|
||||
;; and icon.id = ?
|
||||
;; order by created_at desc")
|
||||
;;
|
||||
;; (defn retrieve-icon
|
||||
;; [conn id]
|
||||
;; (let [row (db/exec-one! conn [sql:single-icon id])]
|
||||
;; (when-not row
|
||||
;; (ex/raise :type :not-found))
|
||||
;; row))
|
||||
;;
|
|
@ -23,54 +23,6 @@
|
|||
(s/def ::team-id ::us/uuid)
|
||||
(s/def ::file-id ::us/uuid)
|
||||
|
||||
;; ;; --- Query: Media Libraries
|
||||
;;
|
||||
;; (def ^:private sql:libraries
|
||||
;; "select lib.*,
|
||||
;; (select count(*) from media where library_id = lib.id) as num_media
|
||||
;; from media_library as lib
|
||||
;; where lib.team_id = ?
|
||||
;; and lib.deleted_at is null
|
||||
;; order by lib.created_at desc")
|
||||
;;
|
||||
;; (s/def ::media-libraries
|
||||
;; (s/keys :req-un [::profile-id ::team-id]))
|
||||
;;
|
||||
;; (sq/defquery ::media-libraries
|
||||
;; [{:keys [profile-id team-id]}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (teams/check-read-permissions! conn profile-id team-id)
|
||||
;; (db/exec! conn [sql:libraries team-id])))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Query: Media Library
|
||||
;;
|
||||
;; (declare retrieve-library)
|
||||
;;
|
||||
;; (s/def ::media-library
|
||||
;; (s/keys :req-un [::profile-id ::id]))
|
||||
;;
|
||||
;; (sq/defquery ::media-library
|
||||
;; [{:keys [profile-id id]}]
|
||||
;; (db/with-atomic [conn db/pool]
|
||||
;; (let [lib (retrieve-library conn id)]
|
||||
;; (teams/check-read-permissions! conn profile-id (:team-id lib))
|
||||
;; lib)))
|
||||
;;
|
||||
;; (def ^:private sql:single-library
|
||||
;; "select lib.*,
|
||||
;; (select count(*) from media where library_id = lib.id) as num_media
|
||||
;; from media_library as lib
|
||||
;; where lib.deleted_at is null
|
||||
;; and lib.id = ?")
|
||||
;;
|
||||
;; (defn- retrieve-library
|
||||
;; [conn id]
|
||||
;; (let [row (db/exec-one! conn [sql:single-library id])]
|
||||
;; (when-not row
|
||||
;; (ex/raise :type :not-found))
|
||||
;; row))
|
||||
|
||||
|
||||
;; --- Query: Media objects (by file)
|
||||
|
||||
|
|
|
@ -120,23 +120,6 @@
|
|||
:ordering i
|
||||
:data cp/default-page-data}))
|
||||
|
||||
;; (defn create-image-library
|
||||
;; [conn team-id i]
|
||||
;; (#'images/create-library conn {:id (mk-uuid "imgcoll" i)
|
||||
;; :team-id team-id
|
||||
;; :name (str "image library " i)}))
|
||||
;;
|
||||
;; (defn create-icon-library
|
||||
;; [conn team-id i]
|
||||
;; (#'icons/create-library conn {:id (mk-uuid "imgcoll" i)
|
||||
;; :team-id team-id
|
||||
;; :name (str "icon library " i)}))
|
||||
;; (defn create-color-library
|
||||
;; [conn team-id i]
|
||||
;; (#'colors/create-library conn {:id (mk-uuid "imgcoll" i)
|
||||
;; :team-id team-id
|
||||
;; :name (str "color library " i)}))
|
||||
|
||||
(defn handle-error
|
||||
[^Throwable err]
|
||||
(if (instance? java.util.concurrent.ExecutionException err)
|
||||
|
|
|
@ -22,65 +22,6 @@
|
|||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
;; (t/deftest color-libraries-crud
|
||||
;; (let [id (uuid/next)
|
||||
;; prof (th/create-profile db/pool 2)
|
||||
;; team-id (:default-team-id prof)
|
||||
;; proj (th/create-project db/pool (:id prof) team-id 2)]
|
||||
;;
|
||||
;; (t/testing "create library file"
|
||||
;; (let [data {::sm/type :create-file
|
||||
;; :profile-id (:id prof)
|
||||
;; :name "sample library"
|
||||
;; :project-id (:id proj)
|
||||
;; :id id
|
||||
;; :is-shared true}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= id (:id result)))
|
||||
;; (t/is (= (:id proj) (:project-id result)))
|
||||
;; (t/is (= (:name data) (:name result))))))
|
||||
;;
|
||||
;; (t/testing "update library file"
|
||||
;; (let [data {::sm/type :rename-color-library
|
||||
;; :name "renamed"
|
||||
;; :profile-id (:id prof)
|
||||
;; :id id}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= "renamed" (get-in result [:name]))))))
|
||||
;;
|
||||
;; (t/testing "delete library"
|
||||
;; (let [data {::sm/type :delete-color-library
|
||||
;; :profile-id (:id prof)
|
||||
;; :id id}
|
||||
;;
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;; (t/is (nil? (:result out)))))
|
||||
;;
|
||||
;; (t/testing "query libraries after delete"
|
||||
;; (let [data {::sq/type :color-libraries
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= 0 (count result))))))
|
||||
;; ))
|
||||
|
||||
(t/deftest colors-crud
|
||||
(let [prof (th/create-profile db/pool 1)
|
||||
team-id (:default-team-id prof)
|
||||
|
@ -88,7 +29,7 @@
|
|||
file (th/create-file db/pool (:id prof) (:id proj) true 1)
|
||||
color-id (uuid/next)]
|
||||
|
||||
(t/testing "upload color to library"
|
||||
(t/testing "upload color to library file"
|
||||
(let [data {::sm/type :create-color
|
||||
:id color-id
|
||||
:profile-id (:id prof)
|
||||
|
|
|
@ -129,105 +129,4 @@
|
|||
(t/is (= 0 (count result))))))
|
||||
))
|
||||
|
||||
;; (t/deftest file-images-crud
|
||||
;; (let [prof (th/create-profile db/pool 1)
|
||||
;; team-id (:default-team-id prof)
|
||||
;; proj-id (:default-project-id prof)
|
||||
;; file (th/create-file db/pool (:id prof) proj-id 1)]
|
||||
;;
|
||||
;; (t/testing "create file image from url"
|
||||
;; (let [url "https://raw.githubusercontent.com/uxbox/uxbox/develop/frontend/resources/images/penpot-login.jpg"
|
||||
;; data {::sm/type :add-file-image-from-url
|
||||
;; :profile-id (:id prof)
|
||||
;; :file-id (:id file)
|
||||
;; :url url}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= (:id file) (:file-id result)))
|
||||
;; (t/is (not (nil? (:name result))))
|
||||
;; (t/is (= 787 (:width result)))
|
||||
;; (t/is (= 2000 (:height result)))
|
||||
;; (t/is (= "image/jpeg" (:mtype result)))
|
||||
;;
|
||||
;; (t/is (string? (:path result)))
|
||||
;; (t/is (string? (:uri result)))
|
||||
;; (t/is (string? (:thumb-path result)))
|
||||
;; (t/is (string? (:thumb-uri result))))))
|
||||
;;
|
||||
;; (t/testing "upload file image"
|
||||
;; (let [content {:filename "sample.jpg"
|
||||
;; :tempfile (th/tempfile "uxbox/tests/_files/sample.jpg")
|
||||
;; :content-type "image/jpeg"
|
||||
;; :size 312043}
|
||||
;; data {::sm/type :upload-file-image
|
||||
;; :profile-id (:id prof)
|
||||
;; :file-id (:id file)
|
||||
;; :name "testfile"
|
||||
;; :content content}
|
||||
;;
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= (:id file) (:file-id result)))
|
||||
;; (t/is (= (:name data) (:name result)))
|
||||
;; (t/is (= 800 (:width result)))
|
||||
;; (t/is (= 800 (:height result)))
|
||||
;; (t/is (= (:content-type content) (:mtype result)))
|
||||
;;
|
||||
;; (t/is (string? (:path result)))
|
||||
;; (t/is (string? (:uri result)))
|
||||
;; (t/is (string? (:thumb-path result)))
|
||||
;; (t/is (string? (:thumb-uri result))))))
|
||||
;;
|
||||
;; ;; (t/testing "import from library"
|
||||
;; ;; (let [lib (th/create-image-library db/pool team-id 1)
|
||||
;; ;; image-id (uuid/next)
|
||||
;; ;;
|
||||
;; ;; content {:filename "sample.jpg"
|
||||
;; ;; :tempfile (th/tempfile "uxbox/tests/_files/sample.jpg")
|
||||
;; ;; :content-type "image/jpeg"
|
||||
;; ;; :size 312043}
|
||||
;; ;;
|
||||
;; ;; data {::sm/type :upload-image
|
||||
;; ;; :id image-id
|
||||
;; ;; :profile-id (:id prof)
|
||||
;; ;; :library-id (:id lib)
|
||||
;; ;; :name "testfile"
|
||||
;; ;; :content content}
|
||||
;; ;; out1 (th/try-on! (sm/handle data))]
|
||||
;; ;;
|
||||
;; ;; ;; (th/print-result! out1)
|
||||
;; ;; (t/is (nil? (:error out1)))
|
||||
;; ;;
|
||||
;; ;; (let [result (:result out1)]
|
||||
;; ;; (t/is (= image-id (:id result)))
|
||||
;; ;; (t/is (= "testfile" (:name result)))
|
||||
;; ;; (t/is (= "image/jpeg" (:mtype result)))
|
||||
;; ;; (t/is (= "image/jpeg" (:thumb-mtype result))))
|
||||
;; ;;
|
||||
;; ;; (let [data2 {::sm/type :import-image-to-file
|
||||
;; ;; :image-id image-id
|
||||
;; ;; :file-id (:id file)
|
||||
;; ;; :profile-id (:id prof)}
|
||||
;; ;; out2 (th/try-on! (sm/handle data2))]
|
||||
;; ;;
|
||||
;; ;; ;; (th/print-result! out2)
|
||||
;; ;; (t/is (nil? (:error out2)))
|
||||
;; ;;
|
||||
;; ;; (let [result1 (:result out1)
|
||||
;; ;; result2 (:result out2)]
|
||||
;; ;; (t/is (not= (:path result2)
|
||||
;; ;; (:path result1)))
|
||||
;; ;; (t/is (not= (:thumb-path result2)
|
||||
;; ;; (:thumb-path result1)))))))
|
||||
;; ))
|
||||
|
||||
|
||||
;; TODO: delete file image
|
||||
|
|
|
@ -1,180 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
(ns uxbox.tests.test-services-icons
|
||||
(:require
|
||||
[clojure.java.io :as io]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]
|
||||
[uxbox.common.uuid :as uuid]
|
||||
[uxbox.db :as db]
|
||||
[uxbox.services.mutations :as sm]
|
||||
[uxbox.services.queries :as sq]
|
||||
[uxbox.tests.helpers :as th]
|
||||
[uxbox.util.storage :as ust]))
|
||||
|
||||
;; (t/use-fixtures :once th/state-init)
|
||||
;; (t/use-fixtures :each th/database-reset)
|
||||
;;
|
||||
;; (t/deftest icon-libraries-crud
|
||||
;; (let [id (uuid/next)
|
||||
;; prof (th/create-profile db/pool 2)
|
||||
;; team-id (:default-team-id prof)]
|
||||
;;
|
||||
;; (t/testing "create library"
|
||||
;; (let [data {::sm/type :create-icon-library
|
||||
;; :name "sample library"
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id
|
||||
;; :id id}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= id (:id result)))
|
||||
;; (t/is (= team-id (:team-id result)))
|
||||
;; (t/is (= (:name data) (:name result))))))
|
||||
;;
|
||||
;; (t/testing "rename library"
|
||||
;; (let [data {::sm/type :rename-icon-library
|
||||
;; :name "renamed"
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id
|
||||
;; :id id}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= id (:id result)))
|
||||
;; (t/is (= "renamed" (:name result))))))
|
||||
;;
|
||||
;; (t/testing "query libraries"
|
||||
;; (let [data {::sq/type :icon-libraries
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= 1 (count result)))
|
||||
;; (t/is (= id (get-in result [0 :id])))
|
||||
;; (t/is (= "renamed" (get-in result [0 :name]))))))
|
||||
;;
|
||||
;; (t/testing "delete library"
|
||||
;; (let [data {::sm/type :delete-icon-library
|
||||
;; :profile-id (:id prof)
|
||||
;; :id id}
|
||||
;;
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;; (t/is (nil? (:result out)))))
|
||||
;;
|
||||
;; (t/testing "query libraries after delete"
|
||||
;; (let [data {::sq/type :icon-libraries
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= 0 (count result))))))
|
||||
;; ))
|
||||
;;
|
||||
;; (t/deftest icons-crud
|
||||
;; (let [prof (th/create-profile db/pool 1)
|
||||
;; team-id (:default-team-id prof)
|
||||
;; coll (th/create-icon-library db/pool team-id 1)
|
||||
;; icon-id (uuid/next)]
|
||||
;;
|
||||
;; (t/testing "upload icon to library"
|
||||
;; (let [data {::sm/type :create-icon
|
||||
;; :id icon-id
|
||||
;; :profile-id (:id prof)
|
||||
;; :library-id (:id coll)
|
||||
;; :name "testfile"
|
||||
;; :content "<rect></rect>"
|
||||
;; :metadata {:width 100
|
||||
;; :height 100
|
||||
;; :view-box [0 0 100 100]
|
||||
;; :mimetype "text/svg"}}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= (:id data) (:id result)))
|
||||
;; (t/is (= (:name data) (:name result)))
|
||||
;; (t/is (= (:content data) (:content result))))))
|
||||
;;
|
||||
;; (t/testing "list icons by library"
|
||||
;; (let [data {::sq/type :icons
|
||||
;; :profile-id (:id prof)
|
||||
;; :library-id (:id coll)}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;; ;; (th/print-result! out)
|
||||
;;
|
||||
;; (t/is (= icon-id (get-in out [:result 0 :id])))
|
||||
;; (t/is (= "testfile" (get-in out [:result 0 :name])))))
|
||||
;;
|
||||
;; (t/testing "single icon"
|
||||
;; (let [data {::sq/type :icon
|
||||
;; :profile-id (:id prof)
|
||||
;; :id icon-id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;; ;; (th/print-result! out)
|
||||
;;
|
||||
;; (t/is (= icon-id (get-in out [:result :id])))
|
||||
;; (t/is (= "testfile" (get-in out [:result :name])))))
|
||||
;;
|
||||
;; (t/testing "delete icons"
|
||||
;; (let [data {::sm/type :delete-icon
|
||||
;; :profile-id (:id prof)
|
||||
;; :id icon-id}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;; (t/is (nil? (:result out)))))
|
||||
;;
|
||||
;; (t/testing "query icon after delete"
|
||||
;; (let [data {::sq/type :icon
|
||||
;; :profile-id (:id prof)
|
||||
;; :id icon-id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (let [error (:error out)]
|
||||
;; (t/is (th/ex-info? error))
|
||||
;; (t/is (th/ex-of-type? error :service-error)))
|
||||
;;
|
||||
;; (let [error (ex-cause (:error out))]
|
||||
;; (t/is (th/ex-info? error))
|
||||
;; (t/is (th/ex-of-type? error :not-found)))))
|
||||
;;
|
||||
;; (t/testing "query icons after delete"
|
||||
;; (let [data {::sq/type :icons
|
||||
;; :profile-id (:id prof)
|
||||
;; :library-id (:id coll)}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= 0 (count result))))))
|
||||
;; ))
|
|
@ -21,88 +21,6 @@
|
|||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
;; (t/deftest image-libraries-crud
|
||||
;; (let [id (uuid/next)
|
||||
;; prof (th/create-profile db/pool 2)
|
||||
;; team-id (:default-team-id prof)]
|
||||
;;
|
||||
;; (t/testing "create library"
|
||||
;; (let [data {::sm/type :create-image-library
|
||||
;; :name "sample library"
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id
|
||||
;; :id id}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= team-id (:team-id result)))
|
||||
;; (t/is (= (:name data) (:name result))))))
|
||||
;;
|
||||
;; (t/testing "rename library"
|
||||
;; (let [data {::sm/type :rename-image-library
|
||||
;; :name "renamed"
|
||||
;; :profile-id (:id prof)
|
||||
;; :id id}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= id (:id result)))
|
||||
;; (t/is (= "renamed" (:name result))))))
|
||||
;;
|
||||
;; (t/testing "query single library"
|
||||
;; (let [data {::sq/type :image-library
|
||||
;; :profile-id (:id prof)
|
||||
;; :id id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= id (:id result)))
|
||||
;; (t/is (= "renamed" (:name result))))))
|
||||
;;
|
||||
;; (t/testing "query libraries"
|
||||
;; (let [data {::sq/type :image-libraries
|
||||
;; :team-id team-id
|
||||
;; :profile-id (:id prof)}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;;
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= 1 (count result)))
|
||||
;; (t/is (= id (get-in result [0 :id]))))))
|
||||
;;
|
||||
;; (t/testing "delete library"
|
||||
;; (let [data {::sm/type :delete-image-library
|
||||
;; :profile-id (:id prof)
|
||||
;; :id id}
|
||||
;;
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;; (t/is (nil? (:result out)))))
|
||||
;;
|
||||
;; (t/testing "query libraries after delete"
|
||||
;; (let [data {::sq/type :image-libraries
|
||||
;; :profile-id (:id prof)
|
||||
;; :team-id team-id}
|
||||
;; out (th/try-on! (sq/handle data))]
|
||||
;;
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
;; (t/is (= 0 (count (:result out))))))
|
||||
;; ))
|
||||
|
||||
(t/deftest media-crud
|
||||
(let [prof (th/create-profile db/pool 1)
|
||||
team-id (:default-team-id prof)
|
||||
|
@ -127,14 +45,12 @@
|
|||
(t/is (= object-id-1 (get-in out [:result :id])))
|
||||
(t/is (not (nil? (get-in out [:result :name]))))
|
||||
(t/is (= "image/jpeg" (get-in out [:result :mtype])))
|
||||
;; (t/is (= "image/jpeg" (get-in out [:result :thumb-mtype])))
|
||||
(t/is (= 787 (get-in out [:result :width])))
|
||||
(t/is (= 2000 (get-in out [:result :height])))
|
||||
|
||||
(t/is (string? (get-in out [:result :path])))
|
||||
;; (t/is (string? (get-in out [:result :thumb-path])))
|
||||
(t/is (string? (get-in out [:result :uri])))))
|
||||
;; (t/is (string? (get-in out [:result :thumb-uri])))))
|
||||
(t/is (string? (get-in out [:result :uri])))
|
||||
(t/is (string? (get-in out [:result :thumb-uri])))))
|
||||
|
||||
(t/testing "upload media object to file"
|
||||
(let [content {:filename "sample.jpg"
|
||||
|
@ -156,14 +72,12 @@
|
|||
(t/is (= object-id-2 (get-in out [:result :id])))
|
||||
(t/is (= "testfile" (get-in out [:result :name])))
|
||||
(t/is (= "image/jpeg" (get-in out [:result :mtype])))
|
||||
;; (t/is (= "image/jpeg" (get-in out [:result :thumb-mtype])))
|
||||
(t/is (= 800 (get-in out [:result :width])))
|
||||
(t/is (= 800 (get-in out [:result :height])))
|
||||
|
||||
(t/is (string? (get-in out [:result :path])))
|
||||
;; (t/is (string? (get-in out [:result :thumb-path])))
|
||||
(t/is (string? (get-in out [:result :uri])))))
|
||||
;; (t/is (string? (get-in out [:result :thumb-uri])))))
|
||||
(t/is (string? (get-in out [:result :uri])))
|
||||
(t/is (string? (get-in out [:result :thumb-uri])))))
|
||||
|
||||
(t/testing "list media objects by file"
|
||||
(let [data {::sq/type :media-objects
|
||||
|
@ -177,14 +91,12 @@
|
|||
(t/is (= object-id-2 (get-in out [:result 0 :id])))
|
||||
(t/is (= "testfile" (get-in out [:result 0 :name])))
|
||||
(t/is (= "image/jpeg" (get-in out [:result 0 :mtype])))
|
||||
;; (t/is (= "image/jpeg" (get-in out [:result 0 :thumb-mtype])))
|
||||
(t/is (= 800 (get-in out [:result 0 :width])))
|
||||
(t/is (= 800 (get-in out [:result 0 :height])))
|
||||
|
||||
(t/is (string? (get-in out [:result 0 :path])))
|
||||
;; (t/is (string? (get-in out [:result 0 :thumb-path])))
|
||||
(t/is (string? (get-in out [:result 0 :uri])))))
|
||||
;; (t/is (string? (get-in out [:result 0 :thumb-uri])))))
|
||||
(t/is (string? (get-in out [:result 0 :uri])))
|
||||
(t/is (string? (get-in out [:result 0 :thumb-uri])))))
|
||||
|
||||
(t/testing "single media object"
|
||||
(let [data {::sq/type :media-object
|
||||
|
@ -196,14 +108,11 @@
|
|||
(t/is (= object-id-2 (get-in out [:result :id])))
|
||||
(t/is (= "testfile" (get-in out [:result :name])))
|
||||
(t/is (= "image/jpeg" (get-in out [:result :mtype])))
|
||||
;; (t/is (= "image/jpeg" (get-in out [:result :thumb-mtype])))
|
||||
(t/is (= 800 (get-in out [:result :width])))
|
||||
(t/is (= 800 (get-in out [:result :height])))
|
||||
|
||||
(t/is (string? (get-in out [:result :path])))
|
||||
;; (t/is (string? (get-in out [:result :thumb-path])))
|
||||
(t/is (string? (get-in out [:result :uri])))))
|
||||
;; (t/is (string? (get-in out [:result :thumb-uri])))))
|
||||
|
||||
(t/testing "delete media objects"
|
||||
(let [data {::sm/type :delete-media-object
|
||||
|
|
|
@ -93,20 +93,17 @@
|
|||
(t/is (= "en" (:lang result)))
|
||||
(t/is (= "dark" (:theme result))))))
|
||||
|
||||
;; (t/testing "update photo"
|
||||
;; (let [data {::sm/type :update-profile-photo
|
||||
;; :profile-id (:id profile)
|
||||
;; :file {:name "sample.jpg"
|
||||
;; :path "tests/uxbox/tests/_files/sample.jpg"
|
||||
;; :size 123123
|
||||
;; :mtype "image/jpeg"}}
|
||||
;; out (th/try-on! (sm/handle data))]
|
||||
(t/testing "update photo"
|
||||
(let [data {::sm/type :update-profile-photo
|
||||
:profile-id (:id profile)
|
||||
:file {:filename "sample.jpg"
|
||||
:size 123123
|
||||
:tempfile "tests/uxbox/tests/_files/sample.jpg"
|
||||
:content-type "image/jpeg"}}
|
||||
out (th/try-on! (sm/handle data))]
|
||||
|
||||
;; ;; (th/print-result! out)
|
||||
;; (t/is (nil? (:error out)))
|
||||
|
||||
;; (let [result (:result out)]
|
||||
;; (t/is (= (:id profile) (:id result))))))
|
||||
;; (th/print-result! out)
|
||||
(t/is (nil? (:error out)))
|
||||
))
|
||||
|
||||
|
||||
|
|
|
@ -1619,13 +1619,13 @@
|
|||
"es" : "Ocultar capas"
|
||||
}
|
||||
},
|
||||
"workspace.header.menu.hide-libraries" : {
|
||||
"workspace.header.menu.hide-assets" : {
|
||||
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:132" ],
|
||||
"translations" : {
|
||||
"en" : "Hide libraries",
|
||||
"fr" : "Masquer les librairies",
|
||||
"ru" : "Спрятать библиотеки",
|
||||
"es" : "Ocultar bibliotecas"
|
||||
"en" : "Hide assets",
|
||||
"fr" : "",
|
||||
"ru" : "",
|
||||
"es" : "Ocultar recursos"
|
||||
}
|
||||
},
|
||||
"workspace.header.menu.hide-palette" : {
|
||||
|
@ -1664,13 +1664,13 @@
|
|||
"es" : "Mostrar capas"
|
||||
}
|
||||
},
|
||||
"workspace.header.menu.show-libraries" : {
|
||||
"workspace.header.menu.show-assets" : {
|
||||
"used-in" : [ "src/uxbox/main/ui/workspace/header.cljs:133" ],
|
||||
"translations" : {
|
||||
"en" : "Show libraries",
|
||||
"fr" : "Montrer les librairies",
|
||||
"ru" : "Показать библиотеки",
|
||||
"es" : "Mostrar bibliotecas"
|
||||
"en" : "Show assets",
|
||||
"fr" : "",
|
||||
"ru" : "",
|
||||
"es" : "Mostrar recursos"
|
||||
}
|
||||
},
|
||||
"workspace.header.menu.show-palette" : {
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
@import 'main/layouts/login';
|
||||
@import 'main/layouts/projects-page';
|
||||
@import 'main/layouts/recent-files-page';
|
||||
@import 'main/layouts/library-page';
|
||||
@import "main/layouts/not-found";
|
||||
@import "main/layouts/viewer";
|
||||
|
||||
|
@ -51,13 +50,12 @@
|
|||
@import 'main/partials/color-palette';
|
||||
@import 'main/partials/colorpicker';
|
||||
@import 'main/partials/context-menu';
|
||||
@import 'main/partials/dashboard-bar';
|
||||
@import 'main/partials/dashboard-grid';
|
||||
@import 'main/partials/debug-icons-preview';
|
||||
@import 'main/partials/editable-label';
|
||||
@import 'main/partials/forms';
|
||||
@import 'main/partials/left-toolbar';
|
||||
@import 'main/partials/library-bar';
|
||||
@import 'main/partials/dashboard-sidebar';
|
||||
@import 'main/partials/loader';
|
||||
@import 'main/partials/main-bar';
|
||||
@import 'main/partials/modal';
|
||||
|
@ -77,4 +75,3 @@
|
|||
@import 'main/partials/user-settings';
|
||||
@import 'main/partials/workspace';
|
||||
@import 'main/partials/workspace-header';
|
||||
@import 'main/partials/workspace-libraries';
|
||||
|
|
|
@ -1,360 +0,0 @@
|
|||
.library-page {
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-rows: 40px 1fr;
|
||||
grid-template-columns: 14.5rem 1fr;
|
||||
grid-template-areas: "header header" "sidebar content";
|
||||
border-right: 1px solid $color-gray-30;
|
||||
|
||||
& .main-bar {
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
& .library-sidebar {
|
||||
grid-area: sidebar;
|
||||
}
|
||||
|
||||
& .library-content {
|
||||
grid-area: content;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.library-content-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.library-content-empty-text {
|
||||
color: #7C7C7C;
|
||||
border: 1px dashed #AFB2BF;
|
||||
text-align: center;
|
||||
padding: 5rem;
|
||||
margin: 2rem;
|
||||
}
|
||||
|
||||
.library-page #main-bar {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.library-header-navigation {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.library-header-navigation-item {
|
||||
margin: 0 $size-6;
|
||||
color: $color-gray-30;
|
||||
text-transform: uppercase;
|
||||
border-bottom: 1px solid transparent;
|
||||
|
||||
&:hover {
|
||||
color: $color-black;
|
||||
}
|
||||
|
||||
&.current {
|
||||
color: $color-black;
|
||||
border-bottom: 1px solid $color-primary;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.library-sidebar {
|
||||
background-color: $color-white;
|
||||
padding: $size-2;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.library-sidebar-list {
|
||||
margin-top: $size-4;
|
||||
overflow: scroll;
|
||||
height: 100%;
|
||||
padding-bottom: 4rem;
|
||||
}
|
||||
|
||||
.library-sidebar-list-element {
|
||||
color: $color-black;
|
||||
cursor: pointer;
|
||||
font-size: $fs14;
|
||||
overflow: hidden;
|
||||
padding: $size-2;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
background-color: $color-primary-lighter;
|
||||
}
|
||||
|
||||
&.current {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.library-top-menu {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
border-bottom: 1px solid #e3e3e3;
|
||||
justify-content: space-between;
|
||||
padding: $size-2 1.5rem;
|
||||
|
||||
svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
fill: #7C7C7C;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
fill: $color-primary;
|
||||
}
|
||||
}
|
||||
|
||||
& > * {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.library-top-menu-current-element {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.library-top-menu-current-element-name {
|
||||
font-size: 15px;
|
||||
line-height: 18px;
|
||||
color: $color-black;
|
||||
font-weight: normal;
|
||||
margin-right: $size-2;
|
||||
}
|
||||
|
||||
.library-top-menu-current-action {
|
||||
& svg {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.library-top-menu-actions {
|
||||
display: flex;
|
||||
|
||||
.btn-secondary {
|
||||
margin-left: $size-2;
|
||||
}
|
||||
}
|
||||
|
||||
.library-top-menu-actions-delete {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
&:hover {
|
||||
svg {
|
||||
fill: $color-danger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.library-page-cards-container {
|
||||
align-content: flex-start;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
height: 100%;
|
||||
overflow: scroll;
|
||||
padding: $size-2;
|
||||
padding-bottom: 4rem;
|
||||
}
|
||||
|
||||
.library-card {
|
||||
margin: $size-2;
|
||||
background: $color-white;
|
||||
border: 2px solid transparent;
|
||||
|
||||
&.library-icon, &.library-color {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
&.library-image {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
height: 200px;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
|
||||
& .library-card-footer-menu {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border: 2px solid $color-primary;
|
||||
}
|
||||
|
||||
&:hover .library-card-footer-menu {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.library-card .input-checkbox {
|
||||
margin: 0;
|
||||
top: $size-2;
|
||||
right: $size-2;
|
||||
position: absolute;
|
||||
|
||||
& label {
|
||||
margin: 0;
|
||||
|
||||
&:before {
|
||||
margin: 0;
|
||||
background-color: white;
|
||||
border: 1px solid #AFB2BF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.library-card-image {
|
||||
height: 136px;
|
||||
|
||||
.library-color & {
|
||||
height: 104px;
|
||||
}
|
||||
|
||||
padding: $size-2;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
|
||||
& object, & svg, & img {
|
||||
margin: auto;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
& svg {
|
||||
height: 50%;
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.library-card-footer {
|
||||
border-top: 1px solid $color-gray-10;
|
||||
padding: $size-2 $size-2 $size-2 $size-4;
|
||||
display: grid;
|
||||
grid-template-rows: 50% 50%;
|
||||
grid-template-columns: 1fr 16px 1px;
|
||||
grid-template-areas: "name . ." "timestamp menu options";
|
||||
|
||||
.library-card.library-color & {
|
||||
height: 50%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.library-card-footer-name {
|
||||
color: $color-black;
|
||||
grid-area: name;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.library-card-footer-timestamp {
|
||||
font-size: 12px;
|
||||
grid-area: timestamp;
|
||||
}
|
||||
|
||||
.library-card-footer-color {
|
||||
font-size: 15px;
|
||||
grid-area: timestamp;
|
||||
}
|
||||
|
||||
.library-card-footer-color-label {
|
||||
color: $color-gray-30;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
.library-card-footer-color-rgb {
|
||||
color: $color-black;
|
||||
}
|
||||
|
||||
.library-card-footer-menu {
|
||||
grid-area: menu;
|
||||
cursor: pointer;
|
||||
|
||||
& svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.library-card-footer .context-menu {
|
||||
grid-area: options;
|
||||
& .context-menu-items {
|
||||
top: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.modal-create-color {
|
||||
position: relative;
|
||||
background-color: $color-white;
|
||||
padding: 4rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
& .sketch-picker, .chrome-picker {
|
||||
box-shadow: none !important;
|
||||
border: 1px solid $color-gray-10 !important;
|
||||
border-radius: 0 !important;
|
||||
|
||||
& input {
|
||||
background-color: $color-white;
|
||||
}
|
||||
}
|
||||
|
||||
& .close {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
transform: rotate(45deg);
|
||||
top: 1rem;
|
||||
|
||||
svg {
|
||||
fill: $color-black;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
|
||||
&:hover {
|
||||
fill: $color-danger;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
& .btn-primary {
|
||||
width: 10rem;
|
||||
padding: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-create-color-title {
|
||||
color: $color-black;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
grid-template-columns: 40px 180px 1fr;
|
||||
height: 100vh;
|
||||
|
||||
& .library-bar {
|
||||
& .dashboard-sidebar {
|
||||
grid-row: 2;
|
||||
grid-column: 1 / span 2;
|
||||
overflow: hidden;
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||
// Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
.dashboard-bar {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
font-size: $fs14;
|
||||
padding: $small $medium $small $x-big*2;
|
||||
|
||||
.dashboard-images {
|
||||
flex-basis: 70px;
|
||||
}
|
||||
|
||||
.dashboard-info {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
width: 500px;
|
||||
justify-content: space-around;
|
||||
|
||||
.dashboard-projects {
|
||||
font-weight: bold;
|
||||
margin-right: $medium;
|
||||
}
|
||||
|
||||
.sort-by {
|
||||
margin-left: $small;
|
||||
}
|
||||
|
||||
.input-select {
|
||||
background-color: transparent;
|
||||
border-color: $color-gray-60;
|
||||
font-size: $fs14;
|
||||
margin-bottom: 0;
|
||||
margin-left: $medium;
|
||||
padding: 3px 25px 3px 3px;
|
||||
|
||||
option {
|
||||
color: $color-gray-60;
|
||||
background: $color-gray-60;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.dashboard-search {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
margin-left: $small;
|
||||
|
||||
.input-text {
|
||||
background: $color-gray-50;
|
||||
border: 0;
|
||||
color: $color-gray-60;
|
||||
padding: 4px 8px;
|
||||
margin: 0;
|
||||
max-width: 160px;
|
||||
}
|
||||
|
||||
.clear-search {
|
||||
align-items: center;
|
||||
background: $color-gray-50;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
height: 22px;
|
||||
padding: 0 5px;
|
||||
width: 22px;
|
||||
|
||||
svg {
|
||||
fill: $color-gray-30;
|
||||
height: 15px;
|
||||
transform: rotate(45deg);
|
||||
width: 15px;
|
||||
|
||||
&:hover {
|
||||
fill: $color-danger;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&.library-gap {
|
||||
padding: $small $medium $small 270px;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
||||
// Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
.library-bar {
|
||||
.dashboard-sidebar {
|
||||
background-color: $color-white;
|
||||
|
||||
.sidebar-team {
|
||||
|
@ -17,51 +17,19 @@
|
|||
padding-bottom: 2.8rem;
|
||||
}
|
||||
|
||||
.library-bar-inside {
|
||||
.dashboard-sidebar-inside {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
border-right: 1px solid $color-gray-10;
|
||||
|
||||
.library-tabs {
|
||||
align-items: center;
|
||||
background-color: $color-white;
|
||||
border-bottom: 1px solid $color-gray-20;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin: 0;
|
||||
padding-top: 12px;
|
||||
|
||||
li {
|
||||
background-color: $color-white;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: $color-gray-30;
|
||||
cursor: pointer;
|
||||
font-size: $fs14;
|
||||
padding: .6rem;
|
||||
text-align: center;
|
||||
width: 118px;
|
||||
|
||||
&:hover {
|
||||
color: $color-gray-60;
|
||||
}
|
||||
|
||||
&.current {
|
||||
border-color: $color-primary;
|
||||
color: $color-gray-60;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.library-elements {
|
||||
.dashboard-elements {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-y: auto;
|
||||
margin: 0;
|
||||
|
||||
&.library-common {
|
||||
&.dashboard-common {
|
||||
overflow: unset;
|
||||
}
|
||||
|
||||
|
@ -138,7 +106,7 @@
|
|||
&.profile-bar {
|
||||
background-color: $color-gray-10;
|
||||
|
||||
.library-bar-inside {
|
||||
.dashboard-sidebar-inside {
|
||||
display: none;
|
||||
}
|
||||
}
|
|
@ -197,3 +197,53 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.modal-create-color {
|
||||
position: relative;
|
||||
background-color: $color-white;
|
||||
padding: 4rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
& .sketch-picker, .chrome-picker {
|
||||
box-shadow: none !important;
|
||||
border: 1px solid $color-gray-10 !important;
|
||||
border-radius: 0 !important;
|
||||
|
||||
& input {
|
||||
background-color: $color-white;
|
||||
}
|
||||
}
|
||||
|
||||
& .close {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
transform: rotate(45deg);
|
||||
top: 1rem;
|
||||
|
||||
svg {
|
||||
fill: $color-black;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
|
||||
&:hover {
|
||||
fill: $color-danger;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
& .btn-primary {
|
||||
width: 10rem;
|
||||
padding: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-create-color-title {
|
||||
color: $color-black;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
.libraries-window-bar {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 50%);
|
||||
padding: 0.5rem;
|
||||
align-items: center;
|
||||
|
||||
& .context-menu-items {
|
||||
left: initial;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.libraries-window-bar-title {
|
||||
color: #F0F0F0;
|
||||
font-size: $fs14;
|
||||
}
|
||||
|
||||
.libraries-window-bar-options {
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0 0.5rem;
|
||||
|
||||
button {
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
& svg {
|
||||
width: 0.7rem;
|
||||
height: 0.7rem;
|
||||
fill: #F0F0F0;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
.library-tab {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.library-tab-content {
|
||||
display: grid;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
padding: 0.25rem;
|
||||
overflow-y: auto;
|
||||
|
||||
.icons-tab & {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
.images-tab & {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.library-tab-element {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #1F1F1F;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
margin: 0.25rem;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
|
||||
& svg, & img {
|
||||
height: auto;
|
||||
margin: auto;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: $color-primary;
|
||||
|
||||
& .library-tab-element-name {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
.icons-tab & {
|
||||
background: $color-white;
|
||||
color: $color-black;
|
||||
height: 4rem;
|
||||
width: 4rem;
|
||||
padding: $size-3;
|
||||
}
|
||||
|
||||
.images-tab & {
|
||||
height: 4rem;
|
||||
width: 6.2rem;
|
||||
color: $color-white;
|
||||
padding: $size-2 0;
|
||||
}
|
||||
|
||||
&.is-dragging {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
|
||||
& .library-tab-element-name {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.library-tab-element-name {
|
||||
display: none;
|
||||
position: absolute;
|
||||
font-size: 9px;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.library-tab-libraries {
|
||||
background-color: $color-gray-50;
|
||||
margin: 0.5rem;
|
||||
width: 90%;
|
||||
padding: 0.5rem;
|
||||
box-sizing: border-box;
|
||||
color: $color-gray-20;
|
||||
font-size: 12px;
|
||||
border: 1px solid $color-gray-40;
|
||||
|
||||
option {
|
||||
background-color: $color-white;
|
||||
color: $color-gray-60;
|
||||
}
|
||||
}
|
||||
|
||||
.library-tab-libraries-item {
|
||||
padding: 1rem;
|
||||
}
|
|
@ -20,233 +20,7 @@
|
|||
[uxbox.util.time :as dt]
|
||||
[uxbox.common.uuid :as uuid]))
|
||||
|
||||
;; ;; TODO: need a good refactor
|
||||
;;
|
||||
;; ;; --- Initialize
|
||||
;;
|
||||
;; (declare fetch-collections)
|
||||
;; (declare persist-collections)
|
||||
;; (declare collections-fetched?)
|
||||
;;
|
||||
;; ;; --- Collections Fetched
|
||||
;;
|
||||
;; (defrecord CollectionsFetched [data]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [{:keys [version value]} data]
|
||||
;; (-> state
|
||||
;; (update :colors-collections merge value)
|
||||
;; (assoc ::version version)))))
|
||||
;;
|
||||
;; (defn collections-fetched
|
||||
;; [data]
|
||||
;; {:pre [(map? data)]}
|
||||
;; (CollectionsFetched. data))
|
||||
;;
|
||||
;; (defn collections-fetched?
|
||||
;; [v]
|
||||
;; (instance? CollectionsFetched v))
|
||||
;;
|
||||
;; ;; --- Fetch Collections
|
||||
;;
|
||||
;; (defrecord FetchCollections []
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (->> (rp/query! :user-attr {:key "color-collections"})
|
||||
;; (rx/map collections-fetched)
|
||||
;; (rx/catch (fn [{:keys [type] :as error}]
|
||||
;; (if (= type :not-found)
|
||||
;; (rx/empty)
|
||||
;; (rx/throw error)))))))
|
||||
;;
|
||||
;; (defn fetch-collections
|
||||
;; []
|
||||
;; (FetchCollections.))
|
||||
;;
|
||||
;; ;; --- Create Collection
|
||||
;;
|
||||
;; (defrecord CreateCollection [id]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [item {:name (tr "ds.default-library-title" (gensym "c"))
|
||||
;; :id id
|
||||
;; :created-at (dt/now)
|
||||
;; :type :own
|
||||
;; :colors #{}}]
|
||||
;; (assoc-in state [:colors-collections id] item)))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (rx/of (persist-collections)
|
||||
;; (rt/nav :dashboard/colors nil {:type :own :id id}))))
|
||||
;;
|
||||
;; (defn create-collection
|
||||
;; []
|
||||
;; (let [id (uuid/next)]
|
||||
;; (CreateCollection. id)))
|
||||
;;
|
||||
;; ;; --- Persist Collections
|
||||
;;
|
||||
;; (defrecord PersistCollections []
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [builtin? #(= :builtin (:type %))
|
||||
;; xform (remove (comp builtin? second))
|
||||
;; version (or (get state ::version) -1)
|
||||
;; value (->> (get state :colors-collections)
|
||||
;; (into {} xform))
|
||||
;; data {:key "color-collections"
|
||||
;; :val value}]
|
||||
;; (->> (rp/mutation! :upsert-user-attr data)
|
||||
;; (rx/map collections-fetched)))))
|
||||
;;
|
||||
;; (defn persist-collections
|
||||
;; []
|
||||
;; (PersistCollections.))
|
||||
;;
|
||||
;; ;; --- Rename Collection
|
||||
;;
|
||||
;; (defrecord RenameCollection [id name]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (assoc-in state [:colors-collections id :name] name))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (rx/of (persist-collections))))
|
||||
;;
|
||||
;; (defn rename-collection
|
||||
;; [item name]
|
||||
;; (RenameCollection. item name))
|
||||
;;
|
||||
;; ;; --- Delete Collection
|
||||
;;
|
||||
;; (defrecord DeleteCollection [id]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update state :colors-collections dissoc id))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (rx/of (persist-collections))))
|
||||
;;
|
||||
;; (defn delete-collection
|
||||
;; [id]
|
||||
;; (DeleteCollection. id))
|
||||
;;
|
||||
;; ;; --- Replace Color
|
||||
;;
|
||||
;; (defrecord AddColor [coll-id color]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update-in state [:colors-collections coll-id :colors] set/union #{color}))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (rx/of (persist-collections))))
|
||||
;;
|
||||
;; (defn add-color
|
||||
;; "Add or replace color in a collection."
|
||||
;; [coll-id color]
|
||||
;; (AddColor. coll-id color))
|
||||
;;
|
||||
;; ;; --- Remove Color
|
||||
;;
|
||||
;; (defrecord RemoveColors [id colors]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update-in state [:colors-collections id :colors]
|
||||
;; #(set/difference % colors)))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (rx/of (persist-collections))))
|
||||
;;
|
||||
;; (defn remove-colors
|
||||
;; "Remove color in a collection."
|
||||
;; [id colors]
|
||||
;; (RemoveColors. id colors))
|
||||
;;
|
||||
;; ;; --- Select color
|
||||
;;
|
||||
;; (defrecord SelectColor [color]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update-in state [:dashboard :colors :selected] conj color)))
|
||||
;;
|
||||
;; (defrecord DeselectColor [color]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update-in state [:dashboard :colors :selected] disj color)))
|
||||
;;
|
||||
;; (defrecord ToggleColorSelection [color]
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [selected (get-in state [:dashboard :colors :selected])]
|
||||
;; (rx/of
|
||||
;; (if (selected color)
|
||||
;; (DeselectColor. color)
|
||||
;; (SelectColor. color))))))
|
||||
;;
|
||||
;; (defn toggle-color-selection
|
||||
;; [color]
|
||||
;; {:pre [(color/hex? color)]}
|
||||
;; (ToggleColorSelection. color))
|
||||
;;
|
||||
;; ;; --- Copy Selected Color
|
||||
;;
|
||||
;; (defrecord CopySelected [id]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [selected (get-in state [:dashboard :colors :selected])]
|
||||
;; (update-in state [:colors-collections id :colors] set/union selected)))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (rx/of (persist-collections))))
|
||||
;;
|
||||
;; (defn copy-selected
|
||||
;; [id]
|
||||
;; {:pre [(or (uuid? id) (nil? id))]}
|
||||
;; (CopySelected. id))
|
||||
;;
|
||||
;; ;; --- Move Selected Color
|
||||
;;
|
||||
;; (defrecord MoveSelected [from to]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [selected (get-in state [:dashboard :colors :selected])]
|
||||
;; (-> state
|
||||
;; (update-in [:colors-collections from :colors] set/difference selected)
|
||||
;; (update-in [:colors-collections to :colors] set/union selected))))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (rx/of (persist-collections))))
|
||||
;;
|
||||
;; (defn move-selected
|
||||
;; [from to]
|
||||
;; {:pre [(or (uuid? from) (nil? from))
|
||||
;; (or (uuid? to) (nil? to))]}
|
||||
;; (MoveSelected. from to))
|
||||
;;
|
||||
;; ;; --- Delete Colors
|
||||
;;
|
||||
;; (defrecord DeleteColors [coll-id colors]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (assoc-in state [:dashboard :colors :selected] #{}))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (rx/of (remove-colors coll-id colors))))
|
||||
;;
|
||||
;; (defn delete-colors
|
||||
;; [coll-id colors]
|
||||
;; (DeleteColors. coll-id colors))
|
||||
|
||||
|
||||
;;;; NEW
|
||||
(declare create-color-result)
|
||||
|
||||
(defn create-color
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.main.data.icons
|
||||
(:require
|
||||
[cljs.spec.alpha :as s]
|
||||
[beicon.core :as rx]
|
||||
[cuerdas.core :as str]
|
||||
[potok.core :as ptk]
|
||||
[uxbox.common.spec :as us]
|
||||
[uxbox.common.data :as d]
|
||||
[uxbox.main.repo :as rp]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.webapi :as wapi]
|
||||
[uxbox.util.i18n :as i18n :refer [t tr]]
|
||||
[uxbox.util.router :as r]
|
||||
[uxbox.common.uuid :as uuid]))
|
||||
|
||||
(s/def ::id uuid?)
|
||||
(s/def ::name string?)
|
||||
(s/def ::created-at inst?)
|
||||
(s/def ::modified-at inst?)
|
||||
(s/def ::user-id uuid?)
|
||||
(s/def ::collection-id ::us/uuid)
|
||||
|
||||
(s/def ::collection
|
||||
(s/keys :req-un [::id
|
||||
::name
|
||||
::created-at
|
||||
::modified-at
|
||||
::user-id]))
|
||||
|
||||
;; --- Create Icon
|
||||
(defn- parse-svg
|
||||
[data]
|
||||
(s/assert ::us/string data)
|
||||
(let [valid-tags #{"defs" "path" "circle" "rect" "metadata" "g"
|
||||
"radialGradient" "stop"}
|
||||
div (dom/create-element "div")
|
||||
gc (dom/create-element "div")
|
||||
g (dom/create-element "http://www.w3.org/2000/svg" "g")
|
||||
_ (dom/set-html! div data)
|
||||
svg (dom/query div "svg")]
|
||||
(loop [child (dom/get-first-child svg)]
|
||||
(if child
|
||||
(let [tagname (dom/get-tag-name child)]
|
||||
(if (contains? valid-tags tagname)
|
||||
(dom/append-child! g child)
|
||||
(dom/append-child! gc child))
|
||||
(recur (dom/get-first-child svg)))
|
||||
(let [width (.. ^js svg -width -baseVal -value)
|
||||
height (.. ^js svg -height -baseVal -value)
|
||||
view-box [(.. ^js svg -viewBox -baseVal -x)
|
||||
(.. ^js svg -viewBox -baseVal -y)
|
||||
(.. ^js svg -viewBox -baseVal -width)
|
||||
(.. ^js svg -viewBox -baseVal -height)]
|
||||
props {:width width
|
||||
:mimetype "image/svg+xml"
|
||||
:height height
|
||||
:view-box view-box}]
|
||||
[(dom/get-outer-html g) props])))))
|
||||
|
||||
|
||||
(declare create-icon-result)
|
||||
|
||||
(defn create-icons
|
||||
[library-id files]
|
||||
(s/assert (s/nilable uuid?) library-id)
|
||||
(ptk/reify ::create-icons
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
(letfn [(parse [file]
|
||||
(->> (wapi/read-file-as-text file)
|
||||
(rx/map parse-svg)))
|
||||
(allowed? [file]
|
||||
(= (.-type file) "image/svg+xml"))
|
||||
(prepare [[content metadata]]
|
||||
{:library-id library-id
|
||||
:content content
|
||||
:id (uuid/next)
|
||||
;; TODO Keep the name of the original icon
|
||||
:name (name (gensym "Icon "))
|
||||
:metadata metadata})]
|
||||
(->> (rx/from files)
|
||||
(rx/filter allowed?)
|
||||
(rx/merge-map parse)
|
||||
(rx/map prepare)
|
||||
(rx/flat-map #(rp/mutation! :create-icon %))
|
||||
(rx/map (partial create-icon-result library-id)))))))
|
||||
|
||||
(defn create-icon-result
|
||||
[library-id item]
|
||||
(ptk/reify ::create-icon-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [{:keys [id] :as item} (assoc item :type :icon)]
|
||||
(-> state
|
||||
(update-in [:library-items :icons library-id] #(into [item] %)))))))
|
|
@ -1,229 +0,0 @@
|
|||
(ns uxbox.main.data.library
|
||||
(:require
|
||||
[cljs.spec.alpha :as s]
|
||||
[beicon.core :as rx]
|
||||
[cuerdas.core :as str]
|
||||
[potok.core :as ptk]
|
||||
[uxbox.common.spec :as us]
|
||||
[uxbox.common.data :as d]
|
||||
[uxbox.main.repo :as rp]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.webapi :as wapi]
|
||||
[uxbox.util.i18n :as i18n :refer [t tr]]
|
||||
[uxbox.util.router :as r]
|
||||
[uxbox.common.uuid :as uuid]))
|
||||
|
||||
;; Retrieve libraries
|
||||
|
||||
(declare retrieve-libraries-result)
|
||||
|
||||
(defn retrieve-libraries
|
||||
([section]
|
||||
(retrieve-libraries section uuid/zero))
|
||||
([section team-id]
|
||||
(s/assert ::us/uuid team-id)
|
||||
(let [method (case section
|
||||
:icons :icon-libraries
|
||||
:images :image-libraries
|
||||
:palettes :color-libraries)]
|
||||
(ptk/reify ::retrieve-libraries
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(->> (rp/query! method {:team-id team-id})
|
||||
(rx/map (partial retrieve-libraries-result section team-id))))))))
|
||||
|
||||
(defn- retrieve-libraries-result
|
||||
[section team-id result]
|
||||
(ptk/reify ::retrieve-libraries-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:library section team-id] result))))
|
||||
|
||||
;; Retrieve library data
|
||||
|
||||
(declare retrieve-library-data-result)
|
||||
|
||||
(defn retrieve-library-data
|
||||
[section library-id]
|
||||
(ptk/reify ::retrieve-library-data
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [method (case section
|
||||
:icons :icons
|
||||
:images :images
|
||||
:palettes :colors)]
|
||||
(->> (rp/query! method {:library-id library-id})
|
||||
(rx/map (partial retrieve-library-data-result section library-id)))))))
|
||||
|
||||
(defn retrieve-library-data-result
|
||||
[section library-id data]
|
||||
(ptk/reify ::retrieve-library-data-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(assoc-in [:library-items section library-id] data)))))
|
||||
|
||||
|
||||
;; Create library
|
||||
|
||||
(declare create-library-result)
|
||||
|
||||
(defn create-library
|
||||
[section team-id name]
|
||||
(ptk/reify ::create-library
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [method (case section
|
||||
:icons :create-icon-library
|
||||
:images :create-image-library
|
||||
:palettes :create-color-library)]
|
||||
(->> (rp/mutation! method {:team-id team-id
|
||||
:name name})
|
||||
(rx/map (partial create-library-result section team-id)))))))
|
||||
|
||||
(defn create-library-result
|
||||
[section team-id result]
|
||||
(ptk/reify ::create-library-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(update-in [:library section team-id] #(into [result] %))))))
|
||||
|
||||
;; Rename library
|
||||
|
||||
(declare rename-library-result)
|
||||
|
||||
(defn rename-library
|
||||
[section team-id library-id name]
|
||||
(ptk/reify ::rename-library
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [method (case section
|
||||
:icons :rename-icon-library
|
||||
:images :rename-image-library
|
||||
:palettes :rename-color-library)]
|
||||
(->> (rp/mutation! method {:id library-id
|
||||
:name name})
|
||||
(rx/map #(rename-library-result section team-id library-id name)))))))
|
||||
|
||||
(defn rename-library-result
|
||||
[section team-id library-id name]
|
||||
(ptk/reify ::rename-library-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(letfn [(change-name
|
||||
[library] (if (= library-id (:id library))
|
||||
(assoc library :name name)
|
||||
library))
|
||||
(update-fn [libraries] (map change-name libraries))]
|
||||
|
||||
(-> state
|
||||
(update-in [:library section team-id] update-fn))))))
|
||||
|
||||
;; Delete library
|
||||
|
||||
(declare delete-library-result)
|
||||
|
||||
(defn delete-library
|
||||
[section team-id library-id]
|
||||
(ptk/reify ::delete-library
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(assoc-in [:library :last-deleted-library] library-id)))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [method (case section
|
||||
:icons :delete-icon-library
|
||||
:images :delete-image-library
|
||||
:palettes :delete-color-library)]
|
||||
(->> (rp/mutation! method {:id library-id})
|
||||
(rx/map #(delete-library-result section team-id library-id)))))))
|
||||
|
||||
(defn delete-library-result
|
||||
[section team-id library-id]
|
||||
(ptk/reify ::create-library-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [update-fn (fn [libraries]
|
||||
(filterv #(not= library-id (:id %)) libraries))]
|
||||
(-> state
|
||||
(update-in [:library section team-id] update-fn))))))
|
||||
|
||||
;; Delete library item
|
||||
|
||||
(declare delete-item-result)
|
||||
|
||||
(defn delete-item
|
||||
[section library-id item-id]
|
||||
(ptk/reify ::delete-item
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [method (case section
|
||||
:icons :delete-icon
|
||||
:images :delete-image
|
||||
:palettes :delete-color)]
|
||||
(->> (rp/mutation! method {:id item-id})
|
||||
(rx/map #(delete-item-result section library-id item-id)))))))
|
||||
|
||||
(defn delete-item-result
|
||||
[section library-id item-id]
|
||||
(ptk/reify ::delete-item-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [update-fn (fn [items]
|
||||
(filterv #(not= item-id (:id %)) items))]
|
||||
(-> state
|
||||
(update-in [:library-items section library-id] update-fn))))))
|
||||
|
||||
;; Batch delete
|
||||
|
||||
(declare batch-delete-item-result)
|
||||
|
||||
(defn batch-delete-item
|
||||
[section library-id item-ids]
|
||||
(ptk/reify ::batch-delete-item
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [method (case section
|
||||
:icons :delete-icon
|
||||
:images :delete-image
|
||||
:palettes :delete-color)]
|
||||
(->> (rx/from item-ids)
|
||||
(rx/flat-map #(rp/mutation! method {:id %}))
|
||||
(rx/last)
|
||||
(rx/map #(batch-delete-item-result section library-id item-ids)))))))
|
||||
|
||||
(defn batch-delete-item-result
|
||||
[section library-id item-ids]
|
||||
(ptk/reify ::batch-delete-item-result
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [item-ids-set (set item-ids)
|
||||
update-fn (fn [items]
|
||||
(filterv #(not (item-ids-set (:id %))) items))]
|
||||
(-> state
|
||||
(update-in [:library-items section library-id] update-fn))))))
|
||||
|
||||
;; Workspace - select library
|
||||
|
||||
(defn select-library
|
||||
[section library-id]
|
||||
(ptk/reify ::select-library
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(assoc-in [:library-selected section] library-id)))))
|
||||
|
||||
|
||||
;; Workspace - change library filter
|
||||
|
||||
(defn change-library-filter
|
||||
[section filter]
|
||||
(ptk/reify ::change-library-filter
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(assoc-in [:library-filter section] filter)))))
|
|
@ -33,16 +33,8 @@
|
|||
;; (s/def ::thumbnail string?)
|
||||
(s/def ::id uuid?)
|
||||
(s/def ::uri string?)
|
||||
;; (s/def ::collection-id uuid?)
|
||||
(s/def ::user-id uuid?)
|
||||
|
||||
;; (s/def ::collection
|
||||
;; (s/keys :req-un [::id
|
||||
;; ::name
|
||||
;; ::created-at
|
||||
;; ::modified-at
|
||||
;; ::user-id]))
|
||||
|
||||
(s/def ::media-object
|
||||
(s/keys :req-un [::id
|
||||
::name
|
||||
|
@ -55,301 +47,6 @@
|
|||
;; ::thumb-uri
|
||||
::user-id]))
|
||||
|
||||
;; ;; --- Initialize Collection Page
|
||||
;;
|
||||
;; (declare fetch-media-objects)
|
||||
;;
|
||||
;; (defn initialize
|
||||
;; [collection-id]
|
||||
;; (us/verify ::us/uuid collection-id)
|
||||
;; (ptk/reify ::initialize
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (assoc-in state [:dashboard-media-objects :selected] #{}))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (rx/of (fetch-media-objects collection-id)))))
|
||||
;;
|
||||
;; ;; --- Fetch Collections
|
||||
;;
|
||||
;; (declare collections-fetched)
|
||||
;;
|
||||
;; (def fetch-collections
|
||||
;; (ptk/reify ::fetch-collections
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (->> (rp/query! :media-object-collections)
|
||||
;; (rx/map collections-fetched)))))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Collections Fetched
|
||||
;;
|
||||
;; (defn collections-fetched
|
||||
;; [items]
|
||||
;; (us/verify (s/every ::collection) items)
|
||||
;; (ptk/reify ::collections-fetched
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (reduce (fn [state {:keys [id user] :as item}]
|
||||
;; (let [type (if (uuid/zero? (:user-id item)) :builtin :own)
|
||||
;; item (assoc item :type type)]
|
||||
;; (assoc-in state [:media-objects-collections id] item)))
|
||||
;; state
|
||||
;; items))))
|
||||
;;
|
||||
;;
|
||||
;; ;; --- Create Collection
|
||||
;;
|
||||
;; (declare collection-created)
|
||||
;;
|
||||
;; (def create-collection
|
||||
;; (ptk/reify ::create-collection
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (let [data {:name (tr "ds.default-library-title" (gensym "c"))}]
|
||||
;; (->> (rp/mutation! :create-media-object-collection data)
|
||||
;; (rx/map collection-created))))))
|
||||
;;
|
||||
;; ;; --- Collection Created
|
||||
;;
|
||||
;; (defn collection-created
|
||||
;; [item]
|
||||
;; (us/verify ::collection item)
|
||||
;; (ptk/reify ::collection-created
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [{:keys [id] :as item} (assoc item :type :own)]
|
||||
;; (update state :media-objects-collections assoc id item)))))
|
||||
;;
|
||||
;; ;; --- Rename Collection
|
||||
;;
|
||||
;; (defn rename-collection
|
||||
;; [id name]
|
||||
;; (ptk/reify ::rename-collection
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (assoc-in state [:media-objects-collections id :name] name))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (let [params {:id id :name name}]
|
||||
;; (->> (rp/mutation! :rename-media-object-collection params)
|
||||
;; (rx/ignore))))))
|
||||
;;
|
||||
;; ;; --- Delete Collection
|
||||
;;
|
||||
;; (defn delete-collection
|
||||
;; [id on-success]
|
||||
;; (ptk/reify ::delete-collection
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update state :media-objects-collections dissoc id))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (->> (rp/mutation! :delete-media-object-collection {:id id})
|
||||
;; (rx/tap on-success)
|
||||
;; (rx/ignore)))))
|
||||
;;
|
||||
;; ;; --- Update Media object
|
||||
;;
|
||||
;; (defn persist-media-object
|
||||
;; [id]
|
||||
;; (us/verify ::us/uuid id)
|
||||
;; (ptk/reify ::persist-media-object
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [data (get-in state [:media-objects id])]
|
||||
;; (->> (rp/mutation! :update-media-object data)
|
||||
;; (rx/ignore))))))
|
||||
;;
|
||||
;; ;; --- Fetch Media objects
|
||||
;;
|
||||
;; (declare media-objects-fetched)
|
||||
;;
|
||||
;; (defn fetch-media-objects
|
||||
;; "Fetch a list of media-objects of the selected collection"
|
||||
;; [id]
|
||||
;; (us/verify ::us/uuid id)
|
||||
;; (ptk/reify ::fetch-media-objects
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (let [params {:collection-id id}]
|
||||
;; (->> (rp/query! :media-objects-by-collection params)
|
||||
;; (rx/map (partial media-objects-fetched id)))))))
|
||||
;;
|
||||
;; ;; --- Media objects Fetched
|
||||
;;
|
||||
;; (s/def ::media-objects (s/every ::media-object))
|
||||
;;
|
||||
;; (defn media-objects-fetched
|
||||
;; [collection-id items]
|
||||
;; (us/verify ::us/uuid collection-id)
|
||||
;; (us/verify ::media-objects items)
|
||||
;; (ptk/reify ::media-objects-fetched
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [media-objects (d/index-by :id items)]
|
||||
;; (assoc state :media-objects media-objects)))))
|
||||
;;
|
||||
;; ;; --- Fetch Media object
|
||||
;;
|
||||
;; (declare media-object-fetched)
|
||||
;;
|
||||
;; (defrecord FetchMediaObject [id]
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [existing (get-in state [:media-objects id])]
|
||||
;; (if existing
|
||||
;; (rx/empty)
|
||||
;; (->> (rp/query! :media-object-by-id {:id id})
|
||||
;; (rx/map media-object-fetched)
|
||||
;; (rx/catch rp/client-error? #(rx/empty)))))))
|
||||
;;
|
||||
;; (defn fetch-media-object
|
||||
;; "Conditionally fetch media-object by its id. If media-object
|
||||
;; is already loaded, this event is noop."
|
||||
;; [id]
|
||||
;; {:pre [(uuid? id)]}
|
||||
;; (FetchMediaObject. id))
|
||||
;;
|
||||
;; ;; --- MediaObject Fetched
|
||||
;;
|
||||
;; (defrecord MediaObjectFetched [media-object]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [id (:id media-object)]
|
||||
;; (update state :media-objects assoc id media-object))))
|
||||
;;
|
||||
;; (defn media-object-fetched
|
||||
;; [media-object]
|
||||
;; {:pre [(map? media-object)]}
|
||||
;; (MediaObjectFetched. media-object))
|
||||
;;
|
||||
;; ;; --- Rename MediaObject
|
||||
;;
|
||||
;; (defn rename-media-object
|
||||
;; [id name]
|
||||
;; (us/verify ::us/uuid id)
|
||||
;; (us/verify ::us/string name)
|
||||
;; (ptk/reify ::rename-media-object
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (assoc-in state [:media-objects id :name] name))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (rx/of (persist-media-object id)))))
|
||||
;;
|
||||
;; ;; --- MediaObject Selection
|
||||
;;
|
||||
;; (defn select-media-object
|
||||
;; [id]
|
||||
;; (ptk/reify ::select-media-object
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update-in state [:dashboard-media-objects :selected] (fnil conj #{}) id))))
|
||||
;;
|
||||
;; (defn deselect-media-object
|
||||
;; [id]
|
||||
;; (ptk/reify ::deselect-media-object
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update-in state [:dashboard-media-objects :selected] (fnil disj #{}) id))))
|
||||
;;
|
||||
;; (def deselect-all-media-objects
|
||||
;; (ptk/reify ::deselect-all-media-objects
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (assoc-in state [:dashboard-media-objects :selected] #{}))))
|
||||
;;
|
||||
;; ;; --- Delete MediaObjects
|
||||
;;
|
||||
;; (defn delete-media-object
|
||||
;; [id]
|
||||
;; (us/verify ::us/uuid id)
|
||||
;; (ptk/reify ::delete-media-object
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update state :media-objects dissoc id))
|
||||
;;
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state s]
|
||||
;; (rx/merge
|
||||
;; (rx/of deselect-all-media-objects)
|
||||
;; (->> (rp/mutation! :delete-media-object {:id id})
|
||||
;; (rx/ignore))))))
|
||||
;;
|
||||
;; ;; --- Delete Selected
|
||||
;;
|
||||
;; (def delete-selected
|
||||
;; (ptk/reify ::delete-selected
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [selected (get-in state [:dashboard-media-objects :selected])]
|
||||
;; (->> (rx/from selected)
|
||||
;; (rx/map delete-media-object))))))
|
||||
;;
|
||||
;; ;; --- Update Opts (Filtering & Ordering)
|
||||
;;
|
||||
;; (defn update-opts
|
||||
;; [& {:keys [order filter edition]
|
||||
;; :or {edition false}}]
|
||||
;; (ptk/reify ::update-opts
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (update state :dashboard-media-objects merge
|
||||
;; {:edition edition}
|
||||
;; (when order {:order order})
|
||||
;; (when filter {:filter filter})))))
|
||||
|
||||
;; --- Copy Selected MediaObject
|
||||
|
||||
;; (defrecord CopySelected [id]
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [selected (get-in state [:dashboard-media-objects :selected])]
|
||||
;; (rx/merge
|
||||
;; (->> (rx/from selected)
|
||||
;; (rx/flat-map #(rp/mutation! :copy-media-object {:id % :collection-id id}))
|
||||
;; (rx/map media-object-created))
|
||||
;; (->> (rx/from selected)
|
||||
;; (rx/map deselect-media-object))))))
|
||||
|
||||
;; (defn copy-selected
|
||||
;; [id]
|
||||
;; {:pre [(or (uuid? id) (nil? id))]}
|
||||
;; (CopySelected. id))
|
||||
|
||||
;; --- Move Selected MediaObject
|
||||
|
||||
;; (defrecord MoveSelected [id]
|
||||
;; ptk/UpdateEvent
|
||||
;; (update [_ state]
|
||||
;; (let [selected (get-in state [:dashboard-media-objects :selected])]
|
||||
;; (reduce (fn [state media-object]
|
||||
;; (assoc-in state [:media-objects media-object :collection] id))
|
||||
;; state
|
||||
;; selected)))
|
||||
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
;; (let [selected (get-in state [:dashboard-media-objects :selected])]
|
||||
;; (rx/merge
|
||||
;; (->> (rx/from selected)
|
||||
;; (rx/map persist-media-object))
|
||||
;; (->> (rx/from selected)
|
||||
;; (rx/map deselect-media-object))))))
|
||||
|
||||
;; (defn move-selected
|
||||
;; [id]
|
||||
;; {:pre [(or (uuid? id) (nil? id))]}
|
||||
;; (MoveSelected. id))
|
||||
|
||||
|
||||
;;;;;;; NEW
|
||||
|
||||
;; --- Create library Media Objects
|
||||
|
||||
(declare create-media-objects-result)
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#{:sitemap
|
||||
:sitemap-pages
|
||||
:layers
|
||||
:libraries
|
||||
:assets
|
||||
:document-history
|
||||
:colorpalette
|
||||
|
@ -306,7 +305,6 @@
|
|||
left-sidebar? (not (empty? (keep layout [:layers
|
||||
:sitemap
|
||||
:document-history
|
||||
:libraries
|
||||
:assets])))
|
||||
right-sidebar? (not (empty? (keep layout [:element-options])))]
|
||||
(update-in state [:workspace-local]
|
||||
|
@ -1462,9 +1460,8 @@
|
|||
;; Shortcuts impl https://github.com/ccampbell/mousetrap
|
||||
|
||||
(def shortcuts
|
||||
{"ctrl+m" #(st/emit! (toggle-layout-flags :sitemap))
|
||||
"ctrl+i" #(st/emit! (toggle-layout-flags :libraries))
|
||||
"ctrl+l" #(st/emit! (toggle-layout-flags :layers))
|
||||
{"ctrl+i" #(st/emit! (toggle-layout-flags :assets))
|
||||
"ctrl+l" #(st/emit! (toggle-layout-flags :sitemap :layers))
|
||||
"ctrl+shift+r" #(st/emit! (toggle-layout-flags :rules))
|
||||
"ctrl+a" #(st/emit! (toggle-layout-flags :dynamic-alignment))
|
||||
"ctrl+p" #(st/emit! (toggle-layout-flags :colorpalette))
|
||||
|
|
|
@ -296,7 +296,7 @@
|
|||
(rx/of go-to-file)
|
||||
(rx/empty))))))))))
|
||||
|
||||
;; --- Fetch Workspace Images
|
||||
;; --- Fetch Workspace Graphics
|
||||
|
||||
(declare media-objects-fetched)
|
||||
|
||||
|
|
|
@ -76,14 +76,6 @@
|
|||
(seq params))
|
||||
(send-mutation! id form)))
|
||||
|
||||
;; (defmethod mutation :upload-file-image
|
||||
;; [id params]
|
||||
;; (let [form (js/FormData.)]
|
||||
;; (run! (fn [[key val]]
|
||||
;; (.append form (name key) val))
|
||||
;; (seq params))
|
||||
;; (send-mutation! id form)))
|
||||
|
||||
(defmethod mutation :update-profile-photo
|
||||
[id params]
|
||||
(let [form (js/FormData.)]
|
||||
|
|
|
@ -64,22 +64,7 @@
|
|||
["/" :dashboard-team]
|
||||
["/search" :dashboard-search]
|
||||
["/project/:project-id" :dashboard-project]
|
||||
["/libraries" :dashboard-libraries]
|
||||
|
||||
;; ["/library"
|
||||
;; ["/icons"
|
||||
;; ["" { :name :dashboard-library-icons-index :section :icons}]
|
||||
;; ["/:library-id" { :name :dashboard-library-icons :section :icons}]]
|
||||
;;
|
||||
;; ["/images"
|
||||
;; ["" { :name :dashboard-library-images-index :section :images}]
|
||||
;; ["/:library-id" { :name :dashboard-library-images :section :images}]]
|
||||
;;
|
||||
;; ["/palettes"
|
||||
;; ["" { :name :dashboard-library-palettes-index :section :palettes}]
|
||||
;; ["/:library-id" { :name :dashboard-library-palettes :section :palettes }]]]
|
||||
|
||||
]]
|
||||
["/libraries" :dashboard-libraries]]]
|
||||
|
||||
["/workspace/:project-id/:file-id" :workspace]])
|
||||
|
||||
|
@ -122,12 +107,6 @@
|
|||
:dashboard-team
|
||||
:dashboard-project
|
||||
:dashboard-libraries)
|
||||
;; :dashboard-library-icons
|
||||
;; :dashboard-library-icons-index
|
||||
;; :dashboard-library-images
|
||||
;; :dashboard-library-images-index
|
||||
;; :dashboard-library-palettes
|
||||
;; :dashboard-library-palettes-index)
|
||||
[:& dashboard {:route route}]
|
||||
|
||||
:viewer
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
[uxbox.main.ui.dashboard.project :refer [project-page]]
|
||||
[uxbox.main.ui.dashboard.recent-files :refer [recent-files-page]]
|
||||
[uxbox.main.ui.dashboard.libraries :refer [libraries-page]]
|
||||
;; [uxbox.main.ui.dashboard.library :refer [library-page]]
|
||||
[uxbox.main.ui.dashboard.profile :refer [profile-section]]
|
||||
[uxbox.util.router :as rt]
|
||||
[uxbox.util.i18n :as i18n :refer [t]]))
|
||||
|
@ -38,7 +37,6 @@
|
|||
route-name (get-in route [:data :name])
|
||||
team-id (get-in route [:params :path :team-id])
|
||||
project-id (get-in route [:params :path :project-id])]
|
||||
;; library-id (get-in route [:params :path :library-id])]
|
||||
(cond->
|
||||
{:search-term search-term}
|
||||
|
||||
|
@ -51,12 +49,6 @@
|
|||
(= "drafts" project-id)
|
||||
(assoc :project-id (:default-project-id profile)))))
|
||||
|
||||
;; (str/starts-with? (name route-name) "dashboard-library")
|
||||
;; (assoc :library-section (get-in route [:data :section]))
|
||||
;;
|
||||
;; (uuid-str? library-id)
|
||||
;; (assoc :library-id (uuid library-id)))))
|
||||
|
||||
(declare global-notifications)
|
||||
|
||||
|
||||
|
@ -64,7 +56,6 @@
|
|||
[{:keys [route] :as props}]
|
||||
(let [profile (mf/deref refs/profile)
|
||||
page (get-in route [:data :name])
|
||||
;; {:keys [search-term team-id project-id library-id library-section] :as params}
|
||||
{:keys [search-term team-id project-id] :as params}
|
||||
(parse-params route profile)]
|
||||
[:*
|
||||
|
@ -89,17 +80,6 @@
|
|||
:dashboard-libraries
|
||||
[:& libraries-page {:team-id team-id}]
|
||||
|
||||
;; (:dashboard-library-icons
|
||||
;; :dashboard-library-icons-index
|
||||
;; :dashboard-library-images
|
||||
;; :dashboard-library-images-index
|
||||
;; :dashboard-library-palettes
|
||||
;; :dashboard-library-palettes-index)
|
||||
;; [:& library-page {:key (str library-id)
|
||||
;; :team-id team-id
|
||||
;; :library-id library-id
|
||||
;; :section library-section}]
|
||||
|
||||
:dashboard-project
|
||||
[:& project-page {:team-id team-id
|
||||
:project-id project-id}])]]]))
|
||||
|
|
|
@ -1,391 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2015-2020 Andrey Antukh <niwi@niwi.nz>
|
||||
;; Copyright (c) 2015-2020 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
;; (ns uxbox.main.ui.dashboard.library
|
||||
;; (:require
|
||||
;; [okulary.core :as l]
|
||||
;; [rumext.alpha :as mf]
|
||||
;; [cuerdas.core :as str]
|
||||
;; [uxbox.util.router :as rt]
|
||||
;; [uxbox.util.i18n :as i18n :refer [t tr]]
|
||||
;; [uxbox.util.color :as uc]
|
||||
;; [uxbox.util.dom :as dom]
|
||||
;; [uxbox.util.time :as dt]
|
||||
;; [uxbox.main.data.library :as dlib]
|
||||
;; [uxbox.main.data.icons :as dico]
|
||||
;; [uxbox.main.data.images :as dimg]
|
||||
;; [uxbox.main.data.colors :as dcol]
|
||||
;; [uxbox.main.ui.icons :as i]
|
||||
;; [uxbox.main.store :as st]
|
||||
;; [uxbox.main.refs :as refs]
|
||||
;; [uxbox.main.ui.components.context-menu :refer [context-menu]]
|
||||
;; [uxbox.main.ui.components.file-uploader :refer [file-uploader]]
|
||||
;; [uxbox.main.ui.modal :as modal]
|
||||
;; [uxbox.main.ui.confirm :refer [confirm-dialog]]
|
||||
;; [uxbox.main.ui.colorpicker :refer [colorpicker most-used-colors]]
|
||||
;; [uxbox.main.ui.components.editable-label :refer [editable-label]]
|
||||
;; ))
|
||||
;;
|
||||
;; (mf/defc modal-create-color
|
||||
;; [{:keys [on-accept on-cancel] :as ctx}]
|
||||
;; (let [state (mf/use-state { :current-color "#406280" })]
|
||||
;; (letfn [(accept [event]
|
||||
;; (dom/prevent-default event)
|
||||
;; (modal/hide!)
|
||||
;; (when on-accept (on-accept (:current-color @state))))
|
||||
;;
|
||||
;; (cancel [event]
|
||||
;; (dom/prevent-default event)
|
||||
;; (modal/hide!)
|
||||
;; (when on-cancel (on-cancel)))]
|
||||
;; [:div.modal-create-color
|
||||
;; [:h3.modal-create-color-title (tr "modal.create-color.new-color")]
|
||||
;; [:& colorpicker {:value (:current-color @state)
|
||||
;; :colors (into-array @most-used-colors)
|
||||
;; :on-change #(swap! state assoc :current-color %)}]
|
||||
;;
|
||||
;; [:input.btn-primary {:type "button"
|
||||
;; :value (tr "ds.button.save")
|
||||
;; :on-click accept}]
|
||||
;;
|
||||
;; [:a.close {:href "#" :on-click cancel} i/close]])))
|
||||
;;
|
||||
;; (defn create-library [section team-id]
|
||||
;; (let [name (str (str (str/title (name section)) " " (gensym "Library ")))]
|
||||
;; (st/emit! (dlib/create-library section team-id name))))
|
||||
;;
|
||||
;; (defmulti create-item (fn [x _ _] x))
|
||||
;;
|
||||
;; (defmethod create-item :icons [_ library-id files]
|
||||
;; (st/emit! (dico/create-icons library-id files)))
|
||||
;;
|
||||
;; (defmethod create-item :images [_ library-id files]
|
||||
;; (st/emit! (dimg/create-images library-id files)))
|
||||
;;
|
||||
;; (defmethod create-item :palettes [_ library-id]
|
||||
;; (letfn [(dispatch-color [color]
|
||||
;; (st/emit! (dcol/create-color library-id color)))]
|
||||
;; (modal/show! modal-create-color {:on-accept dispatch-color})))
|
||||
;;
|
||||
;; (mf/defc library-header
|
||||
;; [{:keys [section team-id] :as props}]
|
||||
;; (let [icons? (= section :icons)
|
||||
;; images? (= section :images)
|
||||
;; palettes? (= section :palettes)
|
||||
;; locale (i18n/use-locale)]
|
||||
;; [:header#main-bar.main-bar
|
||||
;; [:h1.dashboard-title "Libraries"]
|
||||
;; [:nav.library-header-navigation
|
||||
;; [:a.library-header-navigation-item
|
||||
;; {:class-name (when icons? "current")
|
||||
;; :on-click #(st/emit! (rt/nav :dashboard-library-icons-index {:team-id team-id}))}
|
||||
;; (t locale "dashboard.library.menu.icons")]
|
||||
;; [:a.library-header-navigation-item
|
||||
;; {:class-name (when images? "current")
|
||||
;; :on-click #(st/emit! (rt/nav :dashboard-library-images-index {:team-id team-id}))}
|
||||
;; (t locale "dashboard.library.menu.images")]
|
||||
;; [:a.library-header-navigation-item
|
||||
;; {:class-name (when palettes? "current")
|
||||
;; :on-click #(st/emit! (rt/nav :dashboard-library-palettes-index {:team-id team-id}))}
|
||||
;; (t locale "dashboard.library.menu.palettes")]]]))
|
||||
;;
|
||||
;; (mf/defc library-sidebar
|
||||
;; [{:keys [section items team-id library-id]}]
|
||||
;; (let [locale (i18n/use-locale)]
|
||||
;; [:aside.library-sidebar
|
||||
;; [:button.btn-primary.btn-small
|
||||
;; {:type "button"
|
||||
;; :on-click #(create-library section team-id)}
|
||||
;; (t locale (str "dashboard.library.add-library." (name section)))]
|
||||
;; [:ul.library-sidebar-list
|
||||
;; (for [item items]
|
||||
;; [:li.library-sidebar-list-element
|
||||
;; {:key (:id item)
|
||||
;; :class-name (when (= library-id (:id item)) "current")
|
||||
;; :on-click
|
||||
;; (fn []
|
||||
;; (let [path (keyword (str "dashboard-library-" (name section)))]
|
||||
;; (dlib/retrieve-libraries :icons (:id item))
|
||||
;; (st/emit! (rt/nav path {:team-id team-id :library-id (:id item)}))))}
|
||||
;; [:& editable-label {:value (:name item)
|
||||
;; :on-change #(st/emit! (dlib/rename-library section team-id library-id %))}]
|
||||
;; ])]]))
|
||||
;;
|
||||
;; (mf/defc library-top-menu
|
||||
;; [{:keys [selected section library-id team-id on-delete-selected]}]
|
||||
;; (let [state (mf/use-state {:is-open false
|
||||
;; :editing-name false})
|
||||
;; locale (i18n/use-locale)
|
||||
;; stop-editing #(swap! state assoc :editing-name false)]
|
||||
;; [:header.library-top-menu
|
||||
;; [:div.library-top-menu-current-element
|
||||
;; [:& editable-label {:edit (:editing-name @state)
|
||||
;; :on-change #(do
|
||||
;; (stop-editing)
|
||||
;; (st/emit! (dlib/rename-library section team-id library-id %)))
|
||||
;; :on-cancel #(swap! state assoc :editing-name false)
|
||||
;; :class-name "library-top-menu-current-element-name"
|
||||
;; :value (:name selected)}]
|
||||
;; [:a.library-top-menu-current-action
|
||||
;; { :on-click #(swap! state update :is-open not)}
|
||||
;; [:span i/arrow-down]]
|
||||
;; [:& context-menu
|
||||
;; {:show (:is-open @state)
|
||||
;; :on-close #(swap! state update :is-open not)
|
||||
;; :options [[(t locale "ds.button.rename")
|
||||
;; #(swap! state assoc :editing-name true)]
|
||||
;;
|
||||
;; [(t locale "ds.button.delete")
|
||||
;; (fn []
|
||||
;; (let [path (keyword (str "dashboard-library-" (name section) "-index"))]
|
||||
;; (modal/show!
|
||||
;; confirm-dialog
|
||||
;; {:on-accept #(do
|
||||
;; (st/emit! (dlib/delete-library section team-id library-id))
|
||||
;; (st/emit! (rt/nav path {:team-id team-id})))
|
||||
;; :message "Are you sure you want to delete this library?"
|
||||
;; :accept-text "Delete"})))]]}]]
|
||||
;;
|
||||
;; [:div.library-top-menu-actions
|
||||
;; (when on-delete-selected
|
||||
;; [:a.library-top-menu-actions-delete
|
||||
;; {:on-click on-delete-selected}
|
||||
;; i/trash])
|
||||
;;
|
||||
;; (if (= section :palettes)
|
||||
;; [:button.btn-secondary.btn-small
|
||||
;; {:on-click #(create-item section library-id)}
|
||||
;; (t locale (str "dashboard.library.add-item." (name section)))]
|
||||
;;
|
||||
;; [:& file-uploader {:accept (case section
|
||||
;; :images "image/jpeg,image/png,image/webp"
|
||||
;; :icons "image/svg+xml"
|
||||
;; "")
|
||||
;; :multi true
|
||||
;; :label-text (t locale (str "dashboard.library.add-item." (name section)))
|
||||
;; :label-class "btn-secondary btn-small"
|
||||
;; :input-id "file-upload"
|
||||
;; :on-selected #(create-item section library-id %)}])]]))
|
||||
;;
|
||||
;; (mf/defc library-icon-card
|
||||
;; [{:keys [item on-select on-unselect on-delete]}]
|
||||
;; (let [{:keys [id name url content metadata library-id modified-at]} item
|
||||
;; locale (i18n/use-locale)
|
||||
;; state (mf/use-state {:is-open false :selected false})
|
||||
;; time (dt/timeago modified-at {:locale locale})
|
||||
;; handle-change (fn []
|
||||
;; (swap! state update :selected not)
|
||||
;; (if (:selected @state)
|
||||
;; (when on-unselect (on-unselect id))
|
||||
;; (when on-select (on-select id))))]
|
||||
;; [:div.library-card.library-icon
|
||||
;; [:div.input-checkbox.check-primary
|
||||
;; [:input {:type "checkbox"
|
||||
;; :id (str "icon-" id)
|
||||
;; :on-change handle-change
|
||||
;; :value (:selected @state)}]
|
||||
;; [:label {:for (str "icon-" id)}]]
|
||||
;; [:div.library-card-image
|
||||
;; [:svg {:view-box (->> metadata :view-box (str/join " "))
|
||||
;; :width (:width metadata)
|
||||
;; :height (:height metadata)
|
||||
;; :dangerouslySetInnerHTML {:__html content}}]]
|
||||
;;
|
||||
;; [:div.library-card-footer
|
||||
;; [:div.library-card-footer-name name]
|
||||
;; [:div.library-card-footer-timestamp time]
|
||||
;; [:div.library-card-footer-menu
|
||||
;; { :on-click #(swap! state update :is-open not) }
|
||||
;; i/actions]
|
||||
;; [:& context-menu
|
||||
;; {:show (:is-open @state)
|
||||
;; :on-close #(swap! state update :is-open not)
|
||||
;; :options [[(t locale "ds.button.delete")
|
||||
;; (fn []
|
||||
;; (modal/show!
|
||||
;; confirm-dialog
|
||||
;; {:on-accept #(do
|
||||
;; (st/emit! (dlib/delete-item :icons library-id id))
|
||||
;; (on-delete id))
|
||||
;; :message "Are you sure you want to delete this icon?"
|
||||
;; :accept-text "Delete"}))]]}]]]))
|
||||
;;
|
||||
;; (mf/defc library-image-card
|
||||
;; [{:keys [item on-select on-unselect on-delete]}]
|
||||
;; (let [{:keys [id name thumb-uri library-id modified-at]} item
|
||||
;; locale (i18n/use-locale)
|
||||
;; state (mf/use-state {:is-open false :selected false})
|
||||
;; time (dt/timeago modified-at {:locale locale})
|
||||
;; handle-change (fn []
|
||||
;; (swap! state update :selected not)
|
||||
;; (if (:selected @state)
|
||||
;; (when on-unselect (on-unselect id))
|
||||
;; (when on-select (on-select id))))]
|
||||
;; [:div.library-card.library-image
|
||||
;; [:div.input-checkbox.check-primary
|
||||
;; [:input {:type "checkbox"
|
||||
;; :id (str "image-" id)
|
||||
;; :on-change handle-change
|
||||
;; :value (:selected @state)}]
|
||||
;; [:label {:for (str "image-" id)}]]
|
||||
;; [:div.library-card-image
|
||||
;; [:img {:src thumb-uri}]]
|
||||
;; [:div.library-card-footer
|
||||
;; [:div.library-card-footer-name name]
|
||||
;; [:div.library-card-footer-timestamp time]
|
||||
;; [:div.library-card-footer-menu
|
||||
;; { :on-click #(swap! state update :is-open not) }
|
||||
;; i/actions]
|
||||
;; [:& context-menu
|
||||
;; {:show (:is-open @state)
|
||||
;; :on-close #(swap! state update :is-open not)
|
||||
;; :options [[(t locale "ds.button.delete")
|
||||
;; (fn []
|
||||
;; (modal/show!
|
||||
;; confirm-dialog
|
||||
;; {:on-accept #(do
|
||||
;; (st/emit! (dlib/delete-item :images library-id id))
|
||||
;; (on-delete id))
|
||||
;; :message "Are you sure you want to delete this image?"
|
||||
;; :accept-text "Delete"}))]]}]]]))
|
||||
;;
|
||||
;; (mf/defc library-color-card
|
||||
;; [{:keys [item on-select on-unselect on-delete]}]
|
||||
;; (let [{:keys [id content library-id modified-at]} item
|
||||
;; locale (i18n/use-locale)
|
||||
;; state (mf/use-state {:is-open false :selected false})
|
||||
;; handle-change (fn []
|
||||
;; (swap! state update :selected not)
|
||||
;; (if (:selected @state)
|
||||
;; (when on-unselect (on-unselect id))
|
||||
;; (when on-select (on-select id))))]
|
||||
;; (when content
|
||||
;; [:div.library-card.library-color
|
||||
;; [:div.input-checkbox.check-primary
|
||||
;; [:input {:type "checkbox"
|
||||
;; :id (str "color-" id)
|
||||
;; :on-change handle-change
|
||||
;; :value (:selected @state)}]
|
||||
;; [:label {:for (str "color-" id)}]]
|
||||
;; [:div.library-card-image
|
||||
;; { :style { :background-color content }}]
|
||||
;; [:div.library-card-footer
|
||||
;; [:div.library-card-footer-name content ]
|
||||
;; [:div.library-card-footer-color
|
||||
;; [:span.library-card-footer-color-label "RGB"]
|
||||
;; [:span.library-card-footer-color-rgb (str/join " " (uc/hex->rgb content))]]
|
||||
;; [:div.library-card-footer-menu
|
||||
;; { :on-click #(swap! state update :is-open not) }
|
||||
;; i/actions]
|
||||
;; [:& context-menu
|
||||
;; {:show (:is-open @state)
|
||||
;; :on-close #(swap! state update :is-open not)
|
||||
;; :options [[(t locale "ds.button.delete")
|
||||
;; (fn []
|
||||
;; (modal/show!
|
||||
;; confirm-dialog
|
||||
;; {:on-accept #(do
|
||||
;; (st/emit! (dlib/delete-item :palettes library-id id))
|
||||
;; (on-delete id))
|
||||
;; :message "Are you sure you want to delete this color?"
|
||||
;; :accept-text "Delete"}))]]}]]])))
|
||||
;;
|
||||
;; (defn- make-libraries-ref
|
||||
;; [section team-id]
|
||||
;; #(-> (l/in [:library section team-id])
|
||||
;; (l/derived st/state =)))
|
||||
;;
|
||||
;; (defn- make-library-items-ref
|
||||
;; [section library-id]
|
||||
;; #(-> (l/in [:library-items section library-id])
|
||||
;; (l/derived st/state =)))
|
||||
;;
|
||||
;; (def last-deleted-library-ref
|
||||
;; (-> (l/in [:library :last-deleted-library])
|
||||
;; (l/derived st/state =)))
|
||||
;;
|
||||
;; (mf/defc library-page
|
||||
;; [{:keys [team-id library-id section]}]
|
||||
;; (let [state (mf/use-state {:selected #{}})
|
||||
;; libs-ref (mf/use-memo
|
||||
;; (mf/deps section team-id)
|
||||
;; (make-libraries-ref section team-id))
|
||||
;;
|
||||
;; libraries (mf/deref libs-ref)
|
||||
;; items-ref (mf/use-memo
|
||||
;; (mf/deps section library-id)
|
||||
;; (make-library-items-ref section library-id))
|
||||
;;
|
||||
;; items (mf/deref items-ref)
|
||||
;;
|
||||
;; last-deleted-library (mf/deref last-deleted-library-ref)
|
||||
;; selected-library (first (filter #(= (:id %) library-id) libraries))
|
||||
;; ]
|
||||
;;
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps libraries)
|
||||
;; #(if (and (nil? library-id) (> (count libraries) 0))
|
||||
;; (let [path (keyword (str "dashboard-library-" (name section)))]
|
||||
;; (st/emit! (rt/nav path {:team-id team-id :library-id (:id (first libraries))})))))
|
||||
;;
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps libraries)
|
||||
;; #(if (and library-id (not (some (fn [{id :id}] (= library-id id)) libraries)))
|
||||
;; (let [path (keyword (str "dashboard-library-" (name section) "-index"))]
|
||||
;; (st/emit! (rt/nav path {:team-id team-id})))))
|
||||
;;
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps section team-id)
|
||||
;; #(st/emit! (dlib/retrieve-libraries section team-id)))
|
||||
;;
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps library-id last-deleted-library)
|
||||
;; #(when (and library-id (not= last-deleted-library library-id))
|
||||
;; (st/emit! (dlib/retrieve-library-data section library-id))))
|
||||
;;
|
||||
;; [:div.library-page
|
||||
;; [:& library-header {:section section :team-id team-id}]
|
||||
;; [:& library-sidebar {:items libraries :team-id team-id :library-id library-id :section section}]
|
||||
;;
|
||||
;; (if library-id
|
||||
;; [:section.library-content
|
||||
;; [:& library-top-menu
|
||||
;; {:selected selected-library
|
||||
;; :section section
|
||||
;; :library-id library-id
|
||||
;; :team-id team-id
|
||||
;; :on-delete-selected
|
||||
;; (when-not (empty? (:selected @state))
|
||||
;; (fn []
|
||||
;; (modal/show!
|
||||
;; confirm-dialog
|
||||
;; {:on-accept #(do (st/emit! (dlib/batch-delete-item section library-id (:selected @state)))
|
||||
;; (swap! state assoc :selected #{}))
|
||||
;; :message (str "Are you sure you want to delete " (-> @state :selected count) " items?")
|
||||
;; :accept-text "Delete"})))}]
|
||||
;; [:*
|
||||
;; (if (> (count items) 0)
|
||||
;; [:div.library-page-cards-container
|
||||
;; (for [item items]
|
||||
;; (let [item (assoc item :key (:id item))
|
||||
;; props {:item item
|
||||
;; :key (:id item)
|
||||
;; :on-select #(swap! state update :selected conj %)
|
||||
;; :on-unselect #(swap! state update :selected disj %)
|
||||
;; :on-delete #(swap! state update :selected disj %)}]
|
||||
;; (case section
|
||||
;; :icons [:& library-icon-card props]
|
||||
;; :images [:& library-image-card props]
|
||||
;; :palettes [:& library-color-card props])))]
|
||||
;; [:div.library-content-empty
|
||||
;; [:p.library-content-empty-text "You still have no elements in this library"]])]]
|
||||
;;
|
||||
;; [:div.library-content-empty
|
||||
;; [:p.library-content-empty-text "You still have no image libraries."]])]))
|
|
@ -114,7 +114,7 @@
|
|||
;; (= selected-team-id (:default-team-id profile)))
|
||||
locale (i18n/use-locale)]
|
||||
[:div.sidebar-team
|
||||
[:ul.library-elements.library-common
|
||||
[:ul.dashboard-elements.dashboard-common
|
||||
[:li.recent-projects
|
||||
{:on-click #(st/emit! (rt/nav :dashboard-team {:team-id team-id}))
|
||||
:class-name (when home? "current")}
|
||||
|
@ -139,7 +139,7 @@
|
|||
[:a.btn-icon-light.btn-small {:on-click #(st/emit! dsh/create-project)}
|
||||
i/close]]
|
||||
|
||||
[:ul.library-elements
|
||||
[:ul.dashboard-elements
|
||||
[:& sidebar-projects
|
||||
{:selected-team-id selected-team-id
|
||||
:selected-project-id selected-project-id
|
||||
|
@ -178,8 +178,8 @@
|
|||
(dom/focus! search-input)
|
||||
(debounced-emit! (rt/nav :dashboard-search {:team-id team-id} {}))))]
|
||||
|
||||
[:div.library-bar
|
||||
[:div.library-bar-inside
|
||||
[:div.dashboard-sidebar
|
||||
[:div.dashboard-sidebar-inside
|
||||
[:form.dashboard-search
|
||||
[:input.input-text
|
||||
{:key :images-search-box
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
{:keys [id x y width height rotation metadata]} shape
|
||||
transform (geom/transform-matrix shape)
|
||||
uri (:uri metadata)
|
||||
;; uri (if (or (> (:thumb-width metadata) width)
|
||||
;; (> (:thumb-height metadata) height))
|
||||
;; (:thumb-uri metadata)
|
||||
;; (:uri metadata))
|
||||
|
||||
props (-> (attrs/extract-style-attrs shape)
|
||||
(obj/merge!
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
[okulary.core :as l]
|
||||
[rumext.alpha :as mf]
|
||||
[uxbox.common.math :as mth]
|
||||
[uxbox.main.data.library :as dlib]
|
||||
;; [uxbox.main.data.library :as dlib]
|
||||
[uxbox.main.data.workspace :as udw]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.main.ui.components.context-menu :refer [context-menu]]
|
||||
|
@ -112,8 +112,8 @@
|
|||
|
||||
handle-click
|
||||
(mf/use-callback
|
||||
(fn [library]
|
||||
(st/emit! (dlib/select-library :palettes (:id library)))))]
|
||||
(fn [library]))]
|
||||
;; (st/emit! (dlib/select-library :palettes (:id library)))))]
|
||||
|
||||
(mf/use-layout-effect
|
||||
#(let [dom (mf/ref-val container)
|
||||
|
@ -128,8 +128,8 @@
|
|||
(mf/use-effect
|
||||
(mf/deps selected)
|
||||
(fn []
|
||||
(when selected
|
||||
(st/emit! (dlib/retrieve-library-data :palettes selected)))))
|
||||
(when selected)))
|
||||
;; (st/emit! (dlib/retrieve-library-data :palettes selected)))))
|
||||
|
||||
[:div.color-palette {:class (when left-sidebar? "left-sidebar-open")}
|
||||
[:& context-menu
|
||||
|
@ -164,9 +164,9 @@
|
|||
(:id (first palettes)))]
|
||||
(mf/use-effect
|
||||
(mf/deps team-id)
|
||||
(fn []
|
||||
(st/emit! (dlib/retrieve-libraries :palettes)
|
||||
(dlib/retrieve-libraries :palettes team-id))))
|
||||
(fn []))
|
||||
;; (st/emit! (dlib/retrieve-libraries :palettes)
|
||||
;; (dlib/retrieve-libraries :palettes team-id))))
|
||||
|
||||
[:& palette {:left-sidebar? left-sidebar?
|
||||
:selected selected
|
||||
|
|
|
@ -126,11 +126,11 @@
|
|||
(t locale "workspace.header.menu.show-palette"))]
|
||||
[:span.shortcut "Ctrl+p"]]
|
||||
|
||||
[:li {:on-click #(st/emit! (dw/toggle-layout-flags :libraries))}
|
||||
[:li {:on-click #(st/emit! (dw/toggle-layout-flags :assets))}
|
||||
[:span
|
||||
(if (contains? layout :libraries)
|
||||
(t locale "workspace.header.menu.hide-libraries")
|
||||
(t locale "workspace.header.menu.show-libraries"))]
|
||||
(if (contains? layout :assets)
|
||||
(t locale "workspace.header.menu.hide-assets")
|
||||
(t locale "workspace.header.menu.show-assets"))]
|
||||
[:span.shortcut "Ctrl+i"]]
|
||||
|
||||
[:li {:on-click #(st/emit! (dw/toggle-layout-flags :dynamic-alignment))}
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
:metadata {:width (:width image)
|
||||
:height (:height image)
|
||||
:uri (:uri image)}}
|
||||
;; :thumb-width (:thumb-width image)
|
||||
;; :thumb-height (:thumb-height image)
|
||||
;; :thumb-uri (:thumb-uri image)}}
|
||||
aspect-ratio (/ (:width image) (:height image))]
|
||||
(st/emit! (dw/create-and-add-shape :image shape aspect-ratio))))
|
||||
|
||||
|
@ -96,11 +93,6 @@
|
|||
:class (when (contains? layout :layers) "selected")
|
||||
:on-click #(st/emit! (dw/toggle-layout-flags :sitemap :layers))}
|
||||
i/layers]
|
||||
;; [:li.tooltip.tooltip-right
|
||||
;; {:alt (t locale "workspace.toolbar.libraries")
|
||||
;; :class (when (contains? layout :libraries) "selected")
|
||||
;; :on-click #(st/emit! (dw/toggle-layout-flags :libraries))}
|
||||
;; i/icon-set]
|
||||
[:li.tooltip.tooltip-right
|
||||
{:alt (t locale "workspace.toolbar.assets")
|
||||
:class (when (contains? layout :assets) "selected")
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
[uxbox.main.ui.workspace.sidebar.layers :refer [layers-toolbox]]
|
||||
[uxbox.main.ui.workspace.sidebar.options :refer [options-toolbox]]
|
||||
[uxbox.main.ui.workspace.sidebar.sitemap :refer [sitemap-toolbox]]
|
||||
[uxbox.main.ui.workspace.sidebar.libraries :refer [libraries-toolbox]]
|
||||
[uxbox.main.ui.workspace.sidebar.assets :refer [assets-toolbox]]))
|
||||
|
||||
;; --- Left Sidebar (Component)
|
||||
|
@ -34,8 +33,6 @@
|
|||
[:& history-toolbox])
|
||||
(when (contains? layout :layers)
|
||||
[:& layers-toolbox {:page page}])
|
||||
(when (contains? layout :libraries)
|
||||
[:& libraries-toolbox])
|
||||
(when (contains? layout :assets)
|
||||
[:& assets-toolbox])]])
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
[uxbox.common.uuid :as uuid]
|
||||
[uxbox.util.i18n :as i18n :refer [tr]]
|
||||
[uxbox.util.data :refer [classnames]]
|
||||
[uxbox.main.data.library :as dlib]
|
||||
[uxbox.main.ui.modal :as modal]
|
||||
[uxbox.main.ui.colorpicker :refer [colorpicker most-used-colors]]
|
||||
[uxbox.main.ui.components.tab-container :refer [tab-container tab-element]]
|
||||
|
@ -58,18 +57,19 @@
|
|||
(modal/hide!)
|
||||
(when on-cancel (on-cancel)))]
|
||||
|
||||
[:div.modal-create-color
|
||||
[:h3.modal-create-color-title (tr "modal.create-color.new-color")]
|
||||
[:& colorpicker {:value (:current-color @state)
|
||||
:colors (into-array @most-used-colors)
|
||||
:disable-opacity true
|
||||
:on-change #(swap! state assoc :current-color %)}]
|
||||
[:div.modal-overlay.transparent
|
||||
[:div.modal-create-color
|
||||
[:h3.modal-create-color-title (tr "modal.create-color.new-color")]
|
||||
[:& colorpicker {:value (:current-color @state)
|
||||
:colors (into-array @most-used-colors)
|
||||
:disable-opacity true
|
||||
:on-change #(swap! state assoc :current-color %)}]
|
||||
|
||||
[:input.btn-primary {:type "button"
|
||||
:value (tr "ds.button.save")
|
||||
:on-click accept}]
|
||||
[:input.btn-primary {:type "button"
|
||||
:value (tr "ds.button.save")
|
||||
:on-click accept}]
|
||||
|
||||
[:a.close {:href "#" :on-click cancel} i/close]])))
|
||||
[:a.close {:href "#" :on-click cancel} i/close]]])))
|
||||
|
||||
(mf/defc graphics-box
|
||||
[{:keys [library-id media-objects] :as props}]
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
;; (ns uxbox.main.ui.workspace.sidebar.libraries
|
||||
;; (:require
|
||||
;; [okulary.core :as l]
|
||||
;; [cuerdas.core :as str]
|
||||
;; [rumext.alpha :as mf]
|
||||
;; [uxbox.common.data :as d]
|
||||
;; [uxbox.common.pages :as cp]
|
||||
;; [uxbox.common.geom.shapes :as geom]
|
||||
;; [uxbox.common.geom.point :as gpt]
|
||||
;; [uxbox.main.ui.icons :as i]
|
||||
;; [uxbox.main.data.workspace :as dw]
|
||||
;; [uxbox.main.refs :as refs]
|
||||
;; [uxbox.main.store :as st]
|
||||
;; [uxbox.main.ui.keyboard :as kbd]
|
||||
;; [uxbox.main.ui.shapes.icon :as icon]
|
||||
;; [uxbox.util.dom :as dom]
|
||||
;; [uxbox.util.dom.dnd :as dnd]
|
||||
;; [uxbox.util.timers :as timers]
|
||||
;; [uxbox.common.uuid :as uuid]
|
||||
;; [uxbox.util.i18n :as i18n :refer [tr]]
|
||||
;; [uxbox.util.data :refer [classnames]]
|
||||
;; [uxbox.main.ui.components.tab-container :refer [tab-container tab-element]]
|
||||
;; [uxbox.main.data.library :as dlib]
|
||||
;; [uxbox.main.ui.components.context-menu :refer [context-menu]]))
|
||||
;;
|
||||
;; ;; --- Refs
|
||||
;;
|
||||
;; (defn libraries-ref [section]
|
||||
;; (-> (l/in [:library section])
|
||||
;; (l/derived st/state)))
|
||||
;;
|
||||
;; (defn selected-items-ref [section library-id]
|
||||
;; (-> (l/in [:library-items section library-id])
|
||||
;; (l/derived st/state)))
|
||||
;;
|
||||
;; (defn selected-library-ref [section]
|
||||
;; (-> (l/in [:library-selected section])
|
||||
;; (l/derived st/state)))
|
||||
;;
|
||||
;; (defn selected-filter-ref [section]
|
||||
;; (-> (l/in [:library-filter section])
|
||||
;; (l/derived st/state)))
|
||||
;;
|
||||
;; (defmulti shape-from-item (fn [type _] type))
|
||||
;;
|
||||
;; (defmethod shape-from-item :icons [_ item]
|
||||
;; (-> (cp/make-minimal-shape :icon)
|
||||
;; (merge item)
|
||||
;; (geom/resize (-> item :metadata :width) (-> item :metadata :height))
|
||||
;; (geom/absolute-move (gpt/point 0 0))))
|
||||
;;
|
||||
;; (defmethod shape-from-item :images [_ item]
|
||||
;; (let [metadata (select-keys item [:width :height :thumb-width
|
||||
;; :thumb-height :thumb-uri :uri])]
|
||||
;; (-> (cp/make-minimal-shape :image)
|
||||
;; (merge item)
|
||||
;; (assoc :metadata metadata)
|
||||
;; (geom/resize (-> item :width) (-> item :height))
|
||||
;; (geom/absolute-move (gpt/point 0 0)))))
|
||||
;;
|
||||
;; ;; --- Components
|
||||
;;
|
||||
;; (mf/defc library-tab [{:keys [libraries section]}]
|
||||
;; (when (and libraries (-> libraries count (> 0)))
|
||||
;; (let [state (mf/use-state {:drag-style false})
|
||||
;; first-id (-> libraries first :id)
|
||||
;; current-selection (or (mf/deref (selected-library-ref section)) first-id)]
|
||||
;;
|
||||
;; ;; Check if the current selection is in the list of libraries
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps libraries)
|
||||
;; #(when (not (some (fn [it] (= current-selection (-> it :id))) libraries))
|
||||
;; (st/emit! (dlib/select-library section first-id))))
|
||||
;;
|
||||
;; ;; Retrieve the library data given the current selected library
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps current-selection)
|
||||
;; #(st/emit! (dlib/retrieve-library-data section current-selection)))
|
||||
;;
|
||||
;; [:div.library-tab
|
||||
;; {:class (classnames :icons-tab (= section :icons)
|
||||
;; :images-tab (= section :images))}
|
||||
;; [:select.input-select.library-tab-libraries
|
||||
;; {:value current-selection
|
||||
;; :on-change #(st/emit! (dlib/select-library section (-> % dom/get-target dom/get-value uuid)))}
|
||||
;; (for [library libraries]
|
||||
;; [:option.library-tab-libraries-item
|
||||
;; {:key (:id library)
|
||||
;; :value (:id library)}
|
||||
;; (:name library)])]
|
||||
;; [:div.library-tab-content
|
||||
;; (let [items (mf/deref (selected-items-ref section current-selection))]
|
||||
;; (for [item items]
|
||||
;; [:div.library-tab-element
|
||||
;; {:draggable true
|
||||
;; :class (classnames :is-dragging (:drag-style @state))
|
||||
;; :key (str (:id item))
|
||||
;; :on-drag-start (fn [event]
|
||||
;; (swap! state assoc :drag-style true)
|
||||
;; (dnd/set-data! event "uxbox/shape" (shape-from-item section item))
|
||||
;; (dnd/set-allowed-effect! event "move")
|
||||
;; ;; This state is so we can give custom css to the dragging
|
||||
;; (timers/schedule #(swap! state assoc :drag-style false)))}
|
||||
;; (if (= section :icons)
|
||||
;; [:svg {:view-box (->> item :metadata :view-box (str/join " "))
|
||||
;; :width (-> item :metadata :width)
|
||||
;; :height (-> item :metadata :height)
|
||||
;; :dangerouslySetInnerHTML {:__html (:content item)}}]
|
||||
;; [:img {:draggable false
|
||||
;; :src (:thumb-uri item)}])
|
||||
;; [:span.library-tab-element-name (:name item)]]))]])))
|
||||
;;
|
||||
;; (mf/defc libraries-toolbox
|
||||
;; [{:keys [key]}]
|
||||
;; (let [state (mf/use-state {:menu-open false})
|
||||
;; selected-filter (fn [section] (or (mf/deref (selected-filter-ref section)) :all))
|
||||
;; team-id (-> refs/workspace-project mf/deref :team-id)
|
||||
;;
|
||||
;; filter-to-str {:all (tr "workspace.library.all")
|
||||
;; :own (tr "workspace.library.own")
|
||||
;; :store (tr "workspace.library.store")}
|
||||
;;
|
||||
;; select-option
|
||||
;; (fn [option]
|
||||
;; (st/emit!
|
||||
;; (dlib/change-library-filter :icons option)
|
||||
;; (dlib/change-library-filter :images option)))
|
||||
;;
|
||||
;; filter-libraries
|
||||
;; (fn [section libraries]
|
||||
;; (case (selected-filter section)
|
||||
;; :all (-> libraries vals flatten)
|
||||
;; :own (libraries team-id)
|
||||
;; :store (libraries uuid/zero)))
|
||||
;;
|
||||
;; get-libraries
|
||||
;; (fn [section] (->> (libraries-ref section)
|
||||
;; mf/deref
|
||||
;; (filter-libraries section)))]
|
||||
;;
|
||||
;; (mf/use-effect
|
||||
;; (mf/deps team-id)
|
||||
;; #(when team-id
|
||||
;; (st/emit! (dlib/retrieve-libraries :icons)
|
||||
;; (dlib/retrieve-libraries :images)
|
||||
;; (dlib/retrieve-libraries :icons team-id)
|
||||
;; (dlib/retrieve-libraries :images team-id))))
|
||||
;;
|
||||
;; [:div#libraries.tool-window
|
||||
;; [:div.libraries-window-bar
|
||||
;; [:div.libraries-window-bar-title (tr "workspace.library.libraries")]
|
||||
;; [:div.libraries-window-bar-options
|
||||
;; {:on-click #(swap! state assoc :menu-open true)}
|
||||
;; (filter-to-str (selected-filter :icons))
|
||||
;; [:button
|
||||
;; {
|
||||
;; :type "button"}
|
||||
;; i/arrow-slide
|
||||
;; [:& context-menu
|
||||
;; {:selectable true
|
||||
;; :show (:menu-open @state)
|
||||
;; :selected (filter-to-str (selected-filter :icons))
|
||||
;; :on-close #(swap! state assoc :menu-open false)
|
||||
;; :options (mapv (fn [[key val]] [val #(select-option key)]) filter-to-str)}]]]]
|
||||
;;
|
||||
;; [:div.tool-window-content
|
||||
;; [:& tab-container {}
|
||||
;; [:& tab-element
|
||||
;; {:id :icons :title (tr "workspace.library.icons")}
|
||||
;; [:& library-tab {:section :icons
|
||||
;; :libraries (get-libraries :icons) }]]
|
||||
;;
|
||||
;; [:& tab-element
|
||||
;; {:id :images :title (tr "workspace.library.images")}
|
||||
;; [:& library-tab {:section :images
|
||||
;; :libraries (get-libraries :images)}]]]]]))
|
||||
;;
|
||||
;;
|
|
@ -1,55 +1,55 @@
|
|||
[
|
||||
;; Icons
|
||||
{:name "Material Design (Action)"
|
||||
:images {:path "./icons/material-action"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-action"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Alert)"
|
||||
:images {:path "./icons/material-alert"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-alert"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Av)"
|
||||
:images {:path "./icons/material-av"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-av"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Content)"
|
||||
:images {:path "./icons/material-content"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-content"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Device)"
|
||||
:images {:path "./icons/material-device"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-device"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Editor)"
|
||||
:images {:path "./icons/material-editor"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-editor"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (File)"
|
||||
:images {:path "./icons/material-file"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-file"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Hardware)"
|
||||
:images {:path "./icons/material-hardware"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-hardware"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Image)"
|
||||
:images {:path "./icons/material-image"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-image"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Maps)"
|
||||
:images {:path "./icons/material-maps"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-maps"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Navigation)"
|
||||
:images {:path "./icons/material-navigation"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-navigation"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Notification)"
|
||||
:images {:path "./icons/material-notification"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-notification"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Places)"
|
||||
:images {:path "./icons/material-places"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-places"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Social)"
|
||||
:images {:path "./icons/material-social"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-social"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
{:name "Material Design (Toggle)"
|
||||
:images {:path "./icons/material-toggle"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
:graphics {:path "./icons/material-toggle"
|
||||
:regex #"^.*_48px\.svg$"}}
|
||||
|
||||
;; Images
|
||||
{:name "Unsplash"
|
||||
:images {:path "./images/unsplash"
|
||||
:regex #"^.*\.jpg$"}
|
||||
:graphics {:path "./images/unsplash"
|
||||
:regex #"^.*\.jpg$"}
|
||||
:colors ["Chateau Green" "#419860"
|
||||
"Toast" "#987567"
|
||||
"Confetti" "#EAC75B"
|
||||
|
|
Loading…
Reference in a new issue