Update overview automation history tab

This commit is contained in:
Andrew Kingston 2022-12-20 12:06:08 +00:00
parent 3f7a7eda16
commit bbf41f9656
16 changed files with 134 additions and 154 deletions

View File

@ -57,15 +57,13 @@
<Button cta on:click={publishModal.show}>Publish</Button> <Button cta on:click={publishModal.show}>Publish</Button>
<Modal bind:this={publishModal}> <Modal bind:this={publishModal}>
<ModalContent <ModalContent
title="Publish to Production" title="Publish to production"
confirmText="Publish" confirmText="Publish"
onConfirm={publishApp} onConfirm={publishApp}
dataCy={"deploy-app-modal"} dataCy={"deploy-app-modal"}
> >
<span The changes you have made will be published to the production version of the
>The changes you have made will be published to the production version of application.
the application.</span
>
</ModalContent> </ModalContent>
</Modal> </Modal>

View File

@ -1,39 +0,0 @@
<script>
import { Icon } from "@budibase/bbui"
export let value
$: isError = !value || value.toLowerCase() === "error"
$: isStoppedError = value?.toLowerCase() === "stopped_error"
$: isStopped = value?.toLowerCase() === "stopped" || isStoppedError
$: status = getStatus(isError, isStopped)
function getStatus(error, stopped) {
if (error) {
return { color: "var(--red)", message: "Error", icon: "Alert" }
} else if (stopped) {
return { color: "var(--yellow)", message: "Stopped", icon: "StopCircle" }
} else {
return {
color: "var(--green)",
message: "Success",
icon: "CheckmarkCircle",
}
}
}
</script>
<div class="cell">
<Icon color={status.color} name={status.icon} />
<div style={`color: ${status.color};`}>
{status.message}
</div>
</div>
<style>
.cell {
display: flex;
flex-direction: row;
gap: var(--spacing-m);
align-items: center;
}
</style>

View File

@ -1,11 +0,0 @@
<script>
//export let app
</script>
<div class="automation-tab" />
<style>
.automation-tab {
color: pink;
}
</style>

View File

@ -0,0 +1,27 @@
<script>
import { Badge } from "@budibase/bbui"
export let value
$: isError = !value || value.toLowerCase() === "error"
$: isStoppedError = value?.toLowerCase() === "stopped_error"
$: isStopped = value?.toLowerCase() === "stopped" || isStoppedError
$: info = getInfo(isError, isStopped)
const getInfo = (error, stopped) => {
if (error) {
return { color: "red", message: "Error" }
} else if (stopped) {
return { color: "yellow", message: "Stopped" }
} else {
return { color: "green", message: "Success" }
}
}
</script>
<Badge
green={info.color === "green"}
red={info.color === "red"}
yellow={info.color === "yellow"}
>
{info.message}
</Badge>

View File

