Skip to content

Commit d4c37db

Browse files
committed
fixik
1 parent baa55cb commit d4c37db

28 files changed

+2042
-14
lines changed

internal/docs/front/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
node_modules
2+
3+
# Output
4+
.output
5+
.vercel
6+
.netlify
7+
.wrangler
8+
/.svelte-kit
9+
/build
10+
11+
# OS
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Env
16+
.env
17+
.env.*
18+
!.env.example
19+
!.env.test
20+
21+
# Vite
22+
vite.config.js.timestamp-*
23+
vite.config.ts.timestamp-*

internal/docs/front/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

internal/docs/front/.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Package Managers
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock

internal/docs/front/.prettierrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte"],
7+
"overrides": [
8+
{
9+
"files": "*.svelte",
10+
"options": {
11+
"parser": "svelte"
12+
}
13+
}
14+
]
15+
}

internal/docs/front/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# sv
2+
3+
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
4+
5+
## Creating a project
6+
7+
If you're seeing this, you've probably already done this step. Congrats!
8+
9+
```bash
10+
# create a new project in the current directory
11+
npx sv create
12+
13+
# create a new project in my-app
14+
npx sv create my-app
15+
```
16+
17+
## Developing
18+
19+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
20+
21+
```bash
22+
npm run dev
23+
24+
# or start the server and open the app in a new browser tab
25+
npm run dev -- --open
26+
```
27+
28+
## Building
29+
30+
To create a production version of your app:
31+
32+
```bash
33+
npm run build
34+
```
35+
36+
You can preview the production build with `npm run preview`.
37+
38+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.

internal/docs/front/package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "front",
3+
"private": true,
4+
"version": "0.0.1",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite dev",
8+
"build": "vite build",
9+
"preview": "vite preview",
10+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12+
"format": "prettier --write .",
13+
"lint": "prettier --check ."
14+
},
15+
"devDependencies": {
16+
"@sveltejs/adapter-auto": "^3.0.0",
17+
"@sveltejs/kit": "^2.9.0",
18+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
19+
"prettier": "^3.3.2",
20+
"prettier-plugin-svelte": "^3.2.6",
21+
"svelte": "^5.0.0",
22+
"svelte-check": "^4.0.0",
23+
"typescript": "^5.0.0",
24+
"vite": "^6.0.0"
25+
},
26+
"dependencies": {
27+
"@sveltejs/adapter-static": "^3.0.6",
28+
"@toast-ui/editor": "^3.2.2",
29+
"bulma": "^1.0.2"
30+
}
31+
}

internal/docs/front/src/app.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// See https://svelte.dev/docs/kit/types#app.d.ts
2+
// for information about these interfaces
3+
declare global {
4+
namespace App {
5+
// interface Error {}
6+
// interface Locals {}
7+
// interface PageData {}
8+
// interface PageState {}
9+
// interface Platform {}
10+
}
11+
}
12+
13+
export {};

