Skip to content

Commit

Permalink
Display banner to indicate license expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Oct 4, 2024
1 parent 7ae9edf commit f664688
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
62 changes: 62 additions & 0 deletions enterprise/frontend/src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<script lang="ts">
// Most of your app wide CSS should be put in this file
import '../../app.postcss';
import { AppShell, AppBar } from '@skeletonlabs/skeleton';
import { safeTranslate } from '$lib/utils/i18n';
import SideBar from '$lib/components/SideBar/SideBar.svelte';
import Breadcrumbs from '$lib/components/Breadcrumbs/Breadcrumbs.svelte';
import { pageTitle, clientSideToast } from '$lib/utils/stores';
import { getCookie, deleteCookie } from '$lib/utils/cookies';
import { browser } from '$app/environment';
import * as m from '$paraglide/messages';
let sidebarOpen = true;
$: classesSidebarOpen = (open: boolean) => (open ? 'ml-64' : 'ml-7');
$: if (browser) {
const fromLogin = getCookie('from_login');
if (fromLogin === 'true') {
deleteCookie('from_login');
fetch('/api/waiting-risk-acceptances').then(async (res) => {
const data = await res.json();
const number = data.count ?? 0;
if (number <= 0) return;
clientSideToast.set({
message: m.waitingRiskAcceptances({
number: number,
s: number > 1 ? 's' : '',
itPlural: number > 1 ? 'i' : 'e'
}),
type: 'info'
});
});
}
}
</script>

<!-- App Shell -->
<AppShell
slotPageContent="p-8 bg-gradient-to-br from-violet-100 to-slate-200"
regionPage="transition-all duration-300 {classesSidebarOpen(sidebarOpen)}"
>
<svelte:fragment slot="sidebarLeft">
<SideBar bind:open={sidebarOpen} />
</svelte:fragment>
<svelte:fragment slot="pageHeader">
<AppBar background="bg-white" padding="py-2 px-4">
<span
class="text-2xl font-bold pb-1 bg-gradient-to-r from-pink-500 to-violet-600 bg-clip-text text-transparent"
id="page-title"
>
{safeTranslate($pageTitle)}
</span>
<hr class="w-screen my-1" />
<Breadcrumbs />
</AppBar>
</svelte:fragment>
<!-- Router Slot -->
<slot />
<!-- ---- / ---- -->
</AppShell>
4 changes: 3 additions & 1 deletion enterprise/frontend/src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { LayoutServerLoad } from './$types';
import type { GlobalSettings } from '$lib/utils/types';
import { BASE_API_URL } from '$lib/utils/constants';

export const load: LayoutServerLoad = async ({ fetch, locals }) => {
let clientSettings: GlobalSettings;
if (!locals.globalSettings) {
const _settings = await fetch('/settings/client-settings').then((res) => res.json());
clientSettings = { name: 'clientSettings', settings: _settings };
} else clientSettings = locals.globalSettings;
return { featureFlags: locals.featureFlags, clientSettings };
const licenseStatus = await fetch(`${BASE_API_URL}/license-status/`).then(res => res.json())
return { featureFlags: locals.featureFlags, clientSettings, licenseStatus };
};
3 changes: 2 additions & 1 deletion frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,5 +750,6 @@
"theFollowingControlsWillBeAddedColon": "The following controls will be added:",
"ShowAllNodesMessage": "Show all",
"ShowOnlyAssessable": "Only assessable",
"NoPreviewMessage": "No preview available."
"NoPreviewMessage": "No preview available.",
"licenseExpiredMessage": "Your license has expired. Write operations are disabled. Please contact your administrator to renew it."
}
8 changes: 8 additions & 0 deletions frontend/src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import { getCookie, deleteCookie } from '$lib/utils/cookies';
import { browser } from '$app/environment';
import * as m from '$paraglide/messages';
import type { LayoutData } from './$types';
export let data: LayoutData;
let sidebarOpen = true;
Expand Down Expand Up @@ -45,6 +48,11 @@
<SideBar bind:open={sidebarOpen} />
</svelte:fragment>
<svelte:fragment slot="pageHeader">
{#if data.licenseStatus.status === 'expired'}
<aside class="variant-soft-warning text-center w-full items-center py-2">
{m.licenseExpiredMessage()}
</aside>
{/if}
<AppBar background="bg-white" padding="py-2 px-4">
<span
class="text-2xl font-bold pb-1 bg-gradient-to-r from-pink-500 to-violet-600 bg-clip-text text-transparent"
Expand Down

0 comments on commit f664688

Please sign in to comment.