Skip to content

Commit b884b99

Browse files
committed
restored console and login
1 parent 47abe55 commit b884b99

File tree

19 files changed

+358
-456
lines changed

19 files changed

+358
-456
lines changed

src/main/kotlin/ua/pp/lumivoid/iwtcms/ktor/api/doAuth.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ suspend fun doAuth(
3939
}
4040

4141
return newSuspendedTransaction {
42-
val user: ResultRow =
43-
try {
44-
Users
45-
.selectAll()
46-
.where { (Users.username eq session.name) and (Users.uniqueId eq session.id) }
47-
.first()
48-
} catch (_: NoSuchElementException) {
49-
unauthorized()
50-
return@newSuspendedTransaction HttpStatusCode.Unauthorized
51-
}
42+
val user: ResultRow = try {
43+
Users
44+
.selectAll()
45+
.where { (Users.username eq session.name) and (Users.uniqueId eq session.id) }
46+
.first()
47+
} catch (_: NoSuchElementException) {
48+
unauthorized()
49+
return@newSuspendedTransaction HttpStatusCode.Unauthorized
50+
}
5251

5352
if (user[Users.admin]) {
5453
success()
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
package ua.pp.lumivoid.iwtcms.ktor.api.requests
22

3-
import io.ktor.server.request.receive
3+
import io.ktor.http.HttpStatusCode
44
import io.ktor.server.response.respond
55
import io.ktor.server.routing.Routing
66
import io.ktor.server.routing.get
77
import kotlinx.coroutines.runBlocking
8-
import kotlinx.serialization.Serializable
98
import ua.pp.lumivoid.iwtcms.ktor.api.doAuth
109

1110
object IsAllowedG : Request() {
12-
override val path = "/api/isAllowed"
11+
override val path = "/api/isAllowed/{permission}"
1312

1413
override val request: Routing.() -> Unit = {
1514
get(path) {
16-
val payload = call.receive<IsAllowedPayload>()
15+
if (call.parameters["permission"] == null) {
16+
call.respond(HttpStatusCode.Unauthorized)
17+
return@get
18+
}
1719

1820
doAuth(
1921
call = call,
20-
permission = payload.permission,
22+
permission = call.parameters["permission"]!!,
2123
success = {
2224
runBlocking { call.respond("allowed") }
2325
},
2426
)
2527
}
2628
}
2729
}
28-
29-
@Serializable
30-
data class IsAllowedPayload(
31-
val permission: String,
32-
)

src/main/web/App.svelte

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Header from "./lib/Header.svelte";
33
import Footer from "./lib/Footer.svelte";
44
import ConsoleTab from "./lib/tabs/ConsoleTab/ConsoleTab.svelte";
5-
import SettingsTab from "./lib/tabs/SettingsTab/SettingsTab.svelte";
5+
// import SettingsTab from "./lib/tabs/SettingsTab/SettingsTab.svelte";
66
import PlayersTab from "./lib/tabs/PlayersTab/PlayersTab.svelte";
77
import Login from "./lib/Login.svelte";
88
import ToastSystem from "./scripts/toastSystem";
@@ -19,15 +19,15 @@
1919

2020
<Footer />
2121

22-
{#if window.location.pathname == "/BadConnection"}
22+
{#if window.location.pathname === "/BadConnection"}
2323
<main class="h-screen content-center">
2424
<div class="flex justify-center">
2525
<a href="/"><img src={icon} alt="icon" /></a>
2626
<div class="ml-[20px] flex flex-col content-center justify-center font-['Nunito'] text-[20px]">
27-
<p1>Oh no!</p1>
28-
<p1>It seems like you have a bad connection to the server.</p1>
29-
<p1>Try to refresh the page or check your internet connection.</p1>
30-
<p1>Good luck!</p1>
27+
<h1>Oh no!</h1>
28+
<h1>It seems like you have a bad connection to the server.</h1>
29+
<h1>Try to refresh the page or check your internet connection.</h1>
30+
<h1>Good luck!</h1>
3131
</div>
3232
</div>
3333
</main>
@@ -59,7 +59,7 @@
5959
width: 100%;
6060
height: 100%;
6161
62-
.container {
62+
.tab-container {
6363
display: flex;
6464
align-items: center;
6565
justify-content: center;
@@ -72,6 +72,3 @@
7272
}
7373
</style>
7474
{/if}
75-
76-
<style lang="scss">
77-
</style>

src/main/web/index.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,29 @@
1111

1212
<!-- Meta -->
1313
<meta charset="UTF-8" />
14-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
1514
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1615
<title>I want to control my Server!</title>
1716

1817
<link rel="icon" href="./assets/favicon.ico" type="image/x-icon" />
1918

20-
<!-- Styles -->
21-
<link rel="stylesheet" href="./styles/style.scss" />
22-
2319
<!-- for quick load loading animation -->
2420
<style>
21+
noscript {
22+
position: absolute;
23+
z-index: 100;
24+
color: white;
25+
display: flex;
26+
top: 0;
27+
left: 0;
28+
width: 100vw;
29+
height: 100vh;
30+
background-color: #1f2626;
31+
justify-content: center;
32+
align-items: center;
33+
font-family: "Nunito", sans-serif;
34+
font-weight: 700;
35+
}
36+
2537
/* a part of https://uiverse.io/alexruix/neat-tiger-82 */
2638
.loading {
2739
z-index: 50;

src/main/web/lib/Footer.svelte

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
bottom: 0;
7373
display: flex;
7474
align-items: center;
75-
transition: background-color 0.3s ease;
7675
7776
.left {
7877
display: flex;
@@ -93,12 +92,10 @@
9392
flex-direction: column;
9493
transform: translateX(-50%);
9594
color: var(--footer-authors-color);
96-
transition: color 0.3s ease;
9795
9896
a {
9997
color: var(--footer-authors-url-color);
10098
text-decoration: none;
101-
transition: color 0.3s ease;
10299
}
103100
}
104101
}
@@ -115,15 +112,13 @@
115112
gap: 5px;
116113
transition:
117114
filter 0.3s ease,
118-
box-shadow 0.3s ease,
119-
color 0.3s ease;
115+
box-shadow 0.3s ease;
120116
121117
&:hover {
122118
@include hover-holo-effect.hover-holo-effect;
123119
124120
.material-symbols-rounded {
125121
color: var(--footer-github-star-hover-color);
126-
transition: color ease 0.3s;
127122
}
128123
}
129124
@@ -135,7 +130,6 @@
135130
.material-symbols-rounded {
136131
font-size: 12px;
137132
color: var(--footer-github-star-color);
138-
transition: color ease 0.3s;
139133
}
140134
}
141135
}

src/main/web/lib/Header.svelte

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<!--TODO: Rewrite to tailwind-->
2+
3+
14
<script lang="ts">
25
import iwtcmsIcon from "../assets/icon_clearbg.png";
36
import githubIcon from "../assets/github.svg";
@@ -66,6 +69,7 @@
6669
document.body.classList.toggle("light-mode-impl");
6770
localStorage.setItem("color-mode", colorModeSwitchInput.checked ? "light" : "dark");
6871
};
72+
6973
if (localStorage.getItem("color-mode") == "light") {
7074
colorModeSwitchInput.checked = true;
7175
document.body.classList.add("light-mode-impl");
@@ -163,7 +167,6 @@
163167
align-items: center;
164168
justify-content: center;
165169
background-color: var(--header-color);
166-
transition: background-color 0.3s ease;
167170
border-bottom: solid var(--header-bottom-border-color);
168171
169172
.material-symbols-rounded,
@@ -258,8 +261,7 @@
258261
background-color: var(--header-menu-background-color);
259262
border-radius: 10px;
260263
transition:
261-
left 0.3s ease,
262-
background-color 0.3s ease;
264+
left 0.3s ease;
263265
padding-top: 10px;
264266
padding-bottom: 10px;
265267
z-index: 50;
@@ -280,7 +282,6 @@
280282
border: none;
281283
background-color: transparent;
282284
color: var(--header-menu-item-fg-color);
283-
transition: color 0.3s ease;
284285
font-family: "Nunito", sans-serif;
285286
font-weight: 700;
286287
text-decoration: none;
@@ -294,17 +295,14 @@
294295
font-size: 20px;
295296
margin-right: 10px;
296297
color: var(--header-menu-item-fg-color);
297-
transition: color 0.3s ease;
298298
filter: none;
299299
}
300300
301301
:global(img) {
302302
width: 20px;
303303
height: 20px;
304304
margin-right: 10px;
305-
transition:
306-
filter 0.3s ease,
307-
color 0.3s ease;
305+
transition: filter 0.3s ease;
308306
}
309307
}
310308
}
@@ -350,8 +348,6 @@
350348
351349
.slider {
352350
background-color: var(--color-mode-switch-background-color);
353-
transition: background-color 0.3s ease;
354-
355351
&:before {
356352
background-color: var(--color-mode-switch-handle-color);
357353
content: "brightness_4";
@@ -362,10 +358,7 @@
362358
display: flex;
363359
justify-content: center;
364360
align-items: center;
365-
transition:
366-
background-color 0.3s ease,
367-
color 0.3s ease,
368-
transform 0.4s;
361+
transition: transform 0.4s;
369362
}
370363
}
371364

