|
|
@ -2,11 +2,17 @@ |
|
|
import { onMount, onDestroy } from "svelte" |
|
|
import { onMount, onDestroy } from "svelte" |
|
|
import Spinner from "components/common/Spinner.svelte" |
|
|
import Spinner from "components/common/Spinner.svelte" |
|
|
import { slide } from "svelte/transition" |
|
|
import { slide } from "svelte/transition" |
|
|
import { Heading, Body, Button, Modal } from "@budibase/bbui" |
|
|
import { Heading, Body, Button, Modal, ModalContent } from "@budibase/bbui" |
|
|
import api from "builderStore/api" |
|
|
import api from "builderStore/api" |
|
|
import { notifier } from "builderStore/store/notifications" |
|
|
import { notifier } from "builderStore/store/notifications" |
|
|
import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte" |
|
|
import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte" |
|
|
|
|
|
|
|
|
|
|
|
const DeploymentStatus = { |
|
|
|
|
|
SUCCESS: "SUCCESS", |
|
|
|
|
|
PENDING: "PENDING", |
|
|
|
|
|
FAILURE: "FAILURE", |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const DATE_OPTIONS = { |
|
|
const DATE_OPTIONS = { |
|
|
fullDate: { |
|
|
fullDate: { |
|
|
weekday: "long", |
|
|
weekday: "long", |
|
|
@ -25,6 +31,8 @@ |
|
|
export let appId |
|
|
export let appId |
|
|
|
|
|
|
|
|
let modal |
|
|
let modal |
|
|
|
|
|
let errorReasonModal |
|
|
|
|
|
let errorReason |
|
|
let poll |
|
|
let poll |
|
|
let deployments = [] |
|
|
let deployments = [] |
|
|
let deploymentUrl = `https://${appId}.app.budi.live/${appId}` |
|
|
let deploymentUrl = `https://${appId}.app.budi.live/${appId}` |
|
|
@ -32,10 +40,35 @@ |
|
|
const formatDate = (date, format) => |
|
|
const formatDate = (date, format) => |
|
|
Intl.DateTimeFormat("en-GB", DATE_OPTIONS[format]).format(date) |
|
|
Intl.DateTimeFormat("en-GB", DATE_OPTIONS[format]).format(date) |
|
|
|
|
|
|
|
|
|
|
|
// Required to check any updated deployment statuses between polls |
|
|
|
|
|
function checkIncomingDeploymentStatus(current, incoming) { |
|
|
|
|
|
for (let incomingDeployment of incoming) { |
|
|
|
|
|
if (incomingDeployment.status === DeploymentStatus.FAILURE) { |
|
|
|
|
|
const currentDeployment = current.find( |
|
|
|
|
|
deployment => deployment._id === incomingDeployment._id |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// We have just been notified of an ongoing deployments failure |
|
|
|
|
|
if ( |
|
|
|
|
|
!currentDeployment || |
|
|
|
|
|
currentDeployment.status === DeploymentStatus.PENDING |
|
|
|
|
|
) { |
|
|
|
|
|
showErrorReasonModal(incomingDeployment.err) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async function fetchDeployments() { |
|
|
async function fetchDeployments() { |
|
|
try { |
|
|
try { |
|
|
const response = await api.get(`/api/deployments`) |
|
|
const response = await api.get(`/api/deployments`) |
|
|
deployments = await response.json() |
|
|
const json = await response.json() |
|
|
|
|
|
|
|
|
|
|
|
if (deployments.length > 0) { |
|
|
|
|
|
checkIncomingDeploymentStatus(deployments, json) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deployments = json |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
console.error(err) |
|
|
console.error(err) |
|
|
clearInterval(poll) |
|
|
clearInterval(poll) |
|
|
@ -43,6 +76,11 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function showErrorReasonModal(err) { |
|
|
|
|
|
errorReason = err |
|
|
|
|
|
errorReasonModal.show() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
onMount(() => { |
|
|
onMount(() => { |
|
|
fetchDeployments() |
|
|
fetchDeployments() |
|
|
poll = setInterval(fetchDeployments, POLL_INTERVAL) |
|
|
poll = setInterval(fetchDeployments, POLL_INTERVAL) |
|
|
@ -56,7 +94,7 @@ |
|
|
<header> |
|
|
<header> |
|
|
<h4>Deployment History</h4> |
|
|
<h4>Deployment History</h4> |
|
|
<div class="deploy-div"> |
|
|
<div class="deploy-div"> |
|
|
{#if deployments.some(deployment => deployment.status === 'SUCCESS')} |
|
|
{#if deployments.some(deployment => deployment.status === DeploymentStatus.SUCCESS)} |
|
|
<a target="_blank" href={`https://${appId}.app.budi.live/${appId}`}> |
|
|
<a target="_blank" href={`https://${appId}.app.budi.live/${appId}`}> |
|
|
View Your Deployed App → |
|
|
View Your Deployed App → |
|
|
</a> |
|
|
</a> |
|
|
@ -80,7 +118,14 @@ |
|
|
<Spinner size="10" /> |
|
|
<Spinner size="10" /> |
|
|
{/if} |
|
|
{/if} |
|
|
<div class={`deployment-status ${deployment.status}`}> |
|
|
<div class={`deployment-status ${deployment.status}`}> |
|
|
{deployment.status} |
|
|
<span> |
|
|
|
|
|
{deployment.status} |
|
|
|
|
|
{#if deployment.status === DeploymentStatus.FAILURE} |
|
|
|
|
|
<i |
|
|
|
|
|
class="ri-information-line" |
|
|
|
|
|
on:click={() => showErrorReasonModal(deployment.err)} /> |
|
|
|
|
|
{/if} |
|
|
|
|
|
</span> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</article> |
|
|
</article> |
|
|
@ -91,6 +136,14 @@ |
|
|
<Modal bind:this={modal} width="30%"> |
|
|
<Modal bind:this={modal} width="30%"> |
|
|
<CreateWebhookDeploymentModal /> |
|
|
<CreateWebhookDeploymentModal /> |
|
|
</Modal> |
|
|
</Modal> |
|
|
|
|
|
<Modal bind:this={errorReasonModal} width="30%"> |
|
|
|
|
|
<ModalContent |
|
|
|
|
|
title="Deployment Error" |
|
|
|
|
|
confirmText="OK" |
|
|
|
|
|
showCancelButton={false}> |
|
|
|
|
|
{errorReason} |
|
|
|
|
|
</ModalContent> |
|
|
|
|
|
</Modal> |
|
|
|
|
|
|
|
|
<style> |
|
|
<style> |
|
|
.deployment:nth-child(odd) { |
|
|
.deployment:nth-child(odd) { |
|
|
@ -189,5 +242,11 @@ |
|
|
.FAILURE { |
|
|
.FAILURE { |
|
|
color: var(--red); |
|
|
color: var(--red); |
|
|
background: var(--red-light); |
|
|
background: var(--red-light); |
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
i { |
|
|
|
|
|
position: relative; |
|
|
|
|
|
top: 2px; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |
|
|
|