|
20 | 20 | </div> |
21 | 21 | </div> |
22 | 22 | <script> |
23 | | - $(document).ready(function() { |
24 | | - const query = new graphs.query(` |
25 | | -query ( $address: String!, |
26 | | - $inboundDepth: Int!, |
27 | | - $outboundDepth: Int!, |
28 | | - $limit: Int!, |
29 | | - $currency: Int!, |
30 | | - $from: ISO8601DateTime, |
31 | | - $till: ISO8601DateTime){ |
32 | | -algorand{ |
33 | | - inbound: coinpath(initialAddress: {is: $address}, |
34 | | - currency:{is: $currency}, |
35 | | - depth: {lteq: $inboundDepth}, |
36 | | - options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}, |
37 | | - date:{since: $from, till: $till}) { |
38 | | - sender { |
39 | | - address |
40 | | - annotation |
41 | | - } |
42 | | - receiver { |
43 | | - address |
44 | | - annotation |
45 | | - } |
46 | | - amount |
47 | | - currency{symbol} |
48 | | - depth |
49 | | - count |
50 | | - } |
| 23 | + const query = new graphs.query(` |
| 24 | + query ($address: String!, $inboundDepth: Int!, $outboundDepth: Int!, $limit: Int!, $currency: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) { |
| 25 | + algorand { |
| 26 | + inbound: coinpath( |
| 27 | + initialAddress: {is: $address} |
| 28 | + currency: {is: $currency} |
| 29 | + depth: {lteq: $inboundDepth} |
| 30 | + options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}} |
| 31 | + date: {since: $from, till: $till} |
| 32 | + ) { |
| 33 | + sender { |
| 34 | + address |
| 35 | + annotation |
| 36 | + } |
| 37 | + receiver { |
| 38 | + address |
| 39 | + annotation |
| 40 | + } |
| 41 | + amount |
| 42 | + currency { |
| 43 | + symbol |
| 44 | + } |
| 45 | + depth |
| 46 | + count |
| 47 | + } |
| 48 | + outbound: coinpath( |
| 49 | + initialAddress: {is: $address} |
| 50 | + currency: {is: $currency} |
| 51 | + depth: {lteq: $outboundDepth} |
| 52 | + options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}} |
| 53 | + date: {since: $from, till: $till} |
| 54 | + ) { |
| 55 | + sender { |
| 56 | + address |
| 57 | + annotation |
| 58 | + } |
| 59 | + receiver { |
| 60 | + address |
| 61 | + annotation |
| 62 | + } |
| 63 | + amount |
| 64 | + currency { |
| 65 | + symbol |
| 66 | + } |
| 67 | + depth |
| 68 | + count |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + `) |
51 | 73 |
|
| 74 | + new graphs.address_graph('#graph', query, { |
| 75 | + theme: '<%= @theme %>', |
| 76 | + }) |
52 | 77 |
|
53 | | - outbound: coinpath(initialAddress: {is: $address}, |
54 | | - currency:{is: $currency}, |
55 | | - depth: {lteq: $outboundDepth}, |
56 | | - options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}, |
57 | | - date:{since: $from, till: $till}) { |
58 | | - sender { |
59 | | - address |
60 | | - annotation |
61 | | - } |
62 | | - receiver { |
63 | | - address |
64 | | - annotation |
65 | | - } |
66 | | - amount |
67 | | - currency{symbol} |
68 | | - depth |
69 | | - count |
70 | | - } |
71 | | -} |
72 | | -}`) |
73 | | - window.query = query |
74 | | - new graphs.address_graph('#graph', query, { |
75 | | - theme: '<%= @theme %>', |
76 | | - }) |
| 78 | + new graphs.addControls('#graph', query, { |
| 79 | + theme: '<%= @theme %>', |
| 80 | + currencies: [ |
| 81 | + <%= @currencies.collect do |cur| |
| 82 | + value = cur.token_id == '' ? 0 : cur.token_id |
77 | 83 |
|
78 | | - new graphs.addControls('#graph', query, { |
79 | | - theme: '<%= @theme %>', |
80 | | - currencies: [<%= @currencies.collect{|cur| "{token_id:#{cur.token_id},symbol:\"#{cur.symbol}\",name:\"#{cur.name}\",search:#{cur.token_id}}"}.join(',').html_safe %>], |
81 | | - }) |
| 84 | + "{token_id:\"#{cur.token_id}\",symbol:\"#{cur.symbol}\",name:\"#{cur.name}\",search:\"#{value}\"}" |
| 85 | + end.join(',').html_safe %> |
| 86 | + ] |
| 87 | + }) |
82 | 88 |
|
83 | | - new graphs.address_sankey('#sankey-graph', query, { |
84 | | - theme: '<%= @theme %>', |
85 | | - }) |
| 89 | + new graphs.address_sankey('#sankey-graph', query, { |
| 90 | + theme: '<%= @theme %>', |
| 91 | + }) |
86 | 92 |
|
87 | | - new graphs.addControls('#sankey-graph', query, { |
88 | | - theme: '<%= @theme %>', |
89 | | - currencies: [<%= @currencies.collect{|cur| "{token_id:#{cur.token_id},symbol:\"#{cur.symbol}\",name:\"#{cur.name}\",search:#{cur.token_id}}"}.join(',').html_safe %>], |
90 | | - }) |
| 93 | + new graphs.addControls('#sankey-graph', query, { |
| 94 | + theme: '<%= @theme %>', |
| 95 | + currencies: [ |
| 96 | + <%= @currencies.collect do |cur| |
| 97 | + value = cur.token_id == '' ? 0 : cur.token_id |
91 | 98 |
|
92 | | - queryWithTimeRange(rr, query, <%= @from.html_safe %>, <%= @till.html_safe %>, {"inboundDepth": 1, "outboundDepth": 1, "limit": 10, "offset": 0, "network": "<%= params['network']['network'] %>", "address": "<%= @address %>", "currency": <%= @currencies.first && @currencies.first.token_id || 0 %>}) |
93 | | - }) |
| 99 | + "{token_id:\"#{value}\",symbol:\"#{cur.symbol}\",name:\"#{cur.name}\",search:\"#{value}\"}" |
| 100 | + end.join(',').html_safe %> |
| 101 | + ] |
| 102 | + }) |
| 103 | + |
| 104 | + queryWithTimeRange(rr, query, <%= @from.html_safe %>, <%= @till.html_safe %>, { |
| 105 | + "inboundDepth": 1, |
| 106 | + "outboundDepth": 1, |
| 107 | + "limit": 10, |
| 108 | + "offset": 0, |
| 109 | + "network": "<%= params['network']['network'] %>", |
| 110 | + "address": "<%= @address %>", |
| 111 | + "currency": <%= @currencies&.first&.token_id.present? || 0 %>, |
| 112 | + }) |
94 | 113 | </script> |
95 | 114 | </div> |
| 115 | + |
| 116 | + |
| 117 | + |
0 commit comments