src/main/web/lib/Login.svelte

Lines changed: 21 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -24,105 +24,32 @@
2424
});
2525
</script>
2626

27-
<div class="login" bind:this={loginDiv}>
28-
<div class="background"></div>
29-
<div class="container">
30-
<h1>Login</h1>
31-
<a href="https://modrinth.com/mod/i-want-to-control-my-server"><img src={icon} alt="IWTCMS logo" /></a>
32-
<form id="loginForm" method="post" bind:this={loginForm}>
33-
<label for="username" id="username">Username:</label>
34-
<input type="text" name="username" required />
35-
<br />
36-
<label for="password" id="password">Password:</label>
37-
<input type="password" name="password" required />
38-
<br />
39-
<button type="submit">Login</button>
27+
<div class="absolute flex items-center justify-center w-screen h-screen z-10" bind:this={loginDiv}>
28+
<div class="absolute w-screen h-screen z-[99] bg-[var(--login-background-color)] backdrop-blur-[20px]"></div>
29+
<div class="flex z-[100] items-center absolute h-[250px] bg-[var(--login-panel-background-color)] rounded-[10px] pr-[10px] pl-px">
30+
<h1 class="absolute top-0 left-[50%] transform-[translateX(-50%)]">Login</h1>
31+
<a class="h-[110px] w-[110px] block" href="https://modrinth.com/mod/i-want-to-control-my-server"><img class="block h-[110px] w-[110px] transition-[filer 0.3s ease, box-shadow 0.3s ease]" src={icon} alt="IWTCMS logo" /></a>
32+
<form class="w-[250px]" bind:this={loginForm}>
33+
<label for="username">Username:</label>
34+
<input class="bg-[var(--login-input-background-color)] border-none rounded-[5px] focus:outline-none w-full text-[var(--login-text-color)] px-[5px] transition-[filer 0.3s ease, box-shadow 0.3s ease] mb-[10px]" type="text" id="username" name="username" required />
35+
36+
<label for="password">Password:</label>
37+
<input class="bg-[var(--login-input-background-color)] border-none rounded-[5px] focus:outline-none w-full text-[var(--login-text-color)] px-[5px] transition-[filer 0.3s ease, box-shadow 0.3s ease] mb-[10px]" type="password" name="password" required />
38+
39+
<button class="w-full h-[25px] bg-[var(--login-input-background-color)] border-none rounded-[5px] text-[var(--login-text-color)] transition-[filer 0.3s ease, box-shadow 0.3s ease]" type="submit" id="password">Login</button>
4040
</form>
4141
</div>
4242
</div>
4343

