Compare commits
659
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
758e9e2d94 | ||
|
|
a5f86ed839 | ||
|
|
dbfdf59bfe | ||
|
|
abacf29b85 | ||
|
|
5e7a31e5c5 | ||
|
|
ab78ae867a | ||
|
|
5e60f38b9b | ||
|
|
8f4b4be6db | ||
|
|
696195aefd | ||
|
|
36f0a544e9 | ||
|
|
f23242b18c | ||
|
|
75dd6d659b | ||
|
|
a23d8228b4 | ||
|
|
59f3d54597 | ||
|
|
8b3166582d | ||
|
|
fd13316b8e | ||
|
|
5991ab03ec | ||
|
|
b9bc6184d4 | ||
|
|
aab3e836c3 | ||
|
|
ed0fc60900 | ||
|
|
6764ae268e | ||
|
|
6d3d9ddacf | ||
|
|
ccd76ec284 | ||
|
|
d52ea0e997 | ||
|
|
15e23fe486 | ||
|
|
d9e5b11026 | ||
|
|
21c19c94c2 | ||
|
|
c31d9d6c72 | ||
|
|
a7e89b075b | ||
|
|
f50430e9e2 | ||
|
|
4891250959 | ||
|
|
ad1b89ff88 | ||
|
|
49053d31c2 | ||
|
|
651ebdbb41 | ||
|
|
d21de803f6 | ||
|
|
bb81151392 | ||
|
|
2b277b84a2 | ||
|
|
2bf4502d06 | ||
|
|
94d1b9d784 | ||
|
|
ceee66d5f2 | ||
|
|
2e9a968752 | ||
|
|
6c2989b139 | ||
|
|
6c2bfee616 | ||
|
|
30c5ea7fb2 | ||
|
|
a6831b5548 | ||
|
|
b42943fe8d | ||
|
|
06c833e96c | ||
|
|
9aff02b225 | ||
|
|
4229a523a8 | ||
|
|
82e9e6b6bf | ||
|
|
904a6db1d0 | ||
|
|
2a9f03741e | ||
|
|
fd3de056c1 | ||
|
|
978a1e8566 | ||
|
|
36e1771579 | ||
|
|
0d23fd50f5 | ||
|
|
367c9c1c7c | ||
|
|
78f5526ce7 | ||
|
|
a1d7ebd260 | ||
|
|
3fda1cb369 | ||
|
|
2c2a68022b | ||
|
|
bb321926bc | ||
|
|
45c35ba1b2 | ||
|
|
77c61d5e3f | ||
|
|
12962ed5ca | ||
|
|
f472db002c | ||
|
|
6939f32f69 | ||
|
|
0107d934e5 | ||
|
|
ce9880a9b1 | ||
|
|
317f17d7da | ||
|
|
7da128da6b | ||
|
|
f603866860 | ||
|
|
dc2d525955 | ||
|
|
e97335189a | ||
|
|
81ce58268f | ||
|
|
7dace3fc1d | ||
|
|
f4794bea33 | ||
|
|
b044ff3b2a | ||
|
|
cd7856c46e | ||
|
|
3be0ee6072 | ||
|
|
198d26fda1 | ||
|
|
8b26ac4456 | ||
|
|
d6f172e953 | ||
|
|
91ee9b739a | ||
|
|
b568128180 | ||
|
|
53a87530ee | ||
|
|
450de301a9 | ||
|
|
462b0f4eda | ||
|
|
17402ce94a | ||
|
|
b7fae8a6f5 | ||
|
|
4058a98290 | ||
|
|
06d7693ed6 | ||
|
|
2b01f3d902 | ||
|
|
d231ee50b7 | ||
|
|
815546d5ab | ||
|
|
3fda0e4427 | ||
|
|
a1eec029ac | ||
|
|
2bbe92dbab | ||
|
|
b3d0040faa | ||
|
|
c3e924be17 | ||
|
|
dc5574e660 | ||
|
|
5c19b391b1 | ||
|
|
79cb3162f2 | ||
|
|
e49254356a | ||
|
|
3192ef5561 | ||
|
|
8158bcb4f3 | ||
|
|
b03cb94d60 | ||
|
|
0f968c65b6 | ||
|
|
6b92773e87 | ||
|
|
870e1b7301 | ||
|
|
477a2f6da3 | ||
|
|
85fe84406d | ||
|
|
e8096a4db9 | ||
|
|
e68e673835 | ||
|
|
53274e865a | ||
|
|
64df20cb36 | ||
|
|
1977ad8ad4 | ||
|
|
a7e63d02e9 | ||
|
|
593be8d069 | ||
|
|
f7e173f902 | ||
|
|
7eefae4c42 | ||
|
|
7bb0951169 | ||
|
|
787fb879d2 | ||
|
|
c23dafcb89 | ||
|
|
111278b63b | ||
|
|
2008478378 | ||
|
|
d5de60bc21 | ||
|
|
76172d0a5f | ||
|
|
1893df1f5c | ||
|
|
a07fa26bfe | ||
|
|
41447067a2 | ||
|
|
1dd3d39a21 | ||
|
|
4f772a1d57 | ||
|
|
97bd49d221 | ||
|
|
b4374cec6b | ||
|
|
7e5c1218a3 | ||
|
|
475970659c | ||
|
|
e0706dde01 | ||
|
|
986ea74e63 | ||
|
|
fa0e6f7c10 | ||
|
|
ea5156122c | ||
|
|
97b974a31f | ||
|
|
ef98682620 | ||
|
|
d70eb158c4 | ||
|
|
6fc34e922a | ||
|
|
fe65554c7a | ||
|
|
78d9b678a8 | ||
|
|
88302c9470 | ||
|
|
ac6c9e5c46 | ||
|
|
b1de323151 | ||
|
|
24e57872ce | ||
|
|
ddd3f301b3 | ||
|
|
7007fc9d6b | ||
|
|
7ca407fc42 | ||
|
|
5217e8801e | ||
|
|
ddd50cd916 | ||
|
|
9ae3ababfa | ||
|
|
753cac0e7a | ||
|
|
6c3c9ebbcb | ||
|
|
3aaa25a3e8 | ||
|
|
3fc0bce1de | ||
|
|
fdb4544cb5 | ||
|
|
f5741d8095 | ||
|
|
539d1cfeae | ||
|
|
c1ed79757c | ||
|
|
c37727f482 | ||
|
|
b25cd39481 | ||
|
|
5f93bed074 | ||
|
|
ef9502c81b | ||
|
|
4b2c2de990 | ||
|
|
79dc76c5df | ||
|
|
fdbc64dfc5 | ||
|
|
62c20c96b4 | ||
|
|
6b491ec209 | ||
|
|
d009deea0e | ||
|
|
390d901463 | ||
|
|
a0bd207d93 | ||
|
|
d62f88691c | ||
|
|
b7c018b664 | ||
|
|
83127523b9 | ||
|
|
86c824e28d | ||
|
|
0349ff95bf | ||
|
|
f62c867a20 | ||
|
|
b403cacb93 | ||
|
|
4499a3751f | ||
|
|
6d887cb72f | ||
|
|
10e13dd51d | ||
|
|
85edf68ff0 | ||
|
|
259ac99cdd | ||
|
|
39c3a34158 | ||
|
|
dde8223052 | ||
|
|
2548f27527 | ||
|
|
ff03f092f5 | ||
|
|
53ef67869b | ||
|
|
d48f34d109 | ||
|
|
a2d9c39325 | ||
|
|
0c4f684036 | ||
|
|
e587c8dbd7 | ||
|
|
069ab45164 | ||
|
|
7b7de6f8fc | ||
|
|
9ed3b2aecb | ||
|
|
ecf3f922df | ||
|
|
1aa283fc8c | ||
|
|
bfbf640986 | ||
|
|
b6cd470ca6 | ||
|
|
d826cff9d7 | ||
|
|
ff65a5ca5b | ||
|
|
9e012a2b3a | ||
|
|
a6f1c51539 | ||
|
|
655f27543b | ||
|
|
762baca586 | ||
|
|
ec769b49f6 | ||
|
|
5153e8725c | ||
|
|
f79f2cc5b9 | ||
|
|
cdf4f341d4 | ||
|
|
f649c26304 | ||
|
|
3a8d759a26 | ||
|
|
29ca6e98fb | ||
|
|
328dd9b2d3 | ||
|
|
a1e58e5498 | ||
|
|
ef43aebc5d | ||
|
|
9a3304201e | ||
|
|
cd88710385 | ||
|
|
2b3e4a4579 | ||
|
|
05731cb9a2 | ||
|
|
01eeadaf42 | ||
|
|
b4721882ec | ||
|
|
3e894d0e27 | ||
|
|
4e42125398 | ||
|
|
664cc37a03 | ||
|
|
f4a0da3518 | ||
|
|
5339d4ff93 | ||
|
|
a31368f08d | ||
|
|
136938ba1e | ||
|
|
09316b630d | ||
|
|
99a661089f | ||
|
|
f26cb80e5f | ||
|
|
cda3d18838 | ||
|
|
fae0325e87 | ||
|
|
118ca7248d | ||
|
|
afa194ac54 | ||
|
|
3538712692 | ||
|
|
604c34384c | ||
|
|
c18f1baafa | ||
|
|
8e04920ab9 | ||
|
|
aa3147a4a6 | ||
|
|
f7ab968e1b | ||
|
|
5ce3d9d1a9 | ||
|
|
e2a9c91d3f | ||
|
|
78a8652e7a | ||
|
|
e9c536df96 | ||
|
|
94429a1fbc | ||
|
|
f2728dcf78 | ||
|
|
cbfd18c371 | ||
|
|
60a31eb102 | ||
|
|
7c1e95d35d | ||
|
|
90a046d539 | ||
|
|
935a6f846c | ||
|
|
b02f814c65 | ||
|
|
8c42aa93a2 | ||
|
|
357bc5ad44 | ||
|
|
07fb9e8eb7 | ||
|
|
d641eba252 | ||
|
|
9f9fc4c8ab | ||
|
|
2aef052398 | ||
|
|
1c2027506a | ||
|
|
c3274b2008 | ||
|
|
99aef9e86e | ||
|
|
77697f4312 | ||
|
|
247d8b7ee8 | ||
|
|
06bed8747f | ||
|
|
8e9233022e | ||
|
|
954dc582dc | ||
|
|
df510f0e3b | ||
|
|
ef9b3b0544 | ||
|
|
b8b3a57e8e | ||
|
|
d18020a45c | ||
|
|
e652c1cd24 | ||
|
|
8f5d6ccd51 | ||
|
|
cbe4a488b9 | ||
|
|
8ce3ef69d0 | ||
|
|
ab9fab13d9 | ||
|
|
309b0e64b2 | ||
|
|
a6324a9aa2 | ||
|
|
64417a6867 | ||
|
|
8e16dcde0d | ||
|
|
2d8f6df0e2 | ||
|
|
10199fb7ad | ||
|
|
6f6ac2866c | ||
|
|
46837facbf | ||
|
|
4916211301 | ||
|
|
1d8c4a0954 | ||
|
|
64601914b2 | ||
|
|
b3ca5f133e | ||
|
|
9c3397d367 | ||
|
|
b3dfce9f91 | ||
|
|
590d0028c2 | ||
|
|
67cf817aa9 | ||
|
|
35811512a4 | ||
|
|
c13c85ed44 | ||
|
|
5c85dabad8 | ||
|
|
c134b0f5ca | ||
|
|
d92ad7e2b6 | ||
|
|
4547d8cec1 | ||
|
|
402a1f50f2 | ||
|
|
bada16ade7 | ||
|
|
9794465d88 | ||
|
|
1f163615c5 | ||
|
|
4304d7f786 | ||
|
|
38a5d95df9 | ||
|
|
4897195629 | ||
|
|
1416f05fbd | ||
|
|
ac1f64c3f5 | ||
|
|
8fa82840be | ||
|
|
af92b8922f | ||
|
|
f3d1569cb3 | ||
|
|
da41a23c0e | ||
|
|
e79aebbc8a | ||
|
|
fcd6038d5d | ||
|
|
d1fe0a03b5 | ||
|
|
cfdca08cfe | ||
|
|
d400bf6263 | ||
|
|
fa438db001 | ||
|
|
31dd34522f | ||
|
|
f5221910c8 | ||
|
|
6e7e1980f5 | ||
|
|
11e884e166 | ||
|
|
88943f0857 | ||
|
|
a5459a3aff | ||
|
|
e8fa4f23c6 | ||
|
|
df82c0790b | ||
|
|
81f1d91f5b | ||
|
|
abf0d45784 | ||
|
|
556e2ab99e | ||
|
|
4b60fb5141 | ||
|
|
5eb9c57ba1 | ||
|
|
e08b80afee | ||
|
|
9b8e5896a2 | ||
|
|
55e8c60a0b | ||
|
|
a30b026c9d | ||
|
|
cb79cbeb45 | ||
|
|
0e101aaf8b | ||
|
|
e8244595f3 | ||
|
|
37512eb8d6 | ||
|
|
567db063f3 | ||
|
|
cc1484a81e | ||
|
|
0dc278eed5 | ||
|
|
43ba30365a | ||
|
|
02ac95404d | ||
|
|
8388bdf1ec | ||
|
|
019c3dd8db | ||
|
|
481380f883 | ||
|
|
7c66260ff1 | ||
|
|
ad465b593f | ||
|
|
00d702f998 | ||
|
|
872f55d6c3 | ||
|
|
84f4c38336 | ||
|
|
b9b907490a | ||
|
|
8c6835a919 | ||
|
|
3a6bda4e08 | ||
|
|
60f76344c2 | ||
|
|
1fff7d5bcd | ||
|
|
d77d3ab6c7 | ||
|
|
4c91538f22 | ||
|
|
2eca4f7f14 | ||
|
|
053fa461a2 | ||
|
|
aa997466f0 | ||
|
|
fdf4fce5fa | ||
|
|
5746460e8d | ||
|
|
569ac8e3e0 | ||
|
|
d9efbb879d | ||
|
|
92ff4198ef | ||
|
|
48bd3ab49a | ||
|
|
9c7fc000e5 | ||
|
|
d2454b6b85 | ||
|
|
b4cda81535 | ||
|
|
2d0fae0cbe | ||
|
|
5515404062 | ||
|
|
24c4dc1861 | ||
|
|
3b1a2357cc | ||
|
|
35371fe971 | ||
|
|
365394f28b | ||
|
|
88c70a3ea0 | ||
|
|
b0eb1175c1 | ||
|
|
e90d627125 | ||
|
|
c1190d4ef9 | ||
|
|
67487415ad | ||
|
|
dcf80d7067 | ||
|
|
99a778811a | ||
|
|
eb76f0a6c5 | ||
|
|
b8de813859 | ||
|
|
6b480afd43 | ||
|
|
40d21542ae | ||
|
|
a8af5d2523 | ||
|
|
bfd12aed63 | ||
|
|
76936ea50d | ||
|
|
6947aea35e | ||
|
|
34be51c648 | ||
|
|
56b68b9a24 | ||
|
|
84e6f010d7 | ||
|
|
b360f953db | ||
|
|
320427c9c5 | ||
|
|
5e8543902e | ||
|
|
edae3c9ab7 | ||
|
|
fd9892c6b6 | ||
|
|
51c89fb8cc | ||
|
|
45668baaf8 | ||
|
|
305cc0e01c | ||
|
|
f0f365538b | ||
|
|
f9bba0baed | ||
|
|
306c18065a | ||
|
|
ded674d87c | ||
|
|
c64c71c98c | ||
|
|
7de87c1c25 | ||
|
|
12716bb6e1 | ||
|
|
8e68d573ff | ||
|
|
dd66e94bfd | ||
|
|
d399f75648 | ||
|
|
937173dd2f | ||
|
|
f1f7a40fba | ||
|
|
5522d364d4 | ||
|
|
3a218d246e | ||
|
|
bafc28e3bc | ||
|
|
6d1eb474c4 | ||
|
|
d172f4ffab | ||
|
|
c527b6e84f | ||
|
|
b8c7abd6b3 | ||
|
|
fea8e184c1 | ||
|
|
44a7bc0de9 | ||
|
|
4bad9ef183 | ||
|
|
590835c627 | ||
|
|
997766df92 | ||
|
|
cdbf66cd6c | ||
|
|
4c90eed59e | ||
|
|
d260f8ce2c | ||
|
|
12d0afb215 | ||
|
|
a9040f5f8f | ||
|
|
6e6acb5a71 | ||
|
|
256697d5b0 | ||
|
|
be9067b22e | ||
|
|
a5874a59f0 | ||
|
|
e8405e5638 | ||
|
|
ab70c9dfb1 | ||
|
|
1e4d8584c7 | ||
|
|
29eef77099 | ||
|
|
c50e89ae78 | ||
|
|
89917713d6 | ||
|
|
1e0ac46e07 | ||
|
|
6279b8f5f5 | ||
|
|
4007c87e20 | ||
|
|
ec0f42e76c | ||
|
|
99f63c2a6f | ||
|
|
12ac20f756 | ||
|
|
9d36d74005 | ||
|
|
da2cc977a0 | ||
|
|
84e7bdb586 | ||
|
|
b062a229c8 | ||
|
|
8680b3d815 | ||
|
|
6ab0e4c5a7 | ||
|
|
867bcf97d0 | ||
|
|
360bf9b37e | ||
|
|
4d85106fbf | ||
|
|
64a253b581 | ||
|
|
5f379c1356 | ||
|
|
76c80383ce | ||
|
|
e5a6ea80f0 | ||
|
|
b921e644df | ||
|
|
1c3fb8c192 | ||
|
|
d530d86a30 | ||
|
|
9d9229ef56 | ||
|
|
6f6f3c0800 | ||
|
|
7b234044f6 | ||
|
|
d46c82f34c | ||
|
|
4d5af610f0 | ||
|
|
1e94466f24 | ||
|
|
3210c0bce4 | ||
|
|
849f4ac579 | ||
|
|
6d56f67697 | ||
|
|
c0289719e7 | ||
|
|
a32e969b39 | ||
|
|
f5899e7781 | ||
|
|
ed07c956a7 | ||
|
|
2022ee5a07 | ||
|
|
a0bc1e8691 | ||
|
|
c1951ac49a | ||
|
|
e159e0e77b | ||
|
|
6bbd4134ec | ||
|
|
8a72b2150a | ||
|
|
e4d5d1eeb2 | ||
|
|
6bf2726b63 | ||
|
|
a63af0cb46 | ||
|
|
b2a7e1d2ed | ||
|
|
32a38b3b5a | ||
|
|
8533bcf0a7 | ||
|
|
e00eae1129 | ||
|
|
95595c4cbf | ||
|
|
aad36a4972 | ||
|
|
cc03f47d70 | ||
|
|
5c5e5c23ef | ||
|
|
4b531a2a1a | ||
|
|
35530bec0b | ||
|
|
5853bb2436 | ||
|
|
bfdf45d30d | ||
|
|
a330bc5020 | ||
|
|
66f68ef3ec | ||
|
|
d6e651129b | ||
|
|
d4a59b8253 | ||
|
|
569f1460a4 | ||
|
|
2f369dbd57 | ||
|
|
444e486862 | ||
|
|
b42504d827 | ||
|
|
18ac85a454 | ||
|
|
788a1a06c5 | ||
|
|
787b485bce | ||
|
|
788df0e888 | ||
|
|
916532f7c5 | ||
|
|
3c511bb177 | ||
|
|
49f13755c6 | ||
|
|
dcb4b1ae7e | ||
|
|
2152b48fe2 | ||
|
|
b6f2f99f21 | ||
|
|
c44df8ec06 | ||
|
|
493f082d6d | ||
|
|
bbe76b2709 | ||
|
|
ce8eda24fc | ||
|
|
9f9113bf9a | ||
|
|
a199595938 | ||
|
|
83de5fac75 | ||
|
|
c688657d53 | ||
|
|
a5c62c66b1 | ||
|
|
6d595d18ee | ||
|
|
946e8f1c47 | ||
|
|
b765c3756d | ||
|
|
54dc7bf6c3 | ||
|
|
6142a08db6 | ||
|
|
ca59976e00 | ||
|
|
7f7a160916 | ||
|
|
c8eb51c303 | ||
|
|
4160233a58 | ||
|
|
c5f79f754b | ||
|
|
5f568d681a | ||
|
|
83a2147428 | ||
|
|
9dd2cee6d9 | ||
|
|
57365013bd | ||
|
|
3d55ef075b | ||
|
|
14da6461b1 | ||
|
|
e84d3df024 | ||
|
|
ed38fe0ce9 | ||
|
|
b5daee3bcf | ||
|
|
f5c8c29f5a | ||
|
|
89fa2eae50 | ||
|
|
41b8c9238c | ||
|
|
28b66306da | ||
|
|
0bdbc1897a | ||
|
|
c3d9443a89 | ||
|
|
400db13a78 | ||
|
|
1d7d5858d5 | ||
|
|
8792f24c5d | ||
|
|
76d35b16eb | ||
|
|
81f7fe72ab | ||
|
|
649ba11edb | ||
|
|
2fc6d7c262 | ||
|
|
45421eedce | ||
|
|
8ecb3118e4 | ||
|
|
3fdb10890d | ||
|
|
2a6224c88d | ||
|
|
8d6ddc8250 | ||
|
|
6cc8590a1c | ||
|
|
063d908775 | ||
|
|
93565f0ebf | ||
|
|
1d7fcf5d18 | ||
|
|
897d20f12f | ||
|
|
a928925252 | ||
|
|
4088affa15 | ||
|
|
7def6aacd2 | ||
|
|
94ae1780cd | ||
|
|
2c65c4376b | ||
|
|
68bb3dbfa1 | ||
|
|
82a73693a6 | ||
|
|
612cd4a4c8 | ||
|
|
b3828dfc53 | ||
|
|
01f26567ed | ||
|
|
90d21c9c15 | ||
|
|
6351c1340e | ||
|
|
18cdddf76d | ||
|
|
b14c8bb1ac | ||
|
|
ceff286120 | ||
|
|
59aa4677e8 | ||
|
|
996cd4c856 | ||
|
|
9287149c26 | ||
|
|
306b56a999 | ||
|
|
812cf0a43f | ||
|
|
2c539fd833 | ||
|
|
334295ed67 | ||
|
|
c157b9cdfd | ||
|
|
8280b7a815 | ||
|
|
fb7f982c65 | ||
|
|
75b50d93e8 | ||
|
|
865bdac9df | ||
|
|
ebe5f468d7 | ||
|
|
1bc8d886f4 | ||
|
|
38e352e0d3 | ||
|
|
f6079e7031 | ||
|
|
8c51488190 | ||
|
|
9aad08ada6 | ||
|
|
2d3d11ba59 | ||
|
|
6087953185 | ||
|
|
851654c8a5 | ||
|
|
57a4745e29 | ||
|
|
32cd00895e | ||
|
|
dee5f2684f | ||
|
|
f639a526cf | ||
|
|
d168d8712e | ||
|
|
78a9605383 | ||
|
|
a713b1018e | ||
|
|
9f626dd10c | ||
|
|
8ec7fdd60a | ||
|
|
ffb2245ae6 | ||
|
|
21051c9a0b | ||
|
|
1c8bd34144 | ||
|
|
f614fb7e7d | ||
|
|
b222cd3e55 | ||
|
|
4f2be64813 | ||
|
|
bfb73ffc5a | ||
|
|
9bb7025752 | ||
|
|
bbfbd0b691 | ||
|
|
5628e96a90 | ||
|
|
ef517b7554 | ||
|
|
ba06af327d | ||
|
|
b8b03172bc | ||
|
|
fb5c3c1e6e | ||
|
|
faaa7b11d4 | ||
|
|
92a0467e1e | ||
|
|
3bb2025ea2 | ||
|
|
f2730ff0d7 | ||
|
|
7fcff9e5b4 | ||
|
|
51f83f4880 | ||
|
|
88cb510aea | ||
|
|
452c642af0 | ||
|
|
3fafc5004e | ||
|
|
fd8e502140 | ||
|
|
b499a5c38b | ||
|
|
2320383b16 | ||
|
|
59b3e73330 | ||
|
|
9d9a1b86c4 | ||
|
|
21cc2cefbf | ||
|
|
904df4260d | ||
|
|
af785d5d0b | ||
|
|
1d796856ca | ||
|
|
35f0d5a53f | ||
|
|
2b2fdd2b94 | ||
|
|
9e4539a902 | ||
|
|
a76c8ffd98 | ||
|
|
d7474cb8da | ||
|
|
890a23a537 | ||
|
|
ab17eee260 | ||
|
|
acadc3bd7c | ||
|
|
258d4a3fc1 | ||
|
|
c53f6425cd |
No files matched your search
@@ -4,6 +4,7 @@ BinPackParameters: false
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
PenaltyReturnTypeOnItsOwnLine: 140
|
||||
ReflowComments: false
|
||||
---
|
||||
Language: Proto
|
||||
IndentWidth: 2
|
||||
|
||||
@@ -7,6 +7,24 @@
|
||||
"commands": [
|
||||
"dotnet-format"
|
||||
]
|
||||
},
|
||||
"fable": {
|
||||
"version": "4.0.0-theta-018",
|
||||
"commands": [
|
||||
"fable"
|
||||
]
|
||||
},
|
||||
"fantomas": {
|
||||
"version": "5.2.2",
|
||||
"commands": [
|
||||
"fantomas"
|
||||
]
|
||||
},
|
||||
"fake-cli": {
|
||||
"version": "6.0.0",
|
||||
"commands": [
|
||||
"fake"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,3 +50,8 @@ trace_data/
|
||||
*.tmp/*
|
||||
/.venv*/*
|
||||
.cache/
|
||||
/src/Spark.Admin.WebApp/tsconfig.*.g.json
|
||||
/src/Spark.Admin.WebApp/src/bin/
|
||||
**/CMakeDeps.cmake
|
||||
**/CMakeDeps_win.cmake
|
||||
**/devcontainer.json
|
||||
@@ -1,12 +1,3 @@
|
||||
[submodule "externals"]
|
||||
path = externals
|
||||
url = git@bitbucket.org:bluetradesys/externals.git
|
||||
[submodule "docker/linux"]
|
||||
path = docker/linux
|
||||
url = git@bitbucket.org:bluetradesys/linux_docker.git
|
||||
[submodule "docker/windows"]
|
||||
path = docker/windows
|
||||
url = git@bitbucket.org:bluetradesys/windows_docker.git
|
||||
[submodule "src/deribit-crypto-connector-demo-application"]
|
||||
path = src/deribit-crypto-connector-demo-application
|
||||
url = git@gitlab.com:cryptoexchanges1/deribit-crypto-connector-demo-application.git
|
||||
+160
-72
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(spark)
|
||||
|
||||
if(WIN32)
|
||||
@@ -7,100 +7,188 @@ else()
|
||||
set(platform "linux")
|
||||
endif()
|
||||
|
||||
set(EXTERNALS_ROOT "${CMAKE_SOURCE_DIR}/externals/${platform}")
|
||||
set(SPARK_PYTHON "${EXTERNALS_ROOT}/python")
|
||||
set(
|
||||
EXTERNALS_ROOT
|
||||
"${CMAKE_SOURCE_DIR}/externals/${platform}"
|
||||
CACHE
|
||||
STRING
|
||||
"External dependencies root folder (should contain folders: lib, bin, include")
|
||||
set(SPARK_BIN "${EXTERNALS_ROOT}/bin")
|
||||
set(SPARK_INCLUDE "${EXTERNALS_ROOT}/include")
|
||||
set(SPARK_LIB "${EXTERNALS_ROOT}/lib/${CMAKE_BUILD_TYPE}")
|
||||
set(SPARK_LIB "${EXTERNALS_ROOT}/lib/$<CONFIG>")
|
||||
set(BUILD_SPARK_CONFIG OFF CACHE BOOL "Build lib_spark_config")
|
||||
set(BUILD_API_SERVER OFF CACHE BOOL "Build the api server")
|
||||
set(BUILD_DOCS OFF CACHE BOOL "Build documentation")
|
||||
set(BUILD_SDK OFF CACHE BOOL "Build the sdk")
|
||||
set(BUILD_WEB ON CACHE BOOL "Build the web server")
|
||||
set(BUILD_ADMIN_WEB_APP ON CACHE BOOL "Build the Admin WebApp")
|
||||
if (WIN32)
|
||||
set(BUILD_SPARKD OFF CACHE BOOL "Build sparkd")
|
||||
else()
|
||||
set(BUILD_SPARKD ON CACHE BOOL "Build sparkd")
|
||||
endif()
|
||||
|
||||
include_directories(BEFORE SYSTEM ${SPARK_INCLUDE} ${EXTERNALS_ROOT}/include/zlib)
|
||||
link_directories(${SPARK_LIB})
|
||||
|
||||
if(WIN32)
|
||||
# flags
|
||||
set(
|
||||
CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} \
|
||||
/MP \
|
||||
/WX /wd4251 /wd4250 /wd4251 /wd4244 /wd4267 /wd4355 /wd4275 /wd4345 \
|
||||
/bigobj \
|
||||
/DCURL_STATICLIB \
|
||||
/D_WINSOCK_DEPRECATED_NO_WARNINGS \
|
||||
/D__TBB_NO_IMPLICIT_LINKAGE \
|
||||
/DBOOST_ALL_NO_LIB \
|
||||
/std:c++17 \
|
||||
/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
|
||||
set(
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_RELEASE} \
|
||||
/DEBUG \
|
||||
/OPT:REF \
|
||||
/OPT:ICF \
|
||||
/LTCG")
|
||||
|
||||
add_compile_definitions(SHARED_MEMORY_PREFIX="spark")
|
||||
add_compile_definitions(APP_DATA_DIR="\$\{APPDATA\}/bts/")
|
||||
# subdirs
|
||||
add_subdirectory(src/lib_expression)
|
||||
add_subdirectory(src/lib)
|
||||
elseif(BUILD_SPARK_CONFIG)
|
||||
add_compile_definitions(SHARED_MEMORY_PREFIX="sparkd")
|
||||
add_compile_definitions(APP_DATA_DIR="\$\{HOME\}/sparkdata/")
|
||||
add_subdirectory(src/lib_core)
|
||||
add_subdirectory(src/lib_logging)
|
||||
add_subdirectory(src/lib_io)
|
||||
add_subdirectory(src/lib_domain)
|
||||
add_subdirectory(src/lib_protobuf)
|
||||
add_subdirectory(src/lib_threading)
|
||||
add_subdirectory(src/lib_expression)
|
||||
add_subdirectory(src/lib_md)
|
||||
add_subdirectory(src/lib_spark_config)
|
||||
else()
|
||||
# make sparkd look for libspark.so in its directory
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH ".")
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install/${CMAKE_BUILD_TYPE}/sparkd")
|
||||
add_compile_definitions(SPARK_ENABLE_CCAPI)
|
||||
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_FTX)
|
||||
add_compile_definitions(CCAPI_ENABLE_LOG_WARN)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install")
|
||||
set(SPARK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/$<CONFIG>")
|
||||
|
||||
# flags
|
||||
set(
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-pedantic \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wno-missing-braces \
|
||||
-Wno-ignored-qualifiers \
|
||||
--std=c++17 -fdiagnostics-color")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -DNDEBUG -O3")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
|
||||
if(BUILD_API_SERVER)
|
||||
add_compile_definitions(SPARK_ENABLE_API_SERVER)
|
||||
add_compile_definitions(APP_DATA_DIR="\$\{HOME\}/spark_api/")
|
||||
add_compile_definitions(SHARED_MEMORY_PREFIX="spark_api")
|
||||
elseif(BUILD_SPARKD)
|
||||
add_compile_definitions(SHARED_MEMORY_PREFIX="sparkd")
|
||||
add_compile_definitions(APP_DATA_DIR="\$\{HOME\}/sparkdata/")
|
||||
|
||||
# Note: All macros that begin w/ 'CCAPI' are ccapi's macros (defined and/or
|
||||
# read by their code). We override some below.
|
||||
add_compile_definitions(SPARK_ENABLE_CCAPI)
|
||||
|
||||
# This allows us to override hardcoded exchange-urls with ones read from
|
||||
# config (i.e., resolved at runtime rather than compile-time)
|
||||
add_compile_definitions(CCAPI_EXPOSE_INTERNAL)
|
||||
|
||||
# Enable ccapi exchanges/services
|
||||
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_DERIBIT)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_FTX)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE_US)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE_USDS_FUTURES)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE_COIN_FUTURES)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_HUOBI)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP)
|
||||
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP)
|
||||
|
||||
set(CCAPI_LOG_LEVEL
|
||||
"Warn"
|
||||
CACHE STRING "<Fatal|Error|Warn|Info|Debug|Trace> Log level for ccapi")
|
||||
string(TOUPPER "${CCAPI_LOG_LEVEL}" _ccapi_log_level_upper)
|
||||
add_compile_definitions("CCAPI_ENABLE_LOG_${_ccapi_log_level_upper}")
|
||||
|
||||
# ** Binance **
|
||||
add_compile_definitions(CCAPI_BINANCE_URL_REST_BASE="https://api.binance.com")
|
||||
add_compile_definitions(BINANCE_INSTRUMENTS_PATH="/api/v3/exchangeInfo")
|
||||
add_compile_definitions(BINANCE_PRICE_STATS_PATH="/api/v3/ticker/24hr")
|
||||
|
||||
# ** Binance US **
|
||||
add_compile_definitions(BINANCE_US_INSTRUMENTS_PATH="/api/v3/exchangeInfo")
|
||||
add_compile_definitions(BINANCE_US_PRICE_STATS_PATH="/api/v3/ticker/24hr")
|
||||
|
||||
# ** Binance USDS Futures **
|
||||
add_compile_definitions(CCAPI_BINANCE_USDS_FUTURES_URL_REST_BASE="https://dapi.binance.com")
|
||||
add_compile_definitions(BINANCE_USDS_FUTURES_INSTRUMENTS_PATH="/dapi/v1/exchangeInfo")
|
||||
add_compile_definitions(BINANCE_USDS_FUTURES_PRICE_STATS_PATH="/dapi/v1/ticker/24hr")
|
||||
|
||||
endif()
|
||||
|
||||
# subdirs
|
||||
add_subdirectory(src/server/sparkd)
|
||||
if (BUILD_SPARKD)
|
||||
add_subdirectory(src/server/sparkd)
|
||||
add_subdirectory(src/data_files)
|
||||
# add_subdirectory(src/lib_md)
|
||||
add_subdirectory(src/lib_core)
|
||||
add_subdirectory(src/lib_logging)
|
||||
add_subdirectory(src/lib_threading)
|
||||
add_subdirectory(src/lib_expression)
|
||||
add_subdirectory(src/lib_spark_config)
|
||||
endif()
|
||||
add_subdirectory(src/lib)
|
||||
if (BUILD_WEB)
|
||||
add_subdirectory(src/web)
|
||||
if (BUILD_ADMIN_WEB_APP)
|
||||
add_subdirectory(src/Spark.Admin.WebApp)
|
||||
endif()
|
||||
if (BUILD_API_SERVER)
|
||||
set(_cs_source_dirs
|
||||
spark_api
|
||||
spark_api_server
|
||||
spark_core
|
||||
spark_websocket)
|
||||
foreach(cs_source_dir IN LISTS _cs_source_dirs)
|
||||
file(GLOB cs_source_dir "${CMAKE_SOURCE_DIR}/src/client/${cs_source_dir}/*.cs")
|
||||
list(APPEND _api_server_sources ${cs_source_dir})
|
||||
endforeach()
|
||||
|
||||
list(APPEND _api_server_sources
|
||||
${CMAKE_SOURCE_DIR}/src/client/spark_api/spark_api.csproj
|
||||
${CMAKE_SOURCE_DIR}/src/client/spark_api_server/spark_api_server.csproj
|
||||
${CMAKE_SOURCE_DIR}/src/client/spark_core/spark_core.csproj
|
||||
${CMAKE_SOURCE_DIR}/src/client/spark_websocket/spark_websocket.csproj)
|
||||
|
||||
set(_out_dir ${CMAKE_BINARY_DIR}/$<CONFIG>)
|
||||
set(_api_server_dlls
|
||||
${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0/spark_api.dll
|
||||
${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0/spark_core.dll
|
||||
${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0/spark_websocket.dll
|
||||
${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0/spark_api_server)
|
||||
add_custom_command(
|
||||
OUTPUT ${_api_server_dlls}
|
||||
COMMAND dotnet build ${CMAKE_SOURCE_DIR}/Spark.Api.Server.sln --verbosity minimal --configuration $<CONFIG>
|
||||
COMMENT "Building Spark.Api.Server.sln"
|
||||
DEPENDS ${_api_server_sources})
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0/libspark.so
|
||||
COMMAND ln -sf ARGS ${CMAKE_BINARY_DIR}/src/lib/$<CONFIG>/libspark.so ${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0
|
||||
COMMENT "Symlink libspark to api server bins"
|
||||
DEPENDS ${_api_server_dlls})
|
||||
add_custom_target(websocket_api_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/$<CONFIG>/bin/net7.0/libspark.so)
|
||||
endif()
|
||||
if(BUILD_DOCS)
|
||||
add_subdirectory(doc/user)
|
||||
endif()
|
||||
add_subdirectory(doc/user)
|
||||
if(BUILD_SDK)
|
||||
add_subdirectory(src/sdk)
|
||||
endif()
|
||||
add_subdirectory(src/data_files)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/server/sparkd/sparkd ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND
|
||||
ln ARGS -sf
|
||||
${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0
|
||||
${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
|
||||
COMMENT "Creating server runtime layout"
|
||||
DEPENDS sparkd data_files_dir)
|
||||
if(BUILD_SPARKD)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/server/sparkd/sparkd ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND
|
||||
ln ARGS -sf
|
||||
${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0
|
||||
${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
|
||||
COMMENT "Creating server runtime layout"
|
||||
DEPENDS sparkd data_files_dir)
|
||||
|
||||
add_custom_target(server_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/server)
|
||||
add_custom_target(server_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/server)
|
||||
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/externals/linux/lib/${CMAKE_BUILD_TYPE}/libACE-5.7.5.so" DESTINATION bin)
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/externals/linux/lib/${CMAKE_BUILD_TYPE}/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0" DESTINATION bin)
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/externals/src/emumba/sparkd.lic" DESTINATION bin)
|
||||
install(
|
||||
DIRECTORY "${CMAKE_BINARY_DIR}/server/plugins"
|
||||
DESTINATION "${SPARK_INSTALL_PREFIX}/bin")
|
||||
install(
|
||||
FILES
|
||||
"${SPARK_LIB}/libACE-5.7.5.so"
|
||||
"${SPARK_LIB}/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0"
|
||||
"${CMAKE_SOURCE_DIR}/externals/src/emumba/sparkd.lic"
|
||||
DESTINATION "${SPARK_INSTALL_PREFIX}/bin")
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,283 @@
|
||||
{
|
||||
"version": 4,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 23,
|
||||
"patch": 0
|
||||
},
|
||||
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "spark",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"environment": {
|
||||
"SPARK_CMAKE_CXX_FLAGS": "/MP /WX /wd4250 /wd4251 /wd4244 /wd4267 /wd4355 /wd4275 /wd4345 /bigobj /EHsc /DCURL_STATICLIB /D_WINSOCK_DEPRECATED_NO_WARNINGS /D__TBB_NO_IMPLICIT_LINKAGE /DBOOST_ALL_NO_LIB /std:c++17 /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_FLAGS": "$env{SPARK_CMAKE_CXX_FLAGS}",
|
||||
"CMAKE_CXX_FLAGS_DEBUG": "$env{SPARK_CMAKE_CXX_FLAGS} /MTd",
|
||||
"CMAKE_CXX_FLAGS_RELEASE": "$env{SPARK_CMAKE_CXX_FLAGS} /MT",
|
||||
"CMAKE_SHARED_LINKER_FLAGS_RELEASE": "/DEBUG /OPT:REF /OPT:ICF /LTCG",
|
||||
"EXTERNALS_ROOT": "${sourceDir}/externals/windows"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
},
|
||||
"hidden": true,
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"cacheVariables": {
|
||||
"platform": "",
|
||||
"CMAKE_BUILD_WITH_INSTALL_RPATH": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
},
|
||||
"CMAKE_INSTALL_RPATH": ".",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}/sparkd",
|
||||
"CMAKE_EXE_LINKER_FLAGS": "-Wno-undef",
|
||||
"EXTERNALS_ROOT": "${sourceDir}/externals/linux",
|
||||
"CMAKE_CXX_STANDARD": "17",
|
||||
"BUILD_SDK": {
|
||||
"type": "BOOL",
|
||||
"value": "OFF"
|
||||
},
|
||||
"BUILD_ADMIN_WEB_APP": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-debug",
|
||||
"inherits": "sparkd",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
},
|
||||
"CCAPI_LOG_LEVEL": "Debug"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-release",
|
||||
"inherits": "sparkd",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CCAPI_LOG_LEVEL": "Warn"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-debug-clang",
|
||||
"inherits": "sparkd-debug",
|
||||
"displayName": "Debug (clang)",
|
||||
"description": "Debug build compiled w/ clang",
|
||||
"binaryDir": "${sourceDir}/build/clang/debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_CXX_FLAGS_DEBUG": "-g -fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++17 -fdiagnostics-color -DDEBUG",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/clang/debug/sparkd"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-debug-gcc",
|
||||
"inherits": "sparkd-debug",
|
||||
"displayName": "Debug (gcc)",
|
||||
"description": "Debug build compiled w/ gcc",
|
||||
"binaryDir": "${sourceDir}/build/gcc/debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "gcc",
|
||||
"CMAKE_CXX_COMPILER": "g++",
|
||||
"CMAKE_CXX_FLAGS_DEBUG": "-g -fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++17 -fdiagnostics-color -Wno-stringop-overread -DDEBUG",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/gcc/debug/sparkd"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-release-clang",
|
||||
"inherits": "sparkd-release",
|
||||
"displayName": "Release (clang)",
|
||||
"description": "Release build compiled w/ clang",
|
||||
"binaryDir": "${sourceDir}/build/clang/release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "clang",
|
||||
"CMAKE_CXX_COMPILER": "clang++",
|
||||
"CMAKE_CXX_FLAGS_RELEASE": "-fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++17 -fdiagnostics-color -fno-omit-frame-pointer -DNDEBUG -O3",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/clang/release/sparkd"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-release-gcc",
|
||||
"inherits": "sparkd-release",
|
||||
"displayName": "Release (gcc)",
|
||||
"description": "Release build compiled w/ gcc",
|
||||
"binaryDir": "${sourceDir}/build/gcc/release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "gcc",
|
||||
"CMAKE_CXX_COMPILER": "g++",
|
||||
"CMAKE_CXX_FLAGS_RELEASE": "-fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++17 -fdiagnostics-color -Wno-stringop-overread -Wno-maybe-uninitialized -fno-omit-frame-pointer -DNDEBUG -O3",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/gcc/release/sparkd"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-publish",
|
||||
"inherits": "sparkd-release-gcc",
|
||||
"displayName": "Publish",
|
||||
"description": "Production build compiled w/ gcc and ready to ship"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "spark-config",
|
||||
"displayName": "Spark Config",
|
||||
"description": "Test build for lib_spark_config",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"generator": "Unix Makefiles",
|
||||
"cacheVariables": {
|
||||
"platform": "linux",
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_BUILD_WITH_INSTALL_RPATH": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
},
|
||||
"CMAKE_INSTALL_RPATH": ".",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}",
|
||||
"CMAKE_EXE_LINKER_FLAGS": "-Wno-undef",
|
||||
"EXTERNALS_ROOT": "${sourceDir}/externals/linux",
|
||||
"CMAKE_CXX_STANDARD": "17",
|
||||
"BUILD_SPARKD": {
|
||||
"type": "BOOL",
|
||||
"value": "OFF"
|
||||
},
|
||||
"BUILD_DOCS": {
|
||||
"type": "BOOL",
|
||||
"value": "OFF"
|
||||
},
|
||||
"BUILD_SDK": {
|
||||
"type": "BOOL",
|
||||
"value": "OFF"
|
||||
},
|
||||
"BUILD_SPARK_CONFIG": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
},
|
||||
"BUILD_ADMIN_WEB_APP": {
|
||||
"type": "BOOL",
|
||||
"value": "OFF"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "spark",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"hidden": true,
|
||||
"jobs": 4
|
||||
},
|
||||
|
||||
{
|
||||
"name": "spark-dev",
|
||||
"displayName": "Development",
|
||||
"inherits": "spark",
|
||||
"configurePreset": "spark",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "spark-prod",
|
||||
"displayName": "Production",
|
||||
"inherits": "spark",
|
||||
"configurePreset": "spark",
|
||||
"configuration": "Release"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
},
|
||||
"hidden": true,
|
||||
"jobs": 4,
|
||||
"targets": [
|
||||
"data_files_dir",
|
||||
"admin_web_app_bundle",
|
||||
"install",
|
||||
"libspark",
|
||||
"rapidjson_project",
|
||||
"server_layout",
|
||||
"sparkd"
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-debug-clang",
|
||||
"configurePreset": "sparkd-debug-clang",
|
||||
"displayName": "Debug (clang)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-debug-gcc",
|
||||
"configurePreset": "sparkd-debug-gcc",
|
||||
"displayName": "Debug (gcc)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-release-clang",
|
||||
"configurePreset": "sparkd-release-clang",
|
||||
"displayName": "Release (clang)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-release-gcc",
|
||||
"configurePreset": "sparkd-release-gcc",
|
||||
"displayName": "Release (gcc)",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "spark-config",
|
||||
"configurePreset": "spark-config",
|
||||
"displayName": "Spark Config",
|
||||
"inherits": "sparkd"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sparkd-publish",
|
||||
"configurePreset": "sparkd-publish",
|
||||
"displayName": "Publish",
|
||||
"inherits": "sparkd",
|
||||
"targets": "install"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32922.545
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_websocket", "src\client\spark_websocket\spark_websocket.csproj", "{3201359D-C071-4089-9EDE-B04D759F1508}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api_server", "src\client\spark_api_server\spark_api_server.csproj", "{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "spark_test", "src\client\spark_test\spark_test.csproj", "{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spark.Console", "src\client\Spark.Console\Spark.Console.csproj", "{89D666E6-B500-498F-B026-4D167F68ADFC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
Release|x64 = Release|x64
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Debug|x64.Build.0 = Debug|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Debug|x64.Build.0 = Debug|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.Release|x64.Build.0 = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Debug|x64.Build.0 = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Release|x64.ActiveCfg = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Release|x64.Build.0 = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Debug|x64.Build.0 = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Release|x64.ActiveCfg = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Release|x64.Build.0 = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.Debug|x64.Build.0 = Debug|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.Release|x64.ActiveCfg = Release|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.Release|x64.Build.0 = Release|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.RelWithDebInfo|x64.ActiveCfg = Debug|x64
|
||||
{EFC9FC4D-E92B-4C6D-9B97-26D38EAA118D}.RelWithDebInfo|x64.Build.0 = Debug|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.Debug|x64.Build.0 = Debug|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.Release|x64.ActiveCfg = Release|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.Release|x64.Build.0 = Release|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.RelWithDebInfo|x64.ActiveCfg = Debug|x64
|
||||
{89D666E6-B500-498F-B026-4D167F68ADFC}.RelWithDebInfo|x64.Build.0 = Debug|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {422D1620-0166-4C26-9A81-CA8A2EB1AB58}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+26
-14
@@ -16,13 +16,26 @@ function(Protobuf_Generate_Cpp SRCS HDRS)
|
||||
|
||||
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
|
||||
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
|
||||
|
||||
set(PROTOBUF_INCLUDE_DIR_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
# list(APPEND PROTOBUF_INCLUDE_DIR_ARGS " -I ")
|
||||
# list(APPEND PROTOBUF_INCLUDE_DIR_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
foreach(INC ${PROTOBUF_INCLUDE_DIRS})
|
||||
set(PROTOBUF_INCLUDE_DIR_ARGS ${PROTOBUF_INCLUDE_DIR_ARGS} -I ${INC})
|
||||
# list(APPEND PROTOBUF_INCLUDE_DIR_ARGS " -I ")
|
||||
# list(APPEND PROTOBUF_INCLUDE_DIR_ARGS ${INC})
|
||||
endforeach()
|
||||
set(PROTOBUF_INCLUDE_DIR_ARGS ${PROTOBUF_INCLUDE_DIR_ARGS} -I ${CMAKE_CURRENT_BINARY_DIR})
|
||||
# string(JOIN " -I " PROTOBUF_INCLUDE_DIR_ARGS_ ${PROTOBUF_INCLUDE_DIR_ARGS})
|
||||
message("pb inc: ${PROTOBUF_INCLUDE_DIR_ARGS}")
|
||||
# set(cmd_text "${Protobuf_PROTOC_EXECUTABLE} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} -I ${PROTOBUF_INCLUDE_DIR_ARGS_} -I ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL}")
|
||||
message("CMD: ${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR} -I ${PROTOBUF_INCLUDE_DIR_ARGS} ${ABS_FIL}")
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
||||
COMMAND
|
||||
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${CMAKE_BINARY_DIR}/src -I
|
||||
${PROTOBUF_INCLUDE_DIRS} -I ${CMAKE_SOURCE_DIR}/src ${ABS_FIL}
|
||||
COMMAND ${Protobuf_PROTOC_EXECUTABLE} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} -I ${PROTOBUF_INCLUDE_DIR_ARGS} ${ABS_FIL}
|
||||
# COMMAND
|
||||
# ${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR} -I
|
||||
# ${PROTOBUF_INCLUDE_DIR_ARGS} ${ABS_FIL}
|
||||
DEPENDS ${ABS_FIL}
|
||||
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
||||
VERBATIM)
|
||||
@@ -90,10 +103,10 @@ function(Service_Compiler_Generate_Cpp SRCS HDRS)
|
||||
COMMAND SET PYTHONPATH=${SPARK_PYTHON}
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/.venv/Scripts/activate.bat
|
||||
COMMAND
|
||||
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${CMAKE_BINARY_DIR}/src
|
||||
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR}
|
||||
--plugin=protoc-gen-service=${CMAKE_SOURCE_DIR}/src/lib/api/service_compiler/plugin.cmd
|
||||
--service_out=lang=cpp:${CMAKE_BINARY_DIR}/src -I
|
||||
${PROTOBUF_INCLUDE_DIRS} -I ${CMAKE_SOURCE_DIR}/src ${ABS_FIL}
|
||||
--service_out=lang=cpp:${CMAKE_CURRENT_BINARY_DIR} -I
|
||||
${PROTOBUF_INCLUDE_DIRS} -I ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL}
|
||||
DEPENDS ${ABS_FIL} ${TEMPLATES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api/service_compiler/plugin.py
|
||||
COMMENT "Running C++ service compiler on ${FIL}"
|
||||
@@ -106,12 +119,13 @@ function(Service_Compiler_Generate_Cpp SRCS HDRS)
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.client.pb.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.server.pb.cc"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.server.pb.h"
|
||||
COMMAND
|
||||
"PYTHONPATH=${SPARK_PYTHON}" ${Protobuf_PROTOC_EXECUTABLE} ARGS
|
||||
--cpp_out=${CMAKE_BINARY_DIR}/src
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/tools/venv_exec.sh
|
||||
ARGS
|
||||
${Protobuf_PROTOC_EXECUTABLE}
|
||||
--cpp_out=${CMAKE_CURRENT_BINARY_DIR}
|
||||
--plugin=protoc-gen-service=${CMAKE_SOURCE_DIR}/src/lib/api/service_compiler/plugin.py
|
||||
--service_out=lang=cpp,make_file_name=${ABS_FIL}:${CMAKE_BINARY_DIR}/src
|
||||
-I ${PROTOBUF_INCLUDE_DIRS} -I ${CMAKE_SOURCE_DIR}/src ${ABS_FIL}
|
||||
--service_out=lang=cpp,make_file_name=${ABS_FIL}:${CMAKE_CURRENT_BINARY_DIR}
|
||||
-I ${PROTOBUF_INCLUDE_DIRS} -I ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL}
|
||||
DEPENDS ${ABS_FIL} ${TEMPLATES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api/service_compiler/plugin.py
|
||||
COMMENT "Running C++ service compiler on ${FIL}"
|
||||
@@ -120,8 +134,6 @@ function(Service_Compiler_Generate_Cpp SRCS HDRS)
|
||||
|
||||
endforeach()
|
||||
|
||||
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
||||
|
||||
# remove some warnings from protobuf generated files
|
||||
if(WIN32)
|
||||
set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
[cmake ext]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools
|
||||
[cmake presets]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
|
||||
[cpp ext]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
|
||||
[clangd ext]: https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
|
||||
[py venv]: https://docs.python.org/3/library/venv.html
|
||||
|
||||
# C++ Intellisense for Spark on Windows (VS Code)
|
||||
**Steps**
|
||||
1. Install the **[C++ extension][cpp ext]**
|
||||
2. Install the **[CMake extension][cmake ext]**
|
||||
3. Copy `c_cpp_properties.json` from this folder to `$workspaceFolder/.vscode/`
|
||||
4. In the VS Code Command Palette, run **CMake: Select Configure Preset**, then
|
||||
select '**spark**' from the dropdown
|
||||
|
||||
**Notes**
|
||||
* Intellisense won't work for generated files/types until you build libspark
|
||||
|
||||
# C++ Intellisense for Sparkd on Linux (VS Code)
|
||||
1. Install the **[CMake extension][cmake ext]**
|
||||
2. Install the **[Clangd extension][clangd ext]**
|
||||
3. (Optional) Install the **[C++ extension][cpp ext]** (*needed for debugging,
|
||||
but intellisense should work without it*).
|
||||
4. If the **[C++ extension][cpp ext]** is installed, disable its intellisense in
|
||||
your workspace settings (*Clangd intellisense is better*)
|
||||
```
|
||||
"C_Cpp.intelliSenseEngine": "disabled"
|
||||
```
|
||||
5. In the VS Code Command Palette, run **CMake: Select Configure Preset**, then select the
|
||||
**[preset][cmake presets]** you wish to build from the dropdown
|
||||
* *The **Clang** presets may work best with the **Clangd** extension*
|
||||
* *Intellisense won't work for generated files/types until you build libspark*
|
||||
|
||||
# Build Sparkd on Linux
|
||||
|
||||
**Notes**
|
||||
* Sparkd is built using **[CMakePresets][cmake presets]**
|
||||
|
||||
**Steps**
|
||||
1. Set up the **[Python virtual environment][py venv]**<br>
|
||||
* *Run commands from the repo root dir unless otherwise noted*
|
||||
1. Create the virtual environment
|
||||
```
|
||||
python3 -m venv .venv
|
||||
```
|
||||
2. Activate the virtual environment
|
||||
```
|
||||
. .venv/bin/activate
|
||||
```
|
||||
3. Verify `python` in the venv is first in the path<br>
|
||||
* ***Expected:** output shows the absolute path to `.venv/bin/python`*
|
||||
```
|
||||
which python
|
||||
```
|
||||
4. Update `pip`<br>
|
||||
* *The venv module initializes virtual environments with its own version
|
||||
of pip, rather than the system's version. Even if the latter is up-to-date, the
|
||||
former may not be.*
|
||||
```
|
||||
python -m pip install --upgrade pip
|
||||
```
|
||||
5. Install the packages listed `requirements.txt`
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
2. Build **Sparkd**<br>
|
||||
* From the terminal
|
||||
```
|
||||
tools/build_sparkd.sh
|
||||
```
|
||||
* *Run with `--help` to see available options*
|
||||
* From VS Code
|
||||
1. Install the **[CMake extension][cmake ext]**
|
||||
2. In the VS Code Command Palette, run **CMake: Select Configure
|
||||
Preset**, then select the **[preset][cmake presets]** you wish to
|
||||
build from the dropdown
|
||||
3. Run **CMake: Build** in the command palette.
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": 4,
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Windows",
|
||||
"intelliSenseMode": "windows-msvc-x64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/src/",
|
||||
"${workspaceFolder}/build/src/",
|
||||
"${workspaceFolder}/externals/windows/include/"
|
||||
],
|
||||
"defines": ["_WIN32", "__x86_64__"],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceRoot}/src",
|
||||
"${workspaceRoot}/build/src"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true
|
||||
},
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++17",
|
||||
"configurationProvider": "ms-vscode.cmake-tools",
|
||||
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
|
||||
"mergeConfigurations": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -46,6 +46,7 @@ function setup_build
|
||||
assert_dir $repo_root
|
||||
assert_dir $build_root
|
||||
set compiler "$argv[1]"
|
||||
set c_compiler (which cc)
|
||||
set build_type "$argv[2]"
|
||||
|
||||
if test \( -z "$build_type" \) -o \( \( "$build_type" != debug \) -a \( "$build_type" != release \) \)
|
||||
@@ -59,6 +60,7 @@ function setup_build
|
||||
else
|
||||
# set compiler_arg "/usr/lib/ccache/clang++"
|
||||
set compiler_arg "clang++"
|
||||
set c_compiler (which clang)
|
||||
end
|
||||
else if test "$build_type" = release
|
||||
set build_type_arg Release
|
||||
@@ -85,7 +87,7 @@ function setup_build
|
||||
rm -rf "$build_dest"
|
||||
mkdir -p "$build_dest"
|
||||
cd "$build_dest"
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=$build_type_arg -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=$compiler_arg $repo_root
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=$build_type_arg -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_C_COMPILER=$c_compiler -DCMAKE_CXX_COMPILER=$compiler_arg $repo_root
|
||||
end
|
||||
|
||||
# The while loop below removes arguments (via shift) as it parses them.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
set(sources /home/taha/spark/doc/user/build.sh;content/_index.md;content/bts_spark/Glossary/_index.md;content/bts_spark/Help/_index.md;content/bts_spark/Help/about_spark.png;content/bts_spark/Help/image39.png;content/bts_spark/Help/image58.png;content/bts_spark/Launcher/_index.md;content/bts_spark/Launcher/image38.png;content/bts_spark/Launcher/image68.png;content/bts_spark/Logging-In-to-the-System/_index.md;content/bts_spark/Logging-In-to-the-System/image3.png;content/bts_spark/Logging-In-to-the-System/image64.png;content/bts_spark/Market/_index.md;content/bts_spark/Market/change_securities.png;content/bts_spark/Market/image11.png;content/bts_spark/Market/image14.png;content/bts_spark/Market/image20.png;content/bts_spark/Market/image21.png;content/bts_spark/Market/image23.png;content/bts_spark/Market/image24.png;content/bts_spark/Market/image34.png;content/bts_spark/Market/image49.png;content/bts_spark/Market/image53.png;content/bts_spark/Market/image66.png;content/bts_spark/Market/image69.png;content/bts_spark/Market/market_view.png;content/bts_spark/Market/settings_icon.png;content/bts_spark/Market/time_and_sales.png;content/bts_spark/My-Windows/_index.md;content/bts_spark/My-Windows/image15.png;content/bts_spark/My-Windows/image16.png;content/bts_spark/My-Windows/image37.png;content/bts_spark/Settings/_index.md;content/bts_spark/Settings/image51.png;content/bts_spark/Settings/image9.png;content/bts_spark/Spreader/_index.md;content/bts_spark/Spreader/image10.png;content/bts_spark/Spreader/image13.png;content/bts_spark/Spreader/image18.png;content/bts_spark/Spreader/image19.png;content/bts_spark/Spreader/image28.png;content/bts_spark/Spreader/image29.png;content/bts_spark/Spreader/image31.png;content/bts_spark/Spreader/image35.png;content/bts_spark/Spreader/image40.png;content/bts_spark/Spreader/image43.png;content/bts_spark/Spreader/image54.png;content/bts_spark/Spreader/image55.png;content/bts_spark/Spreader/image56.png;content/bts_spark/Spreader/image6.png;content/bts_spark/Spreader/image7.png;content/bts_spark/Spreader/image70.png;content/bts_spark/Spreader/image72.png;content/bts_spark/Spreader/image8.png;content/bts_spark/Trading/OrderTypes/index.md;content/bts_spark/Trading/_index.md;content/bts_spark/Trading/algo_studio.png;content/bts_spark/Trading/collapse_all_icon.png;content/bts_spark/Trading/cover_algo_control.png;content/bts_spark/Trading/expand_all_icon.png;content/bts_spark/Trading/image1.png;content/bts_spark/Trading/image17.png;content/bts_spark/Trading/image2.png;content/bts_spark/Trading/image25.png;content/bts_spark/Trading/image27.png;content/bts_spark/Trading/image33.png;content/bts_spark/Trading/image42.png;content/bts_spark/Trading/image44.png;content/bts_spark/Trading/image47.png;content/bts_spark/Trading/image48.png;content/bts_spark/Trading/image5.png;content/bts_spark/Trading/image50.png;content/bts_spark/Trading/image52.png;content/bts_spark/Trading/image57.png;content/bts_spark/Trading/image59.png;content/bts_spark/Trading/image60.png;content/bts_spark/Trading/image61.png;content/bts_spark/Trading/image62.png;content/bts_spark/Trading/image73.png;content/bts_spark/Trading/image74.png;content/bts_spark/Trading/join_algo_control.png;content/bts_spark/Trading/ladder.png;content/bts_spark/Trading/ladder_badges.png;content/bts_spark/Trading/ladder_main_part.png;content/bts_spark/Trading/lean_algo_control.png;content/bts_spark/Trading/mini_orderbook.png;content/bts_spark/Trading/oco_algo_control.png;content/bts_spark/Trading/offset_algo_control.png;content/bts_spark/Trading/pnl_calculation.png;content/bts_spark/Trading/pnl_window.png;content/bts_spark/Trading/recreate_icon.png;content/bts_spark/Trading/settings_icon.png;content/bts_spark/Trading/spark_menu_order_book.png;content/bts_spark/Trading/top_algo_control.png;content/bts_spark/Trading/trigger_algo_control.png;content/bts_spark/_index.md;content/release_notes/_index.md;content/system_requirements/_index.md;static/book.js;static/favicon.ico;static/image.js;templates/index.html;templates/page.html;templates/section.html;templates/shortcodes/back_button.html)
|
||||
-1
Submodule docker/linux deleted from 05967d0f18.
@@ -0,0 +1,103 @@
|
||||
FROM ubuntu:22.10
|
||||
|
||||
RUN \
|
||||
apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
clang-13 \
|
||||
clang-format-13 \
|
||||
clangd-13 \
|
||||
clang-15 \
|
||||
clang-format-15 \
|
||||
clangd-15 \
|
||||
cmake \
|
||||
curl \
|
||||
dotnet7 \
|
||||
fish \
|
||||
g++-11 \
|
||||
g++-12 \
|
||||
gnupg \
|
||||
liblttng-ust-dev \
|
||||
libssh2-1-dev \
|
||||
libpcap0.8-dev \
|
||||
locales \
|
||||
ninja-build \
|
||||
nodejs \
|
||||
npm \
|
||||
openssh-server \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
rapidjson-dev \
|
||||
software-properties-common \
|
||||
sqlite3 \
|
||||
sudo \
|
||||
tar \
|
||||
vim \
|
||||
wget
|
||||
|
||||
# this is done here so that ccache sees clang++ installed, not clang-10
|
||||
RUN \
|
||||
apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ccache
|
||||
|
||||
# emumba deps
|
||||
RUN \
|
||||
apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
tzdata \
|
||||
build-essential \
|
||||
cmake-curses-gui \
|
||||
git-all \
|
||||
doxygen \
|
||||
python3-sphinx \
|
||||
graphviz \
|
||||
libgtest-dev \
|
||||
libssl-dev \
|
||||
libboost-filesystem-dev \
|
||||
libboost-program-options-dev \
|
||||
libboost-test-dev \
|
||||
libboost-date-time-dev \
|
||||
zlib1g-dev \
|
||||
netcat-traditional \
|
||||
net-tools \
|
||||
gdb gdbserver \
|
||||
pkg-config
|
||||
|
||||
# set up default executables (update-alternatives)
|
||||
RUN \
|
||||
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-13 100; \
|
||||
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-13 100; \
|
||||
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100; \
|
||||
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-13 100; \
|
||||
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100; \
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100
|
||||
|
||||
# Add compiler symlinks for ccache
|
||||
RUN \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/clang; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/clang++; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/clang-13; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/clang++-13; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/clang-15; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/clang++-15; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/gcc; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/g++; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/gcc-11; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/g++-11; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/gcc-12; \
|
||||
ln -s /usr/bin/ccache /usr/local/bin/g++-12
|
||||
|
||||
RUN locale-gen en_US.UTF-8
|
||||
|
||||
ARG docker_user="bts"
|
||||
ARG docker_uid="1000"
|
||||
ARG docker_pass="bts"
|
||||
|
||||
RUN \
|
||||
groupadd -g "$docker_uid" "$docker_user" \
|
||||
&& useradd \
|
||||
-m \
|
||||
-u "$docker_uid" \
|
||||
-g "$docker_uid" \
|
||||
-G sudo \
|
||||
--password "$(openssl passwd -1 "$docker_pass")" \
|
||||
"$docker_user"
|
||||
@@ -0,0 +1,64 @@
|
||||
[dev containers]: https://code.visualstudio.com/docs/devcontainers/containers
|
||||
[dev containers ext]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
|
||||
[docker repo sparkd-dev]: https://hub.docker.com/repository/docker/bluetradingsystems/sparkd-dev/general
|
||||
# Sparkd Dev Container
|
||||
## How to create a VS Code [Dev Container][dev containers]
|
||||
|
||||
1. Make sure the **[Dev Containers][dev containers ext]** extension is installed
|
||||
1. Make sure your Docker image is up to date
|
||||
```
|
||||
docker pull bluetradingsystems/sparkd-dev:latest
|
||||
```
|
||||
1. Copy **devcontainer.json** from this folder to **$workspaceFolder/.devcontainer/**.
|
||||
|
||||
1. In the VS Code Command Palette, run **Dev Containers: Reopen in Container**
|
||||
|
||||
---
|
||||
## How to create a Sparkd Container in the terminal (without VS Code)
|
||||
|
||||
1. Make sure your Docker image is up to date
|
||||
```
|
||||
docker pull bluetradingsystems/sparkd-dev:latest
|
||||
```
|
||||
2. Start the container
|
||||
```
|
||||
# Replace <cont_name> with a name for the container. The container's
|
||||
# "$HOME" dir will be mounted to "$HOME/.sparkd-dev/mounts/<cont_name> on
|
||||
# the host
|
||||
|
||||
./start_docker.sh --container <cont_name> --mount-existing
|
||||
```
|
||||
* *Replace <cont_name> with a name for the container*
|
||||
* *The container's `$HOME` dir will be mounted to
|
||||
`$HOME/.sparkd-dev/mounts<cont_name>` on the host*<br>
|
||||
* *Run: `./start_docker.sh --help` to see additional options*
|
||||
3. *(Optional) Attach VS Code to the running container.*<br>
|
||||
Run **Dev Containers: Attach to Running Container** from the command palette,
|
||||
then select your container in the dropdown
|
||||
|
||||
---
|
||||
## How to update the Docker image
|
||||
|
||||
1. Change the image by modifying the Dockerfile (don't tag arbitrary
|
||||
images on your machine and push them to our repo on Docker Hub)
|
||||
|
||||
1. After modifying the Dockerfile, (re)build the image
|
||||
```
|
||||
# Run in this dir
|
||||
docker build -t bluetradingsystems/sparkd-dev:latest .
|
||||
```
|
||||
***Note:** Your docker login must have write permissions to push to the
|
||||
[sparkd-dev][docker repo sparkd-dev] repository*
|
||||
|
||||
2. Commit the changes to Dockerfile in git
|
||||
|
||||
3. Push the new image to Docker Hub
|
||||
|
||||
```
|
||||
docker push johncolvin/bluetradingsystems:sparkd-dev
|
||||
```
|
||||
***Note:** The image doesn't have to be on Docker Hub, we can simply build
|
||||
it from scratch on our local machines (with the Dockerfile). However, this
|
||||
takes time. It is significantly quicker to download a prebuilt image, so we
|
||||
store it on a remote repository to save time when setting up a new dev
|
||||
machine.*
|
||||
@@ -0,0 +1,119 @@
|
||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return;;
|
||||
esac
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=1000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# If set, the pattern "**" used in a pathname expansion context will
|
||||
# match all files and zero or more directories and subdirectories.
|
||||
#shopt -s globstar
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||
case "$TERM" in
|
||||
xterm-color|*-256color) color_prompt=yes;;
|
||||
esac
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
#force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
fi
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto'
|
||||
#alias dir='dir --color=auto'
|
||||
#alias vdir='vdir --color=auto'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
fi
|
||||
|
||||
# colored GCC warnings and errors
|
||||
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# Add an "alert" alias for long running commands. Use like so:
|
||||
# sleep 10; alert
|
||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||
|
||||
# Alias definitions.
|
||||
# You may want to put all your additions into a separate file like
|
||||
# ~/.bash_aliases, instead of adding them here directly.
|
||||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
||||
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
@@ -0,0 +1,22 @@
|
||||
set fish_config_home $XDG_CONFIG_HOME/fish
|
||||
if test -f "$fish_config_home/aliases.fish"
|
||||
source "$fish_config_home/aliases.fish"
|
||||
end
|
||||
# enable general colors and case insensitive search in 'less'
|
||||
set -x LESS "$LESS -R -Q -I"
|
||||
set -x LC_ALL en_US.UTF-8
|
||||
# enable syntax highlighting in 'less'
|
||||
# set highlight color scheme in 'less' (fg)(bg)
|
||||
set -g LESS_TERMCAP_md (tput bold)(tput setaf 36)
|
||||
set -g LESS_TERMCAP_me (tput sgr0)
|
||||
set -g LESS_TERMCAP_so (tput setaf 232)(tput setab 49)
|
||||
|
||||
set -q TERM
|
||||
if test $status != 0; or test $TERM = 'xterm'
|
||||
set -g TERM 'xterm-256color'
|
||||
end
|
||||
|
||||
# Fix impossible-to-see navy blue command text color
|
||||
set fish_color_command F8F8F2
|
||||
|
||||
set -g PATH "$HOME/.local/bin" "$PATH"
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"image": "bluetradingsystems/sparkd-dev:latest",
|
||||
"initializeCommand": "${localWorkspaceFolder}/docker/sparkd/dev/devcontainer_initialize.sh",
|
||||
"postCreateCommand": "/home/bts/spark/docker/sparkd/dev/devcontainer_post_create.sh",
|
||||
"containerUser": "bts",
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/home/bts/spark,type=bind",
|
||||
"workspaceFolder": "/home/bts/spark",
|
||||
"updateRemoteUserUID": true,
|
||||
"shutdownAction": "none",
|
||||
// Note: If running multiple containers on the same host, each must use a
|
||||
// unique set of ports. Usually we just add 1000 to each port as needed. For
|
||||
// example, if 8000-8003 is taken, go with 9000-9003, then 10000-10003, etc.
|
||||
"runArgs": [
|
||||
"-p",
|
||||
"8000:8000",
|
||||
"-p",
|
||||
"8001:8001",
|
||||
"-p",
|
||||
"8002:8002",
|
||||
"-p",
|
||||
"8003:8003"
|
||||
],
|
||||
"mounts": [
|
||||
"source=${localEnv:HOME}/.sparkd-dev/mounts/sparkd-dev,target=/home/bts,type=bind"
|
||||
]
|
||||
}
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
mkdir -p "$HOME/.sparkd-dev/mounts/sparkd-dev"
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
this_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
repo_dir="$(cd "$this_dir" && git rev-parse --show-toplevel)"
|
||||
tools_dir="$repo_dir/tools"
|
||||
gen_tag="GENERATED BY $(basename "${BASH_SOURCE[0]}")"
|
||||
|
||||
function copy_if_not_exist() {
|
||||
src="$1"
|
||||
dest="$2"
|
||||
if [[ ! -e "$src" ]]; then
|
||||
echo "Unable to copy $src to $dest. Source file doesn't exist"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e "$dest" ]]; then
|
||||
cp "$src" "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
# Init bashrc
|
||||
echo "Initializing bashrc"
|
||||
copy_if_not_exist "$this_dir/bashrc" "$HOME/.bashrc"
|
||||
|
||||
# Init fish config
|
||||
echo "Initializing fish config"
|
||||
fish_cfg_dir="$HOME/.config/fish/"
|
||||
mkdir -p "$fish_cfg_dir"
|
||||
exec "$tools_dir/write_tag_block.sh" \
|
||||
--tag "$gen_tag" \
|
||||
--replace \
|
||||
--in-place \
|
||||
--file "$fish_cfg_dir/config.fish" \
|
||||
--text "$(cat "$this_dir/config.fish")"
|
||||
Executable
+250
@@ -0,0 +1,250 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function _exit() {
|
||||
if [[ "$#" -gt 1 ]]; then
|
||||
# When there are multiple args, the last arg is the exit code.
|
||||
echo "${@:1:($# - 1)}"
|
||||
exit "${@: -1}"
|
||||
fi
|
||||
echo "$1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
help_text="\
|
||||
Add or update a user's uid
|
||||
|
||||
This script is intended to be run in a Docker container as a means to obtain
|
||||
file permissions in mounted directories owned by the specified UID.
|
||||
|
||||
Usage: set_user.sh [OPTIONS] USER UID
|
||||
|
||||
Positionals:
|
||||
USER The name of the user
|
||||
|
||||
Options:
|
||||
--user USER The name of the user (defaults to 'bts')
|
||||
--uid UID The new uid to give USER (defaults to '1000')
|
||||
--group GROUP The primary group to give USER (defaults to USER)
|
||||
--gid GID The primary gid to give USER (defaults to UID)
|
||||
--pass PASSWORD The password to give USER (defaults to USER, only applies
|
||||
if USER hasn't been created yet)
|
||||
--modify-existing Update UID/GID even if USER already exists
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
"
|
||||
|
||||
function _add_group() {
|
||||
if [[ "$#" -ne 2 ]]; then
|
||||
_exit "'_add_group' requires exactly 2 args (group, gid). Received $#." 1
|
||||
fi
|
||||
local group="$1"
|
||||
local gid="$2"
|
||||
# Check if gid already exists
|
||||
local existing_group=""
|
||||
existing_group="$(getent group "$gid" | cut -d : -f 1)"
|
||||
if [[ -n "$existing_group" ]]; then
|
||||
if [[ "$existing_group" != "$group" ]]; then
|
||||
echo "\
|
||||
The gid '$gid' is already in use by group '$existing_group' (will not rename \
|
||||
the group)"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
# Check if group with same name already exists
|
||||
local existing_gid=""
|
||||
existing_gid="$(getent group "$group" | cut -d : -f 3)"
|
||||
if [[ -n "$existing_gid" ]]; then
|
||||
# The group already exists. Only modify if --modify-existing was specified.
|
||||
if [[ "$modify_existing" -eq 0 ]]; then
|
||||
_exit "\
|
||||
The group '$group' already exists with gid '$existing_gid'.
|
||||
Specify --modify-existing to change the gid anyways." 1
|
||||
fi
|
||||
echo "Changing gid for group '$group' from '$existing_gid' to '$gid'"
|
||||
groupmod -g "$gid" "$group"
|
||||
else
|
||||
# The group doesn't exist. Add it
|
||||
echo "Adding group '$group:$gid'"
|
||||
groupadd -g "$gid" "$group"
|
||||
fi
|
||||
}
|
||||
|
||||
function _add_user() {
|
||||
local user="$1"
|
||||
local uid="$2"
|
||||
local group="$3"
|
||||
local gid="$4"
|
||||
local pass="$5"
|
||||
if [[ "$#" -ne 5 ]]; then
|
||||
_exit "'_add_user' requires exactly 5 args (user, uid, group, gid, pass). \
|
||||
Received $#." 1
|
||||
fi
|
||||
|
||||
# Check if uid is being used by another user
|
||||
local existing_user=""
|
||||
existing_user="$(getent passwd "$uid" | cut -d : -f 1)"
|
||||
if [[ -n "$existing_user" ]]; then
|
||||
if [[ "$existing_user" != "$user" ]]; then
|
||||
_exit "The uid '$uid' is already in use by user '$existing_user'." 1
|
||||
fi
|
||||
|
||||
echo "The user '$user' already has the specified uid '$uid'."
|
||||
# Modify gid if necessary
|
||||
local existing_gid=""
|
||||
existing_gid="$(id -g "$user" 2> /dev/null)"
|
||||
if [[ "$existing_gid" = "$gid" ]]; then
|
||||
echo "The user '$user' already has the specified gid '$gid'."
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$modify_existing" -eq 0 ]]; then
|
||||
_exit "\
|
||||
The user '$user' is associated with the primary group '$existing_gid'.
|
||||
Specify --modify-existing to change the gid anyways." 1
|
||||
fi
|
||||
|
||||
echo "Changing primary group for '$user' from '$existing_gid' to '$gid'."
|
||||
usermod -g "$gid" "$user"
|
||||
return
|
||||
fi
|
||||
|
||||
# Check if user with same name already exists
|
||||
local existing_uid=""
|
||||
existing_uid="$(id -u "$user" 2> /dev/null)"
|
||||
if [[ -n "$existing_uid" ]]; then
|
||||
if [[ "$existing_uid" = "$uid" ]]; then
|
||||
_exit "The user '$user' already has the specified uid '$uid'" 0
|
||||
fi
|
||||
|
||||
if [[ "$modify_existing" -eq 0 ]]; then
|
||||
_exit "\
|
||||
User '$user' already exists with uid '$existing_uid'.
|
||||
Specify --modify-existing to change the uid anyways." 1
|
||||
fi
|
||||
|
||||
echo "Changing uid for user '$user' from '$existing_uid' to '$uid'"
|
||||
if ! usermod -u "$uid" -g "$gid" "$user"; then
|
||||
_exit "usermod exited with code $?" 1
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
# The user doesn't exist. Add it
|
||||
echo "Adding user '$user:$uid' (group='$group:$gid', password='$pass')"
|
||||
useradd -m -u "$uid" -g "$gid" -G sudo --password "$(openssl passwd -1 "$pass")" "$user"
|
||||
}
|
||||
|
||||
function _update_fish_dir_perms() {
|
||||
local user="$1"
|
||||
local uid="$2"
|
||||
local gid="$3"
|
||||
# When a fish shell session starts, a temp dir named '/tmp/fish.<user>' is
|
||||
# created with the user's current uid/gid. If such a dir exists for the
|
||||
# specified USER, make sure the uid/gid match the new values.
|
||||
fish_dir="/tmp/fish.$user"
|
||||
if [[ -d "$fish_dir" ]]; then
|
||||
perms="$uid:$gid"
|
||||
existing_perms="$(stat -c %u:%g "$fish_dir")"
|
||||
if [[ "$existing_perms" != "$perms" ]]; then
|
||||
echo "Changing uid:gid for dir '$fish_dir' from '$existing_perms' to '$perms'"
|
||||
chown -R "$perms" "$fish_dir"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
user=""
|
||||
group=""
|
||||
pass=""
|
||||
declare -i uid=0
|
||||
declare -i gid=0
|
||||
declare -i modify_existing=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--user)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "USER (--user) must be non-empty" 1
|
||||
elif [[ "$2" = "root" ]]; then
|
||||
_exit "USER (--user) cannot be 'root'" 1
|
||||
fi
|
||||
user="$2"
|
||||
shift 2
|
||||
;;
|
||||
--group)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "GROUP (--group) must be non-empty" 1
|
||||
elif [[ "$2" = "root" ]]; then
|
||||
_exit "GROUP (--group) cannot be 'root'" 1
|
||||
fi
|
||||
group="$2"
|
||||
shift 2
|
||||
;;
|
||||
--uid)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "UID (--uid) must be non-empty" 1
|
||||
fi
|
||||
uid="$2"
|
||||
shift 2
|
||||
;;
|
||||
--gid)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "GID (--gid) must be non-empty" 1
|
||||
fi
|
||||
gid="$2"
|
||||
shift 2
|
||||
;;
|
||||
--pass)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "PASS (--pass) must be non-empty" 1
|
||||
fi
|
||||
pass="$2"
|
||||
shift 2
|
||||
;;
|
||||
--modify-existing)
|
||||
modify_existing=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
;&
|
||||
--help)
|
||||
_exit "$help_text" 0
|
||||
;;
|
||||
*)
|
||||
if [[ -z "$1" ]]; then
|
||||
_exit "Invalid positional argument '$1'" 1
|
||||
elif [[ -z "$user" ]]; then
|
||||
user="$1"
|
||||
elif [[ -z "$uid" ]]; then
|
||||
uid="$1"
|
||||
else
|
||||
_exit "Unexpected argument '$1'" 1
|
||||
fi
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$user" ]]; then
|
||||
user="bts"
|
||||
fi
|
||||
|
||||
if [[ $uid -eq 0 ]]; then
|
||||
uid=1000
|
||||
fi
|
||||
|
||||
# In general, a user's primary group/gid matches the user's name/uid.
|
||||
# If group/gid args weren't specified, set them to name/uid.
|
||||
if [[ -z "$group" ]]; then
|
||||
group="$user"
|
||||
fi
|
||||
if [[ $gid -eq 0 ]]; then
|
||||
gid=$uid
|
||||
fi
|
||||
if [[ -z "$pass" ]]; then
|
||||
pass="$user"
|
||||
fi
|
||||
|
||||
_add_group "$group" "$gid"
|
||||
_add_user "$user" "$uid" "$group" "$gid" "$pass"
|
||||
_update_fish_dir_perms "$user" "$uid" "$gid"
|
||||
Executable
+230
@@ -0,0 +1,230 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function _exit() {
|
||||
if [[ "$#" -gt 1 ]]; then
|
||||
# When there are multiple args, the last arg is the exit code.
|
||||
echo "${@:1:($# - 1)}"
|
||||
exit "${@: -1}"
|
||||
fi
|
||||
echo "$1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
help_text="\
|
||||
Start a docker dev container
|
||||
Usage: start_docker.sh [OPTIONS] image container
|
||||
|
||||
Positionals:
|
||||
image The image to instantiate
|
||||
container The name for the container
|
||||
|
||||
Options:
|
||||
-u,--user USER The user to add in the container (defaults to 'bts')
|
||||
-p,--pass PASS The password for USER in the container (defaults to USER)
|
||||
-i,--image IMAGE The image to instantiate (defaults to 'bluetradingsystems/sparkd-dev:latest')
|
||||
-c,--container CONT The name for the container
|
||||
-m,--mount MOUNT The name for the folder (outside the container) to create/mount to the home
|
||||
directory in the container. Mount folders are added here: $mount_prefix
|
||||
--mount-existing Mount the specified dir even if it already exists
|
||||
--port <cont_port>:<host_port> OR [<cont_port>:<host_port>,...] Port mapping(s). May be
|
||||
specified multiple times.
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
"
|
||||
|
||||
mount_prefix="$HOME/.sparkd-dev/mounts"
|
||||
declare docker_user=""
|
||||
declare docker_pass=""
|
||||
declare image_name=""
|
||||
declare cont_name=""
|
||||
declare mount_name=""
|
||||
declare -i mount_existing=0
|
||||
declare -a port_mappings=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-u)
|
||||
;&
|
||||
--user)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "User (-u,--user) must be non-empty" 1
|
||||
fi
|
||||
docker_user="$2"
|
||||
shift 2
|
||||
;;
|
||||
-p)
|
||||
;&
|
||||
--pass)
|
||||
if [[ -z "$2" ]]; then
|
||||
_exit "Password (-p,--pass) must be non-empty" 1
|
||||
fi
|
||||
docker_pass="$2"
|
||||
shift 2
|
||||
;;
|
||||
-i)
|
||||
;&
|
||||
--image)
|
||||
if [[ -n "$image_name" ]]; then
|
||||
_exit "Unexpected argument '$1'" 1
|
||||
elif [[ -z "$2" ]]; then
|
||||
_exit "Image (-i,--image) must be non-empty" 1
|
||||
fi
|
||||
image_name="$2"
|
||||
shift 2
|
||||
;;
|
||||
-c)
|
||||
;&
|
||||
--container)
|
||||
if [[ -n "$cont_name" ]]; then
|
||||
_exit "Unexpected argument '$1'" 1
|
||||
elif [[ -z "$2" ]]; then
|
||||
_exit "Container (-c,--container) must be non-empty" 1
|
||||
fi
|
||||
cont_name="$2"
|
||||
shift 2
|
||||
;;
|
||||
--port)
|
||||
# Parse port(s) arg, and append the result to 'port_mappings'
|
||||
# Note: port(s) may be specified in bracketed notation:
|
||||
# [a:b,c:d,...,y:z]
|
||||
next_ports="$(echo "$2" | sed -e 's/\[//g' -e 's/\]//g' -e 's/,/ /g')"
|
||||
if [[ "${#port_mappings[@]}" -gt 0 ]]; then
|
||||
next_ports=" $next_ports"
|
||||
fi
|
||||
port_mappings+=("$next_ports")
|
||||
shift 2
|
||||
;;
|
||||
-m)
|
||||
;&
|
||||
--mount)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "Mount (-m,--mount) must be non-empty"
|
||||
fi
|
||||
mount_name="$2"
|
||||
shift 2
|
||||
;;
|
||||
--mount-existing)
|
||||
mount_existing=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
;&
|
||||
--help)
|
||||
_exit "$help_text" 0
|
||||
;;
|
||||
*)
|
||||
if [[ -z "$1" ]]; then
|
||||
_exit "Invalid positional argument '$1'" "$help_text" 1
|
||||
elif [[ -z "$image_name" ]]; then
|
||||
image_name="$1"
|
||||
elif [[ -z "$cont_name" ]]; then
|
||||
cont_name="$1"
|
||||
else
|
||||
_exit "Unexpected argument '$1'" "$help_text" 1
|
||||
fi
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [[ -z "$image_name" ]]; then
|
||||
image_name="bluetradingsystems/sparkd-dev:latest"
|
||||
fi
|
||||
|
||||
host_name="$(hostname)"
|
||||
if [[ -n "$cont_name" ]]; then
|
||||
host_name="$host_name.$cont_name"
|
||||
fi
|
||||
|
||||
if [[ -z "$mount_name" ]]; then
|
||||
mount_name="$cont_name"
|
||||
fi
|
||||
|
||||
if [[ -z "$mount_name" && -z "$cont_name" ]]; then
|
||||
_exit "Please specify mount (-m,--mount) and/or container (-c,--container)" 1
|
||||
fi
|
||||
|
||||
if [[ -z "$docker_user" ]]; then
|
||||
docker_user="bts"
|
||||
fi
|
||||
|
||||
if [[ "$docker_user" = "root" ]]; then
|
||||
_exit "USER (--user) cannot be 'root'" 1
|
||||
fi
|
||||
|
||||
cont_home="/home/$docker_user"
|
||||
home_src="$mount_prefix/$mount_name"
|
||||
home_tgt="$cont_home"
|
||||
this_dir="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
||||
repo_src="$(cd "$this_dir" && git rev-parse --show-toplevel)"
|
||||
repo_tgt="$cont_home/spark"
|
||||
working_dir="$cont_home"
|
||||
|
||||
if [[ $mount_existing -eq 0 && -e "$home_src" ]]; then
|
||||
# Don't overwrite existing dir (might be mounted in another container)
|
||||
_exit "Mount dir '$home_src' already exists (use --mount-existing to mount \
|
||||
an existing directory)" 1
|
||||
fi
|
||||
|
||||
mkdir -p "$home_src"
|
||||
|
||||
if [[ "${#port_mappings[@]}" -eq 0 ]]; then
|
||||
port_mappings=("8000:8000" "8001:8001" "8002:8002" "8003:8003")
|
||||
fi
|
||||
|
||||
# Adapt port_mappings into args for `docker run` by prepending "-p " to each
|
||||
# item
|
||||
declare -a docker_port_args=()
|
||||
for port_mapping in "${port_mappings[@]}"; do
|
||||
docker_port_args+=("-p $port_mapping")
|
||||
done
|
||||
|
||||
echo "Starting container '$cont_name'
|
||||
image_name : $image_name
|
||||
cont_name : $cont_name
|
||||
home_src : $home_src
|
||||
home_tgt : $home_tgt
|
||||
repo_src : $repo_src
|
||||
repo_tgt : $repo_tgt
|
||||
working dir : $working_dir
|
||||
ports : ${port_mappings[*]}
|
||||
"
|
||||
|
||||
# DON'T wrap $docker_port_args in quotes. We want bash to split args by
|
||||
# whitespace
|
||||
docker run \
|
||||
--net bridge \
|
||||
-h "$host_name" \
|
||||
-e "TZ=America/New_York" \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--security-opt seccomp=unconfined \
|
||||
--name "$cont_name" \
|
||||
-v "$home_src:$home_tgt" \
|
||||
-v "$repo_src:$repo_tgt" \
|
||||
-w "$working_dir" \
|
||||
${docker_port_args[*]} \
|
||||
--shm-size=4024m \
|
||||
-t \
|
||||
-i \
|
||||
-d \
|
||||
-e DISPLAY="$DISPLAY" \
|
||||
"$image_name"
|
||||
|
||||
# Add user w/ same uid and gid as the current user outside of docker, so the
|
||||
# user inside the docker has file permissions in the mounted dir.
|
||||
docker_group="$docker_user"
|
||||
docker_uid="$(id -u "$USER")"
|
||||
docker_gid="$(id -g "$USER")"
|
||||
if [[ -z "$docker_pass" ]]; then
|
||||
docker_pass="$docker_user"
|
||||
fi
|
||||
docker exec -u root -it "$cont_name" "$repo_tgt/docker/sparkd/dev/set_user.sh" \
|
||||
--user "$docker_user" \
|
||||
--uid "$docker_uid" \
|
||||
--group "$docker_group" \
|
||||
--gid "$docker_gid" \
|
||||
--pass "$docker_pass"
|
||||
|
||||
# Run same script VS Code runs to initialize the container
|
||||
docker exec -u "$docker_user" -it "$cont_name" "$repo_tgt/docker/sparkd/dev/devcontainer_post_create.sh"
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function print_help_and_exit() {
|
||||
cat <<EOF
|
||||
Open a shell inside the docker container
|
||||
Usage: docker_shell.sh [OPTIONS] [CONTAINER]
|
||||
|
||||
Options:
|
||||
-u,--user The user to login with in the container (defaults to the current user)
|
||||
-c,--container The container name (may also be specified as positional arg)
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
EOF
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
|
||||
declare docker_user=""
|
||||
declare cont_name=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-u)
|
||||
;&
|
||||
--user)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "User (-u,--user) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
docker_user="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h)
|
||||
;&
|
||||
--help)
|
||||
print_help_and_exit 0
|
||||
;;
|
||||
-c)
|
||||
;&
|
||||
--container)
|
||||
shift 1
|
||||
;&
|
||||
*)
|
||||
if [[ ! -z "$cont_name" ]]; then
|
||||
echo "Unexpected argument '$1'"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
cont_name="$1"
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [[ -z "$cont_name" ]]; then
|
||||
echo "Please specify the container ([-c,--container])"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$docker_user" ]]; then
|
||||
docker_user="$USER"
|
||||
fi
|
||||
|
||||
docker exec -u "$docker_user" -it "$cont_name" bash
|
||||
Executable
+233
@@ -0,0 +1,233 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
mount_prefix="$HOME/.spark-dev/mounts"
|
||||
|
||||
function print_help_and_exit() {
|
||||
cat <<EOF
|
||||
Start a docker dev container
|
||||
Usage: start_docker.sh [OPTIONS] image container
|
||||
|
||||
Positionals:
|
||||
image The image to instantiate
|
||||
container The name for the container
|
||||
|
||||
Options:
|
||||
-u,--user USER The user to add in the container (defaults to the current user)
|
||||
-p,--pass PASS The password for USER in the container (defaults to USER)
|
||||
-i,--image IMAGE The image to instantiate
|
||||
-c,--container CONT The name for the container
|
||||
-m,--mount MOUNT The name for the folder (outside the container) to create/mount to the home
|
||||
directory in the container. Mount folders are added here: $mount_prefix
|
||||
--mount-existing Mount the specified dir even if it already exists
|
||||
--port <cont_port>:<host_port> OR [<cont_port>:<host_port>,...] Port mapping(s). May be
|
||||
specified multiple times.
|
||||
-h,--help Print this help message and exit
|
||||
|
||||
EOF
|
||||
exit "$1"
|
||||
}
|
||||
|
||||
|
||||
declare docker_user=""
|
||||
declare docker_pass=""
|
||||
declare image_name=""
|
||||
declare cont_name=""
|
||||
declare mount_name=""
|
||||
declare -i mount_existing=0
|
||||
declare -a port_mappings=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-u)
|
||||
;&
|
||||
--user)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "User (-u,--user) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
docker_user="$2"
|
||||
shift 2
|
||||
;;
|
||||
-p)
|
||||
;&
|
||||
--pass)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "Password (-p,--pass) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
docker_pass="$2"
|
||||
shift 2
|
||||
;;
|
||||
-i)
|
||||
;&
|
||||
--image)
|
||||
if [[ -n "$image_name" ]]; then
|
||||
echo "Unexpected argument '$1'"
|
||||
print_help_and_exit 1
|
||||
elif [[ -z "$2" ]]; then
|
||||
echo "Image (-i,--image) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
image_name="$2"
|
||||
shift 2
|
||||
;;
|
||||
-c)
|
||||
;&
|
||||
--container)
|
||||
if [[ -n "$cont_name" ]]; then
|
||||
echo "Unexpected argument '$1'"
|
||||
print_help_and_exit 1
|
||||
elif [[ -z "$2" ]]; then
|
||||
echo "Container (-c,--container) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
cont_name="$2"
|
||||
shift 2
|
||||
;;
|
||||
--port)
|
||||
# Parse port(s) arg, and append the result to 'port_mappings'
|
||||
# Note: port(s) may be specified in bracketed notation:
|
||||
# [a:b,c:d,...,y:z]
|
||||
next_ports="$(echo "$2" | sed -e 's/\[//g' -e 's/\]//g' -e 's/,/ /g')"
|
||||
if [[ "${#port_mappings[@]}" -gt 0 ]]; then
|
||||
next_ports=" $next_ports"
|
||||
fi
|
||||
port_mappings+=("$next_ports")
|
||||
shift 2
|
||||
;;
|
||||
-m)
|
||||
;&
|
||||
--mount)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "Mount (-m,--mount) must be non-empty"
|
||||
fi
|
||||
mount_name="$2"
|
||||
shift 2
|
||||
;;
|
||||
--mount-existing)
|
||||
mount_existing=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
;&
|
||||
--help)
|
||||
print_help_and_exit 0
|
||||
;;
|
||||
*)
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Invalid positional argument '$1'"
|
||||
print_help_and_exit 1
|
||||
elif [[ -z "$image_name" ]]; then
|
||||
image_name="$1"
|
||||
elif [[ -z "$cont_name" ]]; then
|
||||
cont_name="$1"
|
||||
else
|
||||
echo "Unexpected argument '$1'"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [[ -z "$image_name" ]]; then
|
||||
image_name="bluetradingsystems/spark-crypto-dev"
|
||||
fi
|
||||
|
||||
host_name="$(hostname)"
|
||||
if [[ -n "$cont_name" ]]; then
|
||||
host_name="$host_name.$cont_name"
|
||||
fi
|
||||
|
||||
if [[ -z "$mount_name" ]]; then
|
||||
mount_name="$cont_name"
|
||||
fi
|
||||
|
||||
if [[ -z "$mount_name" && -z "$cont_name" ]]; then
|
||||
echo "Please specify mount (-m,--mount) and/or container (-c,--container)"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$docker_user" ]]; then
|
||||
docker_user="$USER"
|
||||
fi
|
||||
|
||||
home_src=$mount_prefix/$mount_name
|
||||
home_tgt=$HOME
|
||||
repo_src=$(git rev-parse --show-superproject-working-tree)
|
||||
repo_tgt=$HOME/$(basename "$repo_src")
|
||||
working_dir=$HOME
|
||||
|
||||
if [[ $mount_existing -eq 0 && -e "$home_src" ]]; then
|
||||
# Don't overwrite existing dir (might be mounted in another container)
|
||||
echo "Mount dir '$home_src' already exists (use --mount-existing to mount an existing directory)"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$home_src"
|
||||
|
||||
if [[ "${#port_mappings[@]}" -eq 0 ]]; then
|
||||
port_mappings=("8000:8000" "8001:8001" "8002:8002" "8003:8003")
|
||||
fi
|
||||
|
||||
# Adapt port_mappings into args for `docker run` by prepending "-p " to each
|
||||
# item
|
||||
declare -a docker_port_args=()
|
||||
for port_mapping in "${port_mappings[@]}"; do
|
||||
docker_port_args+=("-p $port_mapping")
|
||||
done
|
||||
|
||||
echo "Starting container '$cont_name'
|
||||
image_name : $image_name
|
||||
cont_name : $cont_name
|
||||
home_src : $home_src
|
||||
home_tgt : $home_tgt
|
||||
repo_src : $repo_src
|
||||
repo_tgt : $repo_tgt
|
||||
working dir : $working_dir
|
||||
ports : ${port_mappings[*]}
|
||||
"
|
||||
|
||||
# DON'T wrap $docker_port_args in quotes. We want bash to split args by
|
||||
# whitespace
|
||||
docker run \
|
||||
--net bridge \
|
||||
-h "$host_name" \
|
||||
-e "TZ=America/New_York" \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--security-opt seccomp=unconfined \
|
||||
--name "$cont_name" \
|
||||
-v "$home_src:$home_tgt" \
|
||||
-v "$repo_src:$repo_tgt" \
|
||||
-w "$working_dir" \
|
||||
${docker_port_args[*]} \
|
||||
--shm-size=4024m \
|
||||
-t \
|
||||
-i \
|
||||
-d \
|
||||
-e DISPLAY="$DISPLAY" \
|
||||
"$image_name" \
|
||||
bash
|
||||
|
||||
# Add user w/ same uid and gid as the current user outside of docker, so the
|
||||
# user inside the docker has file permissions in the mounted dir.
|
||||
docker_group="$docker_user"
|
||||
docker_user_uid="$(id -u "$USER")"
|
||||
docker_user_gid="$(id -g "$USER")"
|
||||
|
||||
echo "Adding user in container '$cont_name'
|
||||
name : $docker_user
|
||||
uid : $docker_user_uid
|
||||
gid : $docker_user_gid"
|
||||
|
||||
if [[ -z "$docker_pass" ]]; then
|
||||
docker_pass="$docker_user"
|
||||
echo "Giving user '$docker_user' a secure password: $docker_pass"
|
||||
fi
|
||||
|
||||
docker exec -u root -it "$cont_name" groupadd -g "$docker_user_gid" "$docker_group"
|
||||
docker exec -u root -it "$cont_name" useradd -u "$docker_user_uid" -g "$docker_user_gid" "$docker_user"
|
||||
docker exec -u root -it "$cont_name" usermod --password "$(openssl passwd -1 "$docker_pass")" "$docker_user"
|
||||
docker exec -u root -it "$cont_name" usermod -aG sudo "$docker_user"
|
||||
docker exec -u root -it "$cont_name" "$repo_tgt/externals/src/emumba/install_emumba-deribit-connector.sh"
|
||||
Submodule docker/windows deleted from de7d40c09d.
+1
-1
Submodule externals updated: 99c440f568...4aaae5b1eb.
+2
-1
@@ -6,12 +6,13 @@ isort==5.9.3
|
||||
lazy-object-proxy==1.6.0
|
||||
mccabe==0.6.1
|
||||
platformdirs==2.3.0
|
||||
protobuf==3.19.1
|
||||
protobuf==4.21.12
|
||||
pybars3==0.9.7
|
||||
pycodestyle==2.7.0
|
||||
pycparser==2.20
|
||||
pylint==2.10.2
|
||||
PyMeta3==0.5.1
|
||||
termcolor==1.1.0
|
||||
toml==0.10.2
|
||||
wrapt==1.12.1
|
||||
yapf==0.31.0
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sparkd", "src\server\sparkd\sparkd.vcxproj", "{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{502FD050-679A-3B50-B438-098500700919}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
MinSizeRel|x64 = MinSizeRel|x64
|
||||
Release|x64 = Release|x64
|
||||
RelWithDebInfo|x64 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Debug|x64.Build.0 = Debug|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.MinSizeRel|x64.Build.0 = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Release|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.Release|x64.Build.0 = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{BBBAFD38-312D-4A8D-9AF0-F2BDEE72CE6F}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Debug|x64.Build.0 = Debug|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.ActiveCfg = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.Release|x64.Build.0 = Release|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{502FD050-679A-3B50-B438-098500700919}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6A7249D7-B40C-4656-9347-60072D0B8FDB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+33
-13
@@ -1,24 +1,28 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32922.545
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark", "src\client\spark\Spark.csproj", "{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\sparkcmd\sparkcmd.csproj", "{387566C6-C6F6-412C-A30C-9855BBCB4816}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark.Console", "src\client\Spark.Console\Spark.Console.csproj", "{387566C6-C6F6-412C-A30C-9855BBCB4816}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_sdk", "src\client\spark_sdk\spark_sdk.csproj", "{6963C314-83C4-4667-B0D0-C2F7AE208C29}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40} = {9FA60215-26AF-3EB7-AB89-D4F4B126EF40}
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25} = {FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_test", "src\client\spark_test\spark_test.csproj", "{ECD78CC5-138F-4809-A764-2358C2AC2E82}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_websocket", "src\client\spark_websocket\spark_websocket.csproj", "{3201359D-C071-4089-9EDE-B04D759F1508}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api_server", "src\client\spark_api_server\spark_api_server.csproj", "{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -35,14 +39,14 @@ Global
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.Release|x64.Build.0 = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Debug|x64.Build.0 = Debug|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Release|x64.ActiveCfg = Release|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.Release|x64.Build.0 = Release|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{9FA60215-26AF-3EB7-AB89-D4F4B126EF40}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.Debug|x64.Build.0 = Debug|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.Release|x64.ActiveCfg = Release|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.Release|x64.Build.0 = Release|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
|
||||
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}.MinSizeRel|x64.ActiveCfg = Release|x64
|
||||
@@ -83,6 +87,22 @@ Global
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.Release|x64.Build.0 = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{ECD78CC5-138F-4809-A764-2358C2AC2E82}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Debug|x64.Build.0 = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Release|x64.ActiveCfg = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.Release|x64.Build.0 = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{3201359D-C071-4089-9EDE-B04D759F1508}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Debug|x64.Build.0 = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.MinSizeRel|x64.ActiveCfg = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.MinSizeRel|x64.Build.0 = Debug|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Release|x64.ActiveCfg = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.Release|x64.Build.0 = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.RelWithDebInfo|x64.ActiveCfg = Release|x64
|
||||
{2B8C5D01-FF78-4BFA-B332-5E430586DAF9}.RelWithDebInfo|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(Spark.Admin.WebApp)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/safe_dep_glob.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/Protobuf.cmake)
|
||||
|
||||
# dependencies
|
||||
set(PROTO_GLOBS
|
||||
../lib/api/*.proto
|
||||
../lib/api/services/*.proto
|
||||
../lib/domain_model/*.proto
|
||||
../lib/sparkproto/*.proto
|
||||
../lib/md/protos/*.proto
|
||||
../../externals/linux/include/google/protobuf/descriptor.proto
|
||||
../../externals/linux/include/google/protobuf/timestamp.proto)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE _proto_rel_SOURCES
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROTO_GLOBS})
|
||||
|
||||
file(
|
||||
GLOB_RECURSE _proto_abs_SOURCES
|
||||
${PROTO_GLOBS})
|
||||
|
||||
file(
|
||||
GLOB_RECURSE _ts_SOURCES
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
src/*.ts)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE _fs_SOURCES
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
src/*.fs)
|
||||
|
||||
set(_tools ${CMAKE_SOURCE_DIR}/tools)
|
||||
set(_quiet_exec ${_tools}/quiet_exec.sh)
|
||||
set(_venv_exec ${_tools}/venv_exec.sh)
|
||||
set(_tools_py ${CMAKE_SOURCE_DIR}/tools/py)
|
||||
|
||||
# The tsconfig file is generated as a function of the cmake build type, and
|
||||
# binary dir. Depending on the build type, it extends either
|
||||
# 'tsconfig.debug.json' or 'tsconfig.release.json'.
|
||||
set(_tsconfig_base "${CMAKE_CURRENT_SOURCE_DIR}/tsconfig.$<IF:$<CONFIG:Debug>,debug,release>.json")
|
||||
set(WEBPACK_MODE $<IF:$<CONFIG:Debug>,"development","production">)
|
||||
set(_tsconfig "${CMAKE_CURRENT_BINARY_DIR}/tsconfig.json")
|
||||
|
||||
set(_venv_python ${CMAKE_SOURCE_DIR}/.venv/bin/python)
|
||||
set(_gen_tsconfig_py ${_tools_py}/gen_tsconfig.py)
|
||||
set(_build_admin_web_app_py ${_tools_py}/build_admin_web_app.py)
|
||||
|
||||
set(_gen_tsconfig_deps ${_venv_exec} ${_venv_python} ${_gen_tsconfig_py} ${_tsconfig_base})
|
||||
|
||||
set(_build_admin_web_app_deps
|
||||
${_quiet_exec}
|
||||
${_venv_exec}
|
||||
${_venv_python}
|
||||
${_build_admin_web_app_py}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/Spark.Admin.WebApp.fsproj
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/webpack.config.js
|
||||
${CMAKE_SOURCE_DIR}/src/lib/api/service_compiler/templates/fs/fable.fs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/package-lock.json
|
||||
${_proto_rel_SOURCES}
|
||||
${_api_ts_SOURCES}
|
||||
${_ui_fs_SOURCES}
|
||||
${_tsconfig})
|
||||
|
||||
update_deps_file("${_build_admin_web_app_deps}")
|
||||
|
||||
function(npm_install path)
|
||||
add_custom_command(
|
||||
OUTPUT ${path}/package-lock.json
|
||||
COMMAND "npm" ARGS "install"
|
||||
DEPENDS ${path}/package.json
|
||||
WORKING_DIRECTORY ${path}
|
||||
COMMENT "Run 'npm install' in ${path}")
|
||||
endfunction()
|
||||
|
||||
npm_install(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${_tsconfig}
|
||||
COMMAND ${_venv_exec}
|
||||
ARGS
|
||||
${_venv_python}
|
||||
${_gen_tsconfig_py}
|
||||
--config-base ${_tsconfig_base}
|
||||
--config-out ${_tsconfig}
|
||||
--build-out ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS ${_gen_tsconfig_deps})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bundle.js
|
||||
COMMAND ${_quiet_exec}
|
||||
ARGS
|
||||
${_venv_exec}
|
||||
${_venv_python}
|
||||
${_build_admin_web_app_py}
|
||||
--protos ${_proto_abs_SOURCES}
|
||||
--tsconfig ${_tsconfig}
|
||||
--mode ${WEBPACK_MODE}
|
||||
--output-dir ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Building Spark.Admin.WebApp"
|
||||
DEPENDS ${_build_admin_web_app_deps})
|
||||
|
||||
add_custom_target(admin_web_app_bundle ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bundle.js)
|
||||
|
||||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DESTINATION "${SPARK_INSTALL_PREFIX}/bin")
|
||||
File renamed without changes.
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Spark.Admin.WebApp", "src\Spark.Admin.WebApp.fsproj", "{C3143A6F-8D32-4F9E-84EE-B34AF3F3A862}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C3143A6F-8D32-4F9E-84EE-B34AF3F3A862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C3143A6F-8D32-4F9E-84EE-B34AF3F3A862}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3143A6F-8D32-4F9E-84EE-B34AF3F3A862}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3143A6F-8D32-4F9E-84EE-B34AF3F3A862}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+5
-3
@@ -5,11 +5,13 @@ import { DynamicService } from "../src/DynamicService"
|
||||
|
||||
test('log in and say hi', async () => {
|
||||
let ctx = await connect("bts", "");
|
||||
expect(ctx instanceof ServiceContext).toBe(true)
|
||||
const admin = new DynamicService(<ServiceContext>ctx, "AdminService", "", [
|
||||
let methods = new Array<[string,number,string,string]>(
|
||||
["get_admin_data", 16, "bts.api.VoidMessage", "bts.api.admin.AdminData"],
|
||||
["update_account", 1, "bts.api.admin.AccountUpdateAPIArgument", "bts.api.admin.AdminServiceOperationResult"]
|
||||
]);
|
||||
)
|
||||
expect(ctx instanceof ServiceContext).toBe(true)
|
||||
const admin = new DynamicService(
|
||||
<ServiceContext>ctx, "AdminService", "", methods, [])
|
||||
const adminData = await admin.get_admin_data({})
|
||||
const account1 = adminData.accounts[2]
|
||||
const dat = account1.exchangeAccountData
|
||||
File renamed without changes.
Generated
+30278
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "npx webpack serve",
|
||||
"build": "npx webpack"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-runtime": "^7.21.0",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"babel-loader": "^9.1.2",
|
||||
"fable-utils": "^1.2.0",
|
||||
"node-sass": "^8.0.0",
|
||||
"protobufjs": "^7.2.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"remotedev": "^0.2.9",
|
||||
"ts2fable": "^0.7.1",
|
||||
"tslib": "^2.5.0",
|
||||
"watch": "^1.0.2",
|
||||
"webpack": "^5.75.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.21.0",
|
||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
||||
"bulma": "^0.9.4",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"core-js": "^3.28.0",
|
||||
"css-loader": "^6.7.3",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"jest": "^29.4.3",
|
||||
"mini-css-extract-plugin": "^2.7.2",
|
||||
"npx": "^10.2.2",
|
||||
"protobufjs-cli": "^1.1.1",
|
||||
"sass": "^1.58.3",
|
||||
"sass-loader": "^13.2.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"ts-jest": "^29.0.5",
|
||||
"ts-loader": "^9.4.2",
|
||||
"tsutils": "^3.21.0",
|
||||
"typescript": "^4.9.5",
|
||||
"webpack-cli": "^5.0.1",
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"ws": "^8.12.1"
|
||||
}
|
||||
}
|
||||
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
File renamed without changes.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -4,8 +4,8 @@
|
||||
<title>BTS Spark Admin</title>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="shortcut icon" type="image/ico" href="img/favicon.ico" />
|
||||
<link rel="stylesheet" href="font-awesome.min.css" />
|
||||
<link rel="shortcut icon" type="image/ico" href="public/img/favicon.ico" />
|
||||
<link rel="stylesheet" href="public/font-awesome.min.css" />
|
||||
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=es6"></script>
|
||||
</head>
|
||||
<body>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -9,20 +9,20 @@ open bts.api.orderman
|
||||
let superuser = "bts"
|
||||
|
||||
let getAdminData (admin:IAdminService) (fsuc) (ffail) =
|
||||
Cmd.ofPromise
|
||||
Cmd.OfPromise.either
|
||||
admin.get_filtered_admin_data ()
|
||||
fsuc
|
||||
(fun e -> ffail e.Message)
|
||||
|
||||
let getAccountOrdersData (admin:IAdminService) (success) (fail) =
|
||||
Cmd.ofPromise
|
||||
Cmd.OfPromise.either
|
||||
admin.get_order_summary
|
||||
()
|
||||
success
|
||||
(fun e -> fail e.Message)
|
||||
|
||||
let getMarginData (span:IMarginService) (account_name: string) (success) (fail) =
|
||||
Cmd.ofPromise
|
||||
Cmd.OfPromise.either
|
||||
span.get_excess_liquidity_report
|
||||
{ account = account_name }
|
||||
success
|
||||
+1
-1
@@ -15,7 +15,7 @@ let columns = [|
|
||||
[ Key "clipSize"; Name "Clip Size"; Editable true ]
|
||||
|]
|
||||
|
||||
[<Pojo>]
|
||||
|
||||
type ClipLimit = {
|
||||
exchange: string
|
||||
securityType : string
|
||||
+1
-1
@@ -32,7 +32,7 @@ let columns = [|
|
||||
positionColumn "Short"
|
||||
|]
|
||||
|
||||
[<Pojo>]
|
||||
|
||||
type ProductLimit = {
|
||||
exchange: string
|
||||
securityType : string
|
||||
+1
-1
@@ -17,7 +17,7 @@ let columns = [|
|
||||
positionColumn "Short"
|
||||
|]
|
||||
|
||||
[<Pojo>]
|
||||
|
||||
type SecurityLimit = {
|
||||
security : string
|
||||
exchange: string
|
||||
@@ -1,17 +1,14 @@
|
||||
module Accounts.State
|
||||
|
||||
open Fable.PowerPack.Fetch
|
||||
open Accounts.Types
|
||||
open bts.api.admin
|
||||
open bts.api.position
|
||||
open Global
|
||||
open Elmish
|
||||
open Fable.PowerPack.PromiseImpl
|
||||
open Fable.Import
|
||||
open bts.co2
|
||||
open Fable
|
||||
open Fable.Core
|
||||
open Fable.PowerPack
|
||||
open bts.api.position
|
||||
|
||||
let isNewAccount (account:BTSAccount) =
|
||||
@@ -173,8 +170,8 @@ let marginSub model dispatch =
|
||||
|
||||
let selectSub (tab:Tab option) model =
|
||||
match tab, model.tab with
|
||||
| Some PositionManagementTab, _ | None, PositionManagementTab -> Cmd.ofSub (positionSub model)
|
||||
| Some MarginTab, _ | None, MarginTab -> Cmd.ofMsg GetMarginData //Cmd.ofSub (marginSub model)
|
||||
| Some PositionManagementTab, _ | None, PositionManagementTab -> Cmd.ofEffect (positionSub model)
|
||||
| Some MarginTab, _ | None, MarginTab -> Cmd.ofMsg GetMarginData //Cmd.ofEffect (marginSub model)
|
||||
| _ ->
|
||||
match model.unsub with
|
||||
| Some (unsub) -> unsub.Dispose()
|
||||
@@ -299,8 +296,8 @@ let setBasePosition basePosBatch (model:Model) =
|
||||
let! result = model.positionService.set_base_position basePosBatch
|
||||
|
||||
match result.ok with
|
||||
| true -> Browser.console.log result.msg
|
||||
| false -> Browser.console.log result.msg
|
||||
| true -> Browser.Dom.console.log result.msg
|
||||
| false -> Browser.Dom.console.log result.msg
|
||||
|
||||
return (Msg.SelectTab model.tab)
|
||||
}
|
||||
@@ -420,7 +417,7 @@ let update msg (model:Model) : Model * Cmd<Msg> =
|
||||
{ model with ShowLoading = false}, (getMarginData model.marginService model.scratch.name UpdateMarginData (box>>ErrorOccured))
|
||||
| UpdateMarginData newData ->
|
||||
let cmd = match model.tab with
|
||||
| MarginTab -> Cmd.ofPromise (fun _ -> promise { do! Promise.sleep 10000 } ) () (fun _ -> GetMarginData) (fun _ -> GetMarginData)
|
||||
| MarginTab -> Cmd.OfPromise.either (fun _ -> promise { do! Promise.sleep 10000 } ) () (fun _ -> GetMarginData) (fun _ -> GetMarginData)
|
||||
| _ -> Cmd.none
|
||||
match (model.marginScratch = emptyMargin || model.marginScratch.account <> model.scratch.name),
|
||||
(compareDouble model.marginData.leverageFactor model.marginScratch.leverageFactor 10000u),
|
||||
@@ -450,7 +447,7 @@ let update msg (model:Model) : Model * Cmd<Msg> =
|
||||
|
||||
| DeleteAccount account ->
|
||||
let mdl = { model with OptionsMenuOpen = ""}
|
||||
match Fable.Import.Browser.window.confirm (sprintf "Are you sure you want to delete '%s'" account.name) with
|
||||
match Browser.Dom.window.confirm (sprintf "Are you sure you want to delete '%s'" account.name) with
|
||||
| true -> mdl, Cmd.ofExistingPromise (deleteAccount model.admin account model ) id (box>>ErrorOccured)
|
||||
| false -> mdl, Cmd.Empty
|
||||
| AddAccount ->
|
||||
@@ -464,7 +461,7 @@ let update msg (model:Model) : Model * Cmd<Msg> =
|
||||
| false -> { model with marginScratch = model.marginData }, Cmd.ofExistingPromise (saveAccount model.admin model.scratch model.ManualFillData model) id (box>>ErrorOccured)
|
||||
| ErrorOccured msg ->
|
||||
Global.alert Global.Error (string msg)
|
||||
Browser.console.log msg
|
||||
Browser.Dom.console.log msg
|
||||
model,Cmd.Empty
|
||||
| SelectTab tab ->
|
||||
match tab with
|
||||
File renamed without changes.
@@ -2,8 +2,9 @@ module Accounts.View
|
||||
|
||||
open Accounts.Types
|
||||
open Accounts.State
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Fable.React
|
||||
open Fable.React.Standard
|
||||
open Fable.React.Props
|
||||
open bts.api.admin
|
||||
open bts.api.orderman
|
||||
open EnumUtils
|
||||
@@ -67,7 +68,7 @@ let accountControls model (dispatch:Msg->unit) =
|
||||
| Some acc -> fun _ -> (dispatch <| SelectAccount acc)
|
||||
| None -> ignore
|
||||
|
||||
div [ClassName "is-main-control-bar"] [
|
||||
div [ ClassName "is-main-control-bar" ] [
|
||||
saveButton model dispatch
|
||||
Button.button "Revert" "" "" (if isDirty model then Button.Enabled else Button.Disabled) revertFun
|
||||
]
|
||||
@@ -100,7 +101,7 @@ let generalView (model:Model) dispatch =
|
||||
Fields.text "Name" account.name [] (AccountName >> Update >> dispatch)
|
||||
Fields.text "Description" account.description [] (Description >> Update >> dispatch)
|
||||
Fields.checkbox "Open For Trading" "Unchecking this stops all users from entering orders into the account" account.isActive [] (IsActive >> Update >> dispatch)
|
||||
(if (State.isNewAccount account && model.can_create) then modal else span[][])
|
||||
(if (State.isNewAccount account && model.can_create) then modal else span [] [])
|
||||
|
||||
accountControls model dispatch
|
||||
]
|
||||
@@ -112,7 +113,7 @@ let marginView model dispatch =
|
||||
{
|
||||
cells =
|
||||
[
|
||||
TableControl.Cell (div [Style [MinWidth "3em"]][str "Time"])
|
||||
TableControl.Cell (div [Style [MinWidth "3em"]] [str "Time"])
|
||||
TableControl.Cell (str "Account")
|
||||
TableControl.Cell (str "Leverage Factor")
|
||||
TableControl.Cell (str "Cash Balance")
|
||||
@@ -148,8 +149,8 @@ let marginView model dispatch =
|
||||
onClick = None
|
||||
}
|
||||
|
||||
div [][
|
||||
TableControl.createDataTable (Some headerRow) [rws] (span [][])
|
||||
div [] [
|
||||
TableControl.createDataTable (Some headerRow) [rws] (span [] [])
|
||||
Fields.checkbox "Enforce Margin Limit" "" (model.marginScratch.shouldEnforceMargin) [] (SetEnforceMargin >> dispatch)
|
||||
Fields.number "Leverage Factor:" (string model.marginScratch.leverageFactor) [Disabled disabled] (fun _ -> true) (double >> SetMarginCashFactor >> dispatch)
|
||||
Fields.intNumber "Cash Balance:" (string model.marginScratch.cashBalance) [Disabled disabled] (double >> SetMarginCashBalance >> dispatch)
|
||||
@@ -221,8 +222,8 @@ let ordersView (model:Model) dispatch =
|
||||
let cancelButton = Button.button "Cancel Selected Orders" (addLoadingString "is-danger" model.ShowLoading) "times" enableCancel (fun _ -> OpenConfirmModal (confirmText, cancelMessage) |> dispatch)
|
||||
let reloadFun = fun _ -> dispatch (SelectTab model.tab)
|
||||
|
||||
div [][
|
||||
TableControl.createDataTable (Some headerRow) rws (span [][ (Button.button "Refresh" "" "exchange" (Button.boolToDisabledConverter model.ShowLoading) reloadFun); nbsp.element; cancelButton ])
|
||||
div [] [
|
||||
TableControl.createDataTable (Some headerRow) rws (span [] [ (Button.button "Refresh" "" "exchange" (Button.boolToDisabledConverter model.ShowLoading) reloadFun); nbsp.element; cancelButton ])
|
||||
]
|
||||
|
||||
let limitFilter (positionLimit:AccountSecurityPositionLimitUnit option) (clipLimit:AccountSecurityClipLimitUnit option) allValueDisplay (array:ExpirationNameList []) =
|
||||
@@ -422,8 +423,8 @@ let clipLimitsView model dispatch =
|
||||
let addRow _ = emptyLimit |> AddClipLimit |> dispatch
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "Clip Limits" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "Clip Limits" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text"; ]
|
||||
[str "Clip limits can be set for one security, for all securities in a product (by selecting \"All\" for securities), or for all products within a security type (by selecting \"All\" for both symbol and security)"]
|
||||
]
|
||||
@@ -614,12 +615,12 @@ let productLimits model dispatch =
|
||||
let addRow _ = emptyLimit |> AddProductLimit |> dispatch
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "Position Limits" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "Position Limits" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text" ]
|
||||
[str "This limits the net position for a product (i.e. accumulated position over all securities belonging to a product). This can be set for one product, or for all products within a security type by selecting \"All\" for symbol. (Note that \"All\" applies the same limits to each symbol, not the combiled position of all symbols)"]
|
||||
]
|
||||
div [][
|
||||
div [] [
|
||||
Fields.radioButton "Use Net Contracts" "" model.scratch.riskLimitEnforcement.productLimitInNetTerms [] (EnforceProductLimitInNetTerms >> dispatch)
|
||||
Fields.radioButton "Use Absolute Contracts" "" (not model.scratch.riskLimitEnforcement.productLimitInNetTerms) [] (not >> EnforceProductLimitInNetTerms >> dispatch)
|
||||
div [] [
|
||||
@@ -640,12 +641,12 @@ let lazyProductLimitsView model dispatch =
|
||||
|
||||
let lossLimitView (model:Model) dispatch =
|
||||
div [] [
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "Loss Limit" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "Loss Limit" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text" ]
|
||||
[str "If Enabled, this limits the account's loss."]
|
||||
]
|
||||
div [][
|
||||
div [] [
|
||||
Fields.checkbox "Enable Loss Limit" "" model.scratch.accountLossLimit.enforce [] (EnforceLossLimit >> dispatch)
|
||||
Fields.inlineText "Total Loss Limit" (string model.scratch.accountLossLimit.totalLossLimit) [] (not model.scratch.accountLossLimit.enforce) (TotalLossLimit >> dispatch)
|
||||
]
|
||||
@@ -726,9 +727,10 @@ let securityLimitsView (model:Model) dispatch =
|
||||
[]
|
||||
((changeSymbol limit) >> SecurityLimits >> dispatch)
|
||||
)
|
||||
|
||||
TableControl.Cell (Fields.mapSelect
|
||||
""
|
||||
(JSMap.toMap (getSecurityMap model (Some limit) None))
|
||||
(JSMap.SparkJSMapCase(getSecurityMap model (Some limit) None) |> JSMap.toJSMap)
|
||||
None
|
||||
(Some (sprintf "%i" limit.security.securityId))
|
||||
((changeSecurityId limit) >> SecurityLimits >> dispatch)
|
||||
@@ -761,8 +763,8 @@ let securityLimitsView (model:Model) dispatch =
|
||||
let addRow _ = Array.append model.scratch.securityPositionLimits [| emptyLimit |] |> (SecurityLimits >> dispatch)
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "Security Limits" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "Security Limits" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text" ]
|
||||
[str "Optionally, the net position for one or more securities can also be limited. For example, the Product Limits can be set to restrict the Max Net Long Position across all ES futures to 10,000 contracts, but Security Limits can be used to restrict the ES Jun future to 500 only"]
|
||||
]
|
||||
@@ -785,11 +787,13 @@ let venueToString (venue:bts.api.Venue) =
|
||||
| bts.api.Venue.UNSET -> "Unset"
|
||||
| bts.api.Venue.BTS -> "BTS"
|
||||
| bts.api.Venue.SIM -> "SIM"
|
||||
| bts.api.Venue.SIMICE -> "SIMICE"
|
||||
| bts.api.Venue.CBOE -> "CBOE"
|
||||
| bts.api.Venue.CBOECFE -> "CBOECFE"
|
||||
| bts.api.Venue.GLBX -> "GLBX"
|
||||
| bts.api.Venue.DERIBIT -> "DERIBIT"
|
||||
| bts.api.Venue.ICE -> "ICE"
|
||||
// | bts.api.Venue.DERIBIT -> "DERIBIT"
|
||||
|
||||
let exchange_display expirationNameList =
|
||||
let s = sprintf "%O" expirationNameList.product.exchange
|
||||
@@ -820,8 +824,8 @@ let getPositionSecMap (sList:(uint32 * PositionSecurity) list) venue symbol =
|
||||
let SODPositionView model dispatch =
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "SOD" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "SOD" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text"; ]
|
||||
[str "Manually add fills for the Start of Day position"]
|
||||
]
|
||||
@@ -856,7 +860,7 @@ let DayPositionView model dispatch =
|
||||
let securityList:(uint32 * PositionSecurity) list =
|
||||
model.mdRelayExpNameData
|
||||
|> List.ofArray
|
||||
|> List.filter (fun i -> i.product.``type`` = bts.api.SecurityType.FUTURE or i.product.``type`` = bts.api.SecurityType.OPTION)
|
||||
|> List.filter (fun i -> i.product.``type`` = bts.api.SecurityType.FUTURE || i.product.``type`` = bts.api.SecurityType.OPTION)
|
||||
|> List.collect (fun i ->
|
||||
JSMap.toList i.names
|
||||
|> List.map (fun x ->
|
||||
@@ -999,7 +1003,7 @@ let DayPositionView model dispatch =
|
||||
(fun _ -> true)
|
||||
(fun v -> (limit.newId, v, "price", true) |> UpdateManualFill |> dispatch)
|
||||
)
|
||||
TableControl.Cell (span [Style [Color "green"]][str "NEW"])
|
||||
TableControl.Cell (span [Style [Color "green"]] [str "NEW"])
|
||||
]
|
||||
className = match validateManualFill limit with true -> "" | false -> "is-invalid"
|
||||
header = None
|
||||
@@ -1011,8 +1015,8 @@ let DayPositionView model dispatch =
|
||||
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "Day Fills" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "Day Fills" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text"; ]
|
||||
[str "Manually add fills for the Day position"]
|
||||
]
|
||||
@@ -1025,8 +1029,8 @@ let DayPositionView model dispatch =
|
||||
let PositionUploadView model dispatch =
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns" ][
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ][str "Upload" ]
|
||||
div [ ClassName "columns" ] [
|
||||
h1 [ ClassName "is-size-3 column is-narrow" ] [str "Upload" ]
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text"; ]
|
||||
[str "Add fills from a file for the Day position"]
|
||||
]
|
||||
@@ -1210,7 +1214,7 @@ let accountSelectionGrid (accountList:BTSAccount list) (currentAccount:BTSAccoun
|
||||
[ for acc in activeAccounts do yield {
|
||||
cells =
|
||||
[
|
||||
TableControl.Cell (a [ OnClick (fun _ -> (acc |> SelectAccount |> dispatch))][
|
||||
TableControl.Cell (a [ OnClick (fun _ -> (acc |> SelectAccount |> dispatch))] [
|
||||
str acc.name
|
||||
])
|
||||
TableControl.Cell (str (sprintf "%b" acc.isActive))
|
||||
@@ -1221,7 +1225,7 @@ let accountSelectionGrid (accountList:BTSAccount list) (currentAccount:BTSAccoun
|
||||
onClick = None
|
||||
}
|
||||
]
|
||||
div[][
|
||||
div [] [
|
||||
TableControl.createSelectorTable (Some headerRow) rws
|
||||
]
|
||||
|
||||
@@ -1242,7 +1246,7 @@ let menuItem account selectedAccount model dispatch =
|
||||
HTMLAttr.Custom ("aria-controls", (sprintf "dropdown-menu-%s" account.name)) ]
|
||||
[ span [ Class "icon is-small" ]
|
||||
[ i [ Class "fa fa-ellipsis-v"
|
||||
HTMLAttr.Custom ("aria-hidden", "true") ][ ]
|
||||
HTMLAttr.Custom ("aria-hidden", "true") ] [ ]
|
||||
]
|
||||
]
|
||||
]
|
||||
@@ -1261,7 +1265,7 @@ let menuItem account selectedAccount model dispatch =
|
||||
]
|
||||
]
|
||||
]
|
||||
else span[][])
|
||||
else span [] [])
|
||||
]
|
||||
|
||||
let NavRoot (accounts:BTSAccount[]) selectedAccount model dispatch =
|
||||
@@ -1308,7 +1312,7 @@ let root (model:Model) dispatch =
|
||||
| "" -> span [] []
|
||||
| _ -> Modal.showConfirm (fst model.ConfirmModal) (fun () -> (snd model.ConfirmModal) |> dispatch) (fun _ -> OpenConfirmModal ("", Msg.SelectTab model.tab ) |> dispatch)
|
||||
match model.adminData with
|
||||
| None -> div[][str "Loading account list..."]
|
||||
| None -> div [] [str "Loading account list..."]
|
||||
| Some data ->
|
||||
div
|
||||
[ Class "columns is-fullheight"
|
||||
@@ -1324,14 +1328,14 @@ let root (model:Model) dispatch =
|
||||
|
||||
div [ ClassName "tabs is-boxed" ] [
|
||||
ul [] [
|
||||
(if (Array.length data.accounts > 0) then (tabHeader General model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader LimitsTab model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader ConnectionsTab model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader General model dispatch) else span [] [] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader LimitsTab model dispatch) else span [] [] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader ConnectionsTab model dispatch) else span [] [] )
|
||||
// tabHeader CreditLimits model.tab dispatch
|
||||
(if (Array.length data.accounts > 0) then (tabHeader ExchangeSettingsTab model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader OrdersTab model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader PositionManagementTab model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader MarginTab model dispatch) else span [][] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader ExchangeSettingsTab model dispatch) else span [] [] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader OrdersTab model dispatch) else span [] [] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader PositionManagementTab model dispatch) else span [] [] )
|
||||
(if (Array.length data.accounts > 0) then (tabHeader MarginTab model dispatch) else span [] [] )
|
||||
]
|
||||
]
|
||||
tabContent model dispatch
|
||||
@@ -1,50 +1,45 @@
|
||||
module App.View
|
||||
|
||||
open Elmish
|
||||
open Elmish.Browser.Navigation
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Import
|
||||
open Fable.Import.Browser
|
||||
open Types
|
||||
open App.State
|
||||
open App.Types
|
||||
open Global
|
||||
|
||||
importAll "../sass/main.scss"
|
||||
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Elmish.React.Common
|
||||
open ServiceContext
|
||||
|
||||
|
||||
let topLevel (sc:ServiceContext.ServiceContext) currentPage dispatch content =
|
||||
div
|
||||
[ Class "columns is-fullheight" ]
|
||||
[ Nav.navRoot currentPage sc dispatch
|
||||
div [ Class "column is-main-content" ]
|
||||
[ content ]
|
||||
]
|
||||
|
||||
let root model dispatch =
|
||||
match model with
|
||||
| PreLogin m -> Login.root m (LoginMsg >> dispatch)
|
||||
| LoggedIn model ->
|
||||
match model.page with
|
||||
| UsersModel m -> Users.View.root m (UsersMsg>>dispatch) |> topLevel model.context model.page dispatch
|
||||
| AccountsModel m -> Accounts.View.root m (AccountsMsg>>dispatch) |> topLevel model.context model.page dispatch
|
||||
|
||||
open Elmish.React
|
||||
open Elmish.Debug
|
||||
open Elmish.HMR
|
||||
|
||||
// App
|
||||
Program.mkProgram init update root
|
||||
#if DEBUG
|
||||
|> Program.withConsoleTrace
|
||||
|> Program.withDebugger
|
||||
|> Program.withHMR
|
||||
#endif
|
||||
|> Program.withReactUnoptimized "elmish-app"
|
||||
|> Program.run
|
||||
module App.View
|
||||
|
||||
open Elmish
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open Types
|
||||
open App.State
|
||||
open App.Types
|
||||
open Global
|
||||
|
||||
importAll "../sass/main.scss"
|
||||
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
open Elmish.React.Common
|
||||
|
||||
|
||||
let topLevel (sc:ServiceContext.ServiceContext) currentPage dispatch content =
|
||||
div
|
||||
[ Class "columns is-fullheight" ]
|
||||
[ Nav.navRoot currentPage sc dispatch
|
||||
div [ Class "column is-main-content" ]
|
||||
[ content ]
|
||||
]
|
||||
|
||||
let root model dispatch =
|
||||
match model with
|
||||
| PreLogin m -> Login.root m (LoginMsg >> dispatch)
|
||||
| LoggedIn model ->
|
||||
match model.page with
|
||||
| UsersModel m -> Users.View.root m (UsersMsg>>dispatch) |> topLevel model.context model.page dispatch
|
||||
| AccountsModel m -> Accounts.View.root m (AccountsMsg>>dispatch) |> topLevel model.context model.page dispatch
|
||||
|
||||
open Elmish.React
|
||||
open Elmish.Debug
|
||||
open Elmish.HMR
|
||||
|
||||
// App
|
||||
Program.mkProgram init update root
|
||||
#if DEBUG
|
||||
|> Program.withConsoleTrace
|
||||
|> Program.withDebugger
|
||||
#endif
|
||||
|> Program.withReactSynchronous "elmish-app"
|
||||
|> Program.run
|
||||
@@ -1,7 +1,7 @@
|
||||
module Cmd
|
||||
let ofExistingPromise p ok err =
|
||||
Elmish.Cmd.ofPromise
|
||||
Elmish.Cmd.OfPromise.either
|
||||
(fun _ -> p)
|
||||
()
|
||||
ok
|
||||
err
|
||||
err
|
||||
@@ -1,8 +1,8 @@
|
||||
module Button
|
||||
|
||||
open Fable.Core
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
|
||||
type IsDisabled =
|
||||
| Disabled
|
||||
@@ -90,8 +90,8 @@ let button text flavor icon disabled click =
|
||||
(match icon with
|
||||
| "" -> str text
|
||||
| _ ->
|
||||
span [][
|
||||
span [ ClassName "icon is-small" ] [i [ ClassName (sprintf "fa fa-%s" icon)][] ]
|
||||
span [] [
|
||||
span [ ClassName "icon is-small" ] [i [ ClassName (sprintf "fa fa-%s" icon)] [] ]
|
||||
nbsp.element
|
||||
str text
|
||||
])
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
module DataGrid
|
||||
open Fable.Core.Exceptions
|
||||
// open Fable.Core.Exceptions
|
||||
open Fable.Core
|
||||
open Fable.Helpers.React
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
|
||||
type GridProps = ReactGrid.GridProps
|
||||
|
||||
@@ -13,9 +14,9 @@ let private update<'a> dispatch (rows:'a[]) (update:ReactGrid.GridUpdate) =
|
||||
dispatch (unbox<'a[]> updatedRows)
|
||||
|
||||
let dataGrid<'a> columns props (rows:'a[]) dispatch =
|
||||
let rgprops =
|
||||
let rgprops =
|
||||
props @ [
|
||||
ReactGrid.RowGetter (fun i -> box rows.[i])
|
||||
ReactGrid.RowGetter (fun i -> box rows.[i])
|
||||
ReactGrid.OnGridRowsUpdated (update dispatch rows)
|
||||
ReactGrid.RowsCount (Array.length rows)
|
||||
]
|
||||
@@ -46,6 +47,6 @@ let mappedDataGrid<'a,'r> (descriptor:MappedDataGridDescriptor<'a,'r>) props (ro
|
||||
props @ [
|
||||
ReactGrid.RowGetter getRow
|
||||
ReactGrid.RowsCount (Array.length rows)
|
||||
ReactGrid.OnGridRowsUpdated onUpdate
|
||||
ReactGrid.OnGridRowsUpdated onUpdate
|
||||
]
|
||||
ReactGrid.reactGrid descriptor.columns rgprops
|
||||
@@ -1,10 +1,11 @@
|
||||
module Fields
|
||||
|
||||
open Fable.Core
|
||||
open Fable.Core.JS
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Fable.Import.React
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
// open Fable.Browser
|
||||
open Global
|
||||
open Fable
|
||||
open JSMap
|
||||
@@ -40,7 +41,7 @@ let inlineText (lbl:string) (dv:string) (attrs:IHTMLProp list) (disabled:bool) o
|
||||
let disabledLabel = if disabled then "disabled-label" else ""
|
||||
span [ ClassName "field" ]
|
||||
[
|
||||
label [ ClassName ("label inline-label " + disabledLabel)][str lbl]
|
||||
label [ ClassName ("label inline-label " + disabledLabel)] [str lbl]
|
||||
span [ ClassName "control" ]
|
||||
[ input ([
|
||||
ClassName "input"
|
||||
@@ -193,8 +194,8 @@ let double (lbl:string) (dv:double) (attrs:IHTMLProp list) onchange =
|
||||
text lbl (string dv) attrs (double>>onchange)
|
||||
|
||||
let enumSelect<'a> (lbl:string) (dv:'a) (values:'a[]) (attrs:IHTMLProp list) (onchange:'a->unit) =
|
||||
let vals = match (Array.tryFindIndex (fun elm -> unbox elm = unbox dv) values) with
|
||||
| None -> Array.concat [[| dv |]; values]
|
||||
let vals = match (Microsoft.FSharp.Collections.Array.tryFindIndex (fun elm -> unbox elm = unbox dv) values) with
|
||||
| None -> Microsoft.FSharp.Collections.Array.concat [[| dv |]; values]
|
||||
| Some _ -> values
|
||||
|
||||
div [ClassName "field"] [
|
||||
@@ -227,7 +228,7 @@ let checkbox (lbl:string) (description:string) (dv:bool) (attrs:IHTMLProp list)
|
||||
str (" " + lbl)
|
||||
]
|
||||
nbsp.element
|
||||
span [ClassName "is-size-7 has-text-grey-mid"][ str description]
|
||||
span [ClassName "is-size-7 has-text-grey-mid"] [ str description]
|
||||
]
|
||||
]
|
||||
|
||||
@@ -246,7 +247,7 @@ let radioButton (lbl:string) (description:string) (dv:bool) (attrs:IHTMLProp lis
|
||||
str (" " + lbl)
|
||||
]
|
||||
nbsp.element
|
||||
span [ClassName "is-size-7 has-text-grey-mid"][ str description]
|
||||
span [ClassName "is-size-7 has-text-grey-mid"] [ str description]
|
||||
]
|
||||
]
|
||||
|
||||
@@ -292,8 +293,8 @@ let mapSelectEx (lbl:string) (options:Map<string,string>) (defaultText:string op
|
||||
|
||||
let optList:ReactElement list =
|
||||
match defaultText with
|
||||
| None -> (option [] [str ""]) :: ([ for opt in options do yield option [ Value opt.Key ] [ str (opt.Value) ] ])
|
||||
| Some dt -> (option [] [str dt]) :: ([ for opt in options do yield option [ Value opt.Key ] [ str (opt.Value) ] ])
|
||||
| None -> (option [] [str ""]) :: ([ for opt in options.entries() do yield option [ Value (fst opt) ] [ str (snd opt) ] ])
|
||||
| Some dt -> (option [] [str dt]) :: ([ for opt in options.entries() do yield option [ Value (fst opt) ] [ str (snd opt) ] ])
|
||||
|
||||
let dv = match defaultValue with
|
||||
| Some d -> d
|
||||
@@ -358,8 +359,8 @@ let menuSelect (options:string list) (onchange:'a->unit) =
|
||||
]
|
||||
]
|
||||
|
||||
let getFileData next (file:Import.Browser.File) =
|
||||
let reader = Fable.Import.Browser.FileReader.Create ()
|
||||
let getFileData next (file:Browser.Types.Blob) =
|
||||
let reader = Browser.Dom.FileReader.Create ()
|
||||
reader.onload <- (fun _ ->
|
||||
reader.result |> string |> next
|
||||
)
|
||||
@@ -375,10 +376,10 @@ let fileUpload (multiple:bool) (onInput:string -> unit) =
|
||||
[ input [ Class "file-input"
|
||||
Type "file"
|
||||
Name "file-upload"
|
||||
OnInput (fun (v:FormEvent) ->
|
||||
OnInput (fun v ->
|
||||
v.target?files
|
||||
|> unbox<Import.Browser.File[]>
|
||||
|> Array.head
|
||||
|> unbox<Browser.Types.Blob[]>
|
||||
|> Microsoft.FSharp.Collections.Array.head
|
||||
|> getFileData onInput
|
||||
)
|
||||
Multiple multiple
|
||||
@@ -1,20 +1,20 @@
|
||||
module Modal
|
||||
|
||||
open Browser.Types
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Fable.Import.React
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
open Global
|
||||
open Fable
|
||||
|
||||
|
||||
let show (title:string) (content:ReactElement) (footerContent:ReactElement) (onCloseClick: MouseEvent -> Unit) =
|
||||
div [ Class "modal is-active" ]
|
||||
[ div [ Class "modal-background" ][ ]
|
||||
[ div [ Class "modal-background" ] [ ]
|
||||
div [ Class "modal-card" ]
|
||||
[ header [ Class "modal-card-head" ]
|
||||
[ p [ Class "modal-card-title" ][ str title ]
|
||||
[ p [ Class "modal-card-title" ] [ str title ]
|
||||
button [ Class "delete"; OnClick onCloseClick ] [ ]
|
||||
]
|
||||
section [ Class "modal-card-body" ] [ content ]
|
||||
@@ -0,0 +1,158 @@
|
||||
module ReactGrid
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
// open Fable.React.Props.HTMLAttr
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Core
|
||||
(* open Fable.Core.JS.Constructors *)
|
||||
open Fable.Core.DynamicExtensions
|
||||
open Fable.Import
|
||||
|
||||
(* *)
|
||||
type GridUpdate = {
|
||||
cellKey : string
|
||||
fromRow : int
|
||||
toRow : int
|
||||
rowIds: int[]
|
||||
updated: obj
|
||||
}
|
||||
|
||||
type ColumnProps =
|
||||
| Key of string
|
||||
| Name of string
|
||||
| Width of int
|
||||
| Editable of bool
|
||||
| Editor of ReactElement
|
||||
| Formatter of ReactElement
|
||||
|
||||
type Row = obj
|
||||
type GridProps =
|
||||
| EnableCellSelect of bool
|
||||
| EnableRowSelect of bool
|
||||
| RowsCount of int
|
||||
| MinHeight of int
|
||||
| RowGetter of (int->Row)
|
||||
| OnGridRowsUpdated of (GridUpdate->unit)
|
||||
| OnRowSelect of (Row list->unit)
|
||||
| RowKey of string
|
||||
|
||||
|
||||
let reactGrid (columns:ColumnProps list[]) props =
|
||||
let props' = (keyValueList CaseRules.LowerFirst props)
|
||||
let columns' = Array.map (keyValueList CaseRules.LowerFirst) columns
|
||||
props'.["columns"] <- columns'
|
||||
ofImport "default" "react-data-grid" props' []
|
||||
|
||||
(* *)
|
||||
type SelectEditorProps = {
|
||||
options : string[]
|
||||
}
|
||||
let selectEditor (props:SelectEditorProps) =
|
||||
ofImport "Editors.DropDownEditor" "react-data-grid-addons" props []
|
||||
|
||||
let selectFormatter (props:SelectEditorProps) =
|
||||
ofImport "Formatters.DropDownFormatter" "react-data-grid-addons" props []
|
||||
|
||||
let selectColumn<'a> key header (options:'a[]) =
|
||||
[ Key key
|
||||
Name header
|
||||
Editor (selectEditor { options = unbox options })
|
||||
Formatter (selectFormatter { options = unbox options })
|
||||
]
|
||||
|
||||
|
||||
|
||||
type MyStu = {
|
||||
value: int
|
||||
}
|
||||
|
||||
type MyUpd = {
|
||||
incr: int
|
||||
}
|
||||
|
||||
(* *)
|
||||
type private ButtonProps = {
|
||||
icon : string
|
||||
title: string
|
||||
action : int->unit
|
||||
// .value will be row.[ColumnProps.Key] -but- if we set it then it does't get overwritten
|
||||
// value : obj option
|
||||
rowIdx : int
|
||||
misc : obj
|
||||
}
|
||||
|
||||
let private my_do_upd (u: MyUpd) (s: MyStu): MyStu =
|
||||
{
|
||||
value = s.value + u.incr
|
||||
}
|
||||
|
||||
let private my_to_view (m: ReactiveComponents.Model<ButtonProps, MyStu>) (proc_msg: MyUpd->unit): ReactElement =
|
||||
div [] []
|
||||
|
||||
let private my_initagain (p: ButtonProps): MyStu =
|
||||
{
|
||||
value = 0
|
||||
}
|
||||
|
||||
// let my_to_view (m: Mod)
|
||||
let private my_init (arg: ButtonProps): ReactiveComponents.Props<ButtonProps, MyStu, MyUpd> =
|
||||
{
|
||||
key = "id"
|
||||
props = arg
|
||||
update = my_do_upd
|
||||
view = my_to_view
|
||||
init = my_initagain
|
||||
}
|
||||
|
||||
|
||||
// let private init_button_ =
|
||||
|
||||
// type private ButtonFormatter(initProps : ButtonProps) as self =
|
||||
// inherit ReactiveComponents.ReactiveCom<ButtonProps, obj, obj>(initProps) with
|
||||
// do self.setInitState ()
|
||||
// override __.render() =
|
||||
// // Browser.console.log(self.props)
|
||||
// p [ ClassName "control" ] [
|
||||
// a [ ClassName "button"
|
||||
// Title self.props.title
|
||||
// OnClick (fun _ -> self.props.action self.props.rowIdx) ] [
|
||||
// span [ ClassName "icon is-small" ] [
|
||||
// i [ ClassName (sprintf "fa fa-%s" self.props.icon)] [ ] ]
|
||||
// ]
|
||||
// ]
|
||||
|
||||
|
||||
type private ButtonFormatter(initProps: ButtonProps) as self =
|
||||
inherit ReactiveComponents.ReactiveCom<ButtonProps, MyStu, MyUpd>(initProps |> my_init)
|
||||
|
||||
override __.render() =
|
||||
p [ ClassName "control" ] [
|
||||
a [ ClassName "button"
|
||||
Title self.props.props.title
|
||||
OnClick (fun _ -> self.props.props.action self.props.props.rowIdx ) ] [
|
||||
span [ ClassName "icon is-small" ] [
|
||||
i [ ClassName (sprintf "fa fa-%s" self.props.props.icon)] []
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
let buttonColumn action header icon misc =
|
||||
let (bn_col_props: ButtonProps) = {
|
||||
title = header;
|
||||
icon = icon;
|
||||
action = action;
|
||||
rowIdx = 0;
|
||||
misc = misc;
|
||||
}
|
||||
[ HTMLAttr.Name header
|
||||
Style [ Fable.React.Props.CSSProp.Width 60 ]
|
||||
]
|
||||
|
||||
// [ Name header
|
||||
// Style [ Width 60 ]
|
||||
// Formatter (ofType<ButtonFormatter, MyStu, MyUpd> { title = header; icon = icon; action = action; rowIdx = 0; misc = misc } [])
|
||||
// ]
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module TableControl
|
||||
|
||||
open Browser.Types
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Fable.Import.React
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
|
||||
type cell = { content:ReactElement; className:string; isHeader:bool; colSpan:int }
|
||||
|
||||
@@ -31,8 +31,8 @@ type row = {
|
||||
|
||||
let createCell (inHeaderRow:bool) (c:cell) =
|
||||
match c.isHeader || inHeaderRow with
|
||||
| false -> td [ ClassName c.className; ColSpan (float c.colSpan) ] [ c.content ]
|
||||
| true -> th [ ClassName c.className; ColSpan (float c.colSpan) ] [ c.content ]
|
||||
| false -> td [ ClassName c.className; ColSpan (int c.colSpan) ] [ c.content ]
|
||||
| true -> th [ ClassName c.className; ColSpan (int c.colSpan) ] [ c.content ]
|
||||
|
||||
let createRow (isHeaderRow:bool) (r:row) =
|
||||
match r.header, isHeaderRow, r.onClick with
|
||||
@@ -70,7 +70,7 @@ let createDataTable (headers:row option) (rl:row list) (buttons:ReactElement) =
|
||||
]
|
||||
| None ->
|
||||
[ tbody [] rws ]
|
||||
div [ Class "bts-data-table-container" ][
|
||||
div [ Class "bts-data-table-container" ] [
|
||||
table [ ClassName (sprintf "table bts-data-table") ] tbl
|
||||
div [Class "is-pulled-right table-buttons"] [ buttons ]
|
||||
div [Class "is-clearfix "] []
|
||||
@@ -86,7 +86,7 @@ let createDataTableWithStyle (headers:row option) (rl:row list) (className:strin
|
||||
]
|
||||
| None ->
|
||||
[ tbody [] rws ]
|
||||
div [ Class "bts-data-table-container" ][
|
||||
div [ Class "bts-data-table-container" ] [
|
||||
table [ ClassName (sprintf "table bts-data-table %s" className); Style style ] tbl
|
||||
div [Class "is-pulled-right table-buttons"] [ buttons ]
|
||||
div [Class "is-clearfix "] []
|
||||
@@ -109,4 +109,4 @@ let createSelectorTableWithStyle (headers:row option) (rl:row list) className st
|
||||
If a callback is provided add a checkbox as the first column and set a background color if it is checked... in addition to the callback
|
||||
*)
|
||||
|
||||
let createSelectorTable (headers:row option) (rl:row list) = createSelectorTableWithStyle headers rl "" []
|
||||
let createSelectorTable (headers:row option) (rl:row list) = createSelectorTableWithStyle headers rl "" []
|
||||
@@ -0,0 +1,7 @@
|
||||
module nbsp
|
||||
|
||||
|
||||
open Fable.Core
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
let element = span [ Style [PaddingLeft "1ex"] ] [str " "]
|
||||
@@ -95,8 +95,33 @@ export class DynamicService {
|
||||
streams : Array<[string,number,string]>) {
|
||||
|
||||
const svc = { context, name, qualifier }
|
||||
// HACK ALERT: Method prefixes 'get_' and 'set_' seem to be ignored by fable bindings. This
|
||||
// was observed in IAdminService.get_filtered_admin_data, IAdminService.get_admin_data, and
|
||||
// IMarginService.set_cash_factor. Calls to those methods (from fsharp) failed in javascript
|
||||
// due to undefined methods 'filtered_admin_data', 'admin_data', and 'cash_factor'
|
||||
// respectively. Adding the methods with the prefix removed seems to fix the problem.
|
||||
//
|
||||
// WARNING: This hack assumes services won't have methods get_<foo> and set_<foo> (if both
|
||||
// are present, one of them will be overwritten).
|
||||
//
|
||||
// TODO: Replace this hack with a stable solution.
|
||||
let strip_prefix = (prefix:string) => {
|
||||
if (!methodName.startsWith(prefix)) {
|
||||
return false
|
||||
}
|
||||
let without_prefix = methodName.substring(prefix.length)
|
||||
if (without_prefix in this) {
|
||||
throw new Error(
|
||||
`The method '${without_prefix}' has already been defined. Services cannot have ` +
|
||||
`methods named get_<foo> and set_<foo> due to a hack in our js generation impl`);
|
||||
}
|
||||
this[without_prefix] = this[methodName]
|
||||
return true
|
||||
}
|
||||
|
||||
for (var [methodName, id, inType, outType] of methods) {
|
||||
this[methodName] = gen_method(svc, id, inType, outType)
|
||||
strip_prefix('get_') || strip_prefix('set_')
|
||||
}
|
||||
for (var [streamName,id,typeName] of streams) {
|
||||
const fnName = "subscribe_" + streamName;
|
||||
@@ -1,66 +1,78 @@
|
||||
module Global
|
||||
open Fable.Core
|
||||
open Fable.PowerPack
|
||||
|
||||
let Class = Fable.Helpers.React.Props.HTMLAttr.ClassName
|
||||
|
||||
type AlertLevel =
|
||||
| Info
|
||||
| Warning
|
||||
| Error
|
||||
|
||||
[<Emit("alert($1)")>]
|
||||
let alert (_:AlertLevel) (_:string) = Fable.Core.Exceptions.jsNative
|
||||
|
||||
let compareDouble (d1:double) (d2:double) (precision: uint32) = (int (d1 * (double precision))) = (int (d2 * (double precision)))
|
||||
|
||||
let epochToDateTimeString (time:int64) =
|
||||
let dto = time |> System.DateTimeOffset.FromUnixTimeSeconds
|
||||
dto.DateTime |> (Date.Format.localFormat Date.Local.englishUS "M/d/yyyy hh:mm tt")
|
||||
|
||||
|
||||
let toSortableDate (badDate:string) =
|
||||
let month = badDate.[0]
|
||||
let year = badDate.[1]
|
||||
|
||||
let curYear = System.DateTime.Now.Year
|
||||
|
||||
let yearMap = Map.empty.
|
||||
Add((string curYear).[3], curYear).
|
||||
Add((string (curYear + 1 )).[3], curYear + 1).
|
||||
Add((string (curYear + 2 )).[3], curYear + 2).
|
||||
Add((string (curYear + 3 )).[3], curYear + 3).
|
||||
Add((string (curYear + 4 )).[3], curYear + 4).
|
||||
Add((string (curYear + 5 )).[3], curYear + 5).
|
||||
Add((string (curYear + 6 )).[3], curYear + 6).
|
||||
Add((string (curYear + 7 )).[3], curYear + 7).
|
||||
Add((string (curYear + 8 )).[3], curYear + 8).
|
||||
Add((string (curYear + 9 )).[3], curYear + 9)
|
||||
|
||||
let fullYear = string yearMap.[year]
|
||||
|
||||
sprintf "%s%c" fullYear month
|
||||
|
||||
|
||||
|
||||
|
||||
module Reflection =
|
||||
open Fable.Core.JsInterop
|
||||
|
||||
[<Emit("Object.keys($0)")>]
|
||||
let keys x : string[] = jsNative
|
||||
|
||||
[<Emit("Object.values($0)")>]
|
||||
let values<'a> x : 'a[] = jsNative
|
||||
|
||||
let iterate<'a> x : (string*'a)[] =
|
||||
Array.zip (keys x) (values x)
|
||||
|
||||
let spread<'a> (a:'a) (b:obj) : 'a = Imports.DynamicService.merge (a,b)
|
||||
|
||||
let objToPairs (o:obj) =
|
||||
Array.zip (keys o) (values o)
|
||||
|
||||
let pairsToObj<'a> (kv: (string*'a) seq) =
|
||||
createObj (unbox kv)
|
||||
|
||||
module Global
|
||||
|
||||
// type Page =
|
||||
// | Home
|
||||
// | Counter
|
||||
// | About
|
||||
|
||||
// let toHash page =
|
||||
// match page with
|
||||
// | About -> "#about"
|
||||
// | Counter -> "#counter"
|
||||
// | Home -> "#home"
|
||||
|
||||
open Fable.Core
|
||||
|
||||
let Class = Fable.React.Props.HTMLAttr.ClassName
|
||||
|
||||
type AlertLevel =
|
||||
| Info
|
||||
| Warning
|
||||
| Error
|
||||
|
||||
[<Emit("alert($1)")>]
|
||||
let alert (l:AlertLevel) (m:string) = jsNative
|
||||
|
||||
// [<Emit("alert($1)")>]
|
||||
// let alert (_:AlertLevel) (_:string) = Fable.Core.JS.Exceptions.jsNative
|
||||
|
||||
let compareDouble (d1:double) (d2:double) (precision: uint32) = (int (d1 * (double precision))) = (int (d2 * (double precision)))
|
||||
|
||||
let epochToDateTimeString (time:int64) =
|
||||
let dto = time |> System.DateTimeOffset.FromUnixTimeSeconds
|
||||
dto.DateTime.ToString("M/d/yyyy hh:mm tt")
|
||||
|
||||
|
||||
let toSortableDate (badDate:string) =
|
||||
let month = badDate.[0]
|
||||
let year = badDate.[1]
|
||||
|
||||
let curYear = System.DateTime.Now.Year
|
||||
|
||||
let yearMap = Map.empty.
|
||||
Add((string curYear).[3], curYear).
|
||||
Add((string (curYear + 1 )).[3], curYear + 1).
|
||||
Add((string (curYear + 2 )).[3], curYear + 2).
|
||||
Add((string (curYear + 3 )).[3], curYear + 3).
|
||||
Add((string (curYear + 4 )).[3], curYear + 4).
|
||||
Add((string (curYear + 5 )).[3], curYear + 5).
|
||||
Add((string (curYear + 6 )).[3], curYear + 6).
|
||||
Add((string (curYear + 7 )).[3], curYear + 7).
|
||||
Add((string (curYear + 8 )).[3], curYear + 8).
|
||||
Add((string (curYear + 9 )).[3], curYear + 9)
|
||||
|
||||
let fullYear = string yearMap.[year]
|
||||
|
||||
sprintf "%s%c" fullYear month
|
||||
|
||||
|
||||
module Reflection =
|
||||
open Fable.Core.JsInterop
|
||||
|
||||
[<Emit("Object.keys($0)")>]
|
||||
let keys x : string[] = jsNative
|
||||
|
||||
[<Emit("Object.values($0)")>]
|
||||
let values<'a> x : 'a[] = jsNative
|
||||
|
||||
let iterate<'a> x : (string*'a)[] =
|
||||
Array.zip (keys x) (values x)
|
||||
|
||||
let spread<'a> (a:'a) (b:obj) : 'a = Imports.DynamicService.merge (a,b)
|
||||
|
||||
let objToPairs (o:obj) =
|
||||
Array.zip (keys o) (values o)
|
||||
|
||||
let pairsToObj<'a> (kv: (string*'a) seq) =
|
||||
createObj (unbox kv)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
module Imports
|
||||
|
||||
open Fable.Core
|
||||
open Fable.Core.JS
|
||||
open Fable.Core.JsInterop
|
||||
|
||||
|
||||
// [<Import("*",from="/home/john/Documents/repos/bts/spark-crypto/src/web/ui/src/web/api/ServiceContext")>]
|
||||
// let ServiceContext : ServiceContext.IExports = jsNative
|
||||
|
||||
// [<Import("*",from="/home/john/Documents/repos/bts/spark-crypto/src/web/ui/src/web/api/DynamicService")>]
|
||||
// let DynamicService : DynamicService.IExports = jsNative
|
||||
[<Import("*",from="ServiceContext")>]
|
||||
let ServiceContext : ServiceContext.IExports = jsNative
|
||||
|
||||
[<Import("*",from="DynamicService")>]
|
||||
let DynamicService : DynamicService.IExports = jsNative
|
||||
|
||||
|
||||
// let ServiceContext : ServiceContext.IExports = importAll "ServiceContext"
|
||||
// let DynamicService : DynamicService.IExports = importAll "DynamicService"
|
||||
|
||||
// let DynamicService : DynamicService.IExports = importAll "web/api/DynamicService"
|
||||
File renamed without changes.
@@ -2,8 +2,8 @@ module Login
|
||||
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Core
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
open Elmish
|
||||
|
||||
//
|
||||
@@ -28,7 +28,7 @@ let init() =
|
||||
{ user = ""; password = ""; error = "" }, Cmd.Empty
|
||||
|
||||
let loginMsg user pass =
|
||||
Cmd.ofPromise
|
||||
Cmd.OfPromise.either
|
||||
Imports.ServiceContext.connect
|
||||
(user,pass)
|
||||
(function | U2.Case1 sc -> LoginSuccess sc | U2.Case2 str -> LoginFailure str)
|
||||
@@ -52,15 +52,15 @@ let update msg model =
|
||||
// View
|
||||
|
||||
let root model dispatch =
|
||||
let sparkImg = "img/BTS-300.png"
|
||||
let handler msg (ev:Fable.Import.React.FormEvent) =
|
||||
let sparkImg = "public/img/BTS-300.png"
|
||||
let handler msg (ev:Browser.Types.Event) =
|
||||
!!ev.target?value |> msg |> dispatch
|
||||
section [ ClassName "hero is-fullheight is-primary" ] [
|
||||
div [ ClassName "hero-body" ] [
|
||||
div [ ClassName "container has-text-centered" ] [
|
||||
div [ ClassName "column is-4 is-offset-4" ] [
|
||||
div [ ClassName "box" ] [
|
||||
p [ Style [Margin "2em 0 3em 0"] ][
|
||||
p [ Style [Margin "2em 0 3em 0"] ] [
|
||||
figure [ ClassName "avatar" ] [
|
||||
img [ Src sparkImg ]
|
||||
]
|
||||
@@ -1,63 +1,60 @@
|
||||
module App.Nav
|
||||
|
||||
|
||||
open Elmish
|
||||
open Elmish.Browser.Navigation
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Import
|
||||
open Fable.Import.Browser
|
||||
open Types
|
||||
open App.State
|
||||
open App.Types
|
||||
open Global
|
||||
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open Elmish.React.Common
|
||||
open ServiceContext
|
||||
open Fable.Helpers
|
||||
open Imports
|
||||
open Fable.Import.React
|
||||
|
||||
let isCurrentPage page currentPage =
|
||||
match page, currentPage with
|
||||
| UsersModel _, UsersModel _ -> true
|
||||
| AccountsModel _, AccountsModel _ -> true
|
||||
| _ -> false
|
||||
|
||||
let navItem label icon state currentPage dispatch =
|
||||
a [
|
||||
OnClick (fun _ -> Navigate state |> dispatch)
|
||||
classList [ "is-active", isCurrentPage (fst state) currentPage ]
|
||||
]
|
||||
[
|
||||
div [ ClassName "icon is-large" ] [
|
||||
i [ ClassName (sprintf "fa fa-2x fa-%s" icon) ] []
|
||||
]
|
||||
div [] [str label]
|
||||
]
|
||||
|
||||
let root (currentPage:Page) (sc:ServiceContext) dispatch =
|
||||
let tmap (a,b) (fa,fb) = (fa a, fb b)
|
||||
div [ Class "column is-narrow is-launcher-sidebar-menu" ]
|
||||
[ aside [ Class "menu" ]
|
||||
[ ul [ Class "menu-list" ]
|
||||
[ li [ Class "launcher-item" ]
|
||||
[ navItem "Users" "users" (tmap (Users.State.init sc) (UsersModel, Cmd.map UsersMsg)) currentPage dispatch ]
|
||||
li [ Class "launcher-item" ]
|
||||
[ navItem "Accounts" "server" (tmap (Accounts.State.init sc) (AccountsModel,Cmd.map AccountsMsg)) currentPage dispatch ]
|
||||
li [ Class "launcher-item" ]
|
||||
[ a [ Href "/" ]
|
||||
[ div [ ClassName "icon is-large" ] [
|
||||
i [ ClassName "fa fa-3x fa-sign-out" ] []
|
||||
]
|
||||
div [] [str ("Logout \n" + sc.username)]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
let (navRoot: Page -> ServiceContext -> Dispatch<Msg> -> ReactElement) =
|
||||
lazyView3With (fun b c -> isCurrentPage (fst b) (fst c)) root
|
||||
module App.Nav
|
||||
|
||||
|
||||
open Elmish
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open Fable.Import
|
||||
open Types
|
||||
open App.State
|
||||
open App.Types
|
||||
open Global
|
||||
|
||||
open Fable.React
|
||||
open Fable.React.Props
|
||||
open Elmish.React.Common
|
||||
open ServiceContext
|
||||
open Imports
|
||||
open Fable.React
|
||||
|
||||
let isCurrentPage page currentPage =
|
||||
match page, currentPage with
|
||||
| UsersModel _, UsersModel _ -> true
|
||||
| AccountsModel _, AccountsModel _ -> true
|
||||
| _ -> false
|
||||
|
||||
let navItem label icon state currentPage dispatch =
|
||||
a [
|
||||
OnClick (fun _ -> Navigate state |> dispatch)
|
||||
classList [ "is-active", isCurrentPage (fst state) currentPage ]
|
||||
]
|
||||
[
|
||||
div [ ClassName "icon is-large" ] [
|
||||
i [ ClassName (sprintf "fa fa-2x fa-%s" icon) ] []
|
||||
]
|
||||
div [] [str label]
|
||||
]
|
||||
|
||||
let root (currentPage:Page) (sc:ServiceContext) dispatch =
|
||||
let tmap (a,b) (fa,fb) = (fa a, fb b)
|
||||
div [ Class "column is-narrow is-launcher-sidebar-menu" ]
|
||||
[ aside [ Class "menu" ]
|
||||
[ ul [ Class "menu-list" ]
|
||||
[ li [ Class "launcher-item" ]
|
||||
[ navItem "Users" "users" (tmap (Users.State.init sc) (UsersModel, Cmd.map UsersMsg)) currentPage dispatch ]
|
||||
li [ Class "launcher-item" ]
|
||||
[ navItem "Accounts" "server" (tmap (Accounts.State.init sc) (AccountsModel,Cmd.map AccountsMsg)) currentPage dispatch ]
|
||||
li [ Class "launcher-item" ]
|
||||
[ a [ Href "/" ]
|
||||
[ div [ ClassName "icon is-large" ] [
|
||||
i [ ClassName "fa fa-3x fa-sign-out" ] []
|
||||
]
|
||||
div [] [str ("Logout \n" + sc.username)]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
let (navRoot: Page -> ServiceContext -> Dispatch<Msg> -> ReactElement) =
|
||||
lazyView3With (fun b c -> isCurrentPage (fst b) (fst c)) root
|
||||
@@ -2,11 +2,7 @@ import {root} from 'proto'
|
||||
import { assert, assertValid } from 'bts_assert'
|
||||
|
||||
function default_ws_uri() {
|
||||
if (typeof window == 'undefined') return 'ws://sparkvm:8000/'
|
||||
const loc = window.location
|
||||
if (loc.hostname === "localhost" && loc.port === '8000') {
|
||||
return "ws://sparkvm:8000/"
|
||||
}
|
||||
let ws_uri = "ws:";
|
||||
if (loc.protocol === "https:") {
|
||||
ws_uri = "wss:";
|
||||
@@ -1,69 +1,86 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(OUT)'==''">
|
||||
<PropertyGroup>
|
||||
<API>../../../../build/web/api</API>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<API>$(OUT)/api</API>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(API)/ServiceContext.fs" />
|
||||
<Compile Include="$(API)/DynamicService.fs" />
|
||||
<Compile Include="Imports.fs" />
|
||||
<Compile Include="Util/JSMap.fs" />
|
||||
<Compile Include="Util/StreamUtils.fs" />
|
||||
<Compile Include="Util/EnumUtils.fs" />
|
||||
<Compile Include="$(API)/fable/timestamp.fable.fs" />
|
||||
<Compile Include="$(API)/fable/apicore.fable.fs" />
|
||||
<Compile Include="$(API)/fable/apioptions.fable.fs" />
|
||||
<Compile Include="$(API)/fable/Security.fable.fs" />
|
||||
<Compile Include="$(API)/fable/SparkProtos.fable.fs" />
|
||||
<Compile Include="$(API)/fable/HelloService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/OrderService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/AdminService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/PositionService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/BasePositionService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/MarginService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/co2.fable.fs" />
|
||||
<Compile Include="$(API)/fable/MarketDataRelay.fable.fs" />
|
||||
<!-- Global to the app -->
|
||||
<Compile Include="Lens.fs" />
|
||||
<Compile Include="Global.fs" />
|
||||
<Compile Include="Cmd.fs" />
|
||||
<Compile Include="Controls/nbsp.fs" />
|
||||
<Compile Include="Controls/Button.fs" />
|
||||
<Compile Include="Controls/ReactGrid.fs" />
|
||||
<Compile Include="Controls/DataGrid.fs" />
|
||||
<Compile Include="Controls/Fields.fs" />
|
||||
<Compile Include="Controls/Table.fs" />
|
||||
<Compile Include="Controls/Modal.fs" />
|
||||
<Compile Include="Access.fs" />
|
||||
<!-- Login -->
|
||||
<Compile Include="Login/Login.fs" />
|
||||
<!-- Accounts -->
|
||||
<Compile Include="Accounts/Types.fs" />
|
||||
<Compile Include="Accounts/ClipLimits.fs" />
|
||||
<Compile Include="Accounts/ProductLimits.fs" />
|
||||
<Compile Include="Accounts/SecurityLimits.fs" />
|
||||
<Compile Include="Accounts/State.fs" />
|
||||
<Compile Include="Accounts/View.fs" />
|
||||
<!-- Users -->
|
||||
<Compile Include="Users/Types.fs" />
|
||||
<Compile Include="Users/State.fs" />
|
||||
<Compile Include="Users/View.fs" />
|
||||
<!-- App -->
|
||||
<Compile Include="Types.fs" />
|
||||
<Compile Include="State.fs" />
|
||||
<Compile Include="Nav.fs" />
|
||||
<Compile Include="App.fs" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(SPARK_ADMIN_WEB_APP_OUTPUT_DIR)'==''">
|
||||
<PropertyGroup>
|
||||
<API>../../../build/Spark.Admin.WebApp</API>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<API>$(SPARK_ADMIN_WEB_APP_OUTPUT_DIR)</API>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<!-- Global to the app -->
|
||||
<Compile Include="Lens.fs" />
|
||||
<Compile Include="Cmd.fs" />
|
||||
|
||||
<Compile Include="$(API)/ServiceContext.fs" />
|
||||
<Compile Include="$(API)/DynamicService.fs" />
|
||||
<Compile Include="Imports.fs" />
|
||||
<Compile Include="Util/JSMap.fs" />
|
||||
<Compile Include="Util/StreamUtils.fs" />
|
||||
<Compile Include="Util/EnumUtils.fs" />
|
||||
<Compile Include="$(API)/fable/timestamp.fable.fs" />
|
||||
<Compile Include="$(API)/fable/apicore.fable.fs" />
|
||||
<Compile Include="$(API)/fable/apioptions.fable.fs" />
|
||||
<Compile Include="$(API)/fable/Security.fable.fs" />
|
||||
<Compile Include="$(API)/fable/SparkProtos.fable.fs" />
|
||||
<Compile Include="$(API)/fable/HelloService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/OrderService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/AdminService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/PositionService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/BasePositionService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/MarginService.fable.fs" />
|
||||
<Compile Include="$(API)/fable/co2.fable.fs" />
|
||||
<Compile Include="$(API)/fable/MarketDataRelay.fable.fs" />
|
||||
<!-- Global to the app -->
|
||||
<Compile Include="Global.fs" />
|
||||
<Compile Include="Controls/nbsp.fs" />
|
||||
<Compile Include="Controls/Button.fs" />
|
||||
<Compile Include="Controls/ReactGrid.fs" />
|
||||
<Compile Include="Controls/DataGrid.fs" />
|
||||
<Compile Include="Controls/Fields.fs" />
|
||||
<Compile Include="Controls/Table.fs" />
|
||||
<Compile Include="Controls/Modal.fs" />
|
||||
<Compile Include="Access.fs" />
|
||||
<!-- Login -->
|
||||
<Compile Include="Login/Login.fs" />
|
||||
<!-- Accounts -->
|
||||
<Compile Include="Accounts/Types.fs" />
|
||||
<Compile Include="Accounts/ClipLimits.fs" />
|
||||
<Compile Include="Accounts/ProductLimits.fs" />
|
||||
<Compile Include="Accounts/SecurityLimits.fs" />
|
||||
<Compile Include="Accounts/State.fs" />
|
||||
<Compile Include="Accounts/View.fs" />
|
||||
<!-- Users -->
|
||||
<Compile Include="Users/Types.fs" />
|
||||
<Compile Include="Users/State.fs" />
|
||||
<Compile Include="Users/View.fs" />
|
||||
<!-- App -->
|
||||
<Compile Include="Types.fs" />
|
||||
<Compile Include="State.fs" />
|
||||
<Compile Include="Nav.fs" />
|
||||
<Compile Include="App.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Elmish" Version="4.0.1" />
|
||||
<PackageReference Include="Elmish.Navigation" Version="1.0.0" />
|
||||
<PackageReference Include="Fable.Core" Version="4.0.0-theta-007" />
|
||||
<PackageReference Include="Fable.Elmish" Version="4.0.1" />
|
||||
<PackageReference Include="Fable.Elmish.Browser" Version="4.0.1" />
|
||||
<PackageReference Include="Fable.Elmish.React" Version="4.0.0" />
|
||||
<PackageReference Include="Fable.Elmish.UrlParser" Version="1.0.1" />
|
||||
<PackageReference Include="Fable.Elmish.Debugger" Version="4.0.0" />
|
||||
<PackageReference Include="Fable.Elmish.HMR" Version="7.0.0" />
|
||||
<PackageReference Include="Fable.Promise" Version="3.2.0" />
|
||||
<PackageReference Include="Fable.React" Version="9.2.0" />
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,39 +1,36 @@
|
||||
module App.State
|
||||
|
||||
open Elmish
|
||||
open Elmish.Browser.Navigation
|
||||
open Elmish.Browser.UrlParser
|
||||
open Fable.Import.Browser
|
||||
open Global
|
||||
open Types
|
||||
|
||||
let init () =
|
||||
let model,cmd = Login.init()
|
||||
PreLogin model, Cmd.map LoginMsg cmd
|
||||
|
||||
let updateLoggedIn msg model =
|
||||
match msg, model.page with
|
||||
| UsersMsg msg, UsersModel m ->
|
||||
let (users, usersCmd) = Users.State.update msg m
|
||||
{ model with page = UsersModel users }, Cmd.map UsersMsg usersCmd
|
||||
| AccountsMsg msg, AccountsModel m ->
|
||||
let (acc, msg) = Accounts.State.update msg m
|
||||
{ model with page = AccountsModel acc }, Cmd.map AccountsMsg msg
|
||||
| Navigate (page,pcmd), _ ->
|
||||
{ model with page = page }, pcmd
|
||||
| _ -> model, Cmd.Empty
|
||||
|
||||
let update msg model =
|
||||
match model with
|
||||
| PreLogin p ->
|
||||
match msg with
|
||||
| LoginMsg (Login.LoginSuccess ctx) ->
|
||||
let (lmodel, lmsg) = Users.State.init ctx
|
||||
LoggedIn { context = ctx; page = UsersModel lmodel }, Cmd.map UsersMsg lmsg
|
||||
| LoginMsg m' ->
|
||||
let (lmodel, lmsg) = Login.update m' p
|
||||
PreLogin lmodel, Cmd.map LoginMsg lmsg
|
||||
| _ -> model, Cmd.Empty
|
||||
| LoggedIn m ->
|
||||
let lmodel, lmsg = updateLoggedIn msg m
|
||||
LoggedIn lmodel, lmsg
|
||||
module App.State
|
||||
|
||||
open Elmish
|
||||
open Types
|
||||
|
||||
|
||||
let init () =
|
||||
let model,cmd = Login.init()
|
||||
PreLogin model, Cmd.map LoginMsg cmd
|
||||
|
||||
let updateLoggedIn msg model =
|
||||
match msg, model.page with
|
||||
| UsersMsg msg, UsersModel m ->
|
||||
let (users, usersCmd) = Users.State.update msg m
|
||||
{ model with page = UsersModel users }, Cmd.map UsersMsg usersCmd
|
||||
| AccountsMsg msg, AccountsModel m ->
|
||||
let (acc, msg) = Accounts.State.update msg m
|
||||
{ model with page = AccountsModel acc }, Cmd.map AccountsMsg msg
|
||||
| Navigate (page,pcmd), _ ->
|
||||
{ model with page = page }, pcmd
|
||||
| _ -> model, Cmd.Empty
|
||||
|
||||
let update msg model =
|
||||
match model with
|
||||
| PreLogin p ->
|
||||
match msg with
|
||||
| LoginMsg (Login.LoginSuccess ctx) ->
|
||||
let (lmodel, lmsg) = Users.State.init ctx
|
||||
LoggedIn { context = ctx; page = UsersModel lmodel }, Cmd.map UsersMsg lmsg
|
||||
| LoginMsg m' ->
|
||||
let (lmodel, lmsg) = Login.update m' p
|
||||
PreLogin lmodel, Cmd.map LoginMsg lmsg
|
||||
| _ -> model, Cmd.Empty
|
||||
| LoggedIn m ->
|
||||
let lmodel, lmsg = updateLoggedIn msg m
|
||||
LoggedIn lmodel, lmsg
|
||||
@@ -1,25 +1,24 @@
|
||||
module App.Types
|
||||
|
||||
open Global
|
||||
open ServiceContext
|
||||
open Imports
|
||||
|
||||
type Page =
|
||||
| UsersModel of Users.Types.Model
|
||||
| AccountsModel of Accounts.Types.Model
|
||||
|
||||
type Msg =
|
||||
| UsersMsg of Users.Types.Msg
|
||||
| LoginMsg of Login.Message
|
||||
| Navigate of Page*Elmish.Cmd<Msg>
|
||||
| AccountsMsg of Accounts.Types.Msg
|
||||
|
||||
|
||||
type LoggedInModel = {
|
||||
context : ServiceContext
|
||||
page : Page
|
||||
}
|
||||
|
||||
type Model =
|
||||
| PreLogin of Login.Model
|
||||
| LoggedIn of LoggedInModel
|
||||
module App.Types
|
||||
|
||||
open Global
|
||||
open ServiceContext
|
||||
|
||||
type Page =
|
||||
| UsersModel of Users.Types.Model
|
||||
| AccountsModel of Accounts.Types.Model
|
||||
|
||||
type Msg =
|
||||
| UsersMsg of Users.Types.Msg
|
||||
| LoginMsg of Login.Message
|
||||
| Navigate of Page*Elmish.Cmd<Msg>
|
||||
| AccountsMsg of Accounts.Types.Msg
|
||||
|
||||
|
||||
type LoggedInModel = {
|
||||
context : ServiceContext
|
||||
page : Page
|
||||
}
|
||||
|
||||
type Model =
|
||||
| PreLogin of Login.Model
|
||||
| LoggedIn of LoggedInModel
|
||||
@@ -1,339 +1,338 @@
|
||||
module Users.State
|
||||
|
||||
open Elmish
|
||||
open Types
|
||||
open System
|
||||
open System.Runtime.InteropServices
|
||||
open Fable.Import
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open System.Xml
|
||||
open Fable.PowerPack.PromiseImpl
|
||||
open bts.api.admin
|
||||
open Global
|
||||
|
||||
let SMPInstructionMap:Map<string, string> = Map.empty
|
||||
.Add("O", "Cancel Resting")
|
||||
.Add("N", "Cancel Aggressing")
|
||||
.Add("", "Undefined")
|
||||
|
||||
let isNewUser (user:BTSUser) =
|
||||
user.id = 0u && user.isPresent
|
||||
|
||||
let getAdminData (admin:IAdminService) (token:string) =
|
||||
Cmd.ofPromise
|
||||
admin.get_filtered_admin_data ()
|
||||
UpdateAdminData
|
||||
(fun _ -> RpcResponse "Error getting admin data")
|
||||
|
||||
let defaultScratchUser = {
|
||||
isPresent = true
|
||||
id = 0u
|
||||
parentGroupId = 1u
|
||||
isActive = true
|
||||
canCreate = false
|
||||
name = ""
|
||||
password = ""
|
||||
fullName = ""
|
||||
company = ""
|
||||
licenseData =
|
||||
{
|
||||
createDate = 0L
|
||||
renewDate = 0L
|
||||
expiryDate = 0L
|
||||
}
|
||||
licenseEntitlements =
|
||||
{
|
||||
clientSideApi = false
|
||||
serverSideApi = false
|
||||
spreader = false
|
||||
}
|
||||
userData =
|
||||
{
|
||||
accountPermissions = { accountPermissions = JSMap.empty<UserAccountPermissionUnit> }
|
||||
exchangeUserData =
|
||||
{
|
||||
adminDisplayFlag = bts.api.admin.ExchangeUserData.AdminDisplay.None
|
||||
cmeData = {
|
||||
operatorId = ""
|
||||
smpId = ""
|
||||
miscTags = JSMap.empty<string>
|
||||
smpInstruction = ""
|
||||
location = ""
|
||||
proNonpro = ProfessionalDesignation.PRO
|
||||
displayNondisplay = DisplayDesignation.DISPLAY
|
||||
mdPermissions = [||]
|
||||
}
|
||||
simData = {
|
||||
operatorId = ""
|
||||
location = ""
|
||||
}
|
||||
iceData = {
|
||||
companyId = 0
|
||||
operatorId = ""
|
||||
authorizedTrader = ""
|
||||
authorizedGroup = ""
|
||||
password = ""
|
||||
custOrderHandingInst = ""
|
||||
mifidDirectElectronicAccess = -1
|
||||
mifidTradingCapacity = -1
|
||||
mifidLiquidityProvision = -1
|
||||
mifidCommodityDerivIndicator = -1
|
||||
mifidInvestmentDecision = -1L
|
||||
mifidExecutionDecision = -1L
|
||||
mifidClientIdCode = -1L
|
||||
mifidId = -1L
|
||||
miscTags = JSMap.empty<string>
|
||||
proNonpro = ProfessionalDesignation.PRO
|
||||
displayNondisplay = DisplayDesignation.DISPLAY
|
||||
mdPermissions = [||]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let init (context:ServiceContext.ServiceContext) : Model * Cmd<Msg> =
|
||||
//let user = UserService.Create context ""
|
||||
let admin = AdminService.Create context ""
|
||||
{
|
||||
userList = []
|
||||
accountsList = []
|
||||
scratchUser = defaultScratchUser
|
||||
PreviousScratchUser = defaultScratchUser
|
||||
currentTab = Tab.General
|
||||
admin = admin
|
||||
adminData = None
|
||||
OptionsMenuOpen = ""
|
||||
ConfirmModal = "", (Msg.SwitchTab Tab.General)
|
||||
token = context.token
|
||||
can_create = context.can_create
|
||||
this_username = context.username
|
||||
}, getAdminData admin context.token
|
||||
|
||||
let rec removeUser (user:BTSUser) (userList:BTSUser list) =
|
||||
match userList with
|
||||
| hd::tl when (fun (usr:BTSUser) -> usr.id = user.id) hd -> tl
|
||||
| hd::tl -> hd::removeUser user tl
|
||||
| _ -> []
|
||||
|
||||
let getFirstUser usrlst =
|
||||
let head = (List.sortBy (fun (u:BTSUser) -> u.name.ToLower()) usrlst) |> List.tryHead
|
||||
match head with
|
||||
| None -> defaultScratchUser
|
||||
| Some hd -> hd
|
||||
|
||||
let findUserInList (user:BTSUser) (userList:BTSUser list) =
|
||||
List.tryFind (fun (x:BTSUser) ->
|
||||
x.id = user.id
|
||||
|| (user.id = 0u && x.name = user.name)
|
||||
)
|
||||
userList
|
||||
|
||||
let getCurrentOrFirstUser (model:Model) (userList:BTSUser list) =
|
||||
match (findUserInList model.scratchUser userList), (findUserInList model.PreviousScratchUser userList) with
|
||||
| Some cu, _ -> cu
|
||||
| None, Some pu -> pu
|
||||
| None, None -> getFirstUser userList
|
||||
|
||||
let getCurrentUser (model:Model) = getCurrentOrFirstUser model model.userList
|
||||
|
||||
let currentUserIsDefault model = ((getCurrentUser model).id = 0u)
|
||||
|
||||
|
||||
let userIsdirty (initialState:BTSUser) (scratch:BTSUser) (existing:BTSUser) = (scratch <> existing) && (scratch <> initialState)
|
||||
|
||||
let userIsSelected (initialState:BTSUser) (scratch:BTSUser) = scratch <> initialState
|
||||
|
||||
let saveUser (admin:IAdminService) (user:BTSUser) (model:Model) = promise {
|
||||
let! result = admin.update_user { completeData = user }
|
||||
if (result.isSuccess) then
|
||||
let! data = admin.get_filtered_admin_data ()
|
||||
return UpdateAdminData data
|
||||
else
|
||||
return ErrorOccured (sprintf "Error saving user: %s" result.errorText)
|
||||
}
|
||||
|
||||
let deleteUser (admin:IAdminService) (user:BTSUser) (model:Model) = promise {
|
||||
let! result = admin.delete_user { id = user.id }
|
||||
if (result.isSuccess) then
|
||||
let! data = admin.get_filtered_admin_data ()
|
||||
return UpdateAdminData data
|
||||
else
|
||||
return ErrorOccured (sprintf "Error deleting user: %s" result.errorText)
|
||||
}
|
||||
|
||||
let createUser (admin:IAdminService) (user:BTSUser) (model:Model)= promise {
|
||||
let args : UserCreateAPIArgument = {
|
||||
parentGroupId = user.parentGroupId
|
||||
name = user.name
|
||||
password = user.password
|
||||
fullName = user.fullName
|
||||
company = user.company
|
||||
licenseData = user.licenseData
|
||||
licenseEntitlements = user.licenseEntitlements
|
||||
}
|
||||
let! result = admin.create_user args
|
||||
if result.isSuccess then
|
||||
return! saveUser admin { user with id = result.newId } model
|
||||
else
|
||||
return ErrorOccured (sprintf "Error creating user: %s" result.errorText)
|
||||
}
|
||||
|
||||
//let updateExchangeMdEntitlementDataCMEData user dta :BTSUser = { user with userData = { user.userData with exchangeMdEntitlementData = { user.userData.exchangeMdEntitlementData with cmeData = dta}}}
|
||||
let updateCMEExchangeUserData (user:BTSUser) dta = { user with userData = { user.userData with exchangeUserData = { user.userData.exchangeUserData with cmeData = dta }}}
|
||||
let updateSIMExchangeUserData (user:BTSUser) dta = { user with userData = { user.userData with exchangeUserData = { user.userData.exchangeUserData with simData = dta }}}
|
||||
let updateICEExchangeUserData (user:BTSUser) dta = { user with userData = { user.userData with exchangeUserData = { user.userData.exchangeUserData with iceData = dta }}}
|
||||
|
||||
let default_user_account = {
|
||||
tradingPermission =
|
||||
{ hasPermissions = false
|
||||
}
|
||||
adminPermission =
|
||||
{ hasPermissions = false
|
||||
hasMdPermissions = false }
|
||||
}
|
||||
|
||||
|
||||
let applyUpdate (field:UserField) (user:BTSUser) =
|
||||
match field with
|
||||
| Name n -> { user with name = n }
|
||||
| Password p -> { user with password = p }
|
||||
| FullName fn -> { user with fullName = fn }
|
||||
| Company cc -> { user with company = cc }
|
||||
| IsActive ia -> { user with isActive = ia }
|
||||
| CanCreate cr -> { user with canCreate = cr }
|
||||
| CMEOperatorID oid -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with operatorId = oid }
|
||||
|
||||
| ICECompanyID oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with companyId = oid }
|
||||
| ICEOperatorID oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with operatorId = oid }
|
||||
| ICEAuthorizedTrader oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with authorizedTrader = oid }
|
||||
| ICEAuthorizedGroup oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with authorizedGroup = oid }
|
||||
| ICEPassword oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with password = oid }
|
||||
| ICECustOrderHandingInst oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with custOrderHandingInst = oid }
|
||||
|
||||
| MifidClientIdCode value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidClientIdCode = value }
|
||||
| MifidCommodityDerivIndicator value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidCommodityDerivIndicator = value }
|
||||
| MifidDirectElectronicAccess value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidDirectElectronicAccess = value }
|
||||
| MifidExecutionDecision value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidExecutionDecision = value }
|
||||
| MifidId value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidId = value }
|
||||
| MifidInvestmentDecision value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidInvestmentDecision = value }
|
||||
| MifidLiquidityProvision value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidLiquidityProvision = value }
|
||||
| MifidTradingCapacity value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidTradingCapacity = value }
|
||||
|
||||
| SimOperatorID oid -> updateSIMExchangeUserData user { user.userData.exchangeUserData.simData with operatorId = oid }
|
||||
| SMPID smpid -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with smpId = smpid }
|
||||
| CMELocation loc -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with location = loc }
|
||||
| CMEProNonPro loc -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with proNonpro = loc }
|
||||
| CMEDisplayNonDisplay loc -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with displayNondisplay = loc }
|
||||
| ICEProNonPro loc -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with proNonpro = loc }
|
||||
| ICEDisplayNonDisplay loc -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with displayNondisplay = loc }
|
||||
| SimLocation loc -> updateSIMExchangeUserData user { user.userData.exchangeUserData.simData with location = loc }
|
||||
| SMPInstruction smpi -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with smpInstruction = smpi }
|
||||
| MiscTags map -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with miscTags = map }
|
||||
| CMEMic mic ->
|
||||
let micArr =
|
||||
let mdperm = user.userData.exchangeUserData.cmeData.mdPermissions
|
||||
let found = Array.tryFind (fun (elm:CMEMicData) -> elm.mic = mic.mic) mdperm
|
||||
match found with
|
||||
| Some elm ->
|
||||
let ndx = Array.findIndex (fun (e:CMEMicData) -> e.mic = elm.mic) mdperm
|
||||
Array.set mdperm ndx mic
|
||||
mdperm
|
||||
| None -> Array.concat [[|mic|]; mdperm]
|
||||
updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with mdPermissions = micArr }
|
||||
| ICEMic (mic:ICEMicData) ->
|
||||
let micArr =
|
||||
let mdperm = user.userData.exchangeUserData.iceData.mdPermissions
|
||||
let found = Array.tryFind (fun (elm:ICEMicData) -> elm.mic = mic.mic) mdperm
|
||||
match found with
|
||||
| Some elm ->
|
||||
let ndx = Array.findIndex (fun (e:ICEMicData) -> e.mic = elm.mic) mdperm
|
||||
Array.set mdperm ndx mic
|
||||
mdperm
|
||||
| None -> Array.concat [[|mic|]; mdperm]
|
||||
updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mdPermissions = micArr }
|
||||
| TradingPerm (id:string, can_trade:bool) ->
|
||||
let find = JSMap.tryFind id user.userData.accountPermissions.accountPermissions
|
||||
let current = if find.IsNone then default_user_account else find.Value
|
||||
let updated = { current with tradingPermission = { current.tradingPermission with hasPermissions = can_trade } }
|
||||
let newAccountPermissions = JSMap.add id updated user.userData.accountPermissions.accountPermissions
|
||||
let newUserData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newAccountPermissions } }
|
||||
{ user with userData = newUserData }
|
||||
| RiskAdmin (id, admin) ->
|
||||
let find = JSMap.tryFind id user.userData.accountPermissions.accountPermissions
|
||||
let current = if find.IsNone then default_user_account else find.Value
|
||||
let updated = { current with adminPermission = { current.adminPermission with hasPermissions = admin } }
|
||||
let newAccountPermissions = JSMap.add id updated user.userData.accountPermissions.accountPermissions
|
||||
let newUserData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newAccountPermissions } }
|
||||
{ user with userData = newUserData }
|
||||
| MDAdmin (id, admin) ->
|
||||
let find = JSMap.tryFind id user.userData.accountPermissions.accountPermissions
|
||||
let current = if find.IsNone then default_user_account else find.Value
|
||||
let updated = { current with adminPermission = { current.adminPermission with hasMdPermissions = admin } }
|
||||
let newAccountPermissions = JSMap.add id updated user.userData.accountPermissions.accountPermissions
|
||||
let newUserData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newAccountPermissions } }
|
||||
{ user with userData = newUserData }
|
||||
|
||||
| RemoveAccount id ->
|
||||
let newObj = JSMap.remove id user.userData.accountPermissions.accountPermissions
|
||||
{ user with userData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newObj }}}
|
||||
|
||||
let update msg (model:Users.Types.Model) : Model * Cmd<Msg> =
|
||||
match msg with
|
||||
| UpdateAdminData adm ->
|
||||
let usrlst = Seq.toList (Seq.filter (fun (usr:BTSUser) -> usr.isPresent) adm.users)
|
||||
|
||||
{model with
|
||||
adminData = Some adm
|
||||
userList = usrlst
|
||||
accountsList = (Seq.toList adm.accounts)
|
||||
scratchUser = (getCurrentOrFirstUser model usrlst)
|
||||
}, Cmd.Empty
|
||||
| RpcResponse str ->
|
||||
printf "%s" str
|
||||
model, Cmd.Empty
|
||||
| UpdateField field ->
|
||||
{ model with scratchUser = applyUpdate field model.scratchUser; ConfirmModal = ("", Msg.SwitchTab model.currentTab) } , Cmd.Empty
|
||||
| CloneUser ->
|
||||
{ model with PreviousScratchUser = model.scratchUser; scratchUser = { model.scratchUser with id = 0u; name = sprintf "%s_clone" model.scratchUser.name }; OptionsMenuOpen = ""}, Cmd.ofMsg (SwitchTab General)
|
||||
| CopyFrom (usrSrc, usrDest) ->
|
||||
let nusr = { usrSrc with
|
||||
id = usrDest.id
|
||||
name = usrDest.name
|
||||
password = usrDest.password
|
||||
fullName = usrDest.fullName
|
||||
company = usrDest.company
|
||||
isActive = usrDest.isActive
|
||||
}
|
||||
{ model with scratchUser = nusr }, Cmd.Empty
|
||||
|
||||
| Delete usr ->
|
||||
let mdl = { model with OptionsMenuOpen = "" }
|
||||
match Fable.Import.Browser.window.confirm (sprintf "Are you sure you want to delete '%s'" usr.name) with
|
||||
| true -> mdl, Cmd.ofExistingPromise (deleteUser model.admin usr model) id (box>>ErrorOccured)
|
||||
| false -> mdl, Cmd.Empty
|
||||
|
||||
| AddUser ->
|
||||
match model.can_create with
|
||||
| true -> { model with PreviousScratchUser = model.scratchUser; scratchUser = { defaultScratchUser with name = "New User" }}, Cmd.ofMsg (SwitchTab General)
|
||||
| false -> model, Cmd.Empty
|
||||
| CancelAddUser ->
|
||||
{ model with scratchUser = { model.PreviousScratchUser with name = "New User" }}, Cmd.ofMsg (SwitchTab General)
|
||||
| SwitchTab tb ->
|
||||
{model with currentTab = tb}, Cmd.Empty
|
||||
|
||||
| SwitchUser usr ->
|
||||
{ model with PreviousScratchUser = model.scratchUser; scratchUser = usr }, Cmd.Empty
|
||||
| SaveUser ->
|
||||
// match on id = 0 to see if it's a new user
|
||||
match model.scratchUser.id with
|
||||
| 0u -> { model with PreviousScratchUser = model.scratchUser}, Cmd.ofExistingPromise (createUser model.admin {model.scratchUser with name = model.scratchUser.name.ToLower() } model) id (box>>ErrorOccured)
|
||||
| _ -> model, Cmd.ofExistingPromise (saveUser model.admin {model.scratchUser with name = model.scratchUser.name.ToLower() } model) id (box>>ErrorOccured)
|
||||
| ErrorOccured msg ->
|
||||
//Browser.console.log msg
|
||||
Global.alert Global.Error (string msg)
|
||||
model,Cmd.Empty
|
||||
| OpenOptionsMenu usrName ->
|
||||
{ model with OptionsMenuOpen = usrName }, Cmd.Empty
|
||||
| OpenConfirmModal (title, okMessage) ->
|
||||
{model with ConfirmModal = title, okMessage}, Cmd.Empty
|
||||
module Users.State
|
||||
|
||||
open Elmish
|
||||
open Types
|
||||
open System
|
||||
open System.Runtime.InteropServices
|
||||
open Fable.Core
|
||||
open Fable.Core.JsInterop
|
||||
open bts.api.admin
|
||||
open Global
|
||||
|
||||
let SMPInstructionMap:Map<string, string> = Map.empty
|
||||
.Add("O", "Cancel Resting")
|
||||
.Add("N", "Cancel Aggressing")
|
||||
.Add("", "Undefined")
|
||||
|
||||
let isNewUser (user:BTSUser) =
|
||||
user.id = 0u && user.isPresent
|
||||
|
||||
let getAdminData (admin:IAdminService) (token:string) =
|
||||
Cmd.OfPromise.either
|
||||
admin.get_filtered_admin_data
|
||||
()
|
||||
UpdateAdminData
|
||||
(fun e -> RpcResponse("Error getting admin data: " + e.Message))
|
||||
|
||||
let defaultScratchUser = {
|
||||
isPresent = true
|
||||
id = 0u
|
||||
parentGroupId = 1u
|
||||
isActive = true
|
||||
canCreate = false
|
||||
name = ""
|
||||
password = ""
|
||||
fullName = ""
|
||||
company = ""
|
||||
licenseData =
|
||||
{
|
||||
createDate = 0L
|
||||
renewDate = 0L
|
||||
expiryDate = 0L
|
||||
}
|
||||
licenseEntitlements =
|
||||
{
|
||||
clientSideApi = false
|
||||
serverSideApi = false
|
||||
spreader = false
|
||||
}
|
||||
userData =
|
||||
{
|
||||
accountPermissions = { accountPermissions = JSMap.empty<UserAccountPermissionUnit> }
|
||||
exchangeUserData =
|
||||
{
|
||||
adminDisplayFlag = bts.api.admin.ExchangeUserData.AdminDisplay.None
|
||||
cmeData = {
|
||||
operatorId = ""
|
||||
smpId = ""
|
||||
miscTags = JSMap.empty<string>
|
||||
smpInstruction = ""
|
||||
location = ""
|
||||
proNonpro = ProfessionalDesignation.PRO
|
||||
displayNondisplay = DisplayDesignation.DISPLAY
|
||||
mdPermissions = [||]
|
||||
}
|
||||
simData = {
|
||||
operatorId = ""
|
||||
location = ""
|
||||
}
|
||||
iceData = {
|
||||
companyId = 0
|
||||
operatorId = ""
|
||||
authorizedTrader = ""
|
||||
authorizedGroup = ""
|
||||
password = ""
|
||||
custOrderHandingInst = ""
|
||||
mifidDirectElectronicAccess = -1
|
||||
mifidTradingCapacity = -1
|
||||
mifidLiquidityProvision = -1
|
||||
mifidCommodityDerivIndicator = -1
|
||||
mifidInvestmentDecision = -1L
|
||||
mifidExecutionDecision = -1L
|
||||
mifidClientIdCode = -1L
|
||||
mifidId = -1L
|
||||
miscTags = JSMap.empty<string>
|
||||
proNonpro = ProfessionalDesignation.PRO
|
||||
displayNondisplay = DisplayDesignation.DISPLAY
|
||||
mdPermissions = [||]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let init (context:ServiceContext.ServiceContext) : Model * Cmd<Msg> =
|
||||
//let user = UserService.Create context ""
|
||||
let admin = AdminService.Create context ""
|
||||
{
|
||||
userList = []
|
||||
accountsList = []
|
||||
scratchUser = defaultScratchUser
|
||||
PreviousScratchUser = defaultScratchUser
|
||||
currentTab = Tab.General
|
||||
admin = admin
|
||||
adminData = None
|
||||
OptionsMenuOpen = ""
|
||||
ConfirmModal = "", (Msg.SwitchTab Tab.General)
|
||||
token = context.token
|
||||
can_create = context.can_create
|
||||
this_username = context.username
|
||||
}, getAdminData admin context.token
|
||||
|
||||
let rec removeUser (user:BTSUser) (userList:BTSUser list) =
|
||||
match userList with
|
||||
| hd::tl when (fun (usr:BTSUser) -> usr.id = user.id) hd -> tl
|
||||
| hd::tl -> hd::removeUser user tl
|
||||
| _ -> []
|
||||
|
||||
let getFirstUser usrlst =
|
||||
let head = (List.sortBy (fun (u:BTSUser) -> u.name.ToLower()) usrlst) |> List.tryHead
|
||||
match head with
|
||||
| None -> defaultScratchUser
|
||||
| Some hd -> hd
|
||||
|
||||
let findUserInList (user:BTSUser) (userList:BTSUser list) =
|
||||
List.tryFind (fun (x:BTSUser) ->
|
||||
x.id = user.id
|
||||
|| (user.id = 0u && x.name = user.name)
|
||||
)
|
||||
userList
|
||||
|
||||
let getCurrentOrFirstUser (model:Model) (userList:BTSUser list) =
|
||||
match (findUserInList model.scratchUser userList), (findUserInList model.PreviousScratchUser userList) with
|
||||
| Some cu, _ -> cu
|
||||
| None, Some pu -> pu
|
||||
| None, None -> getFirstUser userList
|
||||
|
||||
let getCurrentUser (model:Model) = getCurrentOrFirstUser model model.userList
|
||||
|
||||
let currentUserIsDefault model = ((getCurrentUser model).id = 0u)
|
||||
|
||||
|
||||
let userIsdirty (initialState:BTSUser) (scratch:BTSUser) (existing:BTSUser) = (scratch <> existing) && (scratch <> initialState)
|
||||
|
||||
let userIsSelected (initialState:BTSUser) (scratch:BTSUser) = scratch <> initialState
|
||||
|
||||
let saveUser (admin:IAdminService) (user:BTSUser) (model:Model) = promise {
|
||||
let! result = admin.update_user { completeData = user }
|
||||
if (result.isSuccess) then
|
||||
let! data = admin.get_filtered_admin_data ()
|
||||
return UpdateAdminData data
|
||||
else
|
||||
return ErrorOccured (sprintf "Error saving user: %s" result.errorText)
|
||||
}
|
||||
|
||||
let deleteUser (admin:IAdminService) (user:BTSUser) (model:Model) = promise {
|
||||
let! result = admin.delete_user { id = user.id }
|
||||
if (result.isSuccess) then
|
||||
let! data = admin.get_filtered_admin_data ()
|
||||
return UpdateAdminData data
|
||||
else
|
||||
return ErrorOccured (sprintf "Error deleting user: %s" result.errorText)
|
||||
}
|
||||
|
||||
let createUser (admin:IAdminService) (user:BTSUser) (model:Model)= promise {
|
||||
let args : UserCreateAPIArgument = {
|
||||
parentGroupId = user.parentGroupId
|
||||
name = user.name
|
||||
password = user.password
|
||||
fullName = user.fullName
|
||||
company = user.company
|
||||
licenseData = user.licenseData
|
||||
licenseEntitlements = user.licenseEntitlements
|
||||
}
|
||||
let! result = admin.create_user args
|
||||
if result.isSuccess then
|
||||
return! saveUser admin { user with id = result.newId } model
|
||||
else
|
||||
return ErrorOccured (sprintf "Error creating user: %s" result.errorText)
|
||||
}
|
||||
|
||||
//let updateExchangeMdEntitlementDataCMEData user dta :BTSUser = { user with userData = { user.userData with exchangeMdEntitlementData = { user.userData.exchangeMdEntitlementData with cmeData = dta}}}
|
||||
let updateCMEExchangeUserData (user:BTSUser) dta = { user with userData = { user.userData with exchangeUserData = { user.userData.exchangeUserData with cmeData = dta }}}
|
||||
let updateSIMExchangeUserData (user:BTSUser) dta = { user with userData = { user.userData with exchangeUserData = { user.userData.exchangeUserData with simData = dta }}}
|
||||
let updateICEExchangeUserData (user:BTSUser) dta = { user with userData = { user.userData with exchangeUserData = { user.userData.exchangeUserData with iceData = dta }}}
|
||||
|
||||
let default_user_account = {
|
||||
tradingPermission =
|
||||
{ hasPermissions = false
|
||||
}
|
||||
adminPermission =
|
||||
{ hasPermissions = false
|
||||
hasMdPermissions = false }
|
||||
}
|
||||
|
||||
|
||||
let applyUpdate (field:UserField) (user:BTSUser) =
|
||||
match field with
|
||||
| Name n -> { user with name = n }
|
||||
| Password p -> { user with password = p }
|
||||
| FullName fn -> { user with fullName = fn }
|
||||
| Company cc -> { user with company = cc }
|
||||
| IsActive ia -> { user with isActive = ia }
|
||||
| CanCreate cr -> { user with canCreate = cr }
|
||||
| CMEOperatorID oid -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with operatorId = oid }
|
||||
| CMEATSOperatorID _ -> user
|
||||
| MaxOrderRatePerConnection _-> user
|
||||
|
||||
| ICECompanyID oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with companyId = oid }
|
||||
| ICEOperatorID oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with operatorId = oid }
|
||||
| ICEAuthorizedTrader oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with authorizedTrader = oid }
|
||||
| ICEAuthorizedGroup oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with authorizedGroup = oid }
|
||||
| ICEPassword oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with password = oid }
|
||||
| ICECustOrderHandingInst oid -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with custOrderHandingInst = oid }
|
||||
|
||||
| MifidClientIdCode value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidClientIdCode = value }
|
||||
| MifidCommodityDerivIndicator value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidCommodityDerivIndicator = value }
|
||||
| MifidDirectElectronicAccess value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidDirectElectronicAccess = value }
|
||||
| MifidExecutionDecision value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidExecutionDecision = value }
|
||||
| MifidId value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidId = value }
|
||||
| MifidInvestmentDecision value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidInvestmentDecision = value }
|
||||
| MifidLiquidityProvision value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidLiquidityProvision = value }
|
||||
| MifidTradingCapacity value -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mifidTradingCapacity = value }
|
||||
|
||||
| SimOperatorID oid -> updateSIMExchangeUserData user { user.userData.exchangeUserData.simData with operatorId = oid }
|
||||
| SMPID smpid -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with smpId = smpid }
|
||||
| CMELocation loc -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with location = loc }
|
||||
| CMEProNonPro loc -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with proNonpro = loc }
|
||||
| CMEDisplayNonDisplay loc -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with displayNondisplay = loc }
|
||||
| ICEProNonPro loc -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with proNonpro = loc }
|
||||
| ICEDisplayNonDisplay loc -> updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with displayNondisplay = loc }
|
||||
| SimLocation loc -> updateSIMExchangeUserData user { user.userData.exchangeUserData.simData with location = loc }
|
||||
| SMPInstruction smpi -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with smpInstruction = smpi }
|
||||
| MiscTags map -> updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with miscTags = map }
|
||||
| CMEMic mic ->
|
||||
let micArr =
|
||||
let mdperm = user.userData.exchangeUserData.cmeData.mdPermissions
|
||||
let found = Array.tryFind (fun (elm:CMEMicData) -> elm.mic = mic.mic) mdperm
|
||||
match found with
|
||||
| Some elm ->
|
||||
let ndx = Array.findIndex (fun (e:CMEMicData) -> e.mic = elm.mic) mdperm
|
||||
Array.set mdperm ndx mic
|
||||
mdperm
|
||||
| None -> Array.concat [[|mic|]; mdperm]
|
||||
updateCMEExchangeUserData user { user.userData.exchangeUserData.cmeData with mdPermissions = micArr }
|
||||
| ICEMic (mic:ICEMicData) ->
|
||||
let micArr =
|
||||
let mdperm = user.userData.exchangeUserData.iceData.mdPermissions
|
||||
let found = Array.tryFind (fun (elm:ICEMicData) -> elm.mic = mic.mic) mdperm
|
||||
match found with
|
||||
| Some elm ->
|
||||
let ndx = Array.findIndex (fun (e:ICEMicData) -> e.mic = elm.mic) mdperm
|
||||
Array.set mdperm ndx mic
|
||||
mdperm
|
||||
| None -> Array.concat [[|mic|]; mdperm]
|
||||
updateICEExchangeUserData user { user.userData.exchangeUserData.iceData with mdPermissions = micArr }
|
||||
| TradingPerm (id:string, can_trade:bool) ->
|
||||
let find = JSMap.tryFind id user.userData.accountPermissions.accountPermissions
|
||||
let current = if find.IsNone then default_user_account else find.Value
|
||||
let updated = { current with tradingPermission = { current.tradingPermission with hasPermissions = can_trade } }
|
||||
let newAccountPermissions = JSMap.add id updated user.userData.accountPermissions.accountPermissions
|
||||
let newUserData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newAccountPermissions } }
|
||||
{ user with userData = newUserData }
|
||||
| RiskAdmin (id, admin) ->
|
||||
let find = JSMap.tryFind id user.userData.accountPermissions.accountPermissions
|
||||
let current = if find.IsNone then default_user_account else find.Value
|
||||
let updated = { current with adminPermission = { current.adminPermission with hasPermissions = admin } }
|
||||
let newAccountPermissions = JSMap.add id updated user.userData.accountPermissions.accountPermissions
|
||||
let newUserData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newAccountPermissions } }
|
||||
{ user with userData = newUserData }
|
||||
| MDAdmin (id, admin) ->
|
||||
let find = JSMap.tryFind id user.userData.accountPermissions.accountPermissions
|
||||
let current = if find.IsNone then default_user_account else find.Value
|
||||
let updated = { current with adminPermission = { current.adminPermission with hasMdPermissions = admin } }
|
||||
let newAccountPermissions = JSMap.add id updated user.userData.accountPermissions.accountPermissions
|
||||
let newUserData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newAccountPermissions } }
|
||||
{ user with userData = newUserData }
|
||||
|
||||
| RemoveAccount id ->
|
||||
let newObj = JSMap.remove id user.userData.accountPermissions.accountPermissions
|
||||
{ user with userData = { user.userData with accountPermissions = { user.userData.accountPermissions with accountPermissions = newObj }}}
|
||||
|
||||
let update msg (model:Users.Types.Model) : Model * Cmd<Msg> =
|
||||
match msg with
|
||||
| UpdateAdminData adm ->
|
||||
let usrlst = Seq.toList (Seq.filter (fun (usr:BTSUser) -> usr.isPresent) adm.users)
|
||||
|
||||
{model with
|
||||
adminData = Some adm
|
||||
userList = usrlst
|
||||
accountsList = (Seq.toList adm.accounts)
|
||||
scratchUser = (getCurrentOrFirstUser model usrlst)
|
||||
}, Cmd.Empty
|
||||
| RpcResponse str ->
|
||||
printf "%s" str
|
||||
model, Cmd.Empty
|
||||
| UpdateField field ->
|
||||
{ model with scratchUser = applyUpdate field model.scratchUser; ConfirmModal = ("", Msg.SwitchTab model.currentTab) } , Cmd.Empty
|
||||
| CloneUser ->
|
||||
{ model with PreviousScratchUser = model.scratchUser; scratchUser = { model.scratchUser with id = 0u; name = sprintf "%s_clone" model.scratchUser.name }; OptionsMenuOpen = ""}, Cmd.ofMsg (SwitchTab General)
|
||||
| CopyFrom (usrSrc, usrDest) ->
|
||||
let nusr = { usrSrc with
|
||||
id = usrDest.id
|
||||
name = usrDest.name
|
||||
password = usrDest.password
|
||||
fullName = usrDest.fullName
|
||||
company = usrDest.company
|
||||
isActive = usrDest.isActive
|
||||
}
|
||||
{ model with scratchUser = nusr }, Cmd.Empty
|
||||
|
||||
| Delete usr ->
|
||||
let mdl = { model with OptionsMenuOpen = "" }
|
||||
match Browser.Dom.window.confirm (sprintf "Are you sure you want to delete '%s'" usr.name) with
|
||||
| true -> mdl, Cmd.ofExistingPromise (deleteUser model.admin usr model) id (box>>ErrorOccured)
|
||||
| false -> mdl, Cmd.Empty
|
||||
|
||||
| AddUser ->
|
||||
match model.can_create with
|
||||
| true -> { model with PreviousScratchUser = model.scratchUser; scratchUser = { defaultScratchUser with name = "New User" }}, Cmd.ofMsg (SwitchTab General)
|
||||
| false -> model, Cmd.Empty
|
||||
| CancelAddUser ->
|
||||
{ model with scratchUser = { model.PreviousScratchUser with name = "New User" }}, Cmd.ofMsg (SwitchTab General)
|
||||
| SwitchTab tb ->
|
||||
{model with currentTab = tb}, Cmd.Empty
|
||||
|
||||
| SwitchUser usr ->
|
||||
{ model with PreviousScratchUser = model.scratchUser; scratchUser = usr }, Cmd.Empty
|
||||
| SaveUser ->
|
||||
// match on id = 0 to see if it's a new user
|
||||
match model.scratchUser.id with
|
||||
| 0u -> { model with PreviousScratchUser = model.scratchUser}, Cmd.ofExistingPromise (createUser model.admin {model.scratchUser with name = model.scratchUser.name.ToLower() } model) id (box>>ErrorOccured)
|
||||
| _ -> model, Cmd.ofExistingPromise (saveUser model.admin {model.scratchUser with name = model.scratchUser.name.ToLower() } model) id (box>>ErrorOccured)
|
||||
| ErrorOccured msg ->
|
||||
Global.alert Global.Error (string msg)
|
||||
model,Cmd.Empty
|
||||
| OpenOptionsMenu usrName ->
|
||||
{ model with OptionsMenuOpen = usrName }, Cmd.Empty
|
||||
| OpenConfirmModal (title, okMessage) ->
|
||||
{model with ConfirmModal = title, okMessage}, Cmd.Empty
|
||||
File renamed without changes.
File diff suppressed because it is too large.
Load diff
File renamed without changes.
@@ -16,6 +16,15 @@ module private Interop =
|
||||
Array.zip (keys o) (values<'a> o)
|
||||
let spread<'a> (a:'a) (b:obj) : 'a = Imports.DynamicService.merge (a,b)
|
||||
|
||||
// type Boo =
|
||||
// val cheese : string;
|
||||
// val maybe_cheese : option<string>;
|
||||
|
||||
// type BlahUnion =
|
||||
// | BlahVal of string
|
||||
|
||||
// let ofBlah (valstr: string): BlahUnion =
|
||||
// valstr |> BlahVal
|
||||
|
||||
type Key = string
|
||||
[<Erase>]
|
||||
@@ -24,17 +33,32 @@ type JSMap<'a> = | JSMap of obj
|
||||
let ofArray<'a> (a:(Key*'a)[]) : JSMap<'a> =
|
||||
Seq.map (fun (k,v) -> k, box v) a |> createObj |> JSMap
|
||||
|
||||
let toArray<'a> (m:JSMap<'a>) : (Key*'a)[] =
|
||||
let toArray<'a> (m:JSMap<'a>) : (Key*'a)[] =
|
||||
match m with | JSMap j -> Interop.pairs<'a> j
|
||||
|
||||
let ofList<'a> (l: (Key*'a) list) = List.toArray l |> ofArray
|
||||
let toList m = m |> toArray |> List.ofArray
|
||||
let toMap m = m |> toArray |> Map.ofArray
|
||||
|
||||
let add<'a> (k:Key) (v:'a) (map:JSMap<'a>) =
|
||||
let toFSMap<'a>(m: JSMap<'a>) : Map<Key, 'a> =
|
||||
m |> toMap |> Map.map(fun _ v -> unbox<'a>(v))
|
||||
|
||||
// [<Erase>]
|
||||
type JSorFSMap<'a> =
|
||||
| SparkJSMapCase of JSMap<'a>
|
||||
| FSMapCase of Map<Key, 'a>
|
||||
|
||||
let toJSMap<'a>(m: JSorFSMap<'a>) : JS.Map<Key, 'a> =
|
||||
match m with
|
||||
| SparkJSMapCase m -> Fable.Core.JS.Constructors.Map.Create(
|
||||
seq { for j in m |> toFSMap do yield j.Key, j.Value })
|
||||
| FSMapCase m -> Fable.Core.JS.Constructors.Map.Create(
|
||||
seq { for j in m do yield j.Key, j.Value })
|
||||
|
||||
let add<'a> (k:Key) (v:'a) (map:JSMap<'a>) =
|
||||
Interop.spread map (createObj [k ==> v])
|
||||
|
||||
|
||||
|
||||
let empty<'a> : JSMap<'a> = JSMap <| createObj []
|
||||
|
||||
let isEmpty (map:JSMap<'a>) = (Interop.keys map).Length > 0
|
||||
@@ -44,7 +68,7 @@ let concat (maps : JSMap<'a> seq) =
|
||||
maps |> Seq.fold Interop.spread empty |> unbox |> JSMap
|
||||
|
||||
|
||||
let exists<'a> pred map =
|
||||
let exists<'a> pred map =
|
||||
let pairs = Interop.pairs<'a> map
|
||||
Array.exists pred pairs
|
||||
|
||||
@@ -65,8 +89,8 @@ let remove<'a> key (map:JSMap<'a>) =
|
||||
match map with
|
||||
| JSMap m ->
|
||||
Interop.pairs m
|
||||
|> Array.where (fun (k,_) ->
|
||||
printf "%s / %s" k key
|
||||
|> Array.where (fun (k,_) ->
|
||||
printf "%s / %s" k key
|
||||
k <> key)
|
||||
|> ofArray<'a>
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"declarationMap": true,
|
||||
"removeComments": false
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"allowJs": false,
|
||||
"alwaysStrict": true,
|
||||
"sourceMap": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": false,
|
||||
@@ -21,7 +20,6 @@
|
||||
"baseUrl": "src"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"__tests__/**/*"
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"sourceMap": false,
|
||||
"declarationMap": false,
|
||||
"removeComments": true
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,12 @@
|
||||
var path = require("path");
|
||||
var webpack = require("webpack");
|
||||
var fableUtils = require("fable-utils");
|
||||
var mod = require("@babel/preset-env")
|
||||
// var UglifyJsPlugin = require("uglifyjs-webpack-plugin")
|
||||
|
||||
function resolve(filePath) {
|
||||
return path.join(__dirname, filePath)
|
||||
return path.isAbsolute(filePath) ? filePath : path.join(__dirname, filePath)
|
||||
}
|
||||
|
||||
var babelOptions = {
|
||||
presets: ["@babel/preset-env"],
|
||||
// "presets": [
|
||||
// "@babel/preset-env", "@babel/preset-react"
|
||||
// ],
|
||||
plugins: [
|
||||
[
|
||||
"@babel/plugin-transform-runtime",
|
||||
@@ -31,38 +25,44 @@ process.env.NODE_ENV = isProduction ? 'production' : 'development'
|
||||
console.log("Bundling for " + (isProduction ? "production" : "development") + "...");
|
||||
|
||||
module.exports = env => {
|
||||
const build_path = (env||{}).BUILD_PATH || resolve("../../../build/web")
|
||||
const output_path = build_path + "/ui/";
|
||||
const api_path = build_path + "/api/";
|
||||
const build_path = process.env.SPARK_ADMIN_WEB_APP_OUTPUT_DIR
|
||||
const output_path = build_path
|
||||
const api_path = build_path
|
||||
return {
|
||||
watchOptions: {
|
||||
ignored: "./**/*"
|
||||
},
|
||||
devtool: isProduction ? undefined : "source-map",
|
||||
entry: resolve('./src/ui.fsproj'),
|
||||
entry: resolve(`${output_path}/App.js`),
|
||||
output: {
|
||||
filename: 'bundle.js',
|
||||
path: output_path,
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
"node_modules", resolve("./node_modules/"), api_path
|
||||
]
|
||||
alias: {
|
||||
api: `${build_path}/api`
|
||||
},
|
||||
modules: [
|
||||
resolve("./node_modules/"), api_path
|
||||
]
|
||||
},
|
||||
devServer: {
|
||||
contentBase: resolve("./public/"),
|
||||
static: {
|
||||
directory: resolve('./public')
|
||||
},
|
||||
port: 8080,
|
||||
hot: true,
|
||||
inline: true
|
||||
proxy: undefined,
|
||||
hot: false,
|
||||
// Configuration for the development server
|
||||
// redirect requests that start with /api/* to the server on port 8085
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.fs(x|proj)?$/,
|
||||
use: {
|
||||
loader: "fable-loader",
|
||||
options: {
|
||||
babel: babelOptions,
|
||||
define: isProduction ? [] : ["DEBUG"]
|
||||
}
|
||||
}
|
||||
test: /\.([cm]?ts|tsx)$/,
|
||||
use: [
|
||||
"ts-loader"
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
@@ -1,53 +0,0 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<ComputerSpecificConfig>..\..\tools\override\$(computername).props</ComputerSpecificConfig>
|
||||
<SparkRoot>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\..))</SparkRoot>
|
||||
<SourceRoot>$([System.IO.Path]::GetFullPath($(SparkRoot)\src))</SourceRoot>
|
||||
<Externals>$(SparkRoot)\externals\windows</Externals>
|
||||
<DepotName>$([System.IO.Path]::GetFileName($([System.IO.Path]::GetFullPath($(SparkRoot)))))</DepotName>
|
||||
<ErrorReport>None</ErrorReport>
|
||||
<Prefer32Bit>False</Prefer32Bit>
|
||||
<Deterministic>true</Deterministic>
|
||||
<EnableDefaultContentItems>False</EnableDefaultContentItems>
|
||||
<ShowMissingItemTypes>false</ShowMissingItemTypes>
|
||||
<Configuration Condition="'$(configuration)'==''">Debug</Configuration>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Label="Output">
|
||||
<BaseOutputPath>$(SparkRoot)\build\$(Configuration)</BaseOutputPath>
|
||||
<OutputPath>$(BaseOutputPath)\bin</OutputPath>
|
||||
<BaseIntermediateOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<IntermediateOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</IntermediateOutputPath>
|
||||
<GenDir>$(BaseOutputPath)\gen\$(MSBuildProjectName)</GenDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import
|
||||
Project="$(ComputerSpecificConfig)"
|
||||
Condition="Exists($(ComputerSpecificConfig))" />
|
||||
|
||||
<PropertyGroup Label="ProtoBuf">
|
||||
<ProtocPluginBase>$(SparkRoot)\src\lib\api\service_compiler</ProtocPluginBase>
|
||||
<protoc>$(Externals)\bin\protoc.exe</protoc>
|
||||
<protogen>$(Externals)\bin\protogen.exe</protogen>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<Proto2></Proto2>
|
||||
<Proto3>
|
||||
<OutBase>$(IntermediateOutputPath)\gen\%(relativedir)</OutBase>
|
||||
<OutCS>%(OutBase)%(FileName).cs</OutCS>
|
||||
<OutCSClient>%(OutBase)%(FileName).client.pb.cs</OutCSClient>
|
||||
<OutCSServer>%(OutBase)%(FileName).server.pb.cs</OutCSServer>
|
||||
<OutCSImmutable>%(OutBase)%(FileName).immutable.pb.cs</OutCSImmutable>
|
||||
<CompileOptions></CompileOptions>
|
||||
</Proto3>
|
||||
<Proto3Excel>
|
||||
<OutBase>$(IntermediateOutputPath)\gen\%(relativedir)</OutBase>
|
||||
<OutCSExcel>%(OutBase)%(FileName).excel.pb.cs</OutCSExcel>
|
||||
<CompileOptions></CompileOptions>
|
||||
</Proto3Excel>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,95 +0,0 @@
|
||||
<Project>
|
||||
|
||||
<Target
|
||||
Name="CompileProto2"
|
||||
Condition="'@(Proto2)'!=''"
|
||||
Inputs="$(MSBuildProjectFile);$(protogen);%(Proto2.FullPath)"
|
||||
Outputs="$(GenDir)\proto2\%(Proto2.filename).cs"
|
||||
AfterTargets="PreBuildEvent">
|
||||
<PropertyGroup>
|
||||
<SourceRelativeFile>$([System.String]::Copy('%(proto2.fullpath)').Replace($(SourceRoot), ''))</SourceRelativeFile>
|
||||
<SourceRelativeDir>$([System.IO.Path]::GetDirectoryName($(SourceRelativeFile)))</SourceRelativeDir>
|
||||
<WorkingDirectory>$(GenDir)\proto2</WorkingDirectory>
|
||||
</PropertyGroup>
|
||||
<MakeDir Directories="$(WorkingDirectory)" />
|
||||
<Copy
|
||||
SourceFiles="%(Proto2.FullPath)"
|
||||
DestinationFolder="$(WorkingDirectory)"
|
||||
SkipUnchangedFiles="True"
|
||||
UseHardLinksIfPossible="True" />
|
||||
<Error
|
||||
Text="protogen.exe does not exist. If you forgot to clone with externals try: git submodule update --init --recursive"
|
||||
Condition="!Exists($(protogen))" />
|
||||
<Exec
|
||||
Command="$(Protogen) %(Proto2.filename)%(proto2.extension) --csharp_out=. -I. -I$(SourceRoot) -I$(Externals)\include"
|
||||
WorkingDirectory="$(WorkingDirectory)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="$(WorkingDirectory)\%(Proto2.filename).cs" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Run this after GetAssemblyVersion because it happens after the Xaml compiler
|
||||
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
|
||||
passes wipes out the additional compile includes that we add.
|
||||
-->
|
||||
<Target
|
||||
Name="CompileProto3"
|
||||
AfterTargets="GetAssemblyVersion"
|
||||
Condition="'@(Proto3)'!=''"
|
||||
Inputs="$(protoc);
|
||||
%(Proto3.Identity);$(ProtocPluginBase)\plugin.py;
|
||||
$(ProtocPluginBase)\templates\c#\client.pb.cs;
|
||||
$(ProtocPluginBase)\templates\c#\server.pb.cs;
|
||||
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
|
||||
Outputs="%(Proto3.OutCS);%(Proto3.OutCSServer);%(Proto3.OutCSClient);%(Proto3.OutCSImmutable)">
|
||||
<MakeDir Directories="%(Proto3.OutBase)" />
|
||||
|
||||
<Message
|
||||
Importance="High"
|
||||
Text="Generating service %(Proto3.FileName)" />
|
||||
<Exec Command="$(SparkRoot)\.venv\Scripts\activate.bat" />
|
||||
<Exec Command="set PYTHONPATH=$(SparkRoot)\.venv\Scripts\python" />
|
||||
<Exec
|
||||
Command="
|
||||
$(SparkRoot)\tools\build_protos.cmd ^
|
||||
%(Proto3.FullPath) ^
|
||||
--error_format=msvs ^
|
||||
--proto_path=$(SourceRoot) ^
|
||||
--plugin="protoc-gen-service=$(ProtocPluginBase)\plugin.cmd" ^
|
||||
--service_out=lang=c#,strip_out_path=1:%(Proto3.OutBase) ^
|
||||
--csharp_out=%(CompileOptions)%(Proto3.OutBase)"
|
||||
WorkingDirectory="%(relativedir)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="%(Proto3.OutCS)" />
|
||||
<Compile Include="%(Proto3.OutCSClient)" />
|
||||
<Compile Include="%(Proto3.OutCSServer)" />
|
||||
<Compile Include="%(Proto3.OutCSImmutable)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="RemoveSystemRuntimeFromRefPack"
|
||||
BeforeTargets="_HandlePackageFileConflicts"
|
||||
Condition="'@(Reference -> WithMetadataValue('NugetPackageId', 'System.Runtime.Experimental'))' != ''">
|
||||
<ItemGroup>
|
||||
<Reference Remove="@(Reference)"
|
||||
Condition="$([System.String]::Copy(%(Reference.Identity)).Contains('System.Runtime.dll')) and
|
||||
'%(Reference.NuGetPackageId)' == 'Microsoft.NETCore.App.Ref'" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="AfterClean"
|
||||
AfterTargets="Clean">
|
||||
<Delete Files="%(Proto3.OutCS)" />
|
||||
<Delete Files="%(Proto3.OutCSClient)" />
|
||||
<Delete Files="%(Proto3.OutCSServer)" />
|
||||
<Delete Files="%(Proto3.OutCSImmutable)" />
|
||||
<Delete Files="$(GenDir)\proto2\*" />
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="Test"
|
||||
DependsOnTargets="Build"></Target>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,82 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<ComputerSpecificConfig>..\..\tools\override\$(computername).props</ComputerSpecificConfig>
|
||||
<SparkRoot>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\..))</SparkRoot>
|
||||
<SourceRoot>$([System.IO.Path]::GetFullPath($(SparkRoot)\src))</SourceRoot>
|
||||
<DepotName>$([System.IO.Path]::GetFileName($([System.IO.Path]::GetFullPath($(SparkRoot)))))</DepotName>
|
||||
<ErrorReport>None</ErrorReport>
|
||||
<Prefer32Bit>False</Prefer32Bit>
|
||||
<Deterministic>true</Deterministic>
|
||||
<EnableDefaultContentItems>False</EnableDefaultContentItems>
|
||||
<ShowMissingItemTypes>false</ShowMissingItemTypes>
|
||||
<Configuration Condition="'$(configuration)'==''">Debug</Configuration>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<LangVersion>11</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition="'$(OS)' == 'Windows_NT'">
|
||||
<PropertyGroup>
|
||||
<Externals>$(SparkRoot)/externals/windows</Externals>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<Externals>$(SparkRoot)/externals/linux</Externals>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup Label="Output">
|
||||
<BaseOutputPath>$(SparkRoot)\build\$(Configuration)</BaseOutputPath>
|
||||
<OutputPath>$(BaseOutputPath)\bin</OutputPath>
|
||||
<BaseIntermediateOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<IntermediateOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</IntermediateOutputPath>
|
||||
<ProtoOutputPath>$(BaseOutputPath)\obj\$(MSBuildProjectName)</ProtoOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import
|
||||
Project="$(ComputerSpecificConfig)"
|
||||
Condition="Exists($(ComputerSpecificConfig))" />
|
||||
|
||||
<PropertyGroup Label="ProtoBuf">
|
||||
<ProtocPluginBase>$(SparkRoot)\src\lib\api\service_compiler</ProtocPluginBase>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(OS)' == 'Windows_NT'">
|
||||
<PropertyGroup Label="ProtoBuf">
|
||||
<protoc>$(Externals)/bin/protoc.exe</protoc>
|
||||
<ProtocPlugin>$(ProtocPluginBase)/plugin.cmd</ProtocPlugin>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup Label="ProtoBuf">
|
||||
<protoc>$(Externals)/bin/protoc</protoc>
|
||||
<ProtocPlugin>$(ProtocPluginBase)/plugin.sh</ProtocPlugin>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<!--
|
||||
Each .proto input file produces 4 output files. For example,
|
||||
'foo_bar.proto' produces:
|
||||
* FooBar.cs
|
||||
* foo_bar.client.pb.cs
|
||||
* foo_bar.server.pb.cs
|
||||
* foo_bar.immutable.pb.cs
|
||||
Google automatically converts .proto filenames to TitleCase when
|
||||
generating .cs files. Unless the .proto file is already in TitleCase
|
||||
(against Google's recommended practice to use snake_case .proto files),
|
||||
the 'CSName' must be overridden with the TitleCase formatting.
|
||||
For example:
|
||||
<Proto3 Include="foo_bar.proto" CSName="FooBar" />
|
||||
-->
|
||||
<Proto3>
|
||||
<OutDir>$(ProtoOutputPath)/</OutDir>
|
||||
<CSName>%(FileName)</CSName>
|
||||
</Proto3>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,68 @@
|
||||
<Project>
|
||||
|
||||
<!--
|
||||
Run this after GetAssemblyVersion because it happens after the Xaml compiler
|
||||
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
|
||||
passes wipes out the additional compile includes that we add.
|
||||
-->
|
||||
<Target
|
||||
Name="CompileProto3"
|
||||
AfterTargets="GetAssemblyVersion"
|
||||
Condition="'@(Proto3)'!=''"
|
||||
Inputs="$(protoc);
|
||||
%(Proto3.Identity);$(ProtocPluginBase)/plugin.py;
|
||||
$(ProtocPluginBase)/templates/c#/client.pb.cs;
|
||||
$(ProtocPluginBase)/templates/c#/server.pb.cs;
|
||||
$(ProtocPluginBase)/templates/c#/immutable.pb.cs;"
|
||||
Outputs="
|
||||
%(Proto3.OutDir)/%(Proto3.CSName).cs;
|
||||
%(Proto3.OutDir)/%(Proto3.FileName).client.pb.cs;
|
||||
%(Proto3.OutDir)/%(Proto3.FileName).server.pb.cs;
|
||||
%(Proto3.OutDir)/%(Proto3.FileName).immutable.pb.cs">
|
||||
<MakeDir Directories="%(Proto3.OutDir)" />
|
||||
|
||||
<Message
|
||||
Importance="High"
|
||||
Text="Generating service %(Proto3.FileName)" />
|
||||
|
||||
<PropertyGroup>
|
||||
<GenProtosCmd>$(protoc) %(Proto3.FullPath)</GenProtosCmd>
|
||||
<GenProtosCmd>$(GenProtosCmd) --error_format=msvs</GenProtosCmd>
|
||||
<GenProtosCmd>$(GenProtosCmd) --proto_path=$(SourceRoot)</GenProtosCmd>
|
||||
<GenProtosCmd>$(GenProtosCmd) --plugin="protoc-gen-service=$(ProtocPlugin)"</GenProtosCmd>
|
||||
<GenProtosCmd>$(GenProtosCmd) --service_out=lang=c#,strip_out_path=1:%(Proto3.OutDir)</GenProtosCmd>
|
||||
<GenProtosCmd>$(GenProtosCmd) --csharp_out=%(Proto3.OutDir)</GenProtosCmd>
|
||||
</PropertyGroup>
|
||||
<Exec Command="$(GenProtosCmd)" WorkingDirectory="%(Proto3.RelativeDir)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="%(Proto3.OutDir)/%(Proto3.CSName).cs" />
|
||||
<Compile Include="%(Proto3.OutDir)/%(Proto3.FileName).client.pb.cs" />
|
||||
<Compile Include="%(Proto3.OutDir)/%(Proto3.FileName).server.pb.cs" />
|
||||
<Compile Include="%(Proto3.OutDir)/%(Proto3.FileName).immutable.pb.cs" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="RemoveSystemRuntimeFromRefPack"
|
||||
BeforeTargets="_HandlePackageFileConflicts"
|
||||
Condition="'@(Reference -> WithMetadataValue('NugetPackageId', 'System.Runtime.Experimental'))' != ''">
|
||||
<ItemGroup>
|
||||
<Reference Remove="@(Reference)"
|
||||
Condition="$([System.String]::Copy(%(Reference.Identity)).Contains('System.Runtime.dll')) and
|
||||
'%(Reference.NuGetPackageId)' == 'Microsoft.NETCore.App.Ref'" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="AfterClean"
|
||||
AfterTargets="Clean">
|
||||
<Delete Files="%(Proto3.OutDir)/%(Proto3.CSName).cs" />
|
||||
<Delete Files="%(Proto3.OutDir)/%(Proto3.FileName).client.pb.cs" />
|
||||
<Delete Files="%(Proto3.OutDir)/%(Proto3.FileName).server.pb.cs" />
|
||||
<Delete Files="%(Proto3.OutDir)/%(Proto3.FileName).immutable.pb.cs" />
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="Test"
|
||||
DependsOnTargets="Build"></Target>
|
||||
|
||||
</Project>
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net7.0</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifiers>win10-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
@@ -14,10 +15,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj" />
|
||||
<!--<ProjectReference Include="..\spark\Spark.csproj" />-->
|
||||
<ProjectReference Include="..\spark_core\spark_core.csproj" />
|
||||
<ProjectReference Include="..\spark_test\spark_test.csproj" />
|
||||
<!--<Proto3 Include="**/*.proto" />-->
|
||||
<ProjectReference Include="../spark_core/spark_core.csproj" />
|
||||
<ProjectReference Include="../spark_test/spark_test.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Spark.Console {
|
||||
using CommandLine;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class CommandParserEx {
|
||||
public static TResult parse_and_run<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(
|
||||
this Parser parser,
|
||||
IEnumerable<string> args,
|
||||
Func<T1, TResult> on_args1,
|
||||
Func<T2, TResult> on_args2,
|
||||
Func<T3, TResult> on_args3,
|
||||
Func<T4, TResult> on_args4,
|
||||
Func<T5, TResult> on_args5,
|
||||
Func<T6, TResult> on_args6,
|
||||
Func<T7, TResult> on_args7,
|
||||
Func<T8, TResult> on_args8,
|
||||
Func<IEnumerable<Error>, TResult> on_error) =>
|
||||
parser.ParseArguments<T1, T2, T3, T4, T5, T6, T7, T8>(args)
|
||||
.MapResult(
|
||||
on_args1,
|
||||
on_args2,
|
||||
on_args3,
|
||||
on_args4,
|
||||
on_args5,
|
||||
on_args6,
|
||||
on_args7,
|
||||
on_args8,
|
||||
on_error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Spark.Console {
|
||||
using bts;
|
||||
|
||||
using mbts.config;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
class ConfigCommand {
|
||||
public static int run(ConfigCommandOptions opts) {
|
||||
if (opts.sparkd is not null) {
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
BTS.set_config_arg(args, opts.sparkd);
|
||||
}
|
||||
var keys = opts.keys?.ToArray() ?? Array.Empty<string>();
|
||||
var excluded_keys = opts.excluded_keys?.ToArray() ?? Array.Empty<string>();
|
||||
return Configuration.run_config_query(
|
||||
keys,
|
||||
keys.Length,
|
||||
excluded_keys,
|
||||
excluded_keys.Length,
|
||||
opts.all,
|
||||
opts.list_keys,
|
||||
opts.verbose);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Spark.Console {
|
||||
using CommandLine;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
[Verb("config", HelpText = "Get config values")]
|
||||
class ConfigCommandOptions {
|
||||
[Option(
|
||||
"query", MetaValue = "keys", HelpText = "Keys to query (supports regular expressions)")]
|
||||
public IEnumerable<string>? keys { get; set; }
|
||||
|
||||
[Option(
|
||||
"exclude",
|
||||
MetaValue = "keys",
|
||||
HelpText = "Keys to exclude from query (supports regular expressions)")]
|
||||
public IEnumerable<string>? excluded_keys { get; set; }
|
||||
|
||||
[Option("all", HelpText = "Query all keys")]
|
||||
public bool all { get; set; }
|
||||
|
||||
[Option("list-keys", HelpText = "List available keys")]
|
||||
public bool list_keys { get; set; }
|
||||
|
||||
[Option("verbose", HelpText = "Show verbose output")]
|
||||
public bool verbose { get; set; }
|
||||
|
||||
[Option("sparkd", MetaValue = "URL", HelpText = "The sparkd server")]
|
||||
public string? sparkd { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace Spark.Console {
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.md;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
static class MBOCommand {
|
||||
public static int run(MBOCommandOptions o) {
|
||||
_dump_mbo(o.key, o.side);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _dump_mbo(uint key, Side side) {
|
||||
using var ctx = new ServiceContext();
|
||||
var mbo = ctx.locate<MBOService>();
|
||||
var data = mbo.get_orders_for_security(
|
||||
new MBOSecurityQuery { SecurityId = key, PriceLevel = double.NaN });
|
||||
|
||||
Console.WriteLine($"Order data for {data.SecurityId}");
|
||||
var price = 0.0;
|
||||
var color = Console.ForegroundColor;
|
||||
if (side == Side.Sell || side == Side.Undefined) {
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
foreach (var e in data.Ask.Reverse()) {
|
||||
if (e.Price != price) {
|
||||
price = e.Price;
|
||||
Console.WriteLine("================");
|
||||
}
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
if (side == Side.Buy || side == Side.Undefined) {
|
||||
Console.ForegroundColor = ConsoleColor.Blue;
|
||||
foreach (var e in data.Bid) {
|
||||
if (e.Price != price) {
|
||||
price = e.Price;
|
||||
Console.WriteLine("================");
|
||||
}
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
Console.ForegroundColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Spark.Console {
|
||||
using bts.api;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
[Verb("mbo", HelpText = "MBO diagnostic command")]
|
||||
public class MBOCommandOptions {
|
||||
[Option('k', "key", Required = true)]
|
||||
public uint key { get; set; }
|
||||
|
||||
[Option('s', "side", Default = Side.Undefined)]
|
||||
public Side side { get; set; }
|
||||
}
|
||||
}
|
||||
+159
-168
@@ -1,168 +1,159 @@
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.co2;
|
||||
using bts.test;
|
||||
using CommandLine;
|
||||
using mbts.co2;
|
||||
using mbts.config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bts {
|
||||
|
||||
[Verb("orderstress", HelpText = "Create a bunch of orders")]
|
||||
public class OrderStressOptions {
|
||||
// Maybe options to create fewer orders or sleep
|
||||
|
||||
[Option('s', "sleep", HelpText = "Sleep ms between order submission", Default = 100)]
|
||||
public int sleep { get; set; }
|
||||
|
||||
[Option('d', "depth", HelpText = "How many orders per side", Default = 10u)]
|
||||
public uint depth { get; set; }
|
||||
|
||||
[Option('q', "quanityt", HelpText = "Order quantity", Default = 1u)]
|
||||
public uint quantity { get; set; }
|
||||
};
|
||||
|
||||
public struct Market {
|
||||
public SecurityImmutable security;
|
||||
public IntPrice? bid;
|
||||
public IntPrice? ask;
|
||||
}
|
||||
|
||||
public static class OrderStress {
|
||||
static IEnumerable<Market> all_markets(ServiceContext ctx) {
|
||||
var channels =
|
||||
UserSymbol.get_all()
|
||||
.Select(u =>
|
||||
new SecurityChannel() {
|
||||
Time = 0,
|
||||
Flags = (int)(MDRequest.Types.Flags.Direct | MDRequest.Types.Flags.Implied),
|
||||
Type = u.type,
|
||||
Symbol = u.symbol,
|
||||
Exchange = u.exchange
|
||||
}
|
||||
);
|
||||
var request = new MDRequest() { Host = "system_test" };
|
||||
request.Channels.AddRange(channels);
|
||||
|
||||
var relay = ctx.locate<MarketDataRelay>();
|
||||
System.Threading.Thread.Sleep(100);
|
||||
var result = relay.requestmd(request);
|
||||
|
||||
foreach (var ch in result.Channels) {
|
||||
// if (ch.Platform != Platform.Sim) continue;
|
||||
foreach (var update in ch.Updates) {
|
||||
if (update.Security != null) {
|
||||
var m = new Market() {
|
||||
security = new SecurityImmutable(update.Security),
|
||||
bid = best(
|
||||
(a,b) => a > b ? a : b,
|
||||
update.Direct?.Bids?.FirstOrDefault(), update.Implied?.Bids?.FirstOrDefault()),
|
||||
ask = best(
|
||||
(a,b) => a < b ? a : b,
|
||||
update.Direct?.Asks?.FirstOrDefault(), update.Implied?.Asks?.FirstOrDefault())
|
||||
};
|
||||
if (m.bid.HasValue || m.ask.HasValue) {
|
||||
yield return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IntPrice? best(Func<IntPrice, IntPrice,IntPrice> comp, params PriceSizeMessage[] ps) {
|
||||
IntPrice? result = null;
|
||||
foreach (var p in ps) {
|
||||
if (p != null) {
|
||||
var ip = new IntPrice(p.Mantissa, (sbyte)p.Exponent);
|
||||
if (result == null) {
|
||||
result = ip;
|
||||
}
|
||||
else {
|
||||
result = comp(result.Value, ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Create mkorder(uint security, double price, uint size, Side side) {
|
||||
return new Create {
|
||||
Price = price,
|
||||
Quantity = size,
|
||||
NewOrder = new OrderDefinition {
|
||||
SecurityKey = security,
|
||||
Side = side,
|
||||
TimeInForce = TimeInForce.Day,
|
||||
ManualOrderIndicator = ManualOrderIndicator.Yes,
|
||||
CtiCode = CTICode.CtiCode1,
|
||||
CustomerOrFirm = CustomerOrFirm.Firm,
|
||||
AccountId = 1,
|
||||
UserId = 1,
|
||||
CustomDef = new CustomOrderDefinition {
|
||||
Limit = new LimitOrderDefinition()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static int Run(OrderStressOptions o) {
|
||||
|
||||
var ctx = new ServiceContext();
|
||||
ConsoleEx.WriteLine("Please log in to Spark", ConsoleColor.Yellow);
|
||||
ConsoleEx.Write("Username: ", ConsoleColor.Yellow);
|
||||
var name = Console.ReadLine();
|
||||
ConsoleEx.Write("Password: ", ConsoleColor.Yellow);
|
||||
var pw = Console.ReadLine();
|
||||
|
||||
var login_result = ctx.login(name, pw);
|
||||
if (!login_result.Result.success) {
|
||||
ConsoleEx.WriteLine("Invalid Credentials", ConsoleColor.Red);
|
||||
}
|
||||
|
||||
if (Configuration.get<config.DeploymentType>().type.ToUpper() == "PROD") {
|
||||
ConsoleEx.WriteLine("Refusing to run on production system", ConsoleColor.Red);
|
||||
return -1;
|
||||
}
|
||||
|
||||
var orders = ctx.locate<OrderService>();
|
||||
var factor = TimeSpan.TicksPerMillisecond / 1000;
|
||||
foreach (var m in all_markets(ctx)) {
|
||||
ConsoleEx.WriteLine(m.security.security_desc(), ConsoleColor.White);
|
||||
var tick = m.security.ContractSpec.LowTick;
|
||||
if (m.ask.HasValue) {
|
||||
for (var x = 0; x < o.depth; ++x) {
|
||||
var price = m.ask.Value.price() + (tick * x);
|
||||
ConsoleEx.WriteLine($"Sell {o.quantity} at {price}", ConsoleColor.Red);
|
||||
var sw = new System.Diagnostics.Stopwatch();
|
||||
sw.Start();
|
||||
var r = orders.create_order(mkorder(m.security.Id, price, o.quantity, Side.Sell));
|
||||
sw.Stop();
|
||||
// Log.Api.info($"Order: id {r.OrderKey} time {sw.ElapsedTicks/factor}us");
|
||||
Log.Api.info($"Order {m.security.security_desc()}: id {r.OrderKey} {r.ErrorCode} time {sw.ElapsedTicks/factor}us");
|
||||
System.Threading.Thread.Sleep(o.sleep);
|
||||
}
|
||||
}
|
||||
if (m.bid.HasValue) {
|
||||
// start at bid and place 1 order at 10 levels
|
||||
for (var x=0; x < o.depth; ++x) {
|
||||
var price = m.bid.Value.price() - (tick * x);
|
||||
ConsoleEx.WriteLine($"Buy {o.quantity} at {price}", ConsoleColor.Blue);
|
||||
var sw = new System.Diagnostics.Stopwatch();
|
||||
sw.Start();
|
||||
var r = orders.create_order(mkorder(m.security.Id, price, o.quantity, Side.Buy));
|
||||
sw.Stop();
|
||||
Log.Api.info($"Order {m.security.security_desc()}: id {r.OrderKey} {r.ErrorCode} time {sw.ElapsedTicks/factor}us");
|
||||
System.Threading.Thread.Sleep(o.sleep);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
namespace Spark.Console {
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.co2;
|
||||
using bts.config;
|
||||
using bts.test;
|
||||
|
||||
using mbts.co2;
|
||||
using mbts.config;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
static class OrderStressCommand {
|
||||
public static int run(OrderStressOptions o) {
|
||||
var ctx = new ServiceContext();
|
||||
ConsoleEx.WriteLine("Please log in to Spark", ConsoleColor.Yellow);
|
||||
var name = ConsoleEx.prompt("Username: ", ConsoleColor.Yellow);
|
||||
var pw = ConsoleEx.prompt("Password: ", ConsoleColor.Yellow);
|
||||
|
||||
var login_result = ctx.login(name, pw);
|
||||
if (!login_result.Result.success) {
|
||||
ConsoleEx.WriteLine("Invalid Credentials", ConsoleColor.Red);
|
||||
}
|
||||
|
||||
if (Configuration.get<DeploymentType>().Type.ToUpper() == "PROD") {
|
||||
ConsoleEx.WriteLine("Refusing to run on production system", ConsoleColor.Red);
|
||||
return -1;
|
||||
}
|
||||
|
||||
var orders = ctx.locate<OrderService>();
|
||||
var factor = TimeSpan.TicksPerMillisecond / 1000;
|
||||
|
||||
string fmt_order(Market m, Response r, long elapsed_ticks) =>
|
||||
$"Order {m.security.security_desc()}. id: {r.OrderKey}; err: {r.ErrorCode}; " +
|
||||
$"time: {elapsed_ticks / factor}us";
|
||||
|
||||
foreach (var m in _all_markets(ctx)) {
|
||||
ConsoleEx.WriteLine(m.security.security_desc(), ConsoleColor.White);
|
||||
var tick = m.security.ContractSpec.LowTick;
|
||||
if (m.ask.HasValue) {
|
||||
for (var x = 0; x < o.depth; ++x) {
|
||||
var price = m.ask.Value.price() + (tick * x);
|
||||
ConsoleEx.WriteLine($"Sell {o.quantity} at {price}", ConsoleColor.Red);
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var r = orders.create_order(_mkorder(m.security.Id, price, o.quantity, Side.Sell));
|
||||
sw.Stop();
|
||||
Log.Api.info(fmt_order(m, r, sw.ElapsedTicks));
|
||||
Thread.Sleep(o.sleep);
|
||||
}
|
||||
}
|
||||
if (m.bid.HasValue) {
|
||||
// start at bid and place 1 order at 10 levels
|
||||
for (var x = 0; x < o.depth; ++x) {
|
||||
var price = m.bid.Value.price() - (tick * x);
|
||||
ConsoleEx.WriteLine($"Buy {o.quantity} at {price}", ConsoleColor.Blue);
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
var r = orders.create_order(_mkorder(m.security.Id, price, o.quantity, Side.Buy));
|
||||
sw.Stop();
|
||||
Log.Api.info(fmt_order(m, r, sw.ElapsedTicks));
|
||||
Thread.Sleep(o.sleep);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
static IEnumerable<Market> _all_markets(ServiceContext ctx) {
|
||||
var channels =
|
||||
UserSymbol.get_all()
|
||||
.Select(u =>
|
||||
new SecurityChannel() {
|
||||
Time = 0,
|
||||
Flags = (int)(MDRequest.Types.Flags.Direct | MDRequest.Types.Flags.Implied),
|
||||
Type = u.type,
|
||||
Symbol = u.symbol,
|
||||
Exchange = u.exchange
|
||||
}
|
||||
);
|
||||
var request = new MDRequest() { Host = "system_test" };
|
||||
request.Channels.AddRange(channels);
|
||||
|
||||
var relay = ctx.locate<MarketDataRelay>();
|
||||
Thread.Sleep(100);
|
||||
var result = relay.requestmd(request);
|
||||
|
||||
foreach (var ch in result.Channels) {
|
||||
// if (ch.Platform != Platform.Sim) continue;
|
||||
foreach (var update in ch.Updates) {
|
||||
if (update.Security != null) {
|
||||
var m = new Market() {
|
||||
security = new SecurityImmutable(update.Security),
|
||||
bid = _best(
|
||||
(a, b) => a > b ? a : b,
|
||||
update.Direct.Bids.FirstOrDefault(),
|
||||
update.Implied.Bids.FirstOrDefault()),
|
||||
ask = _best(
|
||||
(a, b) => a < b ? a : b,
|
||||
update.Direct.Asks.FirstOrDefault(),
|
||||
update.Implied.Asks.FirstOrDefault())
|
||||
};
|
||||
if (m.bid.HasValue || m.ask.HasValue) {
|
||||
yield return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static IntPrice? _best(
|
||||
Func<IntPrice, IntPrice, IntPrice> comp, params PriceSizeMessage?[] ps) {
|
||||
IntPrice? result = null;
|
||||
foreach (var p in ps) {
|
||||
if (p != null) {
|
||||
var ip = new IntPrice(p.Mantissa, (sbyte)p.Exponent);
|
||||
if (result == null) {
|
||||
result = ip;
|
||||
} else {
|
||||
result = comp(result.Value, ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Create _mkorder(uint security, double price, uint size, Side side) {
|
||||
return new Create {
|
||||
Price = price,
|
||||
Quantity = size,
|
||||
NewOrder = new OrderDefinition {
|
||||
SecurityKey = security,
|
||||
Side = side,
|
||||
TimeInForce = TimeInForce.Day,
|
||||
ManualOrderIndicator = ManualOrderIndicator.Yes,
|
||||
CtiCode = CTICode.CtiCode1,
|
||||
CustomerOrFirm = CustomerOrFirm.Firm,
|
||||
AccountId = 1,
|
||||
UserId = 1,
|
||||
CustomDef = new CustomOrderDefinition {
|
||||
Limit = new LimitOrderDefinition()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct Market {
|
||||
public SecurityImmutable security;
|
||||
public IntPrice? bid;
|
||||
public IntPrice? ask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Spark.Console {
|
||||
using CommandLine;
|
||||
|
||||
[Verb("order-stress", HelpText = "Create a bunch of orders")]
|
||||
public class OrderStressOptions {
|
||||
// Maybe options to create fewer orders or sleep
|
||||
|
||||
[Option('s', "sleep", HelpText = "Sleep ms between order submission", Default = 100)]
|
||||
public int sleep { get; set; }
|
||||
|
||||
[Option('d', "depth", HelpText = "How many orders per side", Default = 10u)]
|
||||
public uint depth { get; set; }
|
||||
|
||||
[Option('q', "quanityt", HelpText = "Order quantity", Default = 1u)]
|
||||
public uint quantity { get; set; }
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
namespace Spark.Console {
|
||||
using bts.api.core;
|
||||
using bts.api.diagnostic;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Reactive.Linq;
|
||||
using Spark.Core;
|
||||
using System.Threading;
|
||||
|
||||
static class ScriptCommand {
|
||||
public static int run(ScriptCommandOptions o) {
|
||||
if (o.server) {
|
||||
_run_server();
|
||||
return 0;
|
||||
}
|
||||
if (o.host is null) {
|
||||
Console.WriteLine("Please specify host");
|
||||
return 1;
|
||||
}
|
||||
if (!o.file.is_null_or_empty() && File.Exists(o.file)) {
|
||||
_run_client(o.host, File.OpenRead(o.file));
|
||||
return 0;
|
||||
}
|
||||
_run_client(o.host, Console.OpenStandardInput());
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _run_client(string qualifier, Stream stream) {
|
||||
using var ctx = new ServiceContext();
|
||||
ShellDiagnosticService diag = ctx.locate<ShellDiagnosticService>(qualifier);
|
||||
var script_id = diag.create(null);
|
||||
ShellScriptHost script = ctx.locate<ShellScriptHost>(script_id.Id);
|
||||
try {
|
||||
using var sub = script.subscribei_output().Subscribe(_script_output);
|
||||
using var reader = new StreamReader(stream);
|
||||
var status = ScriptResult.Complete;
|
||||
|
||||
for (var line = string.Empty; line != "#q"; line = prompt_input()) {
|
||||
var result = script.run(new ScriptLines { Lines = { line } });
|
||||
status = result.Res;
|
||||
switch (status) {
|
||||
case ScriptResult.Invalid:
|
||||
Console.WriteLine($"Syntax error: '{result.Message}'");
|
||||
break;
|
||||
case ScriptResult.RunError:
|
||||
Console.WriteLine($"Exception: {result.Message}");
|
||||
break;
|
||||
case ScriptResult.Complete:
|
||||
if (!result.Message.is_null_or_empty()) {
|
||||
Console.WriteLine(result.Message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string prompt_input() {
|
||||
_write_prompt(status);
|
||||
return reader.ReadLine() ??
|
||||
throw new InvalidOperationException("Received null input");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine($"Done. {e.Message}");
|
||||
} finally {
|
||||
try {
|
||||
script.dispose(null);
|
||||
script.Dispose();
|
||||
} catch (Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
static void _script_output(Update<ScriptLinesImmutable, int> update) {
|
||||
foreach (var lines in update.added) {
|
||||
foreach (var line in lines.Lines) {
|
||||
Console.WriteLine(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _write_prompt(ScriptResult status) {
|
||||
switch (status) {
|
||||
case ScriptResult.Complete:
|
||||
Console.Write(">>> ");
|
||||
break;
|
||||
case ScriptResult.Incomplete:
|
||||
Console.Write("... ");
|
||||
break;
|
||||
case ScriptResult.Invalid:
|
||||
Console.Write("?>> ");
|
||||
break;
|
||||
case ScriptResult.RunError:
|
||||
Console.Write("!>> ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void _run_server() {
|
||||
// for debugging
|
||||
using var ctx = new ServiceContext();
|
||||
var stype = SparkReflectionHelper.find_type(
|
||||
"bts.api.diagnostic.ShellDiagnosticsServiceServer");
|
||||
var server = Activator.CreateInstance(stype, ctx);
|
||||
while (true) {
|
||||
Thread.Sleep(1000);
|
||||
GC.KeepAlive(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Spark.Console {
|
||||
using CommandLine;
|
||||
|
||||
[Verb("script", HelpText = "Remote control for shell diagnostic host")]
|
||||
public class ScriptCommandOptions {
|
||||
[Option('s', "server", HelpText = "Run a script server for testing.")]
|
||||
public bool server { get; set; }
|
||||
|
||||
[Option('h', "host", HelpText = "Connect to {host}")]
|
||||
public string? host { get; set; }
|
||||
|
||||
[Option('f', "fromfile", HelpText = "Read commands from file instead of stdin")]
|
||||
public string? file { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Spark.Console {
|
||||
using bts;
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
class SettingsCommand {
|
||||
public static int run(SettingsCommandOptions _) {
|
||||
var type = SparkReflectionHelper.find_type(
|
||||
"bts.api.diagnostic.ShellDiagnosticsServiceServer");
|
||||
var run = type.GetMethod("run", BindingFlags.Static | BindingFlags.Public);
|
||||
Log.notnull(run).Invoke(null, Array.Empty<object>());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Spark.Console {
|
||||
using CommandLine;
|
||||
|
||||
[Verb("settings", HelpText = "Copy workspaces around")]
|
||||
class SettingsCommandOptions { }
|
||||
}
|
||||
Loaded 100 of 2079 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user