forked from tsai/budibase
14 changed files with 178 additions and 6 deletions
@ -0,0 +1,42 @@ |
|||||
|
<script> |
||||
|
import "@spectrum-css/toast/dist/index-vars.css" |
||||
|
import Portal from "svelte-portal" |
||||
|
import { banner } from "../Stores/banner" |
||||
|
import Banner from "./Banner.svelte" |
||||
|
import { fly } from "svelte/transition" |
||||
|
</script> |
||||
|
|
||||
|
<Portal target=".modal-container"> |
||||
|
<div class="banner"> |
||||
|
{#if $banner.message} |
||||
|
<div transition:fly={{ y: -30 }}> |
||||
|
<Banner |
||||
|
type={$banner.type} |
||||
|
extraButtonText={$banner.extraButtonText} |
||||
|
extraButtonAction={$banner.extraButtonAction} |
||||
|
on:change={$banner.onChange} |
||||
|
> |
||||
|
{$banner.message} |
||||
|
</Banner> |
||||
|
</div> |
||||
|
{/if} |
||||
|
</div> |
||||
|
</Portal> |
||||
|
|
||||
|
<style> |
||||
|
.banner { |
||||
|
position: fixed; |
||||
|
top: 20px; |
||||
|
left: 0; |
||||
|
right: 0; |
||||
|
margin: 0 auto; |
||||
|
padding: 0; |
||||
|
z-index: 9999; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
justify-content: flex-start; |
||||
|
align-items: center; |
||||
|
pointer-events: none; |
||||
|
gap: 10px; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,37 @@ |
|||||
|
import { writable } from "svelte/store" |
||||
|
|
||||
|
export function createBannerStore() { |
||||
|
const DEFAULT_CONFIG = {} |
||||
|
|
||||
|
const banner = writable(DEFAULT_CONFIG) |
||||
|
|
||||
|
const show = async ( |
||||
|
// eslint-disable-next-line
|
||||
|
config = { message, type, extraButtonText, extraButtonAction, onChange } |
||||
|
) => { |
||||
|
banner.update(store => { |
||||
|
return { |
||||
|
...store, |
||||
|
...config, |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
const showStatus = async () => { |
||||
|
const config = { |
||||
|
message: "Some systems are experiencing issues", |
||||
|
type: "negative", |
||||
|
extraButtonText: "View Status", |
||||
|
extraButtonAction: () => window.open("https://status.budibase.com/"), |
||||
|
} |
||||
|
|
||||
|
await show(config) |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
subscribe: banner.subscribe, |
||||
|
showStatus, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export const banner = createBannerStore() |
||||
@ -0,0 +1,9 @@ |
|||||
|
const accounts = require("@budibase/backend-core/accounts") |
||||
|
const env = require("../../../environment") |
||||
|
|
||||
|
exports.fetch = async ctx => { |
||||
|
if (!env.SELF_HOSTED) { |
||||
|
const status = await accounts.getStatus() |
||||
|
ctx.body = status |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
const Router = require("@koa/router") |
||||
|
const controller = require("../../controllers/system/status") |
||||
|
|
||||
|
const router = Router() |
||||
|
|
||||
|
router.get("/api/system/status", controller.fetch) |
||||
|
|
||||
|
module.exports = router |
||||
Loading…
Reference in new issue