Files
app/ts_web/elements/idp-welcome.ts
T

127 lines
3.4 KiB
TypeScript
Raw Normal View History

2024-09-29 13:56:38 +02:00
import * as plugins from '../plugins.js';
import * as elements from '../elements/index.js';
2024-09-29 13:56:38 +02:00
import {
customElement,
DeesElement,
property,
html,
cssManager,
unsafeCSS,
css,
resolveExec,
2024-09-29 13:56:38 +02:00
type TemplateResult,
} from '@design.estate/dees-element';
import type { IdpViewcontainer } from '../views/viewcontainer.js';
import { IdpState } from '../states/idp.state.js';
2024-09-29 13:56:38 +02:00
@customElement('idp-welcome')
export class IdpWelcome extends DeesElement {
viewContainer: IdpViewcontainer;
2024-09-29 13:56:38 +02:00
constructor() {
super();
}
public static styles = [
cssManager.defaultStyles,
css`
:host {
display: block;
color: #fff;
font-family: 'Geist Sans';
}
:host([hidden]) {
display: none;
}
2024-10-07 15:14:44 +02:00
.maincontainer {
padding: 0px 16px;
2024-09-29 13:56:38 +02:00
}
2024-10-07 15:14:44 +02:00
.greeting {
text-align: center;
font-size: 16px;
font-weight: 600;
2024-09-29 13:56:38 +02:00
margin: 24px auto;
}
2024-10-07 15:14:44 +02:00
dees-button {
2024-09-29 13:56:38 +02:00
margin-top: 16px;
2024-10-07 15:14:44 +02:00
margin-bottom: 16px;
2024-09-29 13:56:38 +02:00
}
`,
2024-09-29 13:56:38 +02:00
];
public render(): TemplateResult {
return html`
<style></style>
2024-10-07 15:14:44 +02:00
<idp-centercontainer>
<div class="maincontainer">
${resolveExec(async () => {
const idpState = await IdpState.getSingletonInstance();
await idpState.idpClient.determineLoginStatus();
const data = await idpState.idpClient.whoIs().catch();
if (data?.user) {
return html`
2024-10-07 15:14:44 +02:00
<div class="greeting">Hello ${data.user.data.name}!</div>
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/account');
}}
>Manage your account</dees-button
>
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/logout');
}}
>Logout</dees-button
>
2024-10-07 15:14:44 +02:00
`;
}
return html`
Do you want to sign in or register?
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/login');
}}
>Sign In</dees-button
>
<dees-button
@click=${async () => {
const idpState = await IdpState.getSingletonInstance();
idpState.domtools.router.pushUrl('/register');
}}
>Register</dees-button
>
`;
})}
2024-12-11 01:19:54 +01:00
<dees-button @click=${() => {}}>Learn more about idp.global</dees-button>
<dees-button @click=${() => {}}>Open Developer Dashboard</dees-button>
<dees-button
@click=${() => {
window.open('https://code.foss.global/idp.global/idp.global', '_blank');
}}
2024-10-07 15:14:44 +02:00
>Get the Source Code</dees-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
}