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

feat: Filter transactions table by date #993

Open
wants to merge 57 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b048959
add basic UI
janmichek Nov 14, 2024
6fd2312
watch selected range value
janmichek Nov 14, 2024
00fb597
concat url string for combined parameter
janmichek Nov 14, 2024
e216c2f
style UI
janmichek Nov 14, 2024
2dfaa39
fix combining queries
janmichek Nov 15, 2024
338560f
fix passing parameter
janmichek Nov 15, 2024
e2b9640
style UI
janmichek Nov 18, 2024
f4a9421
todo move solution to store
janmichek Nov 19, 2024
bdae425
todo move solution to store
janmichek Nov 19, 2024
6d5e3c2
todo move solution to store
janmichek Nov 19, 2024
1296b4c
fix combine filtering
janmichek Nov 20, 2024
44a46c4
set parameters to components from directly pasted url
janmichek Nov 20, 2024
82e877a
fix initial state
janmichek Nov 20, 2024
a3adf28
cleanup code
janmichek Nov 22, 2024
e98fdb7
names refactoring
janmichek Nov 22, 2024
32f6dbd
names refactoring
janmichek Nov 22, 2024
4d5a956
add cancel button
janmichek Nov 22, 2024
b870edf
set component state after nevigating throught direct link
janmichek Nov 22, 2024
748e3b5
enable clear date
janmichek Dec 12, 2024
b75c564
increase test timeout
janmichek Dec 16, 2024
86f1e09
fix setting time parameters from url
janmichek Dec 17, 2024
d586ce7
fix initialize table
janmichek Dec 17, 2024
4009485
fix combine parameters
janmichek Dec 18, 2024
0eb2132
resolve edge casees of combining parameters
janmichek Dec 19, 2024
038bdcd
fix code style
janmichek Dec 19, 2024
a367f13
add e2e test before refactoring
janmichek Dec 19, 2024
51f3ea4
components refactoring
janmichek Dec 19, 2024
c5aa757
components refactoring
janmichek Dec 19, 2024
1cb9174
store refactoring
janmichek Dec 19, 2024
cca00fc
edit tx counter
janmichek Dec 19, 2024
e7ad96a
improve tests
janmichek Dec 20, 2024
c303599
refactor store
janmichek Dec 20, 2024
4f65202
refactor store
janmichek Dec 20, 2024
ed5d713
improve test precision
janmichek Dec 20, 2024
ab2a6d9
rename variables
janmichek Dec 20, 2024
16f51f5
move formatting to store
janmichek Dec 21, 2024
4e1bd02
move formatting to store
janmichek Dec 21, 2024
dfd2010
format datetime value inside component
janmichek Dec 25, 2024
b911c14
rename variable
janmichek Dec 25, 2024
7037d0b
Merge branch 'develop' into Filter-transactions-table-by-date
janmichek Dec 25, 2024
be3902d
simplify formatting
janmichek Dec 25, 2024
acb327b
refactor formatting
janmichek Dec 25, 2024
7e72ace
ui style fixes
janmichek Dec 26, 2024
623d2e7
fix code style
janmichek Dec 26, 2024
7d568a2
simplify parameters
janmichek Dec 26, 2024
c7c9611
simplify parameters
janmichek Dec 26, 2024
16343fd
fix styles
janmichek Dec 26, 2024
5410db1
formatting fixes
janmichek Dec 27, 2024
4f10027
tod fix reseting scope
janmichek Dec 27, 2024
78bfc04
use useVModel
janmichek Dec 31, 2024
506199e
reuse clear function
janmichek Dec 31, 2024
7b5bcdb
code cleanup
janmichek Jan 1, 2025
9bcddb1
code cleanup
janmichek Jan 1, 2025
b08fa0b
fix test to pass
janmichek Jan 2, 2025
4c2a907
fix test to pass
janmichek Jan 2, 2025
573795f
Merge branch 'develop' into Filter-transactions-table-by-date
janmichek Jan 14, 2025
79d3bb0
fixes after rebase
janmichek Jan 14, 2025
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
2 changes: 1 addition & 1 deletion cypress/e2e/app/charts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('charts', () => {
cy.visit('/charts/transactions')
cy.get('.charts-navigation__link').should('be.visible')
cy.get('.chart-controls__button').should('be.visible')
cy.get('.range-picker').should('be.visible')
cy.get('.scope-picker').should('be.visible')
cy.get('.transactions-chart-panel__select').should('be.visible')
cy.get('.line-chart canvas').should('be.visible')
cy.get('.chart-controls__button').should('be.visible')
Expand Down
57 changes: 57 additions & 0 deletions cypress/e2e/app/transactions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,61 @@ describe('transactions', () => {
})
})
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was really hard to achive, hence is fully tested

