Skip to content

Commit

Permalink
Merge pull request #147 from Progi1984/pagination
Browse files Browse the repository at this point in the history
Server side pagination
  • Loading branch information
Progi1984 authored Jan 15, 2025
2 parents 5f2561d + 8c0785a commit 9f06573
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 63 deletions.
2 changes: 1 addition & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const pkg = require('./package')

module.exports = {
mode: 'universal',
ssr: true,
env: {
ga: process.env.QANB_GA || 'UA-XXXXXXXX-X',
DOMAIN_URL: process.env.QANB_API_DOMAIN || 'http://www.qa.local/'
Expand Down
42 changes: 3 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 27 additions & 23 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@
<div class="select">
<p class="select-label">Version</p>
<v-select
:items="['All', 'develop', '9.0.x', '8.2.x', '8.1.x', '8.0.x', '1.7.8.x', '1.7.7.x']"
:items="[
'All',
'develop',
'9.0.x',
'8.2.x',
'8.1.x',
'8.0.x',
'1.7.8.x',
'1.7.7.x'
]"
label="All"
:value="''"
append-icon="keyboard_arrow_down"
Expand All @@ -50,7 +59,8 @@
:items="files"
:headers="isMobile ? [] : headers"
:pagination.sync="pagination"
:rows-per-page-items="[20, 50, { text: 'All', value: -1 }]"
:rows-per-page-items="[20, 50, 100]"
:total-items="filesLength"
:footer-props="{
showFirstLastPage: true,
firstIcon: 'mdi-arrow-collapse-left',
Expand Down Expand Up @@ -530,6 +540,7 @@
data: {},
isMobile: false,
files: [],
filesLength: 0,
loading: true,
paramVersion: this.$route.query.version ?? 'All',
paramPlatform: this.$route.query.platform ?? 'All',
Expand Down Expand Up @@ -617,10 +628,13 @@
paramPlatform() {
this.updateFilers()
},
pagination() {
this.updatePagination()
pagination: {
handler() {
this.updatePagination()
},
deep: true
},
'$route.query': function(query) {
'$route.query': function $routeQuery(query) {
this.paramCampaign = query.campaign ?? 'All'
this.paramVersion = query.version ?? 'All'
this.paramPlatform = query.platform ?? 'All'
Expand Down Expand Up @@ -672,40 +686,29 @@
},
async getSuites() {
this.loading = true
let url = `${this.$store.state.env.domain}${URLS.reports}`
let hasParams = false
let url = `${this.$store.state.env.domain}${URLS.reports}?page=${this.pagination.page}&limit=${this.pagination.rowsPerPage}`
if (this.paramPlatform !== 'All') {
url = `${url}?filter_platform[0]=${this.paramPlatform}`
hasParams = true
url = `${url}&filter_platform[0]=${this.paramPlatform}`
}
if (this.paramCampaign !== 'All') {
if (hasParams) {
url = `${url}&filter_campaign[0]=${this.paramCampaign}`
} else {
url = `${url}?filter_campaign[0]=${this.paramCampaign}`
}
hasParams = true
url = `${url}&filter_campaign[0]=${this.paramCampaign}`
}
if (this.paramVersion !== 'All') {
if (hasParams) {
url = `${url}&filter_version[0]=${this.paramVersion}`
} else {
url = `${url}?filter_version[0]=${this.paramVersion}`
}
url = `${url}&filter_version[0]=${this.paramVersion}`
}
const { data } = await this.$axios.get(url, {
crossdomain: true
})
this.filesLength = data.count
if (this.isMobile) {
this.files = data.filter(e => e.id)
this.files = data.reports.filter(e => e.id)
} else {
this.files = data
this.files = data.reports
}
this.loading = false
Expand Down Expand Up @@ -741,6 +744,7 @@
: this.pagination.sortBy
}
this.$router.push({ query: pagination })
this.getSuites()
}
}
}
Expand Down

0 comments on commit 9f06573

Please sign in to comment.