Added login
This commit is contained in:
parent
7833f5326e
commit
6fe708664e
@ -1,16 +1,10 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
|
||||
plugins: ['svelte3', '@typescript-eslint'],
|
||||
ignorePatterns: ['*.cjs'],
|
||||
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
|
||||
settings: {
|
||||
'svelte3/typescript': () => require('typescript')
|
||||
},
|
||||
extends: ['eslint:recommended', 'plugin:svelte/recommended', 'prettier'],
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 2020
|
||||
ecmaVersion: 2020,
|
||||
extraFileExtensions: ['.svelte']
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
|
17
jsconfig.json
Normal file
17
jsconfig.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true
|
||||
}
|
||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias and https://kit.svelte.dev/docs/configuration#files
|
||||
//
|
||||
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||
}
|
1079
package-lock.json
generated
1079
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
34
package.json
34
package.json
@ -6,40 +6,34 @@
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "playwright test",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"test:unit": "vitest",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
|
||||
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
||||
"format": "prettier --plugin-search-dir . --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.28.1",
|
||||
"@skeletonlabs/skeleton": "^1.0.0",
|
||||
"@floating-ui/dom": "^1.5.1",
|
||||
"@skeletonlabs/skeleton": "^1.12.0",
|
||||
"@sveltejs/adapter-auto": "^2.0.0",
|
||||
"@sveltejs/kit": "^1.5.0",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||
"@typescript-eslint/parser": "^5.45.0",
|
||||
"autoprefixer": "^10.4.7",
|
||||
"@tailwindcss/forms": "^0.5.4",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"autoprefixer": "^10.4.15",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss-load-config": "^4.0.1",
|
||||
"eslint-plugin-svelte": "^2.26.0",
|
||||
"postcss": "^8.4.28",
|
||||
"prettier": "^2.8.0",
|
||||
"prettier-plugin-svelte": "^2.8.1",
|
||||
"sass": "^1.65.1",
|
||||
"svelte": "^3.54.0",
|
||||
"svelte-check": "^3.0.1",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"tailwindcss": "^3.1.5",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.3",
|
||||
"vite": "^4.0.0",
|
||||
"vitest": "^0.25.3"
|
||||
"tailwindcss": "^3.3.3",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^4.3.0"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"axios": "^1.3.4"
|
||||
"axios": "^1.4.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {}
|
||||
}
|
||||
};
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
22
src/app.html
22
src/app.html
@ -1,12 +1,12 @@
|
||||
<!DOCTYPE html >
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-theme="skeleton">
|
||||
<div style="display: contents" class="h-full overflow-hidden">%sveltekit.body%</div>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover" data-theme="skeleton">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,11 +1,44 @@
|
||||
<script lang="ts">
|
||||
import '../app.pcss';
|
||||
// The ordering of these imports is critical to your app working properly
|
||||
import '@skeletonlabs/skeleton/themes/theme-skeleton.css';
|
||||
// If you have source.organizeImports set to true in VSCode, then it will auto change this ordering
|
||||
import '@skeletonlabs/skeleton/styles/all.css';
|
||||
// Most of your app wide CSS should be put in this file
|
||||
import '../app.pcss';
|
||||
// The ordering of these imports is critical to your app working properly
|
||||
import '@skeletonlabs/skeleton/themes/theme-skeleton.css';
|
||||
// If you have source.organizeImports set to true in VSCode, then it will auto change this ordering
|
||||
import '@skeletonlabs/skeleton/styles/all.css';
|
||||
// Most of your app wide CSS should be put in this file
|
||||
import '../app.postcss';
|
||||
|
||||
import {alerts, globals} from "$lib/stores.js";
|
||||
|
||||
let alertsvar;
|
||||
let globalvars;
|
||||
|
||||
function closeWarning(e) {
|
||||
let index = e.target.dataset.index;
|
||||
alerts.update(function (data) {
|
||||
data.splice(index, 1)
|
||||
return data;
|
||||
})
|
||||
}
|
||||
alerts.subscribe((value) => {
|
||||
alertsvar = value;
|
||||
});
|
||||
globals.subscribe(value => {
|
||||
globalvars = value;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if typeof globalvars.user !== 'undefined' }
|
||||
{#each alertsvar as alert, i}
|
||||
<aside class="alert variant-filled-{alert.class}">
|
||||
<!-- Icon -->
|
||||
<div><i class="text-2xl icon icon-exclamation-triangle"></i></div>
|
||||
<!-- Message -->
|
||||
<p class="alert-message">{alert.text}</p>
|
||||
<!-- Actions -->
|
||||
<div class="alert-actions">
|
||||
<i on:click={closeWarning} data-index={i} class="icon icon-close"></i>
|
||||
</div>
|
||||
</aside>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<slot />
|
||||
|
@ -1,9 +1,22 @@
|
||||
<script>
|
||||
import { goto } from '$app/navigation';
|
||||
import { onMount } from 'svelte';
|
||||
import {globals} from "$lib/stores.js";
|
||||
|
||||
let globalvars;
|
||||
|
||||
globals.subscribe(value => {
|
||||
globalvars = value;
|
||||
});
|
||||
|
||||
onMount(async () => {
|
||||
goto("/account/login");
|
||||
if(typeof globalvars.user === 'undefined') {
|
||||
goto("/account/login");
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{#if typeof globalvars.user !== 'undefined'}
|
||||
<h1>Welcome {globalvars.user.name}</h1>
|
||||
{/if}
|
@ -1,20 +1,23 @@
|
||||
<div class="container h-full mx-auto flex justify-center items-center flex-col">
|
||||
<h1 class="my-3">Blackbird Chess</h1>
|
||||
|
||||
{#each alertsvar as alert, i}
|
||||
<aside class="alert variant-filled-{alert.class}">
|
||||
<!-- Icon -->
|
||||
<div><i class="text-2xl icon icon-exclamation-triangle"></i></div>
|
||||
<!-- Message -->
|
||||
<p class="alert-message">{alert.text}</p>
|
||||
<!-- Actions -->
|
||||
<div class="alert-actions">
|
||||
<i on:click={closeWarning} data-index={i} class="icon icon-close"></i>
|
||||
</div>
|
||||
</aside>
|
||||
{/each}
|
||||
|
||||
<slot />
|
||||
{#if typeof globalvars.user == 'undefined' }
|
||||
{#each alertsvar as alert, i}
|
||||
<aside class="alert variant-filled-{alert.class} mb-3">
|
||||
<!-- Icon -->
|
||||
<div><i class="text-2xl icon icon-exclamation-triangle"></i></div>
|
||||
<!-- Message -->
|
||||
<p class="alert-message">{alert.text}</p>
|
||||
<!-- Actions -->
|
||||
<div class="alert-actions">
|
||||
<i on:click={closeWarning} data-index={i} class="icon icon-close"></i>
|
||||
</div>
|
||||
</aside>
|
||||
{/each}
|
||||
{/if}
|
||||
<div class="card p-4 w-50 text-token space-y-4">
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -23,9 +26,11 @@
|
||||
</style>
|
||||
|
||||
<script lang="js">
|
||||
import {alerts} from "$lib/stores.js";
|
||||
import {alerts, globals} from "$lib/stores.js";
|
||||
|
||||
let alertsvar;
|
||||
let globalvars;
|
||||
|
||||
function closeWarning(e) {
|
||||
let index = e.target.dataset.index;
|
||||
alerts.update(function (data) {
|
||||
@ -36,4 +41,8 @@
|
||||
alerts.subscribe((value) => {
|
||||
alertsvar = value;
|
||||
});
|
||||
|
||||
globals.subscribe(value => {
|
||||
globalvars = value;
|
||||
});
|
||||
</script>
|
@ -3,7 +3,7 @@
|
||||
</div>
|
||||
<form name="login-server" class="flex flex-col">
|
||||
<label class="label my-3">
|
||||
<span>Username:</span>
|
||||
<span>E-Mail:</span>
|
||||
<input type="email" name="email" id="login-email" class="input" bind:value={email}>
|
||||
</label>
|
||||
<label class="label my-3">
|
||||
@ -31,6 +31,9 @@
|
||||
import { urls, alerts, globals } from "$lib/stores.js";
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import {browser} from "$app/environment";
|
||||
import {requestor} from "../../../serverrequest.js";
|
||||
import {throwError} from "svelte-preprocess/dist/modules/errors.js";
|
||||
import {goto} from "$app/navigation";
|
||||
|
||||
var email = '';
|
||||
var password = '';
|
||||
@ -41,10 +44,23 @@
|
||||
globalvars = value;
|
||||
});
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function handleLogin() {
|
||||
alerts.update(data => [...data, {text: 'Not yet implemented', type: 'notimplemented', class: 'warning'}]);
|
||||
async function handleLogin() {
|
||||
try {
|
||||
let postdata = {email: email, password: password}
|
||||
let response = await requestor.post(urls.login, JSON.stringify(postdata));
|
||||
let responsedata = JSON.parse(response.data);
|
||||
if(response.status != 200) {
|
||||
let message = 'Something went wrong during login'
|
||||
if(typeof responsedata.message !== 'undefined') message = responsedata.message
|
||||
throwError(message)
|
||||
}
|
||||
if(!responsedata.success) return alerts.update(data => [...data, {text: 'Login failed: ' + responsedata.message , class: 'error'}]);
|
||||
globals.update((globalobj) => ({ ...globalobj, ...{user: responsedata.user }}));
|
||||
goto('/')
|
||||
} catch (error) {
|
||||
return alerts.update(data => [...data, {text: error, class: 'error'}]);
|
||||
}
|
||||
}
|
||||
|
||||
function handleGoToServerSelect() {
|
||||
|
@ -166,11 +166,11 @@
|
||||
let responsejson = JSON.parse(response.data);
|
||||
if (response.status !== 200) {
|
||||
alerts.update(data => data.filter(alert => alert.type !== 'register-errors'));
|
||||
alerts.update(data => [...data, {text: responsejson.message, type: 'register-errors', class: 'error'}]);
|
||||
alerts.update(data => [...data, {text: responsejson.Message, type: 'register-errors', class: 'error'}]);
|
||||
return false;
|
||||
}
|
||||
alerts.update(data => []);
|
||||
alerts.update(data => [...data, {text: responsejson.message, type: 'register-success', class: 'success'}]);
|
||||
alerts.update(data => [...data, {text: responsejson.Message, type: 'register-success', class: 'success'}]);
|
||||
return false;
|
||||
} catch (error) {
|
||||
alerts.update(data => [...data, {text: 'Server unavailable', type: 'noserveravailable', class: 'error'}]);
|
||||
|
@ -3,7 +3,8 @@ import {Axios} from "axios";
|
||||
var options = {
|
||||
headers: {
|
||||
'X-BlackbirdChessClient': 'webclient',
|
||||
"Content-Type": "application/json",
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,10 @@
|
||||
import preprocess from 'svelte-preprocess';
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import { vitePreprocess } from '@sveltejs/kit/vite';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||
// for more information about preprocessors
|
||||
preprocess: [
|
||||
vitePreprocess(),
|
||||
preprocess({
|
||||
postcss: true
|
||||
})
|
||||
],
|
||||
preprocess: vitePreprocess(),
|
||||
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||
@ -20,5 +13,4 @@ const config = {
|
||||
adapter: adapter()
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
@ -1,15 +1,14 @@
|
||||
import { join } from 'path'
|
||||
import forms from '@tailwindcss/forms'
|
||||
import typography from '@tailwindcss/typography'
|
||||
import skeleton from '@skeletonlabs/skeleton/tailwind/skeleton.cjs'
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
darkMode: 'class',
|
||||
content: [
|
||||
'./src/**/*.{html,js,svelte,ts}',
|
||||
require('path').join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')
|
||||
],
|
||||
content: ['./src/**/*.{html,js,svelte,ts}', join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')],
|
||||
theme: {
|
||||
extend: {}
|
||||
extend: {},
|
||||
},
|
||||
plugins: [
|
||||
...require('@skeletonlabs/skeleton/tailwind/skeleton.cjs')(),
|
||||
require('@tailwindcss/forms')
|
||||
]
|
||||
};
|
||||
plugins: [forms,typography,...skeleton()],
|
||||
}
|
||||
|
6
vite.config.js
Normal file
6
vite.config.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit()]
|
||||
});
|
Loading…
Reference in New Issue
Block a user