2020-10-17 16:13:25 +02:00
|
|
|
<script>
|
2020-10-18 19:09:14 +02:00
|
|
|
import { onMount, onDestroy } from "svelte"
|
2020-10-19 16:33:26 +02:00
|
|
|
import Spinner from "components/common/Spinner.svelte"
|
2020-10-18 19:09:14 +02:00
|
|
|
import { slide } from "svelte/transition"
|
2020-10-17 16:13:25 +02:00
|
|
|
import { Heading, Body } from "@budibase/bbui"
|
2020-10-18 19:09:14 +02:00
|
|
|
import api from "builderStore/api"
|
|
|
|
import { notifier } from "builderStore/store/notifications"
|
2020-10-17 16:13:25 +02:00
|
|
|
|
|
|
|
const DATE_OPTIONS = {
|
|
|
|
fullDate: {
|
|
|
|
weekday: "long",
|
|
|
|
year: "numeric",
|
|
|
|
month: "long",
|
|
|
|
day: "numeric",
|
|
|
|
},
|
|
|
|
timeOnly: {
|
|
|
|
hour: "numeric",
|
|
|
|
minute: "numeric",
|
|
|
|
hour12: true,
|
|
|
|
},
|
|
|
|
}
|
2020-10-20 16:06:34 +02:00
|
|
|
const POLL_INTERVAL = 5000
|
2020-10-17 16:13:25 +02:00
|
|
|
|
|
|
|
export let appId
|
|
|
|
|
2020-10-18 19:09:14 +02:00
|
|
|
let poll
|
|
|
|
let deployments = []
|
|
|
|
let deploymentUrl = `https://${appId}.app.budi.live/${appId}`
|
|
|
|
|
2020-10-17 16:13:25 +02:00
|
|
|
const formatDate = (date, format) =>
|
|
|
|
Intl.DateTimeFormat("en-GB", DATE_OPTIONS[format]).format(date)
|
2020-10-18 19:09:14 +02:00
|
|
|
|
|
|
|
async function fetchDeployments() {
|
|
|
|
try {
|
|
|
|
const response = await api.get(`/api/deployments`)
|
|
|
|
deployments = await response.json()
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err)
|
|
|
|
clearInterval(poll)
|
|
|
|
notifier.danger("Error fetching deployment history. Please try again.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
poll = setInterval(fetchDeployments, POLL_INTERVAL)
|
|
|
|
})
|
|
|
|
|
|
|
|
onDestroy(() => clearInterval(poll))
|
2020-10-17 16:13:25 +02:00
|
|
|
</script>
|
|
|
|
|
2020-10-18 19:09:14 +02:00
|
|
|
{#if deployments.length > 0}
|
|
|
|
<section class="deployment-history" in:slide>
|
|
|
|
<header>
|
|
|
|
<h4>Deployment History</h4>
|
2020-10-17 16:13:25 +02:00
|
|
|
<a target="_blank" href={`https://${appId}.app.budi.live/${appId}`}>
|
|
|
|
View Your Deployed App →
|
|
|
|
</a>
|
2020-10-18 19:09:14 +02:00
|
|
|
</header>
|
|
|
|
<div class="deployment-list">
|
|
|
|
{#each deployments as deployment}
|
|
|
|
<article class="deployment">
|
|
|
|
<div class="deployment-info">
|
|
|
|
<span class="deploy-date">
|
|
|
|
{formatDate(deployment.updatedAt, 'fullDate')}
|
|
|
|
</span>
|
|
|
|
<span class="deploy-time">
|
|
|
|
{formatDate(deployment.updatedAt, 'timeOnly')}
|
|
|
|
</span>
|
|
|
|
</div>
|
2020-10-19 16:33:26 +02:00
|
|
|
<div class="deployment-right">
|
2020-10-20 16:09:20 +02:00
|
|
|
{#if deployment.status.toLowerCase() === 'pending'}
|
2020-10-19 16:33:26 +02:00
|
|
|
<Spinner size="10" />
|
|
|
|
{/if}
|
|
|
|
<div class={`deployment-status ${deployment.status}`}>
|
|
|
|
{deployment.status}
|
|
|
|
</div>
|
2020-10-18 19:09:14 +02:00
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
{/if}
|
2020-10-17 16:13:25 +02:00
|
|
|
|
|
|
|
<style>
|
2020-10-18 19:09:14 +02:00
|
|
|
.deployment:nth-child(odd) {
|
2020-10-17 16:13:25 +02:00
|
|
|
background: var(--grey-1);
|
|
|
|
}
|
|
|
|
|
2020-10-18 19:09:14 +02:00
|
|
|
.deployment-list {
|
|
|
|
height: 40vh;
|
|
|
|
overflow-y: scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
h4 {
|
|
|
|
margin-top: var(--spacing-xl);
|
|
|
|
margin-bottom: var(--spacing-s);
|
|
|
|
}
|
|
|
|
|
|
|
|
header {
|
|
|
|
margin-left: var(--spacing-l);
|
|
|
|
margin-bottom: var(--spacing-xl);
|
|
|
|
}
|
|
|
|
|
2020-10-17 16:13:25 +02:00
|
|
|
.deployment-history {
|
|
|
|
position: absolute;
|
2020-10-18 19:09:14 +02:00
|
|
|
bottom: 0;
|
|
|
|
width: 100%;
|
2020-10-17 16:13:25 +02:00
|
|
|
background: var(--white);
|
|
|
|
}
|
|
|
|
|
|
|
|
.deployment {
|
|
|
|
padding: var(--spacing-l);
|
|
|
|
height: 100px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
|
|
|
|
.deployment-info {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
margin-right: var(--spacing-s);
|
|
|
|
}
|
|
|
|
|
|
|
|
.deploy-date {
|
|
|
|
font-size: var(--font-size-m);
|
|
|
|
}
|
|
|
|
|
|
|
|
.deploy-time {
|
|
|
|
color: var(--grey-7);
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: var(--font-size-s);
|
|
|
|
}
|
|
|
|
|
2020-10-19 16:33:26 +02:00
|
|
|
.deployment-right {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
gap: 16px;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
2020-10-17 16:13:25 +02:00
|
|
|
.deployment-status {
|
|
|
|
font-size: var(--font-size-s);
|
|
|
|
padding: var(--spacing-s);
|
|
|
|
border-radius: var(--border-radius-s);
|
|
|
|
font-weight: 500;
|
|
|
|
text-transform: lowercase;
|
|
|
|
width: 80px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
.deployment-status:first-letter {
|
|
|
|
text-transform: uppercase;
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
color: var(--blue);
|
|
|
|
font-weight: 500;
|
2020-10-18 19:09:14 +02:00
|
|
|
font-size: var(--font-size-s);
|
2020-10-17 16:13:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.SUCCESS {
|
|
|
|
color: var(--green);
|
|
|
|
background: var(--green-light);
|
|
|
|
}
|
|
|
|
|
|
|
|
.PENDING {
|
|
|
|
color: var(--yellow);
|
|
|
|
background: var(--yellow-light);
|
|
|
|
}
|
|
|
|
|
|
|
|
.FAILURE {
|
|
|
|
color: var(--red);
|
|
|
|
background: var(--red-light);
|
|
|
|
}
|
|
|
|
</style>
|