2024-09-29 13:56:38 +02:00
|
|
|
import * as plugins from '../plugins.js';
|
2024-09-29 16:48:06 +02:00
|
|
|
import * as elements from '../elements/index.js';
|
2024-09-29 13:56:38 +02:00
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
customElement,
|
|
|
|
|
DeesElement,
|
|
|
|
|
property,
|
|
|
|
|
html,
|
|
|
|
|
cssManager,
|
|
|
|
|
unsafeCSS,
|
|
|
|
|
css,
|
|
|
|
|
type TemplateResult,
|
2025-11-30 15:01:28 +00:00
|
|
|
directives
|
2024-09-29 13:56:38 +02:00
|
|
|
} from '@design.estate/dees-element';
|
2025-11-30 15:01:28 +00:00
|
|
|
|
2024-09-29 16:48:06 +02:00
|
|
|
import type { IdpViewcontainer } from '../views/viewcontainer.js';
|
2024-10-06 23:56:03 +02:00
|
|
|
import { IdpState } from '../states/idp.state.js';
|
2024-09-29 13:56:38 +02:00
|
|
|
|
|
|
|
|
@customElement('idp-welcome')
|
|
|
|
|
export class IdpWelcome extends DeesElement {
|
2024-09-29 16:48:06 +02:00
|
|
|
viewContainer: IdpViewcontainer;
|
2024-09-29 13:56:38 +02:00
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
|
css`
|
|
|
|
|
:host {
|
2025-11-30 22:35:24 +00:00
|
|
|
--foreground: hsl(0 0% 98%);
|
|
|
|
|
--muted-foreground: hsl(240 5% 64.9%);
|
|
|
|
|
|
2024-09-29 13:56:38 +02:00
|
|
|
display: block;
|
2025-11-30 22:35:24 +00:00
|
|
|
color: var(--foreground);
|
|
|
|
|
font-family: 'Geist Sans', -apple-system, BlinkMacSystemFont, sans-serif;
|
2024-09-29 13:56:38 +02:00
|
|
|
}
|
2025-11-30 22:35:24 +00:00
|
|
|
|
2024-09-29 13:56:38 +02:00
|
|
|
:host([hidden]) {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-30 22:35:24 +00:00
|
|
|
.form-header {
|
|
|
|
|
margin-bottom: 32px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-header h2 {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: var(--foreground);
|
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
|
letter-spacing: -0.02em;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-header p {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: var(--muted-foreground);
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.button-group {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.secondary-actions {
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
padding-top: 24px;
|
|
|
|
|
border-top: 1px solid hsla(240 3.7% 15.9% / 0.5);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 8px;
|
2024-09-29 13:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-07 15:14:44 +02:00
|
|
|
.greeting {
|
2025-11-30 22:35:24 +00:00
|
|
|
font-size: 14px;
|
|
|
|
|
color: var(--muted-foreground);
|
2024-10-07 15:14:44 +02:00
|
|
|
text-align: center;
|
2025-11-30 22:35:24 +00:00
|
|
|
margin-bottom: 8px;
|
2024-09-29 13:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
2025-11-30 22:35:24 +00:00
|
|
|
.greeting strong {
|
|
|
|
|
color: var(--foreground);
|
|
|
|
|
font-weight: 600;
|
2024-09-29 13:56:38 +02:00
|
|
|
}
|
2024-10-07 10:26:21 +02:00
|
|
|
`,
|
2024-09-29 13:56:38 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
|
return html`
|
2024-10-07 15:14:44 +02:00
|
|
|
<idp-centercontainer>
|
2025-11-30 15:01:28 +00:00
|
|
|
${directives.resolveExec(async () => {
|
2024-10-04 15:43:36 +02:00
|
|
|
const idpState = await IdpState.getSingletonInstance();
|
2024-10-07 10:26:21 +02:00
|
|
|
await idpState.idpClient.determineLoginStatus();
|
|
|
|
|
const data = await idpState.idpClient.whoIs().catch();
|
|
|
|
|
if (data?.user) {
|
|
|
|
|
return html`
|
2025-11-30 22:35:24 +00:00
|
|
|
<div class="form-header">
|
|
|
|
|
<h2>Welcome back</h2>
|
|
|
|
|
<p class="greeting">Signed in as <strong>${data.user.data.name}</strong></p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="button-group">
|
2026-05-07 15:35:37 +00:00
|
|
|
<idp-button
|
|
|
|
|
variant="accent"
|
2025-11-30 22:35:24 +00:00
|
|
|
@click=${async () => {
|
|
|
|
|
const idpState = await IdpState.getSingletonInstance();
|
2026-05-07 15:35:37 +00:00
|
|
|
idpState.domtools.router.pushUrl('/dash/overview');
|
2025-11-30 22:35:24 +00:00
|
|
|
}}
|
2026-05-07 15:35:37 +00:00
|
|
|
>Open dashboard</idp-button>
|
|
|
|
|
<idp-button
|
|
|
|
|
variant="outline"
|
2025-11-30 22:35:24 +00:00
|
|
|
@click=${async () => {
|
|
|
|
|
const idpState = await IdpState.getSingletonInstance();
|
|
|
|
|
idpState.domtools.router.pushUrl('/logout');
|
|
|
|
|
}}
|
2026-05-07 15:35:37 +00:00
|
|
|
>Sign out</idp-button>
|
2025-11-30 22:35:24 +00:00
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
return html`
|
|
|
|
|
<div class="form-header">
|
|
|
|
|
<h2>Welcome</h2>
|
|
|
|
|
<p>Sign in to your account or create a new one</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="button-group">
|
2026-05-07 15:35:37 +00:00
|
|
|
<idp-button
|
|
|
|
|
variant="accent"
|
2024-10-07 10:26:21 +02:00
|
|
|
@click=${async () => {
|
|
|
|
|
const idpState = await IdpState.getSingletonInstance();
|
2025-11-30 22:35:24 +00:00
|
|
|
idpState.domtools.router.pushUrl('/login');
|
2024-10-07 10:26:21 +02:00
|
|
|
}}
|
2026-05-07 15:35:37 +00:00
|
|
|
>Sign In</idp-button>
|
|
|
|
|
<idp-button
|
|
|
|
|
variant="outline"
|
2024-10-07 10:26:21 +02:00
|
|
|
@click=${async () => {
|
|
|
|
|
const idpState = await IdpState.getSingletonInstance();
|
2025-11-30 22:35:24 +00:00
|
|
|
idpState.domtools.router.pushUrl('/register');
|
2024-10-07 10:26:21 +02:00
|
|
|
}}
|
2026-05-07 15:35:37 +00:00
|
|
|
>Create Account</idp-button>
|
2025-11-30 22:35:24 +00:00
|
|
|
</div>
|
2024-10-07 10:26:21 +02:00
|
|
|
`;
|
|
|
|
|
})}
|
2025-11-30 22:35:24 +00:00
|
|
|
<div class="secondary-actions">
|
2026-05-07 15:35:37 +00:00
|
|
|
<idp-button
|
|
|
|
|
variant="ghost"
|
2025-11-30 22:35:24 +00:00
|
|
|
@click=${() => {
|
2026-05-07 15:35:37 +00:00
|
|
|
window.open('https://code.foss.global/idp.global/app', '_blank');
|
2025-11-30 22:35:24 +00:00
|
|
|
}}
|
2026-05-07 15:35:37 +00:00
|
|
|
>View Source Code</idp-button>
|
2024-10-07 15:14:44 +02:00
|
|
|
</div>
|
|
|
|
|
</idp-centercontainer>
|
2024-09-29 13:56:38 +02:00
|
|
|
`;
|
|
|
|
|
}
|
2024-10-07 15:14:44 +02:00
|
|
|
|
|
|
|
|
public async show() {
|
|
|
|
|
await this.updateComplete;
|
|
|
|
|
const centerContainer = this.shadowRoot.querySelector('idp-centercontainer');
|
|
|
|
|
await centerContainer.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async hide() {
|
|
|
|
|
await this.updateComplete;
|
|
|
|
|
const centerContainer = this.shadowRoot.querySelector('idp-centercontainer');
|
|
|
|
|
await centerContainer.hide();
|
|
|
|
|
}
|
2024-09-29 13:56:38 +02:00
|
|
|
}
|