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

2
dtmsvr/storage/boltdb/boltdb.go

@ -276,7 +276,7 @@ func (s *Store) ScanTransGlobalStores(position *string, limit int64) []storage.T
globals := []storage.TransGlobalStore{}
err := s.boltDb.View(func(t *bolt.Tx) error {
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 {
continue
}

Loading…
Cancel
Save