-
-
Save ul/992bd5fcd1d27f06337f to your computer and use it in GitHub Desktop.
renders only <div class="out out_1"></div> in freactive develop as for 2df29ccf182541b20568d5f26c1d98104e1ac9c0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns vion.admin.view.app | |
(:require-macros [freactive.macros :refer [rx]] | |
[taoensso.tower :refer [with-tscope]]) | |
(:require [freactive.core :as r] | |
[cljs-time.core :refer [time-now]] | |
[cljs-time.format :refer [formatter unparse]] | |
[vion.view.window :refer [window]] | |
[vion.view.styled-select :refer [styled-select]] | |
[cljs.core.async :as async] | |
[fusion.view.inspector :refer [inspector]])) | |
(def fmt-time (formatter "HH:mm")) | |
(defn user-menu [t state] | |
[:div.h-box.h-box_user | |
[:div.userpic | |
[:a {:href "#"}]] | |
[:i.nav-arr] | |
[:div.drop.drop_user | |
[:div.row | |
[:span.icon-audio-big] | |
[:div.sel-holder | |
(styled-select [{:value "mic1" | |
:text "FIXME Buit-in mic"}] | |
(r/atom nil) | |
identity)]] | |
[:div.row | |
[:span.icon-eye-big] | |
[:div.sel-holder | |
(styled-select [{:value "cam1" | |
:text "FIXME Buit-in cam"}] | |
(r/atom nil) | |
identity)]] | |
[:button.btn.btn_testing (t :device/start-testing)] | |
[:div.drop__dev] | |
[:div.row | |
[:div.sel-holder | |
(let [acd-status (r/cursor state :acd-status) | |
change-fn (fn [x] | |
(async/put! (:telecom/bus @state) [:acd x]))] | |
(styled-select | |
(with-tscope | |
:acd | |
(mapv (fn [k] {:value k :text (t k)}) | |
[:online :ready :in-service :after-service :d-n-d])) | |
acd-status | |
change-fn))]] | |
[:div.drop__dev] | |
[:h3 (t :common/operator)] | |
[:a {:href "/logout"} | |
[:button.btn-purple (t :login/out)]]] | |
]) | |
(def timer (r/atom (time-now))) | |
(defn update-time [time] | |
(js/setTimeout #(reset! time (time-now)) 5000)) | |
(defn clock [] | |
[:strong (rx | |
(update-time timer) | |
(unparse fmt-time @timer))]) | |
(defn incoming-call-window [t state] | |
(window {:title (t :common/information) | |
:content [:div | |
[:div.win__box | |
[:h2.h2 [:i.icon-audio] (t :call/incoming)]] | |
[:div.win__dev] | |
[:div.text-note | |
[:textarea {:value "Somebody to love is calling you."}]] | |
[:div.win__footer | |
[:button.r-btn.r-btn_up | |
{:on-click | |
(fn [_] | |
(async/put! (:telecom/bus @state) [:call/accept]))} | |
[:span]] | |
[:button.r-btn.r-btn_down | |
{:on-click | |
(fn [_] | |
(async/put! (:telecom/bus @state) [:call/reject]))} | |
[:span]] | |
#_[:button.r-btn.r-btn_arr | |
{:on-click (fn [_] (js/alert "Ooops, FIXME"))} | |
[:span]]]] | |
:on-close (fn [e] | |
;; FIXME handle correct hangup | |
(swap! state assoc-in :incoming-call false))})) | |
(defn app [t state] | |
[:div.out.out_1 | |
[:div.out_2 | |
[:header.header | |
[:div.in | |
[:div.h-box | |
[:div.logo-block | |
[:a.logo {:href "#"}] | |
;[:div.drop] | |
] | |
[:div.nav-item | |
[:a.nav-item__text | |
{:href "#"} | |
(t :menu/active) | |
[:i.nav-arr]]] | |
[:div.nav-item | |
[:a.nav-item__text.nav-item__text_yellow | |
{:href "#"} | |
(t :menu/tools) | |
[:i.nav-arr]]]] | |
[:div.h-box.h-box_form | |
[:form {:action "#"} | |
[:input.input-text | |
{:type "text" | |
:placeholder (t :menu/goto)}] | |
[:div.input-plus] | |
[:i.nav-arr]] | |
;[:div.drop.drop_search] | |
] | |
[:div.h-box | |
[:ul.nav | |
[:li [:a.nav__link {:href "#"} | |
[:i.icon-chat] | |
[:span 17] | |
[:strong.mark-count 3]]] | |
[:li [:a.nav__link {:href "#"} | |
[:i.icon-eye] | |
[:span 17] | |
[:strong.mark-count 3]]] | |
[:li [:a.nav__link {:href "#"} | |
[:i.icon-mike] | |
[:span 17] | |
[:strong.mark-count 3]]] | |
[:li [:a.nav__link {:href "#"} | |
[:i.icon-phone] | |
[:span 17] | |
[:strong.mark-count 3]]] | |
[:li [:a.nav__link {:href "#"} | |
[:i.icon-pencil] | |
[:span 17] | |
[:strong.mark-count 3]]] | |
[:li [:a.nav__link {:href "#"} | |
[:div.icon-graph]]]]] | |
[:div.h-box | |
[:div.icon-win]] | |
[:div.h-box.h-box_madal | |
[:div.icon-medal] | |
[:div.inf-medal | |
[:strong 7] | |
[:span 20]]] | |
[:div.h-box.h-box_time | |
(clock) | |
[:div.icon-pause] | |
[:i.nav-arr] | |
;[:div.drop.drop_center] | |
] | |
(user-menu t state)]] | |
(let [incoming-call (r/cursor state :incoming-call) | |
dev? (r/cursor state :dev?)] | |
[:div | |
(rx (when @incoming-call | |
(print "---- CREATE I-C WINDOW ----") | |
(incoming-call-window t state))) | |
(rx (when @dev? | |
(window {:title "Inspector" | |
:content (inspector state)})))])]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns vion.admin.core | |
(:require-macros [fusion.macros-cljs :refer [go-sub include]] | |
[taoensso.tower :as tower-macros]) | |
(:require [dommy.core :as dom :include-macros true] | |
#_[weasel.repl :as ws-repl] | |
[figwheel.client :as fw :include-macros true] | |
[fusion.component :as component :refer [map->GenericComponent]] | |
[fusion.component.react :refer [map->React]] | |
[fusion.component.i18n :refer [map->I18n]] | |
[fusion.component.sync :refer [map->Sync]] | |
[vion.component.voximplant :refer [map->VoxImplant]] | |
[vion.admin.view.app :refer [app]] | |
[vion.admin.state :refer [state]])) | |
(enable-console-print!) | |
#_(ws-repl/connect "ws://localhost:9001" :verbose false) | |
(defonce system (atom (component/system {} {}))) | |
(def topology | |
{:state [map->GenericComponent] | |
:sync [map->Sync :state] | |
:react [map->React :state :i18n] | |
:i18n [map->I18n] | |
:telecom [map->VoxImplant :state :sync] | |
}) | |
(def dev? (dom/attr js/document.body "data-dev")) | |
(swap! state assoc :dev? dev?) | |
(defn init [] | |
(swap! system component/stop) | |
(let [target (dom/create-element :div) | |
config | |
;; FIXME include config from separate file | |
{:state {:atom state} | |
:sync {:endpoint "/ws-admin" | |
:ready-topic :vion/client-ready} | |
:react {:view app | |
:target target} | |
:i18n {:tconfig {:fallback-locale :en | |
:compiled-dictionary (tower-macros/dict-compile "messages/admin.edn")} | |
:locale (dom/attr js/document.documentElement "lang")} | |
:telecom {:app "cybercraft" | |
:mic-required? true}}] | |
(dom/append! js/document.body target) | |
(reset! system (component/system topology config)) | |
(swap! system component/start))) | |
(dom/listen-once! js/window :load init) | |
(when dev? | |
(fw/watch-and-reload | |
:websocket-url "ws://localhost:3449/figwheel-ws" | |
:jsload-callback (fn [] (init)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns fusion.component.react | |
(:require [fusion.component :as component :refer [IComponent]] | |
[freactive.dom :as dom])) | |
(defn- unmount! [element] | |
(when-let [last-child (.-lastChild element)] | |
(dom/remove! last-child))) | |
(defrecord React [state view target i18n] | |
IComponent | |
(-start [this] | |
(when (and target (not (component/started? this))) | |
(dom/mount! target (view (:t i18n) (:atom state)))) | |
this) | |
(-stop [this] | |
(when (and target (component/started? this)) | |
(unmount! target)) | |
this)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment