TT#120900 CSC: CallRecording - Integrate server side pagination

Change-Id: If64a6291671e205a0b3f109260fd599b5dee87bd
mr9.5.2
Carlo Venusino 4 years ago
parent 51e02f9dc6
commit cd6e98a14a

@ -561,22 +561,23 @@ export async function getBrandingLogo (subscriberId) {
} }
} }
export async function getRecordings (subscriberId) { export async function getRecordings (options) {
let retArr = [] const data = { recordings: [], total_count: 0 }
const res = await Vue.http.get('api/callrecordings/', { const res = await Vue.http.get('api/callrecordings/', {
subscriber_id: subscriberId params: options
}) })
if (res.body.total_count > 0) { if (res.body.total_count > 0) {
const recordings = getJsonBody(res.body)._embedded['ngcp:callrecordings'] const recordings = getJsonBody(res.body)._embedded['ngcp:callrecordings']
retArr = recordings.map(recording => { data.recordings = recordings.map(recording => {
return { return {
id: recording.id, id: recording.id,
time: recording.start_time, time: recording.start_time,
files: [] files: []
} }
}) })
data.total_count = res.body.total_count
} }
return retArr return data
} }
export async function getRecordingStreams (recId) { export async function getRecordingStreams (recId) {

@ -9,6 +9,9 @@
:columns="columns" :columns="columns"
:loading="$wait.is('csc-call-recordings')" :loading="$wait.is('csc-call-recordings')"
row-key="name" row-key="name"
flat
:pagination.sync="pagination"
@request="fetchPaginatedRecordings"
> >
<template v-slot:header="props"> <template v-slot:header="props">
<q-tr :props="props"> <q-tr :props="props">
@ -194,7 +197,14 @@ export default {
], ],
data: [], data: [],
rowStatus: [] rowStatus: [],
pagination: {
sortBy: 'id',
descending: false,
page: 1,
rowsPerPage: 5,
rowsNumber: 0
}
} }
}, },
computed: { computed: {
@ -214,7 +224,9 @@ export default {
} }
}, },
async mounted () { async mounted () {
await this.fetchRecordings() await this.fetchPaginatedRecordings({
pagination: this.pagination
})
}, },
methods: { methods: {
...mapWaitingActions('callRecordings', { ...mapWaitingActions('callRecordings', {
@ -223,6 +235,17 @@ export default {
deleteRecording: 'csc-call-recordings', deleteRecording: 'csc-call-recordings',
downloadRecording: 'csc-call-recordings' downloadRecording: 'csc-call-recordings'
}), }),
async fetchPaginatedRecordings (props) {
const { page, rowsPerPage, sortBy, descending } = props.pagination
const count = await this.fetchRecordings({
page: page,
rows: rowsPerPage,
order_by: sortBy,
order_by_direction: descending ? 'desc' : 'asc'
})
this.pagination = { ...props.pagination }
this.pagination.rowsNumber = count
},
confirmRowDeletion (rowId) { confirmRowDeletion (rowId) {
this.$refs['confirmDelete-' + rowId].open() this.$refs['confirmDelete-' + rowId].open()
}, },
@ -230,7 +253,9 @@ export default {
try { try {
await this.deleteRecording(rowId) await this.deleteRecording(rowId)
showToast(this.$t('Recording successfully deleted')) showToast(this.$t('Recording successfully deleted'))
await this.fetchRecordings() await this.fetchPaginatedRecordings({
pagination: this.pagination
})
} catch (err) { } catch (err) {
showGlobalError(this.$t('Something went wrong. Please retry later')) showGlobalError(this.$t('Something went wrong. Please retry later'))
} }

@ -23,9 +23,13 @@ export default {
} }
}, },
actions: { actions: {
async fetchRecordings (context) { async fetchRecordings (context, options) {
const recs = await getRecordings(context.getters.subscriberId) const recs = await getRecordings({
context.commit('callRecordings', recs) ...options,
subscriber_id: context.getters.subscriberId
})
context.commit('callRecordings', recs.recordings)
return recs.total_count
}, },
async fetchStreams (context, recId) { async fetchStreams (context, recId) {
const streams = await getRecordingStreams(recId) const streams = await getRecordingStreams(recId)

Loading…
Cancel
Save