it('should select date', () => {
cy.visit('/transactions')

cy.get('.paginated-content .scope-picker').click()
cy.get('.dp__today').click()
cy.get('.dp__today').parent().prev().click()

cy.url().should('include', 'scope=')
cy.get('.paginated-content .dp__input').should('not.have.value', '')
})
it('should select type', () => {
cy.visit('/transactions')

cy.get('.paginated-content .multiselect').click()
cy.contains('.paginated-content .multiselect__option', 'SpendTx').click()

cy.url().should('include', 'txType=spend')
cy.get('.paginated-content .multiselect__single').contains('SpendTx')
})

it('should select combined parameters', () => {
cy.visit('/transactions')

cy.get('.paginated-content .scope-picker').click()
cy.get('.dp__today').click()
cy.get('.dp__today').parent().prev().click()

cy.get('.paginated-content .multiselect').click()
cy.contains('.paginated-content .multiselect__option', 'NameClaimTx').click()

cy.url().should('include', 'txType=name_claim').should('include', 'scope=')
cy.get('.paginated-content .multiselect__single').contains('NameClaimTx')
cy.get('.paginated-content .dp__input').should('not.have.value', '')
})

it('should filter by combining parameters from direct URL access', () => {
cy.visit('/transactions?scope=1733871600-1733958000&txType=spend')

cy.get('.paginated-content .multiselect__single').contains('SpendTx')
cy.get('.transactions-table tbody tr').should('have.length', 10)
cy.get('.transactions-table tbody tr').contains('td', 'SpendTx').should('have.length', 1)
cy.get('.paginated-content .dp__input')
.should('have.value', '12/11/2024 - 12/12/2024')
})

