-
Notifications
You must be signed in to change notification settings - Fork 1
/
compact.cirru
2027 lines (2026 loc) · 91.7 KB
/
compact.cirru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{} (:package |app)
:configs $ {} (:init-fn |app.server/main!) (:reload-fn |app.server/reload!) (:version |0.1.19)
:modules $ [] |lilac/ |recollect/ |memof/ |ws-edn.calcit/ |cumulo-util.calcit/ |cumulo-reel.calcit/ |fuzzy-filter/
:entries $ {}
:page $ {} (:init-fn |app.client/main!) (:reload-fn |app.client/reload!)
:modules $ [] |respo.calcit/ |lilac/ |recollect/ |memof/ |respo-ui.calcit/ |ws-edn.calcit/ |cumulo-util.calcit/ |respo-message.calcit/ |cumulo-reel.calcit/ |fuzzy-filter/ |alerts.calcit/ |respo-feather.calcit/
:files $ {}
|app.client $ %{} :FileEntry
:defs $ {}
|*states $ %{} :CodeEntry (:doc |)
:code $ quote
defatom *states $ {}
:states $ {}
|*store $ %{} :CodeEntry (:doc |)
:code $ quote (defatom *store nil)
|connect! $ %{} :CodeEntry (:doc |)
:code $ quote
defn connect! () $ let
url-obj $ url-parse js/location.href true
host $ either (-> url-obj .-query .-host) js/location.hostname
port $ either (-> url-obj .-query .-port) (:port config/site)
ws-connect! (str "\"ws://" host "\":" port)
{}
:on-open $ fn (event) (simulate-login!)
:on-close $ fn (event) (reset! *store nil) (js/console.error "\"Lost connection!")
:on-data on-server-data
|dispatch! $ %{} :CodeEntry (:doc |)
:code $ quote
defn dispatch! (op)
when
and config/dev? $ not= (nth op 0) :states
println "\"Dispatch" op
tag-match op
:states cursor s
reset! *states $ update-states @*states cursor s
(:effect/connect) (connect!)
_ $ ws-send! op
|main! $ %{} :CodeEntry (:doc |)
:code $ quote
defn main! ()
if config/dev? $ load-console-formatter!
println "\"Running mode:" $ if config/dev? "\"dev" "\"release"
render-app!
connect!
add-watch *store :changes $ fn (s p) (render-app!)
add-watch *states :changes $ fn (s p) (render-app!)
js/window.addEventListener "\"keydown" $ fn (event) (on-window-keydown event)
on-page-touch $ \ if (nil? @*store) (connect!)
|mount-target $ %{} :CodeEntry (:doc |)
:code $ quote
def mount-target $ js/document.querySelector |.app
|on-server-data $ %{} :CodeEntry (:doc |)
:code $ quote
defn on-server-data (data)
case-default (:kind data) (println "\"unknown server data kind:" data)
:patch $ let
changes $ :data data
when config/dev? $ js/console.log "\"Changes" changes
reset! *store $ patch-twig @*store changes
|on-window-keydown $ %{} :CodeEntry (:doc |)
:code $ quote
defn on-window-keydown (event)
when
and
= "\"k" $ .-key event
.-metaKey event
case-default (-> @*store :router :name)
do $ println "\"no thing to clear in" (-> @*store :router :name)
:home $ do
dispatch! $ :: :process/clear
if-let
enlarge-view $ -> @*store :session w-js-log :enlarge-view
dispatch! $ :: :process/shorten-content enlarge-view
:history $ dispatch! (:: :process/clear-history)
:process $ dispatch!
:: :process/shorten-content $ -> @*store :router :params :id
|reload! $ %{} :CodeEntry (:doc |)
:code $ quote
defn reload! () $ if
or (some? client-errors) (some? server-errors)
hud! "\"error" $ str client-errors &newline server-errors
do (hud! "\"inactive" nil) (remove-watch *store :changes) (remove-watch *states :changes) (clear-cache!) (render-app!)
add-watch *store :changes $ fn (store prev) (render-app!)
add-watch *states :changes $ fn (states prev) (render-app!)
println "\"Code updated."
|render-app! $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-app! () $ render! mount-target
comp-container (:states @*states) @*store
, dispatch!
|simulate-login! $ %{} :CodeEntry (:doc |)
:code $ quote
defn simulate-login! () $ let
raw $ js/localStorage.getItem (:storage-key config/site)
if (some? raw)
do (println "\"Found storage.")
dispatch! $ :: :user/log-in (parse-cirru-edn raw)
do $ println "\"Found no storage."
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.client $ :require
[] respo.core :refer $ [] render! clear-cache! realize-ssr!
[] respo.cursor :refer $ [] update-states
[] app.comp.container :refer $ [] comp-container
[] app.schema :as schema
[] app.config :as config
[] ws-edn.client :refer $ [] ws-connect! ws-send!
[] recollect.patch :refer $ [] patch-twig
[] cumulo-util.core :refer $ [] on-page-touch
[] "\"url-parse" :default url-parse
"\"bottom-tip" :default hud!
"\"./calcit.build-errors" :default client-errors
"\"../js-out/calcit.build-errors" :default server-errors
|app.comp.command $ %{} :FileEntry
:defs $ {}
|comp-command-button $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-command-button (workflow)
div
{}
:style $ {}
:background-color $ hsl 100 120 60
:padding "|0 8px"
:display :inline-block
:cursor :pointer
:margin 4
:color $ hsl 0 0 40
:on-click $ fn (e d!)
&doseq
command $ vals (:commands workflow)
d! :effect/run $ {}
:command $ :code command
:cwd $ join-path (:base-dir workflow) (:path command)
:title $ :title command
<> $ :name workflow
|comp-command-editor $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-command-editor (states base-command on-submit)
let
cursor $ :cursor states
state $ or (:data states)
if (some? base-command)
select-keys base-command $ [] :code :path :title
{} (:title "\"") (:code "\"") (:path "\"./")
div
{} $ :style
merge ui/column $ {} (:padding "\"0 16px 16px")
div ({})
<> "\"Command" $ {} (:font-size 16) (:font-family ui/font-fancy)
=< nil 8
input $ {}
:style $ merge ui/input
{} (:width 320) (:font-family ui/font-code)
:value $ :title state
:placeholder "\"title..."
:on-input $ fn (e d!)
d! cursor $ assoc state :title (:value e)
=< nil 8
input $ {}
:style $ merge ui/input
{} (:width 320) (:font-family ui/font-code)
:value $ :code state
:placeholder "\"Command code"
:on-input $ fn (e d!)
d! cursor $ assoc state :code (:value e)
=< nil 8
input $ {}
:style $ merge ui/input
{} (:width 320) (:font-family ui/font-code)
:value $ :path state
:placeholder "|Command path"
:on-input $ fn (e d!)
d! cursor $ assoc state :path (:value e)
=< nil 16
div
{} $ :style ui/row-parted
span nil
button
{} (:style style/button)
:on-click $ fn (e d!) (on-submit state d!) (d! cursor nil)
<> |Submit
|comp-command-row $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-command-row (states command workflow-id)
let
cursor $ :cursor states
state $ either (:data states)
{} $ :pop? false
remove-plugin $ use-confirm (>> states :remove) ({})
div
{} $ :style style-command-row
div
{} $ :style ui/row-parted
div
{} $ :style ui/row-middle
<>
or (:title command) "\"Task"
{} $ :font-size 20
=< 8 nil
comp-icon :play
{} (:font-size 14) (:cursor :pointer)
:color $ hsl 200 80 70
fn (e d! m!)
d! :effect/run $ {}
:cwd $ :path command
:command $ :code command
:title $ :title command
div
{} $ :style ui/row-parted
comp-icon :edit-2
&{} :font-size 14 :color (hsl 200 80 60) :cursor :pointer
fn (e d!)
d! cursor $ assoc state :pop? true
comp-modal
{} (:title |Demo)
:style $ {} (:width 400)
:container-style $ {}
:render $ fn (on-close)
comp-command-editor (>> states :edit-command) command $ fn (command-draft d! m!)
d! :workflow/edit-command $ [] workflow-id (:id command) command-draft
on-close
:pop? state
fn (d!)
d! cursor $ assoc state :pop? false
=< 8 nil
comp-icon :x
&{} :font-size 18 :color (hsl 0 80 60) :cursor :pointer
fn (e d!)
.show remove-plugin d! $ fn ()
d! :workflow/remove-command $ [] workflow-id (:id command)
div
{} $ :style
merge ui/row-middle $ {} (:font-family ui/font-code)
<> (:path command)
{} (:display :inline-block)
:background-color $ hsl 0 0 100 0.2
:padding "|0 8px"
=< 24 nil
<> (:code command)
{}
:background-color $ hsl 0 0 100 0.2
:padding "|0 8px"
:display :inline-block
:min-width 320
.render remove-plugin
|style-command-row $ %{} :CodeEntry (:doc |)
:code $ quote
def style-command-row $ merge ui/column
{}
:border $ str "\"1px solid " (hsl 0 0 100 0.3)
:border-radius "\"4px"
:padding "\"8px 8px"
:width 600
:min-width :max-content
:margin "\"16px 8px"
:color :white
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.command $ :require
[] respo-ui.core :refer $ [] hsl
[] respo-ui.core :as ui
[] respo.core :refer $ [] defcomp >> <> span div input button a
[] respo.comp.space :refer $ [] =<
[] feather.core :refer $ [] comp-i comp-icon
[] respo-alerts.core :refer $ [] use-confirm comp-modal
[] app.style :as style
[] app.util :refer $ [] join-path
|app.comp.container $ %{} :FileEntry
:defs $ {}
|comp-container $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-container (states store)
let
state $ :data states
session $ :session store
router $ :router store
router-data $ :data router
if (nil? store) (comp-offline)
div
{} $ :class-name (str-spaced css/global css/fullscreen css/column css-container)
comp-navigation (:logged-in? store) router $ :count store
if (:logged-in? store)
let
router $ :router store
router-data $ :data router
case-default (:name router) (comp-missing router)
:profile $ comp-profile (:user store) router-data
:home $ comp-home (>> states :home) router-data
:workflows $ comp-workflow-container (>> states :workflows) (:workflows router-data)
:history $ comp-history (:histories router-data)
:process $ comp-process-detail (>> states :detail) (:detail router-data)
comp-login $ >> states :login
comp-status-color $ :color store
when dev? $ comp-inspect |Store store
{} (:bottom 0) (:left 0) (:max-width |100%)
comp-messages
get-in store $ [] :session :messages
{}
fn (info d!) (d! :session/remove-message info)
when dev? $ comp-reel (:reel-length store) ({})
|comp-offline $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-offline () $ div
{} $ :style
merge ui/global ui/fullscreen ui/column-dispersive $ {}
:background-color $ :theme config/site
div $ {}
:style $ {} (:height 0)
div $ {}
:style $ {}
:background-image $ str "\"url(" (:icon config/site) "\")"
:width 128
:height 128
:background-size :contain
div
{}
:style $ {} (:cursor :pointer) (:line-height "\"32px")
:on-click $ fn (e d!) (d! :effect/connect nil)
<> "|No connection..." $ {} (:font-family ui/font-fancy) (:font-size 24)
|comp-status-color $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-status-color (color)
div $ {} (:class-name css-status)
:style $ {} (:background-color color)
|css-container $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-container $ {}
"\"&" $ {}
:color $ hsl 0 0 70
|css-status $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-status $ {}
"\"&" $ let
size 24
{} (:width size) (:height size) (:position :absolute) (:bottom 60) (:left 8) (:border-radius "\"50%") (:opacity 0.6) (:pointer-events :none)
|style-body $ %{} :CodeEntry (:doc |)
:code $ quote
def style-body $ {} (:padding "|8px 16px")
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.container $ :require
respo-ui.core :refer $ hsl
respo-ui.css :as css
respo-ui.core :as ui
respo.core :refer $ defcomp <> >> div span button
respo.comp.inspect :refer $ comp-inspect
respo.comp.space :refer $ =<
app.comp.navigation :refer $ comp-navigation
app.comp.profile :refer $ comp-profile
app.comp.login :refer $ comp-login
respo-message.comp.messages :refer $ comp-messages
cumulo-reel.comp.reel :refer $ comp-reel
app.config :refer $ dev?
app.schema :as schema
app.config :as config
app.comp.missing :refer $ comp-missing
app.comp.home :refer $ comp-home
app.comp.workflow :refer $ comp-workflow-container
app.comp.history :refer $ comp-history
app.comp.process-detail :refer $ comp-process-detail
respo.css :refer $ defstyle
|app.comp.history $ %{} :FileEntry
:defs $ {}
|comp-history $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-history (histories)
div
{} $ :class-name css-history-page
div ({})
button $ {} (:class-name css/button) (:inner-text "\"Clear")
:on-click $ fn (e d!) (d! :process/clear-history nil)
=< nil 16
if (empty? histories)
<> "\"Empty" $ {} (:font-family ui/font-fancy) (:font-weight 100) (:color :white)
list->
{} $ :style
merge ui/flex $ {} (:overflow :auto) (:padding "\"16px 0 120px 0")
-> histories $ map
fn (history)
[] (:id history)
div
{} $ :class-name (str-spaced css/row-middle css-history)
<>
-> (:started-at history) dayjs $ .!format "\"MM-DD HH:mm:ss"
, css-date-text
<>
or (:title history) "\"Task"
merge style/text $ {} (:min-width 160)
<> (:command history)
merge style/text $ {} (:min-width 160)
<> (:cwd history) (merge style/text)
|css-date-text $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-date-text $ {}
"\"&" $ merge style/text
{} (:font-size 12)
:color $ hsl 0 0 70
|css-history $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-history $ {}
"\"&" $ {} (:margin "\"0px")
:background-color $ hsl 200 40 28
:padding "\"4px 8px"
:width 960
:min-width :max-content
:border-bottom $ str "\"1px solid " (hsl 0 0 0 0.2)
:word-break :break-word
"\"&:hover" $ {}
:background-color $ hsl 200 40 32
|css-history-page $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-history-page $ {}
"\"&" $ merge ui/flex ui/column
{} (:padding "|16px 16px") (:font-family ui/font-code) (:overflow :auto)
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.history $ :require
respo-ui.core :refer $ hsl
respo-ui.core :as ui
respo.core :refer $ defcomp <> >> list-> span div button
respo.comp.space :refer $ =<
app.style :as style
"\"dayjs" :default dayjs
respo.css :refer $ defstyle
respo-ui.css :as css
|app.comp.home $ %{} :FileEntry
:defs $ {}
|comp-home $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-home (states router-data)
let
cursor $ :cursor states
state $ or (:data states)
{} (:query "\"") (:pop? false)
div
{} $ :class-name (str-spaced css/expand css/column css-home)
=< nil 8
div
{} $ :class-name (str-spaced css/expand css/row)
if-let
enlarge-view $ get router-data :enlarge-view
if-let
large-process $ get (:processes router-data) enlarge-view
comp-process-detail (>> states :enlarge) large-process
div
{} $ :class-name (str-spaced css/expand css/column)
div
{} (:class-name css/row-parted)
:style $ {} (:align-items :center) (:padding "\"0 8px")
div
{} $ :class-name (str-spaced css/flex css/row-middle)
input $ {} (:class-name css-filter) (:placeholder "\"filter...")
:value $ :query state
:on-input $ fn (e d!)
d! cursor $ assoc state :query (:value e)
list->
{}
:class-name $ str-spaced css/flex css/row
:style $ {} (:flex-wrap :wrap)
-> (:workflows router-data) (.to-list)
.filter-pair $ fn (k workflow)
:matches? $ parse-by-letter
.!toLowerCase $ :name workflow
.!toLowerCase $ :query state
.sort-by $ fn (pair)
:name $ last pair
.map-pair $ fn (k workflow)
[] k $ comp-command-button workflow
div
{} $ :class-name css/row-middle
button $ {}
:class-name $ str-spaced css/button style/css-button
:inner-text "\"Run"
:on-click $ fn (e d!)
d! cursor $ assoc state :pop? true
comp-modal
{} (:title |Demo)
:style $ {} (:width 400)
:container-style $ {}
:render $ fn (on-close)
comp-command-editor (>> states :quick-run) nil $ fn (draft d!)
d! :effect/run $ {}
:command $ :code draft
:cwd $ :path draft
:title $ :title draft
on-close d!
:pop? state
fn (d!)
d! cursor $ assoc state :pop? false
=< 8 nil
button $ {}
:class-name $ str-spaced css/button style/css-button
:inner-text "\"Kill all"
:on-click $ fn (e d!)
&doseq
pid $ keys (:processes router-data)
d! :effect/kill pid
=< 8 nil
a
{} (:class-name css/link)
:on-click $ fn (e d!) (d! :process/clear nil)
<> "\"Clear"
list->
{} $ :class-name (str-spaced css/flex css-process-list)
-> (:processes router-data) (.to-list)
filter $ fn (x)
not= (first x) (get router-data :enlarge-view)
.sort $ fn (x y)
if
and
:alive? $ last y
:alive? $ last x
-
:started-at $ last x
:started-at $ last y
-
:started-at $ last y
:started-at $ last x
.sort-by $ fn (pair)
not $ :alive? (last pair)
.map-pair $ fn (pid process)
[] pid $ comp-process process
|css-filter $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-filter $ {}
"\"&" $ {} (:min-width 60) (:width 60) (:background-color :transparent)
:color $ hsl 0 0 100 0.8
:border-width "\"0 0 1px 0"
:border-bottom $ str "\"1px solid " (hsl 0 0 100 0.5)
:border-radius 0
:outline :none
:line-height "\"28px"
:font-size 14
:font-family ui/font-normal
:padding "\"0 8px"
|css-home $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-home $ {}
"\"&" $ merge ui/flex ui/column
{} (:padding "\"8px 0px") (:overflow :auto)
|css-process-list $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-process-list $ {}
"\"&" $ {} (:overflow :auto) (:flex-wrap :wrap) (:padding-bottom 120) (:align-items :flex-start) (:gap "\"8px") (:grid-template-columns "\"repeat(auto-fit, minmax(560px, 1fr))") (:grid-auto-flow :dense) (:display :grid) (:padding-bottom 120) (:margin "\"0 8px") (:overflow :auto)
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.home $ :require
respo-ui.core :refer $ hsl
respo-ui.core :as ui
respo.comp.space :refer $ =<
respo.core :refer $ defcomp >> list-> button <> span div a input
app.comp.process :refer $ comp-process
app.comp.process-detail :refer $ comp-process-detail
app.util :refer $ join-path map-val
app.style :as style
app.comp.command :refer $ comp-command-button comp-command-editor
fuzzy-filter.core :refer $ parse-by-letter
respo-alerts.core :refer $ comp-modal
respo.comp.inspect :refer $ comp-inspect
respo-ui.css :as css
respo.css :refer $ defstyle
|app.comp.login $ %{} :FileEntry
:defs $ {}
|comp-login $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-login (states)
let
cursor $ :cursor states
state $ or (:data states) initial-state
div
{} $ :style (merge ui/flex ui/center)
div ({})
div
{} $ :style ({})
div ({})
input $ {} (:placeholder |Username)
:value $ :username state
:style ui/input
:on-input $ fn (e d!)
d! cursor $ assoc state :username (:value e)
=< nil 8
div ({})
input $ {} (:placeholder |Password)
:value $ :password state
:style ui/input
:on-input $ fn (e d!)
d! cursor $ assoc state :password (:value e)
=< nil 8
div
{} $ :style
{} $ :text-align :right
span $ {} (:inner-text "|Sign up")
:style $ merge style/link
:on-click $ on-submit (:username state) (:password state) true
=< 8 nil
span $ {} (:inner-text "|Log in")
:style $ merge style/link
:on-click $ on-submit (:username state) (:password state) false
|initial-state $ %{} :CodeEntry (:doc |)
:code $ quote
def initial-state $ {} (:username |) (:password |)
|on-submit $ %{} :CodeEntry (:doc |)
:code $ quote
defn on-submit (username password signup?)
fn (e dispatch!)
dispatch! (if signup? :user/sign-up :user/log-in) ([] username password)
js/localStorage.setItem (:storage-key config/site)
format-cirru-edn $ [] username password
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.login $ :require
[] respo.core :refer $ [] defcomp <> div input button span
[] respo.comp.space :refer $ [] =<
[] respo.comp.inspect :refer $ [] comp-inspect
[] respo-ui.core :as ui
[] app.schema :as schema
[] app.style :as style
[] app.config :as config
|app.comp.missing $ %{} :FileEntry
:defs $ {}
|comp-missing $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-missing (router)
div ({}) (<> "|Page missing")
div
{} $ :style
{} $ :font-family ui/font-code
<> router
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.missing $ :require
[] hsl.core :refer $ [] hsl
[] respo-ui.core :as ui
[] respo.core :refer $ [] defcomp <> span div
|app.comp.navigation $ %{} :FileEntry
:defs $ {}
|comp-navigation $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-navigation (logged-in? router count-members)
div
{} $ :class-name css-nav
div
{} $ :style ui/row
render-entry router :home |Termina
=< 16 nil
render-entry router :workflows |Workflows
=< 16 nil
render-entry router :history |History
div
{}
:style $ {} (:cursor |pointer)
:on-click $ fn (e d!)
d! :router/change $ {} (:name :profile)
<> $ if logged-in? |Me |Guest
=< 8 nil
<> count-members
|css-nav $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-nav $ {}
"\"&" $ merge ui/row-center
{} (:height 32) (:justify-content :space-between) (:padding "|0 16px") (:font-size 16)
:border-bottom $ str "|1px solid " (hsl 0 0 0 0.1)
:font-family ui/font-fancy
:background-color $ hsl 0 0 0 0.04
|render-entry $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-entry (router router-name title)
div
{}
:style $ merge style-logo
if
= router-name $ :name router
{} $ :color :white
:on-click $ fn (e d!)
d! :router/change $ {} (:name router-name)
<> title
|style-logo $ %{} :CodeEntry (:doc |)
:code $ quote
def style-logo $ {} (:cursor :pointer)
:color $ hsl 0 0 60
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.navigation $ :require
respo-ui.core :refer $ hsl
respo-ui.core :as ui
respo.comp.space :refer $ =<
respo.core :refer $ defcomp <> >> span div
app.config :as config
respo.css :refer $ defstyle
|app.comp.process $ %{} :FileEntry
:defs $ {}
|comp-process $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-process (process)
div
{} $ :class-name css-process
div
{} (:class-name css-title-bar)
:style $ if (:alive? process)
{} $ :background-color (hsl 50 100 60)
div
{} $ :class-name css/row-middle
<>
or (:title process) "\"Task"
merge style/text $ {} (:color :black)
div
{} $ :class-name css/row-middle
button $ {} (:class-name css/button)
:style $ {}
:background $ hsl 0 0 0 0.1
:color :white
:on-click $ fn (e d!)
d! $ :: :session/enlarge (:pid process)
:inner-text "\"Enlarge"
; =< 8 nil
; a $ {} (:class-name css/link)
:on-click $ fn (e d!)
d! :router/change $ {} (:name :process)
:params $ {}
:id $ :pid process
:inner-text "\"View"
if (:alive? process)
a
{} (:class-name css-link-kill)
:on-click $ fn (e d!)
d! :effect/kill $ :pid process
<> "\"Kill"
a $ {} (:style style/link) (:inner-text "\"Redo")
:on-click $ fn (e d!)
d! :effect/run $ {}
:cwd $ :cwd process
:command $ :command process
:title $ :title process
d! :process/remove-dead $ :pid process
div
{} $ :class-name (str-spaced css/expand css-process-log)
<> (:command process) (merge style/text)
=< 8 nil
<> (:cwd process)
merge style/text $ {}
:color $ hsl 0 0 60
if-not
empty? $ :content process
list->
{} $ :class-name css-content-list
-> (:content process) (.to-list) (take-last 4)
.map-indexed $ fn (idx chunk)
[] idx $ let
urls $ to-calcit-data
.!match (:data chunk) url-pattern
div
{} $ :style
{} (:margin-top 2) (:display :block)
:background-color $ hsl 0 0 0 0.5
if-not (empty? urls)
list-> ({})
-> urls $ map
fn (url)
[] url $ a
{} (:inner-text url) (:target "\"_blank") (:href url)
:style $ {}
:color $ hsl 200 80 70
:margin "\"0 8px"
<> (:data chunk)
{}
:color $ case-default (:type chunk) (hsl 60 0 72)
:stderr $ hsl 60 80 36
:error $ hsl 0 80 50
:padding 8
:display :block
:white-space :pre-line
|css-content-list $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-content-list $ {}
"\"&" $ {} (:font-family ui/font-code) (:white-space :pre) (:font-size 12) (:line-height "\"1.5em") (:max-height 240) (:overflow :auto) (:border-radius "\"4px")
|css-link-kill $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-link-kill $ {}
"\"&" $ merge style/link
{} (:color :red) (:border-color :red)
|css-process $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-process $ {}
"\"&" $ merge
{} (:font-family ui/font-code) (:border-radius "\"4px") (:display :inline-block) (:vertical-align :top)
|css-process-log $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-process-log $ {}
"\"&" $ merge ui/row-middle
{}
:background-color $ hsl 0 0 0 0.5
:font-size 10
|css-title-bar $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-title-bar $ {}
"\"&" $ merge ui/row-parted
{}
:background-color $ hsl 0 0 100 0.4
:color :black
:padding "\"4px 4px"
:border-radius "\"4px"
|url-pattern $ %{} :CodeEntry (:doc |)
:code $ quote
def url-pattern $ new js/RegExp "\"https?://\\S+" "\"g"
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns app.comp.process $ :require
respo-ui.core :refer $ hsl
respo-ui.core :as ui
respo.comp.space :refer $ =<
respo.core :refer $ defcomp list-> >> <> span div button a
app.style :as style
app.util :refer $ map-with-index
respo-alerts.core :refer $ comp-alerts
respo.css :refer $ defstyle
respo-ui.css :as css
|app.comp.process-detail $ %{} :FileEntry
:defs $ {}
|comp-process-detail $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-process-detail (states process)
let
cursor $ :cursor states
state $ either (:data states)
{} (:filter "\"") (:filter? true) (:wrap? true) (:all-log? false) (:hide-thread-info? false)
command-plugin $ use-prompt (>> states :command)
{} (:text "\"change command")
:initial $ :command process
div
{} (:class-name css-process)
:style $ {} (:flex 2)
div
{} $ :class-name css/row-parted
div
{} $ :style
merge ui/row-middle $ {} (:gap 4)
input $ {} (:type "\"checkbox")
:style $ {} (:cursor :pointer) (:opacity 0.8)
:checked $ :filter? state
:on-input $ fn (e d!)
d! cursor $ assoc state :filter?
not $ :filter? state
if (:filter? state)
input $ {} (:class-name css-filter)
:value $ :filter state
:on-input $ fn (e d!)
d! cursor $ assoc state :filter (:value e)
:placeholder "\"filter..."
<> "\"Filter..."
input $ {} (:type "\"checkbox")
:style $ {} (:cursor :pointer) (:opacity 0.8)
:checked $ :all-log? state
:on-input $ fn (e d!)
d! cursor $ assoc state :all-log?
not $ :all-log? state
<> "\"All log?"
comp-icon :arrow-down
{} (:font-size 14) (:class-name css-down-icon)
:color $ hsl 0 0 80
, on-scroll-down!
if-not
empty? $ :content process
a
{}
:on-click $ fn (e d!)
d! :process/shorten-content $ :pid process
:style style/link
<> "\"Clear"
=< 8 nil
input $ {} (:type "\"checkbox")
:style $ {} (:cursor :pointer) (:opacity 0.8)
:checked $ :hide-thread-info? state
:on-input $ fn (e d!)
d! cursor $ assoc state :hide-thread-info?
not $ :hide-thread-info? state
<> "\"HideThread?"
input $ {} (:type "\"checkbox")
:style $ {} (:cursor :pointer) (:opacity 0.8)
:checked $ :wrap? state
:on-input $ fn (e d!)
d! cursor $ assoc state :wrap?
not $ :wrap? state
<> "\"Wrap?"
div
{} $ :class-name css-toolbar
span $ {}
:inner-text $ or (:title process) "\"Task"
:class-name css/font-fancy
:style $ merge style/text
{} $ :padding "\"0 8px"
if (:alive? process)
{} (:color :black) (:border-radius "\"4px")
:background-color $ hsl 60 100 60
:title $ str (:cwd process) &newline (:command process)
:on-click $ fn (e d!)
.show command-plugin d! $ fn (text)
d! $ :: :process/change-command (:pid process) text
; =< 16 nil
; <> (:command process) style/text
; =< 16 nil
; <> $ merge style/text
{} (:font-size 12)
:color $ hsl 0 0 70
; =< 16 nil
; <> (:pid process) style/text
=< 8 nil
if (:alive? process)
a
{} (:class-name css/link)
:style $ {} (:color :red) (:border-color :red)
:on-click $ fn (e d!)
d! :effect/kill $ :pid process
:title $ :command process
<> "\"Kill"
div ({})
a $ {} (:class-name css/link) (:inner-text "\"Redo")
:title $ :command process
:on-click $ fn (e d!)
d! :effect/run $ {}
:cwd $ :cwd process
:command $ :command process
:title $ :title process
:enlarge? true
d! :process/remove-dead $ :pid process
=< 8 nil
a $ {} (:class-name css/link) (:inner-text "\"Drop")
:on-click $ fn (e d!)
d! :router/change $ {} (:name :home)
d! :process/remove-dead $ :pid process
=< nil 8
div
{} $ :class-name (str-spaced "\"scroll-area" css-logs-list)
if (some? process)
list->
{} $ :style
{} $ :white-space
if (:wrap? state) "\"pre-wrap" "\"pre"
-> (:content process)
filter $ fn (chunk)
if
or
not $ :filter? state
blank? $ :filter state
, true $ .includes? (:data chunk) (:filter state)
take-last $ if (:all-log? state) 2000 60
map-indexed $ fn (idx chunk)
[] (:data chunk)
span $ {} (:class-name css-log)
:style $ merge
if
= :stderr $ :type chunk
{} $ :color :red
:inner-text $ do
if (:hide-thread-info? state)
hide-thread-info $ :data chunk
:data chunk
; .!replace (:data chunk) &newline $ str &newline &newline
=< nil 200
.render command-plugin
|css-down-icon $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-down-icon $ {}
"\"&" $ {} (:opacity 0.8) (:cursor :pointer)
"\"&:hover" $ {} (:opacity 1)
|css-filter $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-filter $ {}
"\"&" $ merge ui/input
{}
:color $ hsl 0 0 100
:background-color $ hsl 0 0 100 0
:border-color $ hsl 0 0 100 0.4
|css-log $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-log $ {}
"\"&" $ {} (:font-size 12) (:margin "\"0") (:font-family ui/font-code) (:line-height "\"20px")
|css-logs-list $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-logs-list $ {}
"\"&" $ merge ui/flex
{} (:overflow :auto)
:border $ str "\"1px solid " (hsl 0 0 100 0.3)
:padding 8
:background-color $ hsl 0 0 0 0.5
:overflow :auto
:word-break :break-all
:line-height 1.4
|css-process $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-process $ {}
"\"&" $ merge ui/flex ui/column
{} (; :padding "|8px 16px") (:overflow :auto) (:color "\"#aaa")
|css-toolbar $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-toolbar $ {}
"\"&" $ merge ui/row-middle
{} $ :font-family ui/font-code
|hide-thread-info $ %{} :CodeEntry (:doc |)
:code $ quote