|
@@ -1,11 +1,89 @@
|
|
|
<script>
|
|
<script>
|
|
|
-import "bulma/css/bulma.min.css";
|
|
|
|
|
|
|
+ import "bulma/css/bulma.min.css";
|
|
|
|
|
+
|
|
|
|
|
+ import { onMount } from "svelte";
|
|
|
|
|
+
|
|
|
|
|
+ import auth from "./auth0";
|
|
|
|
|
+ import client from "./unleash";
|
|
|
|
|
+
|
|
|
|
|
+ import {
|
|
|
|
|
+ auth0Authenticated, auth0Claims,
|
|
|
|
|
+ featureImage, featureNotification, featureTable
|
|
|
|
|
+ } from "./store";
|
|
|
|
|
+
|
|
|
|
|
+ import Image from "./Image.svelte";
|
|
|
|
|
+ import Table from "./Table.svelte";
|
|
|
|
|
+ import Notification from "./Notification.svelte";
|
|
|
|
|
+
|
|
|
|
|
+ let auth0Client;
|
|
|
|
|
+ let authenticated;
|
|
|
|
|
+ let claims;
|
|
|
|
|
+
|
|
|
|
|
+ let enabledImage;
|
|
|
|
|
+ let enabledNotification;
|
|
|
|
|
+ let enabledTable;
|
|
|
|
|
+
|
|
|
|
|
+ auth0Authenticated.subscribe(value => authenticated = value);
|
|
|
|
|
+
|
|
|
|
|
+ auth0Claims.subscribe(value => {
|
|
|
|
|
+ claims = value;
|
|
|
|
|
+ let username = claims ? claims.email : "";
|
|
|
|
|
+ if (username) client.updateUnleashUserId(username);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ featureImage.subscribe(value => enabledImage = value);
|
|
|
|
|
+ featureNotification.subscribe(value => enabledNotification = value);
|
|
|
|
|
+ featureTable.subscribe(value => enabledTable = value);
|
|
|
|
|
+
|
|
|
|
|
+ onMount(async () => {
|
|
|
|
|
+ auth0Client = await auth.createClient();
|
|
|
|
|
+
|
|
|
|
|
+ let isAuthenticated = await auth0Client.isAuthenticated();
|
|
|
|
|
+ auth0Authenticated.set(isAuthenticated);
|
|
|
|
|
+ if (isAuthenticated) {
|
|
|
|
|
+ auth0Claims.set(await auth0Client.getIdTokenClaims());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ function login() {
|
|
|
|
|
+ auth.loginWithPopup(auth0Client);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function logout() {
|
|
|
|
|
+ auth.logout(auth0Client);
|
|
|
|
|
+ }
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template lang="pug">
|
|
<template lang="pug">
|
|
|
.columns.mt-4
|
|
.columns.mt-4
|
|
|
.column.is-4.is-offset-4
|
|
.column.is-4.is-offset-4
|
|
|
- .nav-panel
|
|
|
|
|
- p.panel-heading Lorem Ipsum
|
|
|
|
|
- .panel-block Lorem ipsum dolor sit amet.
|
|
|
|
|
|
|
+ .card
|
|
|
|
|
+ | {#if authenticated}
|
|
|
|
|
+ p.card-header-title.is-centered {claims ? claims.email : ""}
|
|
|
|
|
+ .card-content
|
|
|
|
|
+ .content Logged in as {claims ? claims.name : ""} {claims ? claims.family_name : ""}
|
|
|
|
|
+ footer.card-footer
|
|
|
|
|
+ a.card-footer-item(href="/#" on:click="{logout}") Log out
|
|
|
|
|
+ | {:else}
|
|
|
|
|
+ p.card-header-title.is-centered Important
|
|
|
|
|
+ .card-content
|
|
|
|
|
+ .content Access required
|
|
|
|
|
+ footer.card-footer
|
|
|
|
|
+ a.card-footer-item(href="/#" on:click="{login}") Log in
|
|
|
|
|
+ | {/if}
|
|
|
|
|
+ | {#if authenticated}
|
|
|
|
|
+ .columns.mt-4
|
|
|
|
|
+ | {#if enabledImage}
|
|
|
|
|
+ .column.is-4
|
|
|
|
|
+ <Image/>
|
|
|
|
|
+ | {/if}
|
|
|
|
|
+ | {#if enabledNotification}
|
|
|
|
|
+ .column.is-4
|
|
|
|
|
+ <Notification/>
|
|
|
|
|
+ | {/if}
|
|
|
|
|
+ | {#if enabledTable}
|
|
|
|
|
+ .column.is-4
|
|
|
|
|
+ <Table/>
|
|
|
|
|
+ | {/if}
|
|
|
|
|
+ | {/if}
|
|
|
</template>
|
|
</template>
|