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 7f1233576b
5 changed files with 31 additions and 15 deletions

View File

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

View File

@ -18,7 +18,13 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const onChange = e => { 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) dispatch("change", e.detail)
} }
</script> </script>

View File

@ -26,9 +26,11 @@
let modal let modal
let trigger = null let trigger = null
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
$: page = $pageInfo.page let startDate
let endDate
$: fetchBackups(trigger, page) $: page = $pageInfo.page
$: fetchBackups(trigger, page, startDate, endDate)
const triggers = { const triggers = {
PUBLISH: "publish", PUBLISH: "publish",
@ -78,11 +80,13 @@
}) })
} }
async function fetchBackups(trigger, page) { async function fetchBackups(trigger, page, startDate, endDate) {
const response = await backups.searchBackups({ const response = await backups.searchBackups({
appId: app.instance._id, appId: app.instance._id,
trigger, trigger,
page, page,
startDate,
endDate,
}) })
pageInfo.fetched(response.hasNextPage, response.nextPage) pageInfo.fetched(response.hasNextPage, response.nextPage)
@ -139,9 +143,14 @@
</div> </div>
<div> <div>
<DatePicker <DatePicker
range range={true}
label={"Filter Range"} 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> </div>

View File

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

View File

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