1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-06-15 00:05:15 +02:00

Feature: Add pagination & limits to URL parameters (#303)

* Set search conditions to query parameters

* Fixed by review

* Update query parameters when new message notified
This commit is contained in:
Yuuki Takahashi
2024-06-01 20:32:11 +09:00
committed by Ralph Slooten
parent 31390e4b82
commit e87b98b73b
11 changed files with 106 additions and 21 deletions

View File

@ -2,6 +2,7 @@ import axios from 'axios'
import dayjs from 'dayjs'
import ColorHash from 'color-hash'
import { Modal, Offcanvas } from 'bootstrap'
import {limitOptions} from "../stores/pagination";
// BootstrapElement is used to return a fake Bootstrap element
// if the ID returns nothing to prevent errors.
@ -66,14 +67,28 @@ export default {
}
const urlParams = new URLSearchParams(window.location.search)
const q = urlParams.get('q').trim()
if (q == '') {
const q = urlParams.get('q')?.trim()
if (!q) {
return false
}
return q
},
getPaginationParams: function () {
if (!window.location.search) {
return null
}
const urlParams = new URLSearchParams(window.location.search)
const start = parseInt(urlParams.get('start')?.trim(), 10)
const limit = parseInt(urlParams.get('limit')?.trim(), 10)
return {
start: Number.isInteger(start) && start >= 0 ? start : null,
limit: limitOptions.includes(limit) ? limit : null,
}
},
// generic modal get/set function
modal: function (id) {
let e = document.getElementById(id)