-
Notifications
You must be signed in to change notification settings - Fork 1
/
tab-bitcoin.vue
116 lines (105 loc) · 2.56 KB
/
tab-bitcoin.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
<div class="my-wrapper-block">
<div class="d-flex flex-column align-center">
<div class="display-1 modt my-title mt-5 mb-2">{{ title }}</div>
<div class="subtitle-1 modt my-subtitle mb-5">
Bitcoin Transactions Real time from
<a href="https://www.blockchain.com/api/api_websocket"
>blockchain.com</a
>
</div>
<div class="d-flex justify-space-between my-wrapper my-4">
<div class="d-flex flex-row"></div>
<div class="d-flex flex-row justify-end">
<div id="select-field">
<v-select
v-model="fieldSelected"
:items="fieldOptions"
label="Select Transaction Attribute"
outlined
dense
class="my-square-box"
></v-select>
</div>
</div>
</div>
<PlotBitcoin />
</div>
</div>
</template>
<script>
import { capitalCase } from 'change-case';
import PlotBitcoin from '~/components/tab-bitcoin-plot.vue';
import { getStateFromUrl, updateStateInUrl } from '~/js/generic/app-state';
import log from '~/js/generic/log';
export default {
name: 'TabBitcoin',
components: { PlotBitcoin },
props: {},
data() {
return {
dateTime: new Date(),
fieldSelected: null,
objFieldOptions: {
size: 'TX Size',
tcPct: 'TX Transaction Fee (% Value)',
valueEUR: 'TX Value in EUR'
},
mounted: true
};
},
computed: {
title() {
return capitalCase('bitcoin transactions');
},
fieldOptions() {
return Object.entries(this.objFieldOptions).map((e) => ({
value: e[0],
text: e[1]
}));
}
},
watch: {
fieldSelected: {
handler(newVal, oldVal) {
log.watchStart(this, 'fieldSelected', [newVal, oldVal]);
if (this.fieldSelected) this.updateState();
},
immediate: true
}
},
mounted() {
const state = getStateFromUrl(this);
if (state.bitcoin) {
this.fieldSelected = state.bitcoin.fieldSelected;
} else {
this.fieldSelected = 'size';
}
},
methods: {
updateState() {
const fieldSelected = this.fieldSelected;
log.methodStart(this, 'updateState', this.fieldSelected);
updateStateInUrl({
that: this,
update: { bitcoin: { fieldSelected } }
});
}
}
};
</script>
<style lang="scss" scoped>
.my-wrapper-block {
padding-left: 50px;
padding-right: 50px;
}
.my-wrapper {
width: 900px;
}
#select-field {
width: 300px;
}
.my-square-box {
border-radius: 0;
}
</style>