Updating frontend to allow searching by type and trigger.
This commit is contained in:
parent
4bab941d52
commit
c0d16bd395
|
@ -24,18 +24,31 @@
|
||||||
|
|
||||||
let backupData = null
|
let backupData = null
|
||||||
let modal
|
let modal
|
||||||
let trigger = null
|
|
||||||
let pageInfo = createPaginationStore()
|
let pageInfo = createPaginationStore()
|
||||||
let startDate
|
let filterOpt = null
|
||||||
let endDate
|
let startDate = null
|
||||||
|
let endDate = null
|
||||||
|
let filters = getFilters()
|
||||||
|
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
$: fetchBackups(trigger, page, startDate, endDate)
|
$: fetchBackups(filterOpt, page, startDate, endDate)
|
||||||
|
|
||||||
const triggers = {
|
function getFilters() {
|
||||||
PUBLISH: "publish",
|
const options = []
|
||||||
SCHEDULED: "scheduled",
|
let types = ["backup"]
|
||||||
MANUAL: "manual",
|
let triggers = ["manual", "publish", "scheduled", "restoring"]
|
||||||
|
for (let type of types) {
|
||||||
|
for (let trigger of triggers) {
|
||||||
|
let label = `${trigger} ${type}`
|
||||||
|
label = label.charAt(0).toUpperCase() + label?.slice(1)
|
||||||
|
options.push({ label, value: { type, trigger } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options.push({
|
||||||
|
label: `Manual restore`,
|
||||||
|
value: { type: "restore", trigger: "manual" },
|
||||||
|
})
|
||||||
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
const schema = {
|
const schema = {
|
||||||
|
@ -80,10 +93,10 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchBackups(trigger, page, startDate, endDate) {
|
async function fetchBackups(filters, page, startDate, endDate) {
|
||||||
const response = await backups.searchBackups({
|
const response = await backups.searchBackups({
|
||||||
appId: app.instance._id,
|
appId: app.instance._id,
|
||||||
trigger,
|
...filters,
|
||||||
page,
|
page,
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
|
@ -100,7 +113,7 @@
|
||||||
appId: app.instance._id,
|
appId: app.instance._id,
|
||||||
name,
|
name,
|
||||||
})
|
})
|
||||||
await fetchBackups(trigger, page)
|
await fetchBackups(filterOpt, page)
|
||||||
notifications.success(response.message)
|
notifications.success(response.message)
|
||||||
} catch {
|
} catch {
|
||||||
notifications.error("Unable to create backup")
|
notifications.error("Unable to create backup")
|
||||||
|
@ -113,21 +126,21 @@
|
||||||
appId: app.instance._id,
|
appId: app.instance._id,
|
||||||
backupId: detail.backupId,
|
backupId: detail.backupId,
|
||||||
})
|
})
|
||||||
await fetchBackups(trigger, page)
|
await fetchBackups(filterOpt, page)
|
||||||
} else if (detail.type === "backupRestore") {
|
} else if (detail.type === "backupRestore") {
|
||||||
await backups.restoreBackup({
|
await backups.restoreBackup({
|
||||||
appId: app.instance._id,
|
appId: app.instance._id,
|
||||||
backupId: detail.backupId,
|
backupId: detail.backupId,
|
||||||
name: detail.restoreBackupName,
|
name: detail.restoreBackupName,
|
||||||
})
|
})
|
||||||
await fetchBackups(trigger, page)
|
await fetchBackups(filterOpt, page)
|
||||||
} else if (detail.type === "backupUpdate") {
|
} else if (detail.type === "backupUpdate") {
|
||||||
await backups.updateBackup({
|
await backups.updateBackup({
|
||||||
appId: app.instance._id,
|
appId: app.instance._id,
|
||||||
backupId: detail.backupId,
|
backupId: detail.backupId,
|
||||||
name: detail.name,
|
name: detail.name,
|
||||||
})
|
})
|
||||||
await fetchBackups(trigger, page)
|
await fetchBackups(filterOpt, page)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -138,11 +151,11 @@
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<Select
|
<Select
|
||||||
placeholder="All"
|
placeholder="All"
|
||||||
label="Trigger"
|
label="Type"
|
||||||
options={Object.values(triggers)}
|
options={filters}
|
||||||
getOptionLabel={trigger =>
|
getOptionValue={filter => filter.value}
|
||||||
trigger.charAt(0).toUpperCase() + trigger.slice(1)}
|
getOptionLabel={filter => filter.label}
|
||||||
bind:value={trigger}
|
bind:value={filterOpt}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -11,8 +11,15 @@ export function createBackupsStore() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchBackups({ appId, trigger, page, startDate, endDate }) {
|
async function searchBackups({
|
||||||
return API.searchBackups({ appId, trigger, page, startDate, endDate })
|
appId,
|
||||||
|
trigger,
|
||||||
|
type,
|
||||||
|
page,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
}) {
|
||||||
|
return API.searchBackups({ appId, trigger, type, page, startDate, endDate })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restoreBackup({ appId, backupId, name }) {
|
async function restoreBackup({ appId, backupId, name }) {
|
||||||
|
|
|
@ -2,13 +2,14 @@ export const buildBackupsEndpoints = API => ({
|
||||||
/**
|
/**
|
||||||
* Gets a list of users in the current tenant.
|
* Gets a list of users in the current tenant.
|
||||||
*/
|
*/
|
||||||
searchBackups: async ({ appId, trigger, page, startDate, endDate }) => {
|
searchBackups: async ({ appId, trigger, type, page, startDate, endDate }) => {
|
||||||
const opts = {}
|
const opts = {}
|
||||||
if (page) {
|
if (page) {
|
||||||
opts.page = page
|
opts.page = page
|
||||||
}
|
}
|
||||||
if (trigger) {
|
if (trigger && type) {
|
||||||
opts.trigger = trigger.toLowerCase()
|
opts.trigger = trigger.toLowerCase()
|
||||||
|
opts.type = type.toLowerCase()
|
||||||
}
|
}
|
||||||
if (startDate && endDate) {
|
if (startDate && endDate) {
|
||||||
opts.startDate = startDate
|
opts.startDate = startDate
|
||||||
|
|
Loading…
Reference in New Issue