Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNS integration + fixes #220

Merged
merged 26 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8405ae8
feat: automatic update of blocks and transactions
krlz16 Apr 11, 2024
4e8446a
Merge pull request #212 from rsksmart/feat/autoupdate-blocks-txs
ezequiel-rodriguez Apr 15, 2024
03a9b13
fix: autoupdate block - dafault: true
krlz16 Apr 15, 2024
d453ac3
Merge pull request #213 from rsksmart/fix/autoupdate-blocks
ezequiel-rodriguez Apr 15, 2024
e96945d
fix: Search by multiple names was fixed
krlz16 Apr 24, 2024
261a15a
Merge branch 'develop' into fix/input-search
krlz16 Apr 24, 2024
46fa6da
fix: comments and console.logs were deleted
krlz16 May 2, 2024
251db9f
feat: integrating a new form of search in the input
krlz16 May 13, 2024
e6462bc
feat: integrate rns
jonathansmirnoff May 13, 2024
93906c3
fix: unnecessary code deleted
krlz16 May 14, 2024
cac26cf
Merge branch 'D1-1015-rsk-explorer-integration-on-input-search-new-fe…
jonathansmirnoff May 14, 2024
3e57a5e
Merge branch 'D1-1015-rsk-explorer-integration-on-input-search-new-fe…
jonathansmirnoff May 14, 2024
771bfaa
fix: delay in search
krlz16 May 15, 2024
5abc1ff
fix: do not clean the answer even if a link is not found
krlz16 May 23, 2024
1b25c01
fix: duplicate file deleted
krlz16 May 24, 2024
91cf097
fix: showing the balance view without needing to refresh
krlz16 Jun 4, 2024
4bd3a12
Merge pull request #215 from rsksmart/new-search-rns-integration
ezequiel-rodriguez Jun 7, 2024
4074bf9
Revert "Rns Integration & Search bar improvements"
ezequiel-rodriguez Jun 7, 2024
b784e93
Merge pull request #216 from rsksmart/revert-215-new-search-rns-integ…
ezequiel-rodriguez Jun 7, 2024
67a6394
fix: reload data
krlz16 Jun 7, 2024
a5fd398
Revert "Revert "Rns Integration & Search bar improvements""
ezequiel-rodriguez Jun 7, 2024
0642f47
Merge pull request #217 from rsksmart/revert-216-revert-215-new-searc…
ezequiel-rodriguez Jun 7, 2024
8d55930
fix: If the url does not have a parameter, it indicates that it is an…
krlz16 Jun 7, 2024
93d59a2
Merge pull request #218 from rsksmart/new-search-rns-integration
ezequiel-rodriguez Jun 7, 2024
c5d1264
fix: validate that the parameter has not been the same before or is null
krlz16 Jun 7, 2024
5637f21
Merge pull request #219 from rsksmart/new-search-rns-integration
ezequiel-rodriguez Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
369 changes: 230 additions & 139 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"env-cmd": "^10.1.0",
"highlight.js": "^9.18.3",
"highlightjs-solidity": "git+https://github.com/highlightjs/highlightjs-solidity.git",
"keccak": "^3.0.4",
"moment": "^2.27.0",
"socket.io-client": "^2.3.0",
"streamsaver": "^2.0.5",
Expand All @@ -36,7 +37,8 @@
"vue-hotjar": "^1.2.0",
"vue-router": "^3.4.3",
"vuex": "^3.5.1",
"vuex-router-sync": "^5.0.0"
"vuex-router-sync": "^5.0.0",
"@rsksmart/rns-resolver.js": "^1.1.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.12",
Expand Down
11 changes: 7 additions & 4 deletions src/components/DataPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export default {
data () {
return {
storedTitle: '',
storedParamAddress: null,
storedRouteName: null,
storedUrlParam: null,
PAGE_COLORS
}
},
Expand Down Expand Up @@ -300,11 +301,13 @@ export default {
const { module, action, params } = this
const key = this.reqKey
if (!module || !action) return
const paramsAddress = this.$route.params?.address
const routeName = this.$route.name
const urlParam = this.$route.params.address
// If the parameters are the same when the router changes, we do not request the address information.
if (this.storedParamAddress !== paramsAddress) {
if (this.storedRouteName !== routeName || !urlParam || this.storedRouteName !== urlParam) {
// use Date for a random info
this.storedParamAddress = paramsAddress || new Date()
this.storedRouteName = routeName || new Date()
this.storedUrlParam = urlParam
return this.fetchRouteData({ action, params, module, key })
}
},
Expand Down
24 changes: 2 additions & 22 deletions src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
</div>
</template>
<script>
import { mapState, mapGetters, mapActions } from 'vuex'
import { mapState, mapGetters } from 'vuex'
import LastBlocks from '@/components/home/Block/LastBlocks.vue'
import { ROUTES as r } from '../config/types'
import StatsContent from '@/components/home/StatsContent.vue'
import LastBlock from '@/components/home/Block/LastBlock.vue'
import TxDensityChart from '@/components/Charts/TxDensityChart.vue'
Expand All @@ -28,32 +27,13 @@ export default {
LastBlock,
TxDensityChart
},
data () {
return {
topBoxHeight: 0,
r
}
},
computed: {
...mapState({
lastBlocks: state => state.backend.lastBlocks,
autoUpdate: state => state.config.autoUpdateBlocks
lastBlocks: state => state.backend.lastBlocks
}),
...mapGetters({
pending: 'pendingBlocks',
appSize: 'getSize'
})
},
methods: {
...mapActions([
'updateBlocks',
'setAutoUpdate'
]),
setAupdate (value) {
this.updateBlocks()
this.setAutoUpdate(value)
}
}

}
</script>
168 changes: 116 additions & 52 deletions src/components/Search/CtrlSearch.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,60 @@
<template>
<div class="search-content">
<button v-if="!expandSearch" @click="setExpand" class="btn-search">
<img src="@/assets/svg/search.svg" alt="">
</button>
<button v-else class="btn-close" @click="setExpand">X</button>
<div class="content-input">
<input
class="search-input bg-primary"
type="text"
:value="value"
@input.prevent="input"
@keyup.enter="changeInput"
@keyup.stop="onKey"
:placeholder="onFocusValue ? placeholder : null"
:class="cssClass"
@focus="onFocusValue = false"
@blur="onFocusValue = true"
>
<button class="btn-clear" @click="clear" v-if="value">
x
<div class="search-container">
<div class="search-content" :class="`${onFocusValue ? 'search-content-focus' : ''}`">
<button v-if="!expandSearch" @click="setExpand" class="btn-search">
<img src="@/assets/svg/search.svg" alt="">
</button>
<Spinner v-if="isLoading" :width="20" :height="20" :border="2" />
</div>
<div class="search-results bg-secondary" v-if="results.length" ref="results">
<template v-for="(result, i) in results">
<div v-if="result.link && result.value"
:class="{ selected: selectedResult === i+1 }"
:key="`${result.value}${i}`"
:ref="`result-${i}`">
<a
:href="result.link"
@touchend.passive="gotoResult($event, i)"
@click="gotoResult($event, i)">
{{ result.name || result.value }}
</a>
<button v-else class="btn-close" @click="setExpand">X</button>
<div class="content-input">
<input
class="search-input"
type="text"
v-model="value"
ref="inputRef"
@input.prevent="handleInput"
@keyup.enter="debouncedChangeInput"
@keyup.stop="debouncedOnKey"
:placeholder="!onFocusValue ? placeholder : null"
:class="cssClass"
@focus="onFocus(true)"
@blur="isSearchPage ? onFocus(false) : null"
>
<button class="btn-clear" @click="btnClear" v-if="value">
x
</button>
<Spinner v-if="isLoading || typing" :width="20" :height="20" :border="2" />
</div>
<div class="search-results bg-secondary" v-if="value && onFocusValue && !isSearchPage && !typing && !isLoading">
<template v-if="(currentType && searchedTypes.length > 0)">
<div class="title-address capitalize">{{ currentType }}</div>
<router-link :to="`${linkToSearch}`" class="search-address">{{ value }}</router-link>
</template>
<div v-else-if="results.length" ref="results">
<div class="title-address capitalize">Result:</div>
<template v-for="(result, i) in results">
<div v-if="result.link && result.value"
:class="{ selected: selectedResult === i+1 }"
:key="`${result.value}${i}`"
:ref="`result-${i}`">
<a
:href="result.link"
@touchend.passive="gotoResult($event, i)"
@click="gotoResult($event, i)">
{{ result.name || result.value }}
</a>
</div>
</template>
</div>
<div class="no-results bg-secondary" v-else-if="onFocusValue && value && !typing && !isLoading && !isSearchPage">
<div class="title-address">No results found.</div>
</div>
</template>
</div>
</div>
<div class="search-background" v-if="onFocusValue && !isSearchPage" @click="onFocus(false)"></div>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { mapActions, mapGetters } from 'vuex'
import { clamp } from '../../lib/js/utils'
import Spinner from '../Loaders/Spinner.vue'
import { ROUTES } from '../../config/types'
Expand All @@ -57,15 +71,39 @@ export default {
resultEmitted: null,
focused: undefined,
expandSearch: false,
onFocusValue: true
onFocusValue: false,
debounceTime: 800,
typing: false
}
},
created () {
const { searchValue } = this
if (searchValue) this.value = searchValue
this.debouncedOnKey = this.debounce(this.onKey, this.debounceTime)
this.debouncedInput = this.debounce(this.input, this.debounceTime)
this.debouncedChangeInput = this.debounce(this.changeInput, this.debounceTime)
},
methods: {
...mapActions(['searchExpand', 'clearSearchedResults']),
...mapActions([
'searchExpand',
'clearSearchedResults',
'prepareSearch',
'searchTypes',
'fetchSearch'
]),
btnClear () {
this.clear()
this.$refs.inputRef.focus()
},
handleInput (event) {
this.debouncedInput(event)
this.typing = true
},
onFocus (value) {
setTimeout(() => {
this.onFocusValue = value
}, 100)
},
setExpand () {
if (window.innerWidth > 600) return
this.expandSearch = !this.expandSearch
Expand All @@ -80,26 +118,26 @@ export default {
this.selectResult(0)
const value = event.target.value
this.value = value
const typeEvent = this.value.length > 10 ? 'change' : type
this.emit(event, typeEvent, value)
this.emit(event, type, value)
this.emit(event, 'change', value)
},
emit (event, type, value) {
type = type || event.type
this.$emit(type, { value, event })
let timer = 0
if (value.includes('.rsk')) timer = 1500
setTimeout(() => {
this.typing = false
}, timer)
},
changeInput (event) {
const { fullPath } = this.$route
const vm = this
setTimeout(() => {
if (!vm.selectedResult) {
if (fullPath === vm.$route.fullPath) {
vm.onChange(event)
} else {
this.value = ''
vm.emitResult(event, null)
}
}
}, 200)
this.onFocus(false)
if (this.currentType && this.searchedTypes.length) {
this.$router.push(this.linkToSearch, () => { })
} else {
const link = `/${ROUTES.search}/${this.value}`
this.$router.push(link, () => { })
}
},
onChange (event) {
const value = this.value
Expand All @@ -109,6 +147,7 @@ export default {
this.selectedResult = result
},
gotoResult (event, key) {
this.onFocus(false)
const result = this.results[key]
const { link } = result
if (link) this.$router.push(link)
Expand Down Expand Up @@ -138,19 +177,44 @@ export default {
},
onShowMore (event) {
this.emit(event, 'showMore', this.value)
},
debounce (func, wait, immediate) {
let timeout
return function () {
const context = this
const args = arguments
const later = function () {
timeout = null
if (!immediate) func.apply(context, args)
}
const callNow = immediate && !timeout
clearTimeout(timeout)
timeout = setTimeout(later, wait)
if (callNow) func.apply(context, args)
}
}
},
computed: {
...mapGetters({
searchedTypes: 'searchedTypes',
currentType: 'searchedType',
linkToSearch: 'linkToSearch'
}),
totalResults () {
const { results } = this
return (results) ? results.length : 0
},
isLoading () {
return !!this.loading
},
isSearchPage () {
return this.$route.name.toLowerCase() === ROUTES.search.toLowerCase()
}
},
watch: {
$route () {
this.$refs.inputRef.blur()
this.onFocus(false)
if (this.$route.name.toLowerCase() !== ROUTES.search.toLowerCase()) {
this.clearSearchedResults()
this.value = ''
Expand Down
22 changes: 3 additions & 19 deletions src/components/Search/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
</div>
</template>
<script>
import { ROUTES as r } from '../../config/types'
import { mapState, mapGetters, mapActions } from 'vuex'
import CtrlSearch from './CtrlSearch.vue'
// const RESULTS_LENGTH = 10
export default {
name: 'search-box',
components: {
Expand All @@ -24,7 +22,7 @@ export default {
data () {
return {
value: undefined,
msg: 'Search by address, block, tx, token name',
msg: 'Search by address, block, tx, token name, rns domain',
msgTimeout: null,
requestingTimeout: null
}
Expand Down Expand Up @@ -77,26 +75,16 @@ export default {
this.clearSearchedResults()
},
goTo ({ type, value }) {
const link = this.getSearchLink()({ type, value })
if (!link) return
this.clearRequests()
this.$router.push(link, () => { })
},
goToSearchPage (value) {
const link = `/${r.search}/${value}`
this.$router.push(link, () => { })
this.getSearchLink()({ type, value })
},

setValue (value) {
this.value = value
if (this.isSearchPage) {
history.pushState({}, document.title, value)
}
},

onResult ({ event, value }) {
this.setValue(value)
// if (value) this.clearRequests()
},
onInput ({ event, value }) {
this.clearRequests()
Expand All @@ -108,9 +96,7 @@ export default {
await this.prepareSearch({ value })
value = this.searched
const { types } = this
if (!types || !types.length) {
return this.goToSearchPage(value)
} else if (types.length === 1) {
if (types.length === 1) {
const type = types[0]
return this.goTo({ type, value })
} else {
Expand All @@ -120,8 +106,6 @@ export default {
// redirect when there is only one result
if (results && results.length === 1) {
return this.goTo(results[0])
} else {
this.goToSearchPage(value)
}
}
},
Expand Down
Loading
Loading