🎉 Add initial version of viewer.

This commit is contained in:
Andrey Antukh 2020-04-02 17:08:24 +02:00
parent b3e6566bd8
commit 1a3a48e4de
24 changed files with 1109 additions and 92 deletions

View file

@ -16,6 +16,7 @@
[rumext.alpha :as mf]
[uxbox.builtins.icons :as i]
[uxbox.common.exceptions :as ex]
[uxbox.common.data :as d]
[uxbox.main.data.auth :refer [logout]]
[uxbox.main.refs :as refs]
[uxbox.main.store :as st]
@ -25,12 +26,13 @@
[uxbox.main.ui.profile.recovery :refer [profile-recovery-page]]
[uxbox.main.ui.profile.recovery-request :refer [profile-recovery-request-page]]
[uxbox.main.ui.profile.register :refer [profile-register-page]]
[uxbox.main.ui.viewer :refer [viewer-page]]
[uxbox.main.ui.settings :as settings]
[uxbox.main.ui.not-found :refer [not-found-page]]
[uxbox.main.ui.shapes]
[uxbox.main.ui.workspace :as workspace]
[uxbox.util.i18n :refer [tr]]
[uxbox.util.messages :as uum]
[uxbox.util.router :as rt]
[uxbox.util.timers :as ts]))
(def route-iref
@ -49,6 +51,9 @@
["/profile" :settings-profile]
["/password" :settings-password]]
["/view/:page-id/:index" :viewer]
["/not-found" :not-found]
(when *assert*
["/debug/icons-preview" :debug-icons-preview])
@ -78,54 +83,63 @@
[{:keys [error] :as props}]
(let [data (ex-data error)]
(case (:type data)
:not-found [:span "404"]
:not-found [:& not-found-page {:error data}]
[:span "Internal application errror"])))
(mf/defc app
{:wrap [#(wrap-catch % {:fallback app-error})]}
[props]
(let [route (mf/deref route-iref)]
(case (get-in route [:data :name])
:login
(mf/element login-page)
(when route
(case (get-in route [:data :name])
:login
(mf/element login-page)
:profile-register
(mf/element profile-register-page)
:profile-register
(mf/element profile-register-page)
:profile-recovery-request
(mf/element profile-recovery-request-page)
:profile-recovery-request
(mf/element profile-recovery-request-page)
:profile-recovery
(mf/element profile-recovery-page)
:profile-recovery
(mf/element profile-recovery-page)
(:settings-profile
:settings-password)
(mf/element settings/settings #js {:route route})
:viewer
(let [index (d/parse-integer (get-in route [:params :path :index]))
page-id (uuid (get-in route [:params :path :page-id]))]
[:& viewer-page {:page-id page-id
:index index}])
:debug-icons-preview
(when *assert*
(mf/element i/debug-icons-preview))
(:settings-profile
:settings-password)
(mf/element settings/settings #js {:route route})
(:dashboard-search
:dashboard-team
:dashboard-project
:dashboard-library-icons
:dashboard-library-icons-index
:dashboard-library-images
:dashboard-library-images-index
:dashboard-library-palettes
:dashboard-library-palettes-index)
(mf/element dashboard #js {:route route})
:debug-icons-preview
(when *assert*
(mf/element i/debug-icons-preview))
:workspace
(let [project-id (uuid (get-in route [:params :path :project-id]))
file-id (uuid (get-in route [:params :path :file-id]))
page-id (uuid (get-in route [:params :query :page-id]))]
[:& workspace/workspace {:project-id project-id
:file-id file-id
:page-id page-id
:key file-id}])
nil)))
(:dashboard-search
:dashboard-team
:dashboard-project
:dashboard-library-icons
:dashboard-library-icons-index
:dashboard-library-images
:dashboard-library-images-index
:dashboard-library-palettes
:dashboard-library-palettes-index)
(mf/element dashboard #js {:route route})
:workspace
(let [project-id (uuid (get-in route [:params :path :project-id]))
file-id (uuid (get-in route [:params :path :file-id]))
page-id (uuid (get-in route [:params :query :page-id]))]
[:& workspace/workspace {:project-id project-id
:file-id file-id
:page-id page-id
:key file-id}])
:not-found
[:& not-found-page {}]))))
;; --- Error Handling