2021-05-14 21:51:14 +02:00
|
|
|
<script>
|
|
|
|
import { browser } from '$app/env';
|
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
import { session } from '$app/stores';
|
2021-06-22 10:19:20 +02:00
|
|
|
import { toast } from '@zerodevx/svelte-toast';
|
|
|
|
import PasswordField from '$components/PasswordField.svelte';
|
2021-05-16 21:54:44 +02:00
|
|
|
import { request } from '$lib/request';
|
2021-06-22 10:19:20 +02:00
|
|
|
import { settings } from '$store';
|
|
|
|
import Loading from '$components/Loading.svelte';
|
|
|
|
let loading = false;
|
|
|
|
let email = null;
|
|
|
|
let password = null;
|
2021-05-14 21:51:14 +02:00
|
|
|
async function login() {
|
|
|
|
const left = screen.width / 2 - 1020 / 2;
|
|
|
|
const top = screen.height / 2 - 618 / 2;
|
|
|
|
const newWindow = open(
|
|
|
|
`https://github.com/login/oauth/authorize?client_id=${
|
|
|
|
import.meta.env.VITE_GITHUB_APP_CLIENTID
|
|
|
|
}`,
|
|
|
|
'Authenticate',
|
|
|
|
'resizable=1, scrollbars=1, fullscreen=0, height=618, width=1020,top=' +
|
|
|
|
top +
|
|
|
|
', left=' +
|
|
|
|
left +
|
|
|
|
', toolbar=0, menubar=0, status=0'
|
|
|
|
);
|
|
|
|
const timer = setInterval(() => {
|
2021-06-07 21:33:11 +02:00
|
|
|
if (newWindow?.closed) {
|
2021-05-14 21:51:14 +02:00
|
|
|
clearInterval(timer);
|
2021-06-22 10:19:20 +02:00
|
|
|
browser && location.reload();
|
2021-05-14 21:51:14 +02:00
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}
|
2021-06-22 10:19:20 +02:00
|
|
|
async function loginWithEmail() {
|
|
|
|
try {
|
|
|
|
loading = true;
|
2021-06-22 11:40:02 +02:00
|
|
|
const { message } = await request('/api/v1/login/email', $session, {
|
2021-06-22 10:19:20 +02:00
|
|
|
body: {
|
|
|
|
email,
|
|
|
|
password
|
|
|
|
}
|
|
|
|
});
|
2021-06-22 11:40:02 +02:00
|
|
|
toast.push(message);
|
2021-06-22 11:20:21 +02:00
|
|
|
setTimeout(() => {
|
2021-06-22 12:07:51 +02:00
|
|
|
browser && window.location.replace('/')
|
2021-06-22 11:20:21 +02:00
|
|
|
}, 1000);
|
2021-06-22 11:12:30 +02:00
|
|
|
} catch (error) {
|
2021-06-22 10:19:20 +02:00
|
|
|
loading = false;
|
2021-06-22 11:12:30 +02:00
|
|
|
browser && toast.push(error.error || error || 'Ooops something went wrong.');
|
2021-06-22 10:19:20 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-14 21:51:14 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="flex justify-center items-center h-screen w-full bg-warmGray-900">
|
|
|
|
<div class="max-w-7xl mx-auto px-4 sm:py-24 sm:px-6 lg:px-8">
|
|
|
|
<div class="text-center">
|
|
|
|
<p
|
|
|
|
class="mt-1 pb-8 font-extrabold text-white text-5xl sm:tracking-tight lg:text-6xl text-center"
|
|
|
|
>
|
|
|
|
<span class="border-gradient">Coolify</span>
|
|
|
|
</p>
|
2021-06-22 10:19:20 +02:00
|
|
|
<h2 class="text-2xl md:text-3xl font-extrabold text-white py-10">
|
2021-05-14 21:51:14 +02:00
|
|
|
An open-source, hassle-free, self-hostable<br />
|
|
|
|
<span class="text-indigo-400">Heroku</span>
|
|
|
|
& <span class="text-green-400">Netlify</span> alternative
|
|
|
|
</h2>
|
2021-06-22 10:19:20 +02:00
|
|
|
{#if loading}
|
2021-06-22 10:44:08 +02:00
|
|
|
<Loading fullscreen={false} />
|
2021-06-22 10:19:20 +02:00
|
|
|
{:else}
|
|
|
|
<div class="text-center py-10 max-w-7xl">
|
2021-06-22 11:40:02 +02:00
|
|
|
{$session.isLoggedIn}
|
2021-06-22 10:19:20 +02:00
|
|
|
{#if !$session.isLoggedIn}
|
|
|
|
{#if $settings.clientId}
|
|
|
|
<button
|
|
|
|
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
|
|
|
|
on:click={login}>Login with GitHub</button
|
|
|
|
>
|
|
|
|
{:else}
|
|
|
|
<div>
|
|
|
|
<div class="grid grid-flow-row gap-2 items-center pb-6">
|
|
|
|
<div class="grid grid-flow-row">
|
|
|
|
<label for="Email" class="">Email address</label>
|
|
|
|
<input
|
|
|
|
class="border-2"
|
|
|
|
id="Email"
|
|
|
|
bind:value={email}
|
|
|
|
placeholder="hi@coollabs.io"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="grid grid-flow-row">
|
|
|
|
<label for="Password" class="">Password</label>
|
|
|
|
<PasswordField bind:value={password} isEditable />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="space-x-4 pt-10">
|
|
|
|
<button
|
|
|
|
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
|
|
|
|
on:click={loginWithEmail}>Login with Email</button
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{:else}
|
|
|
|
<button
|
|
|
|
class="text-white bg-warmGray-800 hover:bg-warmGray-700 rounded p-2 px-10 font-bold"
|
2021-06-22 10:44:08 +02:00
|
|
|
on:click={() =>
|
|
|
|
$settings.clientId ? goto('/dashboard/applications') : goto('/dashboard/services')}
|
|
|
|
>Get Started</button
|
2021-06-22 10:19:20 +02:00
|
|
|
>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
{/if}
|
2021-05-14 21:51:14 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|