@ -1,21 +1,27 @@
<script> <script>
import { Layout, Table, Select, Pagination, Button } from "@budibase/bbui" import {
Layout,
Table,
Select,
Pagination,
Button,
Body,
Heading,
Divider,
} from "@budibase/bbui"
import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte" import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte"
import StatusRenderer from "./StatusRenderer.svelte" import StatusRenderer from "./_components/StatusRenderer.svelte"
import HistoryDetailsPanel from "./HistoryDetailsPanel.svelte" import HistoryDetailsPanel from "./_components/HistoryDetailsPanel.svelte"
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { createPaginationStore } from "helpers/pagination" import { createPaginationStore } from "helpers/pagination"
import { onMount } from "svelte" import { onMount } from "svelte"
import dayjs from "dayjs" import dayjs from "dayjs"
import { auth, licensing, admin } from "stores/portal" import { auth, licensing, admin, overview } from "stores/portal"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
const ERROR = "error", const ERROR = "error",
SUCCESS = "success", SUCCESS = "success",
STOPPED = "stopped" STOPPED = "stopped"
export let app
$: licensePlan = $auth.user?.license?.plan
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
let runHistory = null let runHistory = null
@ -26,6 +32,8 @@
let status = null let status = null
let timeRange = null let timeRange = null
$: licensePlan = $auth.user?.license?.plan
$: app = $overview.selectedApp
$: page = $pageInfo.page $: page = $pageInfo.page
$: fetchLogs(automationId, status, page, timeRange) $: fetchLogs(automationId, status, page, timeRange)
@ -47,8 +55,8 @@
const runHistorySchema = { const runHistorySchema = {
status: { displayName: "Status" }, status: { displayName: "Status" },
createdAt: { displayName: "Time" },
automationName: { displayName: "Automation" }, automationName: { displayName: "Automation" },
createdAt: { displayName: "Time" },
} }
const customRenderers = [ const customRenderers = [
@ -124,97 +132,94 @@
}) })
</script> </script>
<div class="root" class:panelOpen={showPanel}> <Layout noPadding>
<Layout noPadding gap="M" alignContent="start"> <Layout gap="XS" noPadding>
<div class="search"> <Heading>Automation History</Heading>
<div class="select"> <Body>View the automations your app has executed</Body>
<Select </Layout>
placeholder="All automations" <Divider />
label="Automation"
bind:value={automationId} <div class="search">
options={automationOptions} <div class="select">
/> <Select
</div> placeholder="All"
<div class="select"> label="Status"
<Select bind:value={status}
placeholder="All" options={statusOptions}
label="Date range" />
bind:value={timeRange}
options={timeOptions}
isOptionEnabled={x => {
if (licensePlan?.type === Constants.PlanType.FREE) {
return ["1-w", "30-d", "90-d"].indexOf(x.value) < 0
} else if (licensePlan?.type === Constants.PlanType.TEAM) {
return ["90-d"].indexOf(x.value) < 0
} else if (licensePlan?.type === Constants.PlanType.PRO) {
return ["30-d", "90-d"].indexOf(x.value) < 0
}
return true
}}
/>
</div>
<div class="select">
<Select
placeholder="All status"
label="Status"
bind:value={status}
options={statusOptions}
/>
</div>
{#if (licensePlan?.type !== Constants.PlanType.ENTERPRISE && $auth.user.accountPortalAccess) || !$admin.cloud}
<div class="pro-upgrade">
<div class="pro-copy">Expand your automation log history</div>
<Button primary on:click={$licensing.goToUpgradePage()}>
Upgrade
</Button>
</div>
{/if}
</div> </div>
{#if runHistory} <div class="select">
<div> <Select
<Table placeholder="All"
on:click={viewDetails} label="Automation"
schema={runHistorySchema} bind:value={automationId}
allowSelectRows={false} options={automationOptions}
allowEditColumns={false} />
allowEditRows={false} </div>
data={runHistory} <div class="select">
{customRenderers} <Select
placeholderText="No history found" placeholder="All"
border={false} label="Date range"
/> bind:value={timeRange}
<div class="pagination"> options={timeOptions}
<Pagination isOptionEnabled={x => {
page={$pageInfo.pageNumber} if (licensePlan?.type === Constants.PlanType.FREE) {
hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage} return ["1-w", "30-d", "90-d"].indexOf(x.value) < 0
hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage} } else if (licensePlan?.type === Constants.PlanType.TEAM) {
goToPrevPage={pageInfo.prevPage} return ["90-d"].indexOf(x.value) < 0
goToNextPage={pageInfo.nextPage} } else if (licensePlan?.type === Constants.PlanType.PRO) {
/> return ["30-d", "90-d"].indexOf(x.value) < 0
</div> }
return true
}}
/>
</div>
{#if (licensePlan?.type !== Constants.PlanType.ENTERPRISE && $auth.user.accountPortalAccess) || !$admin.cloud}
<div class="pro-upgrade">
<Button secondary on:click={$licensing.goToUpgradePage()}>
Get more history
</Button>
</div> </div>
{/if} {/if}
</Layout>
<div class="panel" class:panelShow={showPanel}>
<HistoryDetailsPanel
appId={app.devId}
bind:history={selectedHistory}
close={() => {
showPanel = false
}}
/>
</div> </div>
{#if runHistory}
<div>
<Table
on:click={viewDetails}
schema={runHistorySchema}
allowSelectRows={false}
allowEditColumns={false}
allowEditRows={false}
data={runHistory}
{customRenderers}
placeholderText="No history found"
border={false}
/>
<div class="pagination">
<Pagination
page={$pageInfo.pageNumber}
hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage}
hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage}
goToPrevPage={pageInfo.prevPage}
goToNextPage={pageInfo.nextPage}
/>
</div>
</div>
{/if}
</Layout>
<div class="panel" class:panelShow={showPanel}>
<HistoryDetailsPanel
appId={app.devId}
bind:history={selectedHistory}
close={() => {
showPanel = false
}}
/>
</div> </div>
<style> <style>
.root {
display: grid;
grid-template-columns: 1fr;
height: 100%;
padding: var(--spectrum-alias-grid-gutter-medium)
var(--spectrum-alias-grid-gutter-large);
}
.search { .search {
display: flex; display: flex;
gap: var(--spacing-xl); gap: var(--spacing-xl);

View File

@ -18,14 +18,14 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import { backups, licensing, auth, admin } from "stores/portal" import { backups, licensing, auth, admin } from "stores/portal"
import { createPaginationStore } from "helpers/pagination" import { createPaginationStore } from "helpers/pagination"
import AppSizeRenderer from "./AppSizeRenderer.svelte"
import CreateBackupModal from "./CreateBackupModal.svelte"
import ActionsRenderer from "./ActionsRenderer.svelte"
import DateRenderer from "components/common/renderers/DateTimeRenderer.svelte" import DateRenderer from "components/common/renderers/DateTimeRenderer.svelte"
import UserRenderer from "./UserRenderer.svelte" import AppSizeRenderer from "./_components/AppSizeRenderer.svelte"
import StatusRenderer from "./StatusRenderer.svelte" import CreateBackupModal from "./_components/CreateBackupModal.svelte"
import TypeRenderer from "./TypeRenderer.svelte" import ActionsRenderer from "./_components/ActionsRenderer.svelte"
import NameRenderer from "./NameRenderer.svelte" import UserRenderer from "./_components/UserRenderer.svelte"
import StatusRenderer from "./_components/StatusRenderer.svelte"
import TypeRenderer from "./_components/TypeRenderer.svelte"
import NameRenderer from "./_components/NameRenderer.svelte"
import BackupsDefault from "assets/backups-default.png" import BackupsDefault from "assets/backups-default.png"
import { BackupTrigger, BackupType } from "constants/backend/backups" import { BackupTrigger, BackupType } from "constants/backend/backups"
import { onMount } from "svelte" import { onMount } from "svelte"