Merge branch 'feature/backups-ui' of github.com:Budibase/budibase into feature/backups-ui

This commit is contained in:
mike12345567 2022-10-20 17:48:03 +01:00
commit 6256b5f73d
5 changed files with 31 additions and 15 deletions

View File

@ -62,11 +62,9 @@
const [dates] = event.detail
const noTimezone = enableTime && !timeOnly && ignoreTimezones
let newValue = dates[0]
if (newValue) {
newValue = newValue.toISOString()
}
// If time only set date component to 2000-01-01
else if (timeOnly) {
// Classic flackpickr causing issues.
@ -95,10 +93,13 @@
newValue = new Date(dates[0].getTime() - offset)
.toISOString()
.slice(0, -1)
} else if (range) {
console.log("hello")
}
dispatch("change", newValue)
if (range) {
dispatch("change", event.detail)
} else {
dispatch("change", newValue)
}
}
const clearDateOnBackspace = event => {
@ -163,7 +164,7 @@
{#key redrawOptions}
<Flatpickr
bind:flatpickr
value={parseDate(value)}
value={range ? value : parseDate(value)}
on:open={onOpen}
on:close={onClose}
options={flatpickrOptions}

View File

@ -18,7 +18,13 @@
const dispatch = createEventDispatcher()
const onChange = e => {
value = e.detail
if (range) {
// Flatpickr cant take two dates and work out what to display, needs to be provided a string.
// Like - "Date1 to Date2". Hence passing in that specifically from the array
value = e.detail[1]
} else {
value = e.detail
}
dispatch("change", e.detail)
}
</script>

View File

@ -26,9 +26,11 @@
let modal
let trigger = null
let pageInfo = createPaginationStore()
$: page = $pageInfo.page
let startDate
let endDate
$: fetchBackups(trigger, page)
$: page = $pageInfo.page
$: fetchBackups(trigger, page, startDate, endDate)
const triggers = {
PUBLISH: "publish",
@ -78,11 +80,13 @@
})
}
async function fetchBackups(trigger, page) {
async function fetchBackups(trigger, page, startDate, endDate) {
const response = await backups.searchBackups({
appId: app.instance._id,
trigger,
page,
startDate,
endDate,
})
pageInfo.fetched(response.hasNextPage, response.nextPage)
@ -139,9 +143,14 @@
</div>
<div>
<DatePicker
range
range={true}
label={"Filter Range"}
on:change={e => console.log(e)}
on:change={e => {
if (e.detail[0].length > 1) {
startDate = e.detail[0][0].toISOString()
endDate = e.detail[0][1].toISOString()
}
}}
/>
</div>

View File

@ -11,8 +11,8 @@ export function createBackupsStore() {
})
}
async function searchBackups({ appId, trigger, page } = {}) {
return API.searchBackups({ appId, trigger, page })
async function searchBackups({ appId, trigger, page, startDate, endDate }) {
return API.searchBackups({ appId, trigger, page, startDate, endDate })
}
async function restoreBackup({ appId, backupId }) {

View File

@ -10,7 +10,7 @@ export const buildBackupsEndpoints = API => ({
if (trigger) {
opts.trigger = trigger.toLowerCase()
}
if (startDate) {
if (startDate && endDate) {
opts.startDate = startDate
opts.endDate = endDate
}