it('should cancel filtering and clear url', () => {
cy.visit('/transactions?scope=1733871600-1733958000&txType=contract_create')

cy.get('.paginated-content .multiselect').click()
cy.contains('.paginated-content .multiselect__option', 'All Types').click()
cy.get('.dp--clear-btn').click()

cy.url().should('eq', Cypress.config().baseUrl + '/transactions')
cy.get('.paginated-content .multiselect__single').contains('All Types')
cy.get('.paginated-content .dp__input').should('have.value', '')
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"reinstall": "rm -rf node_modules/ && yarn cache clean && yarn install",
"reset": "yarn reinstall && yarn dev",
"e2e:run": "cypress run",
"e2e:open": "cypress open"
"e2e": "cypress open"
},
"dependencies": {
"@aeternity/aepp-sdk": "14.0.0",
Expand Down
18 changes: 9 additions & 9 deletions src/components/AccountsChartPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<line-chart
:data="accountsStatistics"
:interval="range.interval"/>
:interval-by="range.intervalBy"/>

<chart-controls
v-model="range"
Expand All @@ -26,7 +26,7 @@
import { storeToRefs } from 'pinia'
import { chartsHints } from '@/utils/hints/chartsHints'
import { useChartsStore } from '@/stores/charts'
import { CHART_INTERVALS_PRESETS_OPTIONS } from '~/utils/constants'
import { CHART_SCOPE_PRESETS_OPTIONS } from '~/utils/constants'

const chartsStore = useChartsStore()
const { accountsStatistics } = storeToRefs(chartsStore)
Expand All @@ -35,33 +35,33 @@ const { fetchAccountsStatistics } = chartsStore
const props = defineProps({
preselectedRange: {
type: Object,
default: CHART_INTERVALS_PRESETS_OPTIONS[4],
default: CHART_SCOPE_PRESETS_OPTIONS[4],
},
})

const range = ref(props.preselectedRange)

await useAsyncData(async() => {
await loadHashrateStatistics()
await loadAccountStatistics()
return true
})

if (process.client) {
watch([range], async() => {
await loadHashrateStatistics()
await loadAccountStatistics()
})
}

async function loadHashrateStatistics() {
async function loadAccountStatistics() {
await fetchAccountsStatistics(
range.value.interval,
range.value.intervalBy,
range.value.limit,
range.value.customInterval)
range.value.scope)
}
</script>

<style scoped>
.accounts-chart-pane__controls {
.accounts-chart-panel__controls {
margin-top: var(--space-4);
}
</style>
8 changes: 3 additions & 5 deletions src/components/AppSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
:searchable="searchable"
:hide-selected="hideSelected"
:preselect-first="preselectFirst"
:class="[
size ? `multiselect--${size}` : null,
]">
:class="[ size ? `multiselect--${size}` : null]">
<template
v-for="(_, slot) of $slots"
#[slot]="scope">
Expand Down Expand Up @@ -184,7 +182,7 @@ const selectedValue = useVModel(props, 'modelValue', emit)

&--sm {
.multiselect__tags {
min-height: 28px;
min-height: 31px;
padding: 0 var(--space-6) 0 var(--space-1);
}

Expand All @@ -199,7 +197,7 @@ const selectedValue = useVModel(props, 'modelValue', emit)
}

.multiselect__select {
height: 29px;
height: 32px;
}
}
}
Expand Down
41 changes: 20 additions & 21 deletions src/components/ChartControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
<div>
<div class="chart-controls__container">
<app-chip
v-for="option in CHART_INTERVALS_PRESETS_OPTIONS"
v-for="option in CHART_SCOPE_PRESETS_OPTIONS"
:key="option.label"
class="chart-controls__button"
:variant="isPresetSelected(option) ? 'error' : 'secondary'"
@click="selectPreset(option)">
{{ option.label }}
</app-chip>
<range-picker
:is-range-selected="isCustomIntervalSelected"
@updated="selectCustomInterval"/>

<scope-picker
:is-scope-selected="isCustomScopeSelected"
@updated="selectCustomScope"/>
</div>
</div>
</template>
Expand All @@ -23,32 +24,30 @@ const emit = defineEmits(['update:modelValue'])

const props = defineProps({
modelValue: {
type: Number,
default: 0,
type: Object,
default: null,
},
})

const selectedRange = useVModel(props, 'modelValue', emit)
const selectedScope = useVModel(props, 'modelValue', emit)

const isCustomIntervalSelected = computed(() =>
Object.keys(selectedRange.value).includes('customInterval'))
const isCustomScopeSelected = computed(() => Object.keys(selectedScope.value).includes('scope'))