4444
<style lang="scss">
45-
.login {
46-
position: absolute;
47-
display: flex;
48-
align-items: center;
49-
justify-content: center;
50-
width: 100vw;
51-
height: 100vh;
52-
53-
z-index: 10;
54-
55-
.background {
56-
position: absolute;
57-
width: 100vw;
58-
height: 100vh;
59-
z-index: 99;
60-
background: var(--login-background-color);
61-
backdrop-filter: blur(20px);
62-
-webkit-backdrop-filter: blur(20px);
63-
display: flex;
64-
justify-content: center;
65-
align-items: center;
66-
}
67-
68-
.container {
69-
display: flex;
70-
align-items: center;
71-
justify-content: center;
72-
position: absolute;
73-
left: 50%;
74-
top: 50%;
75-
transform: translate(-50%, -50%);
76-
z-index: 100;
77-
width: 400px;
78-
height: 250px;
79-
background-color: var(--login-panel-background-color);
80-
border-radius: 10px;
81-
padding-right: 10px;
82-
83-
h1 {
84-
position: absolute;
85-
top: 0;
86-
left: 50%;
87-
transform: translateX(-50%);
88-
}
89-
90-
input {
91-
border: none;
92-
border-radius: 5px;
93-
94-
&:focus {
95-
outline: none;
96-
}
97-
}
98-
99-
label {
100-
display: inline-block;
101-
width: 90px;
102-
}
103-
104-
br {
105-
margin-bottom: 10px;
106-
}
107-
108-
button {
109-
width: 100%;
110-
height: 20px;
111-
border: none;
112-
border-radius: 5px;
113-
}
114-
115-
input,
116-
button,
117-
img {
118-
// hover holo effect
119-
transition:
120-
filter 0.3s ease,
121-
box-shadow 0.3s ease;
122-
&:hover {
123-
filter: drop-shadow(0 0 10px var(--holo-effect-color));
124-
}
125-
}
45+
@use "../styles/hover-holo-effect";
46+
47+
form > input,
48+
button,
49+
img {
50+
transition: filter 0.3s ease, box-shadow 0.3s ease;
51+
&:hover {
52+
@include hover-holo-effect.hover-holo-effect;
12653
}
12754
}
12855
</style>

0 commit comments

Comments
 (0)