Browse Source

Merge pull request #290 from dtm-labs/alpha

Opt page AllTransactions
pull/294/head
yedf2 4 years ago
committed by GitHub
parent
commit
4e69f9d9df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue
  2. 2
      dtmsvr/storage/boltdb/boltdb.go

29
admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue

@ -53,15 +53,11 @@ const columns = [
} }
] ]
const pager = ref([""]) const pages = ref([''])
const currentState = ref(1) const curPage = ref(1)
const canPrev = computed(() => { const canPrev = computed(() => {
if (currentState.value === 1) { return curPage.value > 1
return false;
}
return true;
}) })
const canNext = computed(() => { const canNext = computed(() => {
@ -83,10 +79,11 @@ const queryData = (params: IListAllTransactions) => {
return listAllTransactions<Data>(params) return listAllTransactions<Data>(params)
} }
const { data, run, current, loading, pageSize } = usePagination(queryData, { const { data, run, current, loading, pageSize } = usePagination(queryData, {
defaultParams: [ defaultParams: [
{ {
limit: 100, limit: 10,
} }
], ],
pagination: { pagination: {
@ -97,25 +94,21 @@ const { data, run, current, loading, pageSize } = usePagination(queryData, {
const dataSource = computed(() => data.value?.data.transactions || []) const dataSource = computed(() => data.value?.data.transactions || [])
const handlePrevPage = () => { const handlePrevPage = () => {
currentState.value -= 1; curPage.value -= 1;
const params = { const params = {
limit: 100 limit: pageSize.value,
} position: pages.value[curPage.value]
if (pager.value[currentState.value - 1]) {
params.position = pager.value[currentState.value - 1]
} }
run(params) run(params)
} }
const handleNextPage = () => { const handleNextPage = () => {
currentState.value += 1; curPage.value += 1;
if (currentState.value >= 2) { pages.value[curPage.value] = data.value?.data.next_position
pager.value[currentState.value - 1] = data.value?.data.next_position
}
run({ run({
position: data.value?.data.next_position, position: data.value?.data.next_position,
limit: 5 limit: pageSize.value,
}) })
} }
</script> </script>

2
dtmsvr/storage/boltdb/boltdb.go

@ -276,7 +276,7 @@ func (s *Store) ScanTransGlobalStores(position *string, limit int64) []storage.T
globals := []storage.TransGlobalStore{} globals := []storage.TransGlobalStore{}
err := s.boltDb.View(func(t *bolt.Tx) error { err := s.boltDb.View(func(t *bolt.Tx) error {
cursor := t.Bucket(bucketGlobal).Cursor() cursor := t.Bucket(bucketGlobal).Cursor()
for k, v := cursor.First(); k != nil; k, v = cursor.Next() { for k, v := cursor.Seek([]byte(*position)); k != nil; k, v = cursor.Next() {
if string(k) == *position { if string(k) == *position {
continue continue
} }

Loading…
Cancel
Save