|
1 | 1 | <template>
|
2 |
| - <div class="columns"> |
| 2 | + <div> |
3 | 3 | <p class="label">
|
4 |
| - {{ $t('History')}} |
| 4 | + {{ $t('History') }} |
5 | 5 | </p>
|
6 |
| - <div class="column is-7"> |
7 |
| - <b-table :data="data" |
8 |
| - hoverable |
9 |
| - > |
10 |
| - <b-table-column |
| 6 | + <b-table :data="data" class="mb-4" hoverable> |
| 7 | + <b-table-column |
11 | 8 | cell-class="short-identity__table"
|
12 |
| - field= 'Type' |
13 |
| - label= 'Type' |
| 9 | + field="Type" |
| 10 | + label="Type" |
14 | 11 | v-slot="props"
|
15 |
| - > |
16 |
| - {{props.row.Type}} |
17 |
| - </b-table-column> |
| 12 | + > |
| 13 | + {{ props.row.Type }} |
| 14 | + </b-table-column> |
18 | 15 | <b-table-column
|
19 | 16 | cell-class="short-identity__table"
|
20 |
| - field= 'From' |
21 |
| - label= 'From' |
| 17 | + field="From" |
| 18 | + label="From" |
22 | 19 | v-slot="props"
|
| 20 | + > |
| 21 | + <router-link |
| 22 | + :to="{ |
| 23 | + name: 'profile', |
| 24 | + params: { id: props.row.From }, |
| 25 | + }" |
23 | 26 | >
|
24 |
| - <router-link :to="{ name: 'profile', params: { id: props.row.From } }"> |
25 |
| - <Identity :address="props.row.From" inline noOverflow /> |
26 |
| - </router-link> |
27 |
| - </b-table-column> |
| 27 | + <Identity :address="props.row.From" inline noOverflow /> |
| 28 | + </router-link> |
| 29 | + </b-table-column> |
28 | 30 | <b-table-column
|
29 | 31 | cell-class="short-identity__table"
|
30 |
| - field= 'To' |
31 |
| - label= 'To' |
| 32 | + field="To" |
| 33 | + label="To" |
32 | 34 | v-slot="props"
|
| 35 | + > |
| 36 | + <router-link |
| 37 | + :to="{ name: 'profile', params: { id: props.row.To } }" |
33 | 38 | >
|
34 |
| - <router-link :to="{ name: 'profile', params: { id: props.row.To } }"> |
35 |
| - <Identity :address="props.row.To" inline noOverflow /> |
36 |
| - </router-link> |
| 39 | + <Identity :address="props.row.To" inline noOverflow /> |
| 40 | + </router-link> |
37 | 41 | </b-table-column>
|
38 | 42 | <b-table-column
|
39 | 43 | cell-class="short-identity__table"
|
40 |
| - field= 'Amount' |
41 |
| - label= 'Amount' |
| 44 | + field="Amount" |
| 45 | + label="Amount" |
42 | 46 | v-slot="props"
|
43 |
| - > |
44 |
| - {{props.row.Amount}} |
| 47 | + > |
| 48 | + {{ props.row.Amount }} |
45 | 49 | </b-table-column>
|
46 | 50 | <b-table-column
|
47 | 51 | cell-class="short-identity__table"
|
48 |
| - field= 'Date' |
49 |
| - label= 'Date' |
| 52 | + field="Date" |
| 53 | + label="Date" |
50 | 54 | v-slot="props"
|
51 |
| - > |
52 |
| - {{props.row.Date}} |
| 55 | + > |
| 56 | + {{ props.row.Date }} |
53 | 57 | </b-table-column>
|
| 58 | + </b-table> |
54 | 59 |
|
55 |
| - |
56 |
| - </b-table> |
57 |
| - </div> |
58 |
| - <div class="column is-5"> |
59 |
| - <PriceChart :priceData="priceData"/> |
60 |
| - </div> |
61 |
| - </div> |
62 |
| -</template> |
| 60 | + <PriceChart :priceData="priceData" /> |
| 61 | + </div> |
| 62 | +</template> |
63 | 63 |
|
64 | 64 | <script lang="ts">
|
65 |
| -
|
66 |
| -import { Component, Vue, Prop, Watch} from 'vue-property-decorator'; |
| 65 | +import { Component, Vue, Prop, Watch } from 'vue-property-decorator'; |
67 | 66 |
|
68 | 67 | const components = {
|
69 |
| - Identity: () => import('@/components/shared/format/Identity.vue'), |
70 |
| - PriceChart: () => import('@/components/rmrk/Gallery/PriceChart.vue'), |
71 |
| -}; |
| 68 | + Identity: () => import('@/components/shared/format/Identity.vue'), |
| 69 | + PriceChart: () => import('@/components/rmrk/Gallery/PriceChart.vue'), |
| 70 | +} |
72 | 71 |
|
73 | 72 | @Component({ components })
|
74 |
| -
|
75 |
| -export default class History extends Vue{ |
76 |
| -
|
77 |
| - @Prop() public events!: any; |
78 |
| - protected data: any = []; |
79 |
| - protected priceData: any = []; |
80 |
| - // protected eventData: Date[] = []; |
81 |
| -
|
82 |
| - public async created(){ |
83 |
| - this.createTable(); |
84 |
| - } |
85 |
| - protected createTable(){ |
86 |
| -
|
87 |
| - let prevOwner : string = ''; |
88 |
| - let curPrice : string = '0.0000000'; |
89 |
| - for(const newEvent of this.events){ |
90 |
| - const event : any = {}; |
91 |
| -
|
92 |
| - // Type |
93 |
| - if(newEvent['interaction'] === 'MINTNFT'){ |
94 |
| - event['Type'] = 'CREATE'; |
95 |
| - event['From'] = newEvent['caller']; |
96 |
| - event['To'] = ''; |
97 |
| - } |
98 |
| - else if(newEvent['interaction'] === 'LIST'){ |
99 |
| - event['Type'] = 'SET-PRICE'; |
100 |
| - event['From'] = newEvent['caller']; |
101 |
| - event['To'] = ''; |
102 |
| - prevOwner = event['From']; |
103 |
| - curPrice = newEvent['meta']; |
104 |
| - } |
105 |
| - else if(newEvent['interaction'] === 'SEND'){ |
106 |
| - event['Type'] = 'GIFT'; |
107 |
| - event['From'] = newEvent['caller']; |
108 |
| - event['To'] = newEvent['meta']; |
109 |
| - } |
110 |
| - else if(newEvent['interaction'] === 'CONSUME'){ |
111 |
| - event['Type'] = 'BURNT'; |
112 |
| - event['From'] = newEvent['caller']; |
113 |
| - event['To'] = ''; |
114 |
| - } |
115 |
| - else |
116 |
| - event['Type'] = newEvent['interaction']; |
117 |
| -
|
118 |
| - // From |
119 |
| - if(!('From' in event)) |
120 |
| - event['From'] = prevOwner; |
121 |
| - // To |
122 |
| - if(!('To' in event)){ |
123 |
| - event['To'] = newEvent['caller'] |
124 |
| - prevOwner = event['To']; |
125 |
| - } |
126 |
| -
|
127 |
| - // Amount |
128 |
| - event['Amount'] = Vue.filter('formatBalance')(curPrice, 12, 'KSM'); |
129 |
| - // Date |
130 |
| - const date = new Date(newEvent['timestamp']) |
131 |
| - event['Date'] = this.parseDate(date); |
132 |
| - if(event['Type'] === 'SET-PRICE' || event['Type'] === 'CREATE'){ |
133 |
| - this.priceData.push([date, this.formatPrice(event['Amount'])]); |
134 |
| - // this.priceData.push([this.formatDate(date), this.formatPrice(event['Amount'])]); |
135 |
| - // this.eventData.push(date); |
136 |
| - } |
137 |
| -
|
138 |
| - this.data.push(event); |
139 |
| - } |
140 |
| - this.data = this.data.reverse(); |
141 |
| - this.priceData.push([new Date(), this.formatPrice(this.data[0]['Amount'])]); |
142 |
| - // this.priceData.push([this.formatDate(new Date()), this.formatPrice(this.data[0]['Amount'])]); |
143 |
| - // this.eventData.push(new Date()); |
144 |
| -
|
145 |
| - } |
146 |
| - protected parseDate(date: Date){ |
147 |
| - const utcDate: string = date.toUTCString(); |
148 |
| - return utcDate.substring(4); |
149 |
| - } |
150 |
| -
|
151 |
| - protected formatDate(date: Date){ |
152 |
| - const yyyy = date.getUTCFullYear(); |
153 |
| - const mm = this.padDigits(date.getUTCMonth()+1); |
154 |
| - const dd = this.padDigits(date.getUTCDate()); |
155 |
| - const hrs = this.padDigits(date.getUTCHours()); |
156 |
| - const mins = this.padDigits(date.getUTCMinutes()); |
157 |
| - const secs = this.padDigits(date.getUTCSeconds()); |
158 |
| - const YYYY_MM_DD_HRS_MINS_SECS = yyyy+'/'+mm+'/'+dd+'\n'+hrs+':'+mins+':'+secs; |
159 |
| - return YYYY_MM_DD_HRS_MINS_SECS; |
160 |
| - } |
161 |
| -
|
162 |
| - protected padDigits(time : number){ |
163 |
| - return time.toString().padStart(2, '0'); |
164 |
| - } |
165 |
| -
|
166 |
| - protected formatPrice(price: string){ |
167 |
| - return parseFloat(price.substring(0,6)) |
168 |
| - } |
169 |
| - @Watch('events') |
170 |
| - async watchEvent(newEvent: [], oldEvent: []){ |
171 |
| - // console.log(this.events) |
172 |
| - this.createTable(); |
173 |
| - } |
174 |
| -
|
| 73 | +export default class History extends Vue { |
| 74 | + @Prop() public events!: any; |
| 75 | + protected data: any = []; |
| 76 | + protected priceData: any = []; |
| 77 | + // protected eventData: Date[] = []; |
| 78 | +
|
| 79 | + public async created() { |
| 80 | + this.createTable(); |
| 81 | + } |
| 82 | +
|
| 83 | + protected createTable() { |
| 84 | + let prevOwner: string = ''; |
| 85 | + let curPrice: string = '0.0000000'; |
| 86 | + for (const newEvent of this.events) { |
| 87 | + const event: any = {}; |
| 88 | +
|
| 89 | + // Type |
| 90 | + if (newEvent['interaction'] === 'MINTNFT') { |
| 91 | + event['Type'] = 'CREATE'; |
| 92 | + event['From'] = newEvent['caller']; |
| 93 | + event['To'] = ''; |
| 94 | + } else if (newEvent['interaction'] === 'LIST') { |
| 95 | + event['Type'] = 'SET-PRICE'; |
| 96 | + event['From'] = newEvent['caller']; |
| 97 | + event['To'] = ''; |
| 98 | + prevOwner = event['From']; |
| 99 | + curPrice = newEvent['meta']; |
| 100 | + } else if (newEvent['interaction'] === 'SEND') { |
| 101 | + event['Type'] = 'GIFT'; |
| 102 | + event['From'] = newEvent['caller']; |
| 103 | + event['To'] = newEvent['meta']; |
| 104 | + } else if (newEvent['interaction'] === 'CONSUME') { |
| 105 | + event['Type'] = 'BURNT'; |
| 106 | + event['From'] = newEvent['caller']; |
| 107 | + event['To'] = ''; |
| 108 | + } else event['Type'] = newEvent['interaction']; |
| 109 | +
|
| 110 | + // From |
| 111 | + if (!('From' in event)) event['From'] = prevOwner; |
| 112 | +
|
| 113 | + // To |
| 114 | + if (!('To' in event)) { |
| 115 | + event['To'] = newEvent['caller']; |
| 116 | + prevOwner = event['To']; |
| 117 | + } |
| 118 | +
|
| 119 | + // Amount |
| 120 | + event['Amount'] = Vue.filter('formatBalance')(curPrice, 12, 'KSM'); |
| 121 | +
|
| 122 | + // Date |
| 123 | + const date = new Date(newEvent['timestamp']); |
| 124 | + event['Date'] = this.parseDate(date); |
| 125 | + if (event['Type'] === 'SET-PRICE' || event['Type'] === 'CREATE') { |
| 126 | + this.priceData.push([date, this.formatPrice(event['Amount'])]); |
| 127 | + } |
| 128 | +
|
| 129 | + this.data.push(event); |
| 130 | + } |
| 131 | +
|
| 132 | + this.data = this.data.reverse(); |
| 133 | + this.priceData.push([ |
| 134 | + new Date(), |
| 135 | + this.formatPrice(this.data[0]['Amount']), |
| 136 | + ]); |
| 137 | + } |
| 138 | +
|
| 139 | + protected parseDate(date: Date) { |
| 140 | + const utcDate: string = date.toUTCString(); |
| 141 | + return utcDate.substring(4); |
| 142 | + } |
| 143 | +
|
| 144 | + protected formatDate(date: Date) { |
| 145 | + const yyyy = date.getUTCFullYear(); |
| 146 | + const mm = this.padDigits(date.getUTCMonth() + 1); |
| 147 | + const dd = this.padDigits(date.getUTCDate()); |
| 148 | + const hrs = this.padDigits(date.getUTCHours()); |
| 149 | + const mins = this.padDigits(date.getUTCMinutes()); |
| 150 | + const secs = this.padDigits(date.getUTCSeconds()); |
| 151 | + const YYYY_MM_DD_HRS_MINS_SECS = |
| 152 | + yyyy + '/' + mm + '/' + dd + '\n' + hrs + ':' + mins + ':' + secs; |
| 153 | + return YYYY_MM_DD_HRS_MINS_SECS; |
| 154 | + } |
| 155 | +
|
| 156 | + protected padDigits(time: number) { |
| 157 | + return time.toString().padStart(2, '0'); |
| 158 | + } |
| 159 | +
|
| 160 | + protected formatPrice(price: string) { |
| 161 | + return parseFloat(price.substring(0, 6)); |
| 162 | + } |
| 163 | +
|
| 164 | + @Watch('events') |
| 165 | + async watchEvent(newEvent: [], oldEvent: []) { |
| 166 | + // console.log(this.events) |
| 167 | + this.createTable(); |
| 168 | + } |
175 | 169 | }
|
176 |
| -
|
177 | 170 | </script>
|
178 | 171 | <style>
|
179 |
| - .short-identity__table { |
180 |
| - max-width: 50em; |
181 |
| - overflow: hidden; |
182 |
| - text-overflow: ellipsis; |
183 |
| - } |
| 172 | +.short-identity__table { |
| 173 | + max-width: 50em; |
| 174 | + overflow: hidden; |
| 175 | + text-overflow: ellipsis; |
| 176 | +} |
184 | 177 | </style>
|
0 commit comments