Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tomochain/tomo-explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhson1085 committed Sep 20, 2018
2 parents 80f8db2 + 21f8316 commit 975cdde
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 36 deletions.
66 changes: 58 additions & 8 deletions client/pages/address/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,38 @@
</div>
</div>

<b-tabs class="tomo-tabs">
<b-tabs
ref="allTabs"
v-model="tabIndex"
class="tomo-tabs">
<b-tab
:title="'Transactions (' + txsCount + ')'">
id="transactions"
:title="'Transactions (' + txsCount + ')'"
href="#transactions"
@click="onClick">
<table-tx
:address="hash"
:page="this"/>
</b-tab>
<b-tab
v-if="!address.isContract"
:title="'Mined Blocks (' + blocksCount + ')'">
:title="'Mined Blocks (' + blocksCount + ')'"
href="#minedBlocks"
@click="onClick">
<table-tx-by-account :page="this"/>
</b-tab>
<b-tab
v-if="address && address.hashTokens"
:title="'Token Holding (' + tokensCount + ')'">
:title="'Token Holding (' + tokensCount + ')'"
@click="onClick">
<table-tokens-by-account
:address="hash"
:page="this"/>
</b-tab>
<b-tab
v-if="address && address.isContract"
title="Code"
href="#code"
@click="refreshCodemirror">
<section v-if="smartContract">
<h5 class="mb-4">
Expand Down Expand Up @@ -227,18 +237,24 @@
</b-tab>
<b-tab
v-if="address && address.isContract && smartContract"
title="Read Contract">
title="Read Contract"
href="readContract"
@click="onClick">
<read-contract/>
</b-tab>
<b-tab
:title="'Events (' + eventsCount + ')'">
:title="'Events (' + eventsCount + ')'"
href="#events"
@click="onClick">
<table-event
:address="hash"
:page="this"/>
</b-tab>
<b-tab
v-if="hasReward && !address.isContract"
:title="'Rewards (' + rewardTime + ')'">
:title="'Rewards (' + rewardTime + ')'"
href="#rewards"
@click="onClick">
<table-reward
:address="hash"
:page="this"/>
Expand Down Expand Up @@ -284,7 +300,8 @@ export default {
tokensCount: 0,
loading: true,
hasReward: true,
rewardTime: 0
rewardTime: 0,
tabIndex: 0
}),
computed: {
usdPrice () {
Expand All @@ -298,12 +315,24 @@ export default {
]
}
},
watch: {
$route (to, from) {
if (window.location.hash) {
this.updateHashChange()
}
}
},
created () {
let hash = this.$route.params.slug
if (hash) {
this.hash = hash
}
},
updated () {
if (window.location.hash) {
this.updateHashChange()
}
},
mounted () {
let self = this
Expand Down Expand Up @@ -341,6 +370,7 @@ export default {
}
}
})
this.onClick()
},
copyCode (e) {
let id = e.trigger.parentNode.id
Expand Down Expand Up @@ -381,6 +411,26 @@ export default {
? '<i class="fa fa-adjust mr-1"></i> Light Mode' : '<i class="fa fa-adjust mr-1"></i> Dark Mode'
mode = (mode === 'light') ? 'dark' : 'light'
e.target.setAttribute('data-mode', mode)
},
updateHashChange () {
const allTabs = this.$refs.allTabs
if (this.$route.hash) {
allTabs.tabs.forEach((i, index) => {
if (i.href === this.$route.hash) {
this.tabIndex = index
return
}
return true
})
}
},
onClick () {
const allTabs = this.$refs.allTabs
if (allTabs) {
const value = this.tabIndex
const location = window.location
location.hash = allTabs.tabs[value].href
}
}
}
}
Expand Down
48 changes: 44 additions & 4 deletions client/pages/blocks/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,23 @@
</div>
</div>

