Updating rendering of table - as per Andy's new designs based on the restore event.

This commit is contained in:
mike12345567 2022-10-20 17:43:54 +01:00
parent 7822fadd12
commit d4d69f92c1
12 changed files with 112 additions and 120 deletions

View File

@ -1,6 +1,5 @@
<script> <script>
import { import {
ActionButton,
ActionMenu, ActionMenu,
MenuItem, MenuItem,
Icon, Icon,
@ -55,15 +54,17 @@
</script> </script>
<div class="cell"> <div class="cell">
<ActionButton on:click={restoreDialog.show}>Restore</ActionButton> <ActionMenu align="right">
<ActionMenu>
<div slot="control"> <div slot="control">
<Icon size="M" hoverable name="MoreSmallList" /> <Icon size="M" hoverable name="MoreSmallList" />
</div> </div>
{#if row.type !== "restore"}
<MenuItem on:click={restoreDialog.show} icon="Revert">Restore</MenuItem>
<MenuItem on:click={deleteDialog.show} icon="Delete">Delete</MenuItem> <MenuItem on:click={deleteDialog.show} icon="Delete">Delete</MenuItem>
<MenuItem on:click={updateDialog.show} icon="Edit">Update</MenuItem>
<MenuItem on:click={downloadExport} icon="Download">Download</MenuItem> <MenuItem on:click={downloadExport} icon="Download">Download</MenuItem>
{/if}
<MenuItem on:click={updateDialog.show} icon="Edit">Update</MenuItem>
</ActionMenu> </ActionMenu>
</div> </div>

View File

@ -0,0 +1,41 @@
<script>
import { Icon } from "@budibase/bbui"
export let row
$: automations = row?.automations
$: datasources = row?.datasources
$: screens = row?.screens
</script>
<div class="cell">
{#if automations != null && screens != null && datasources != null}
<div class="item">
<Icon name="Data" />
<div>{datasources || 0}</div>
</div>
<div class="item">
<Icon name="WebPage" />
<div>{screens || 0}</div>
</div>
<div class="item">
<Icon name="JourneyVoyager" />
<div>{automations || 0}</div>
</div>
{/if}
</div>
<style>
.cell {
display: flex;
flex-direction: row;
gap: calc(var(--spacing-xl) * 2);
align-items: center;
}
.item {
display: flex;
gap: var(--spacing-s);
flex-direction: row;
}
</style>

View File

@ -12,14 +12,13 @@
import { backups } from "stores/portal" import { backups } from "stores/portal"
import { createPaginationStore } from "helpers/pagination" import { createPaginationStore } from "helpers/pagination"
import DatasourceRenderer from "./DatasourceRenderer.svelte" import AppSizeRenderer from "./AppSizeRenderer.svelte"
import ScreensRenderer from "./ScreensRenderer.svelte"
import AutomationsRenderer from "./AutomationsRenderer.svelte"
import CreateBackupModal from "./CreateBackupModal.svelte" import CreateBackupModal from "./CreateBackupModal.svelte"
import TriggerRenderer from "./TriggerRenderer.svelte"
import ActionsRenderer from "./ActionsRenderer.svelte" import ActionsRenderer from "./ActionsRenderer.svelte"
import DateRenderer from "./DateRenderer.svelte" import DateRenderer from "./DateRenderer.svelte"
import DaysRenderer from "./DaysRenderer.svelte" import UserRenderer from "./UserRenderer.svelte"
import StatusRenderer from "./StatusRenderer.svelte"
import TypeRenderer from "./TypeRenderer.svelte"
export let app export let app
@ -38,66 +37,47 @@
} }
const schema = { const schema = {
trigger: { type: {
displayName: "Trigger", displayName: "Type",
},
days: {
displayName: null,
},
name: {
displayName: "Name",
}, },
createdAt: { createdAt: {
displayName: "Date", displayName: "Date",
}, },
datasources: { name: {
displayName: "Data", displayName: "Name",
}, },
screens: { appSize: {
displayName: "Screens", displayName: "App size",
}, },
automations: { createdBy: {
displayName: "Automations",
},
userId: {
displayName: "User", displayName: "User",
}, },
status: {
displayName: "Status",
},
actions: { actions: {
displayName: null, displayName: null,
}, },
} }
const customRenderers = [ const customRenderers = [
{ column: "datasources", component: DatasourceRenderer }, { column: "appSize", component: AppSizeRenderer },
{ column: "screens", component: ScreensRenderer },
{ column: "automations", component: AutomationsRenderer },
{ column: "trigger", component: TriggerRenderer },
{ column: "actions", component: ActionsRenderer }, { column: "actions", component: ActionsRenderer },
{ column: "createdAt", component: DateRenderer }, { column: "createdAt", component: DateRenderer },
{ column: "days", component: DaysRenderer }, { column: "createdBy", component: UserRenderer },
{ column: "status", component: StatusRenderer },
{ column: "type", component: TypeRenderer },
] ]
function flattenBackups(backups) { function flattenBackups(backups) {
return backups.map(backup => { return backups.map(backup => {
return { return {
...backup, ...backup,
days: getDaysBetween(backup.timestamp),
...backup?.contents, ...backup?.contents,
} }
}) })
} }
function getDaysBetween(date) {
const now = new Date()
const backupDate = new Date(date)
backupDate.setDate(backupDate.getDate() - 1)
const oneDay = 24 * 60 * 60 * 1000
return now > backupDate
? Math.round(Math.abs((now - backupDate) / oneDay))
: 0
}
async function fetchBackups(trigger, page) { async function fetchBackups(trigger, page) {
const response = await backups.searchBackups({ const response = await backups.searchBackups({
appId: app.instance._id, appId: app.instance._id,
@ -123,6 +103,7 @@
} }
async function handleButtonClick({ detail }) { async function handleButtonClick({ detail }) {
console.log(detail.type)
if (detail.type === "backupDelete") { if (detail.type === "backupDelete") {
await backups.deleteBackup({ await backups.deleteBackup({
appId: app.instance._id, appId: app.instance._id,

View File

@ -5,8 +5,10 @@
</script> </script>
<div class="cell"> <div class="cell">
{#if value != null}
<Icon name="Data" /> <Icon name="Data" />
<div>{value || 0}</div> <div>{value || 0}</div>
{/if}
</div> </div>
<style> <style>

View File

@ -1,10 +1,15 @@
<script> <script>
import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte" import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte"
import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
dayjs.extend(relativeTime)
export let value export let value
$: timeSince = dayjs(value).fromNow()
</script> </script>
<div class="cell"> <div class="cell">
<DateTimeRenderer {value} /> {timeSince} - <DateTimeRenderer {value} />
</div> </div>
<style> <style>

View File

@ -1,17 +0,0 @@
<script>
export let value
</script>
<div class="cell">
{value}
{`day${value == 1 ? "" : "s"} ago`}
</div>
<style>
.cell {
display: flex;
flex-direction: row;
gap: var(--spacing-m);
align-items: center;
}
</style>

View File

@ -1,19 +0,0 @@
<script>
import { Icon } from "@budibase/bbui"
export let value
</script>
<div class="cell">
<Icon name="WebPage" />
<div>{value || 0}</div>
</div>
<style>
.cell {
display: flex;
flex-direction: row;
gap: var(--spacing-m);
align-items: center;
}
</style>

View File

@ -0,0 +1,10 @@
<script>
import { Badge } from "@budibase/bbui"
export let value = "started"
$: status = value.charAt(0).toUpperCase() + value.slice(1)
</script>
<Badge green={value === "complete"} red={value === "failed"} size="S">
{status}
</Badge>

View File

@ -1,32 +0,0 @@
<script>
import { Icon } from "@budibase/bbui"
export let value
$: console.log(value)
let trigger = value?.charAt(0).toUpperCase() + value?.slice(1)
</script>
<div class="cell">
{#if value === "publish"}
<Icon name="GlobeCheck" />
<div>{trigger}</div>
{:else if value === "manual"}
<Icon name="SaveFloppy" />
<div>{trigger}</div>
{:else if value === "scheduled"}
<Icon name="Clock" />
<div>{trigger}</div>
{:else if value === "restore"}
<Icon name="Refresh" />
<div>{trigger}</div>
{/if}
</div>
<style>
.cell {
display: flex;
flex-direction: row;
gap: var(--spacing-m);
align-items: center;
}
</style>

View File

@ -0,0 +1,20 @@
<script>
export let row
$: baseTrig = row?.trigger || "manual"
$: type = row?.type || "backup"
$: trigger = baseTrig.charAt(0).toUpperCase() + baseTrig.slice(1)
</script>
<div class="cell">
{trigger}
{type}
</div>
<style>
.cell {
display: flex;
flex-direction: row;
align-items: center;
}
</style>

View File

@ -1,12 +1,14 @@
<script> <script>
import { Icon } from "@budibase/bbui"
export let value export let value
$: username = value?.firstName
? `${value?.firstName} ${value?.lastName}`
: value?.email
</script> </script>
<div class="cell"> <div class="cell">
<Icon name="JourneyVoyager" /> {#if value != null}
<div>{value || 0}</div> <div>{username}</div>
{/if}
</div> </div>
<style> <style>

View File

@ -10,12 +10,10 @@ export const buildBackupsEndpoints = API => ({
if (trigger) { if (trigger) {
opts.trigger = trigger.toLowerCase() opts.trigger = trigger.toLowerCase()
} }
if (startDate) { if (startDate) {
opts.startDate = startDate opts.startDate = startDate
opts.endDate = endDate opts.endDate = endDate
} }
console.log(opts)
return await API.post({ return await API.post({
url: `/api/apps/${appId}/backups/search`, url: `/api/apps/${appId}/backups/search`,
body: opts, body: opts,