Skip to content

Commit

Permalink
webly v2 ui
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Apr 29, 2024
1 parent 5377334 commit ee4ac75
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 64 deletions.
80 changes: 40 additions & 40 deletions lib/helper/src/ta/helper/date_ds.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
[tech.v3.datatype.functional :as dfn]
[tech.v3.datatype.datetime :as datetime]
[tablecloth.api :as tc]
[tick.core :as tick]
[tick.core :as t]
[ta.helper.date :as dt]
[ta.helper.ds :refer [cols-of-type]]))

(defn now []
(-> (tick/now)
(tick/date-time)))
(-> (t/now)
(t/date-time)))

(defn days-ago [n]
(-> (tick/now)
(tick/date-time)
(tick/<< (tick/new-duration n :days))))
(-> (t/now)
(t/date-time)
(t/<< (t/new-duration n :days))))

(defn days-ago-instant [n]
(-> (tick/now)
(tick/- (tick/new-duration n :days))))
(-> (t/now)
(t/- (t/new-duration n :days))))

(defn ds-epoch [ds]
(tds/column-map ds :epoch #(* 1000 (dt/->epoch-second %)) [:date]))
Expand All @@ -40,10 +40,10 @@

(comment

(-> (tc/dataset {:date [(tick/new-date 2021 10 28)
(tick/new-date 2021 10 29)
(tick/new-date 2021 11 01)
(tick/new-date 2021 11 02)]})
(-> (tc/dataset {:date [(t/new-date 2021 10 28)
(t/new-date 2021 10 29)
(t/new-date 2021 11 01)
(t/new-date 2021 11 02)]})
(add-year-and-month-date-as-local-date))
;
)
Expand All @@ -56,29 +56,29 @@
(if (= t :packed-instant)
(do (println "converting to local-datetime")
(-> ds
(tds/column-map :date-close #(tick/date-time %) [:date-close])
(tds/column-map :date-open #(tick/date-time %) [:date-open])))
(tds/column-map :date-close #(t/date-time %) [:date-close])
(tds/column-map :date-open #(t/date-time %) [:date-open])))

(do (println "already local-date")
ds))))

(defn convert-col-instant->localdatetime [ds col]
(println "converting col " col "to local-datetime")
(tds/column-map ds col #(tick/date-time %) [col]))
(tds/column-map ds col #(t/date-time %) [col]))

(defn ds-convert-col-instant->localdatetime [ds]
(let [cols (cols-of-type ds :packed-instant)]
(println "converting cols: " cols)
(reduce convert-col-instant->localdatetime ds cols)))

(defn month-as-int [dt]
(-> dt tick/month .getValue))
(-> dt t/month .getValue))

(comment

(days-ago 50)

(-> (month-as-int (tick/now)) class)
(-> (month-as-int (t/now)) class)
;
)

Expand All @@ -102,48 +102,48 @@
false))))

(comment
(month-end? [(tick/now)])
(month-end? [(t/now)])

(month-begin? [(tick/new-date 2021 10 28)
(tick/new-date 2021 10 29)
(tick/new-date 2021 11 01)
(tick/new-date 2021 11 02)])
(month-begin? [(t/new-date 2021 10 28)
(t/new-date 2021 10 29)
(t/new-date 2021 11 01)
(t/new-date 2021 11 02)])

(month-end? [(tick/new-date 2021 10 28)
(tick/new-date 2021 10 29)
(tick/new-date 2021 11 01)
(tick/new-date 2021 11 02)])
(month-end? [(t/new-date 2021 10 28)
(t/new-date 2021 10 29)
(t/new-date 2021 11 01)
(t/new-date 2021 11 02)])

(month-end? [(tick/new-date 2021 12 28)
(tick/new-date 2021 12 29)
(tick/new-date 2022 1 01)
(tick/new-date 2022 1 02)])
(month-end? [(t/new-date 2021 12 28)
(t/new-date 2021 12 29)
(t/new-date 2022 1 01)
(t/new-date 2022 1 02)])

;
)
(comment
(-> (tick/now)
(tick/year)
(-> (t/now)
(t/year)
.getValue
class)

(into [] (month [(tick/now)]))
(into [] (year [(tick/now)]))
(into [] (month [(t/now)]))
(into [] (year [(t/now)]))

(-> (tick/now)
(tick/date-time)
(-> (t/now)
(t/date-time)

class)

(->> (tc/dataset [{:date-close (tick/now)
:date-open (tick/now)}])
(->> (tc/dataset [{:date-close (t/now)
:date-open (t/now)}])
ensure-roundtrip-date-localdatetime
;tc/columns
;(map meta)
)

(->> (tc/dataset [{:date-close (tick/now)
:date-open (tick/now)
(->> (tc/dataset [{:date-close (t/now)
:date-open (t/now)
:bongo 3
:signal true}])
ds-convert-col-instant->localdatetime
Expand Down
1 change: 0 additions & 1 deletion lib/indicator/src/ta/indicator.clj
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
n v))

(defn- ehlers-tfn
""
[{:keys [c1 c2 c3]}]
(let [f (fn [x y1 y2]
(+ (* c1 x)
Expand Down
8 changes: 4 additions & 4 deletions lib/interact/src/ta/interact/page/algo.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns ta.interact.page.algo
(:require
[spaces]
[spaces.core]
[options.edit :as edit]
[ta.viz.lib.ui :refer [link-href]]
[ta.interact.view.state :as s]
Expand Down Expand Up @@ -40,11 +40,11 @@
(defn algo-ui []
(let [state (s/create-state)]
(fn []
[spaces/viewport
[spaces/top-resizeable {:size 50}
[spaces.core/viewport
[spaces.core/top-resizeable {:size 50}
;[:div.bg-gray-200.w-full.h-full "top"]
[header-ui state]]
[spaces/fill
[spaces.core/fill
;[:div.bg-red-200.w-full.h-full "main"]
[result-view state]]])))

Expand Down
4 changes: 2 additions & 2 deletions lib/interact/src/ta/interact/view/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require
[reagent.core :as r]
[promesa.core :as p]
[ui.webly :refer [notify]]
[frontend.notification :refer [show-notification]]
[goldly.service.core :refer [clj]]))

;; state management
Expand Down Expand Up @@ -32,7 +32,7 @@
(p/then (fn [r]
(set-state state k r)))
(p/catch (fn [_r]
(notify :error (str "data load error:" fun args)))))))
(show-notification :error (str "data load error:" fun args)))))))

(defn get-available-templates [state]
(clj-state-k state :template-list 'ta.interact.template/available-templates)
Expand Down
2 changes: 1 addition & 1 deletion lib/viz/src/ta/viz/lib/format.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns ta.viz.lib.format
(:require
[tick.goldly :refer [dt-format]]
[tick.helper :refer [dt-format]]
[goog.string]))

(defn fmt-nodigits [nr]
Expand Down
2 changes: 1 addition & 1 deletion lib/viz/src/ta/viz/lib/format_date.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns ta.viz.lib.format-date
(:require
[tick.goldly :refer [dt-format]]))
[tick.helper :refer [dt-format]]))

(defn dt-yyyymmdd [dt]
;(println "dt-yyyymmdd: " dt)
Expand Down
18 changes: 9 additions & 9 deletions lib/viz/src/ta/viz/lib/layout.cljs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(ns ta.viz.lib.layout
(:require
[spaces]))
[spaces.core]))

(defn left-right-top [{:keys [top left right]}]
[spaces/viewport
[spaces/top-resizeable {:size 50} top]
[spaces/fill
[spaces/left-resizeable {:size "50%" :scrollable false} left]
[spaces/fill {:scrollable false} right]]])
[spaces.core/viewport
[spaces.core/top-resizeable {:size 50} top]
[spaces.core/fill
[spaces.core/left-resizeable {:size "50%" :scrollable false} left]
[spaces.core/fill {:scrollable false} right]]])

(defn main-top [{:keys [top main]}]
[spaces/viewport
[spaces/top-resizeable {:size 50} top]
[spaces/fill
[spaces.core/viewport
[spaces.core/top-resizeable {:size 50} top]
[spaces.core/fill
main]])
3 changes: 2 additions & 1 deletion lib/viz/src/ta/viz/lib/resolve.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns ta.viz.lib.resolve
(:require
[promesa.core :as p]
[goldly.sci :refer [requiring-resolve]]))
[webly.spa.resolve :refer [get-resolver]]))

; replace symbols with functions
; functions are resolved via requiring-resolve which returns a promesa promise
Expand All @@ -12,6 +12,7 @@
[symbols]
;(println "resolve-symbols: " (pr-str symbols))
(let [symbols (->> symbols (into #{}) (into [])) ; in case some symbols are duplicates
requiring-resolve (get-resolver)
promises (map requiring-resolve symbols)
all (p/all promises)
result (p/deferred)]
Expand Down
5 changes: 2 additions & 3 deletions lib/viz/src/ta/viz/lib/ui.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(ns ta.viz.lib.ui
(:require
[re-frame.core :as rf]
[layout]
[site]))
[ui.site.template :refer [header-menu]]))

;; links

Expand All @@ -20,7 +19,7 @@
;; site layout

(defn site-header []
[site/header-menu
[header-menu
{:brand "DemoGoldly"
:brand-link "/"
:items [{:text "fortune-cookie" :dispatch [:bidi/goto :user/fortune :query-params {}]}
Expand Down
2 changes: 0 additions & 2 deletions lib/viz/src/ta/viz/view/tsymbol.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(ns ta.viz.view.tsymbol
(:require
[reagent.core :as r]
[layout]
[site]
[input]
[goldly.service.core :refer [run-a]]))

Expand Down

0 comments on commit ee4ac75

Please sign in to comment.