<b-tabs class="tomo-tabs">
<b-tabs
ref="allTabs"
v-model="tabIndex"
class="tomo-tabs">
<b-tab
:title="'Transactions (' + txsCount + ')'">
:title="'Transactions (' + txsCount + ')'"
href="#transactions"
@click="onClick">
<table-tx
:block="number"
:block_timestamp="block.timestamp"
:page="this"/>
</b-tab>
<b-tab
:title="'BlockSigner (' + blockSignerCount + ')'">
:title="'BlockSigner (' + blockSignerCount + ')'"
href="#blockSigner"
@click="onClick">
<block-signer
:block="number"
:page="this"/>
Expand Down Expand Up @@ -211,9 +218,20 @@ export default {
timestamp_moment: null,
loading: true,
txsCount: 0,
blockSignerCount: 0
blockSignerCount: 0,
tabIndex: 0
}
},
watch: {
$route (to, from) {
if (window.location.hash) {
this.updateHashChange()
}
}
},
updated () {
this.updateHashChange()
},
created () {
let number = this.$route.params.slug
if (number) {
Expand All @@ -238,6 +256,28 @@ export default {
this.timestamp_moment = `${moment.fromNow()} <small>(${moment.format('lll')} +UTC)</small>`
self.loading = false
},
methods: {
updateHashChange () {
const allTabs = this.$refs.allTabs
if (this.$route.hash) {
allTabs.tabs.forEach((i, index) => {
if (i.href === this.$route.hash) {
this.tabIndex = index
return
}
return true
})
}
},
onClick () {
const allTabs = this.$refs.allTabs
if (allTabs) {
const value = this.tabIndex
const location = window.location
location.hash = allTabs.tabs[value].href
}
}
}
}
</script>
52 changes: 48 additions & 4 deletions client/pages/tokens/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,22 @@

<b-row>
<b-col>
<b-tabs class="tomo-tabs">
<b-tab :title="'Token Transfers (' + tokenTxsCount + ')'">
<b-tabs
ref="allTabs"
v-model="tabIndex"
class="tomo-tabs">
<b-tab
:title="'Token Transfers (' + tokenTxsCount + ')'"
href="#tokenTransfers"
@click="onClick">
<table-token-tx
:token="hash"
:page="this"/>
</b-tab>
<b-tab :title="'Token Holders (' + holdersCount + ')'">
<b-tab
:title="'Token Holders (' + holdersCount + ')'"
href="#tokenHolders"
@click="onClick">
<table-token-holder
:address="hash"
:page="this"/>
Expand Down Expand Up @@ -105,12 +114,25 @@ export default {
symbol: null,
loading: true,
tokenTxsCount: 0,
holdersCount: 0
holdersCount: 0,
tabIndex: 0
}
},
watch: {
$route (to, from) {
if (window.location.hash) {
this.updateHashChange()
}
}
},
created () {
this.hash = this.$route.params.slug
},
updated () {
if (window.location.hash) {
this.updateHashChange()
}
},
async mounted () {
let self = this
Expand All @@ -128,6 +150,28 @@ export default {
self.symbol = data.symbol
self.loading = false
},
methods: {
updateHashChange () {
const allTabs = this.$refs.allTabs
if (this.$route.hash) {
allTabs.tabs.forEach((i, index) => {
if (i.href === this.$route.hash) {
this.tabIndex = index
return
}
return true
})
}
},
onClick () {
const allTabs = this.$refs.allTabs
if (allTabs) {
const value = this.tabIndex
const location = window.location
location.hash = allTabs.tabs[value].href
}
}
}
}
</script>
51 changes: 47 additions & 4 deletions client/pages/txs/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@

<b-row>
<b-col>
<b-tabs class="tomo-tabs">
<b-tab title="Overview">
<b-tabs
ref="allTabs"
v-model="tabIndex"
class="tomo-tabs">
<b-tab
title="Overview"
href="#overview"
@click="onClick">
<div class="card tomo-card tomo-card--transaction">
<div class="tomo-card__body">
<table
Expand Down Expand Up @@ -182,7 +188,9 @@
</b-tab>
<b-tab
v-if="eventsCount > 0"
:title="'Events (' + eventsCount + ')'">
:title="'Events (' + eventsCount + ')'"
href="#events"
@click="onClick">
<table-event
:tx="hash"
:page="this"/>
Expand Down Expand Up @@ -213,7 +221,20 @@ export default {
hash: null,
tx: null,
eventsCount: 0,
loading: true
loading: true,
tabIndex: 0
}
},
watch: {
$route (to, from) {
if (window.location.hash) {
this.updateHashChange()
}
}
},
updated () {
if (window.location.hash) {
this.updateHashChange()
}
},
created () {
Expand All @@ -236,6 +257,28 @@ export default {
this.tx.timestamp_moment = `${moment.fromNow()} <small>(${moment.format('lll')} +UTC)</small>`
self.loading = false
},
methods: {
updateHashChange () {
const allTabs = this.$refs.allTabs
if (this.$route.hash) {
allTabs.tabs.forEach((i, index) => {
if (i.href === this.$route.hash) {
this.tabIndex = index
return
}
return true
})
}
},
onClick () {
const allTabs = this.$refs.allTabs
if (allTabs) {
const value = this.tabIndex
const location = window.location
location.hash = allTabs.tabs[value].href
}
}
}
}
</script>
Loading

0 comments on commit 975cdde

Please sign in to comment.