internal/docs/front/src/app.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
%sveltekit.head%
8+
<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
9+
</head>
10+
<body data-sveltekit-preload-data="hover">
11+
<div style="display: contents">%sveltekit.body%</div>
12+
</body>
13+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const ssr = false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script>
2+
import { page } from '$app/stores';
3+
import 'bulma/css/bulma.min.css';
4+
import { goto } from '$app/navigation';
5+
6+
let isAuthenticated = false;
7+
8+
$: {
9+
isAuthenticated = typeof localStorage !== 'undefined' && !!localStorage.getItem('token');
10+
}
11+
12+
function logout() {
13+
localStorage.removeItem('token');
14+
goto('/login');
15+
}
16+
</script>
17+
18+
<nav class="navbar" role="navigation" aria-label="main navigation">
19+
<div class="navbar-brand">
20+
<a class="navbar-item has-text-weight-bold" href="/"> Docs </a>
21+
</div>
22+
<div class="navbar-end">
23+
<div class="navbar-item">
24+
<div class="buttons">
25+
{#if !isAuthenticated}
26+
<a class="button is-light" href="/organization/create">Create Organization</a>
27+
<a class="button is-light" href="/create-user">Create User</a>
28+
<a class="button is-primary" href="/login">Login</a>
29+
{:else}
30+
<a class="button is-light" href="/dashboard">Dashboard</a>
31+
<button class="button is-danger" on:click={logout}>Logout</button>
32+
{/if}
33+
</div>
34+
</div>
35+
</div>
36+
</nav>
37+
38+
<main>
39+
<slot />
40+
</main>
41+
42+
<style>
43+
main {
44+
padding: 1rem;
45+
/* background-color: white; */
46+
min-height: calc(100vh - 3.25rem);
47+
}
48+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script lang="ts">
2+
import { onMount } from 'svelte';
3+
import { goto } from '$app/navigation';
4+
5+
onMount(() => {
6+
const isAuthenticated = typeof localStorage !== 'undefined' && !!localStorage.getItem('token');
7+
if (isAuthenticated) {
8+
goto('/dashboard');
9+
}
10+
});
11+
</script>
12+
13+
<div class="container has-text-centered">
14+
<h1 class="title is-1">Welcome to Docs</h1>
15+
<p class="subtitle">
16+
Please <a href="/login">login</a> to continue or <a href="/create-user">create an account</a>
17+
</p>
18+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<script lang="ts">
2+
import { enhance } from '$app/forms';
3+
import { goto } from '$app/navigation';
4+
import 'bulma/css/bulma.min.css';
5+
import { PUBLIC_API_URL } from '$env/static/public';
6+
7+
let loading = false;
8+
let error = '';
9+
let showCreatedUser = false;
10+
let createdUser = null;
11+
12+
async function handleSubmit(event: SubmitEvent) {
13+
loading = true;
14+
error = '';
15+
16+
try {
17+
const form = event.target as HTMLFormElement;
18+
const formData = new FormData(form);
19+
20+
const response = await fetch(`${PUBLIC_API_URL}/users`, {
21+
method: 'POST',
22+
body: JSON.stringify({
23+
username: formData.get('username'),
24+
password: formData.get('password'),
25+
token: formData.get('token')
26+
}),
27+
headers: {
28+
'Content-Type': 'application/json'
29+
}
30+
});
31+
32+
if (!response.ok) {
33+
const data = await response.json();
34+
throw new Error(JSON.stringify(data.detail) || 'Failed to create user');
35+
}
36+
37+
createdUser = await response.json();
38+
showCreatedUser = true;
39+
localStorage.setItem('created_user_email', createdUser.email);
40+
} catch (e) {
41+
error = e.message;
42+
} finally {
43+
loading = false;
44+
}
45+
}
46+
</script>
47+
48+
<div class="section">
49+
<div class="container">
50+
<div class="columns is-centered">
51+
<div class="column is-half">
52+
<div class="box">
53+
<h1 class="title has-text-centered">Create User</h1>
54+
55+
{#if error}
56+
<div class="notification is-danger">
57+
{error}
58+
</div>
59+
{/if}
60+
61+
<form on:submit|preventDefault={handleSubmit}>
62+
<div class="field">
63+
<label class="label" for="username">Username</label>
64+
<div class="control">
65+
<input
66+
class="input"
67+
type="text"
68+
name="username"
69+
id="username"
70+
placeholder="user"
71+
required
72+
/>
73+
</div>
74+
</div>
75+
76+
<div class="field">
77+
<label class="label" for="name">Password</label>
78+
<div class="control">
79+
<input
80+
class="input"
81+
type="password"
82+
name="password"
83+
id="password"
84+
placeholder="John Doe"
85+
required
86+
/>
87+
</div>
88+
</div>
89+
90+
<div class="field">
91+
<label class="label" for="token">Organization Token</label>
92+
<div class="control">
93+
<input
94+
class="input"
95+
type="text"
96+
name="token"
97+
id="token"
98+
placeholder="looong string"
99+
value={localStorage.getItem('org_token') || ''}
100+
required
101+
/>
102+
</div>
103+
</div>
104+
105+
<div class="field mt-5">
106+
<div class="control">
107+
<button
108+
class="button is-primary is-fullwidth {loading ? 'is-loading' : ''}"
109+
type="submit"
110+
disabled={loading}
111+
>
112+
Create User
113+
</button>
114+
</div>
115+
</div>
116+
</form>
117+
</div>
118+
119+
{#if showCreatedUser}
120+
<div class="card">
121+
<div class="has-text-centered mt-4">
122+
<p>User ID: {createdUser.id}</p>
123+
<p>Email: {createdUser.email}</p>
124+
<p>Password: {createdUser.password}</p>
125+
</div>
126+
</div>
127+
<div class="has-text-centered mt-4">
128+
<a href="/login" class="has-text-grey"> Login </a>
129+
</div>
130+
{/if}
131+
</div>
132+
</div>
133+
</div>
134+
</div>
135+
136+
<style>
137+
.box {
138+
margin-top: 2rem;
139+
}
140+
141+
.title {
142+
margin-bottom: 2rem;
143+
}
144+
145+
.field {
146+
margin-bottom: 1.5rem;
147+
}
148+
149+
.button.is-primary {
150+
background-color: #00d1b2;
151+
transition: background-color 0.2s ease;
152+
}
153+
154+
.button.is-primary:hover {
155+
background-color: #00c4a7;
156+
}
157+
158+
.mt-4 {
159+
margin-top: 1.5rem;
160+
}
161+
162+
.mt-5 {
163+
margin-top: 2rem;
164+
}
165+
</style>

0 commit comments

Comments
 (0)