function isPresetSelected(option) {
return selectedRange.value.label === option.label
function selectCustomScope(scope) {
selectedScope.value = {
scope: {
minStart: scope[0],
maxStart: scope[1],
},
}
}

function selectPreset(option) {
selectedRange.value = option
function isPresetSelected(option) {
return selectedScope.value.label === option.label
}

function selectCustomInterval(dateCustomInterval) {
const customInterval = {
customInterval: {
minStart: dateCustomInterval[0].toISOString().split('T')[0],
maxStart: dateCustomInterval[1].toISOString().split('T')[0],
},
}
selectedRange.value = customInterval
function selectPreset(option) {
selectedScope.value = option
}

</script>
Expand Down
11 changes: 5 additions & 6 deletions src/components/ContractsChartPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<line-chart
:data="contractsStatistics"
:interval="range.interval"/>
:interval-by="range.intervalBy"/>

<chart-controls
v-model="range"
Expand All @@ -23,7 +23,7 @@
import { storeToRefs } from 'pinia'
import { useChartsStore } from '@/stores/charts'
import LineChart from '@/components/LineChart'
import { CHART_INTERVALS_PRESETS_OPTIONS } from '~/utils/constants'
import { CHART_SCOPE_PRESETS_OPTIONS } from '@/utils/constants'

const chartsStore = useChartsStore()
const { contractsStatistics } = storeToRefs(chartsStore)
Expand All @@ -32,7 +32,7 @@ const { fetchContractsStatistics } = chartsStore
const props = defineProps({
preselectedRange: {
type: Object,
default: CHART_INTERVALS_PRESETS_OPTIONS[4],
default: CHART_SCOPE_PRESETS_OPTIONS[4],
},
})

Expand All @@ -51,11 +51,10 @@ if (process.client) {

async function loadContractsStatistics() {
await fetchContractsStatistics(
range.value.interval,
range.value.intervalBy,
range.value.limit,
range.value.customInterval)
range.value.scope)
}

</script>

<style scoped>
Expand Down
10 changes: 5 additions & 5 deletions src/components/DifficultyChartPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<line-chart
:data="difficultyStatistics"
:interval="range.interval"/>
:interval-by="range.intervalBy"/>

<chart-controls
v-model="range"
Expand All @@ -22,13 +22,13 @@
<script setup>
import { storeToRefs } from 'pinia'
import { useChartsStore } from '@/stores/charts'
import { CHART_INTERVALS_PRESETS_OPTIONS } from '@/utils/constants'
import { CHART_SCOPE_PRESETS_OPTIONS } from '@/utils/constants'

const chartsStore = useChartsStore()
const { difficultyStatistics } = storeToRefs(chartsStore)
const { fetchDifficultyStatistics } = chartsStore

const range = ref(CHART_INTERVALS_PRESETS_OPTIONS[4])
const range = ref(CHART_SCOPE_PRESETS_OPTIONS[4])

await useAsyncData(async() => {
await loadDifficultytatistics()
Expand All @@ -43,9 +43,9 @@ if (process.client) {

async function loadDifficultytatistics() {
await fetchDifficultyStatistics(
range.value.interval,
range.value.intervalBy,
range.value.limit,
range.value.customInterval)
range.value.scope)
}
</script>

Expand Down
19 changes: 11 additions & 8 deletions src/components/HashrateChartPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,29 @@

<line-chart
:data="hashrateStatistics"
:interval="range.interval"/>
:interval-by="range.intervalBy"/>

<chart-controls
v-model="range"
class="hashrate-chart-panel__controls u-hidden-desktop"/>
:interval="range.interval"/>

class="hashrate-chart-panel__controls u-hidden-desktop"/>
</app-panel>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { useChartsStore } from '@/stores/charts'
import { CHART_SCOPE_PRESETS_OPTIONS } from '@/utils/constants'

const chartsStore = useChartsStore()
const { hashrateStatistics } = storeToRefs(chartsStore)
const { fetchHashrateStatistics } = chartsStore

const range = ref(CHART_INTERVALS_PRESETS_OPTIONS[4])
const range = ref(CHART_SCOPE_PRESETS_OPTIONS[4])

await useAsyncData(async() => {
await loadHashratetatistics()
await loadHashrateStatistics()
return true
})

Expand All @@ -40,16 +43,16 @@ if (process.client) {
})
}

async function loadHashratetatistics() {
async function loadHashrateStatistics() {
await fetchHashrateStatistics(
range.value.interval,
range.value.intervalBy,
range.value.limit,
range.value.customInterval)
range.value.scope)
}
</script>

<style scoped>
.hashrate-chart-pane__controls {
.hashrate-chart-panel__controls {
margin-top: var(--space-4);
}
</style>
Loading
Loading