diff --git a/backend/core/db.sqlite b/backend/core/db.sqlite
deleted file mode 100644
index e69de29bb..000000000
diff --git a/backend/core/templates.sql b/backend/core/templates.sql
new file mode 100644
index 000000000..77c429230
--- /dev/null
+++ b/backend/core/templates.sql
@@ -0,0 +1,26 @@
+INSERT INTO templates_template (id, name, author, type, dump)
+VALUES
+(
+ 1,
+ 'Empty Postgres',
+ 'Database Playground',
+ 'PSQL',
+ ''
+),
+(
+ 2,
+ 'Some Users',
+ 'Database Playground',
+ 'PSQL',
+ 'CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(30), age INT);
+ INSERT INTO users (name, age) VALUES (''Timur'', 19);
+ INSERT INTO users (name, age) VALUES (''Kostya'', 18);
+ INSERT INTO users (name, age) VALUES (''Arseniy'', 10);'
+),
+(
+ 3,
+ 'Empty Mongo',
+ 'Database Playground',
+ 'MGDB',
+ ''
+);
diff --git a/frontend-37/src/assets/info.svg b/frontend-37/src/assets/info.svg
deleted file mode 100644
index 8b754a9f5..000000000
--- a/frontend-37/src/assets/info.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/frontend-37/src/assets/inputBgMongo.png b/frontend-37/src/assets/inputBgMongo.png
deleted file mode 100644
index 52846ead5..000000000
Binary files a/frontend-37/src/assets/inputBgMongo.png and /dev/null differ
diff --git a/frontend-37/src/assets/inputBgPGSQL.png b/frontend-37/src/assets/inputBgPGSQL.png
deleted file mode 100644
index 7632992f7..000000000
Binary files a/frontend-37/src/assets/inputBgPGSQL.png and /dev/null differ
diff --git a/frontend-37/src/assets/run.svg b/frontend-37/src/assets/run.svg
deleted file mode 100644
index ee88ffcf4..000000000
--- a/frontend-37/src/assets/run.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/frontend-37/src/features/main/Register.tsx b/frontend-37/src/features/main/Register.tsx
index f89ff39b5..0d1084fd6 100644
--- a/frontend-37/src/features/main/Register.tsx
+++ b/frontend-37/src/features/main/Register.tsx
@@ -31,6 +31,7 @@ export function Register({ onClose, onSwitch }: RegisterProps) {
});
const json = await res.json();
+ console.log(json);
};
return (
diff --git a/frontend-37/src/features/main/TopBar.tsx.bak b/frontend-37/src/features/main/TopBar.tsx.bak
deleted file mode 100644
index f73a851d7..000000000
--- a/frontend-37/src/features/main/TopBar.tsx.bak
+++ /dev/null
@@ -1,51 +0,0 @@
-import { ModalWindow } from "@/shared/ui/ModalWindow";
-import { useState } from "react";
-import styles from "./TopBar.module.css";
-import dropdownImg from "../../assets/topbarDropdown.svg";
-import { Button } from "../../shared/ui/Button";
-import { TopBar } from "../../shared/ui/TopBar";
-import { TopBarElement } from "../../shared/ui/TopBarElement";
-import { Login } from "./Login";
-import { Register } from "./Register";
-
-interface MainTopBarProps {
- onClick: () => void;
-}
-
-export function MainTopBar({ onClick }: MainTopBarProps) {
- const [showLogin, setShowLogin] = useState(false);
- const [showRegister, setShowRegister] = useState(false);
-
- return (
-
-
-
-
-
-
-
-
-
-
- setShowLogin(false)}
- onSwitch={() => setShowRegister(true)}
- />
-
-
-
- setShowRegister(false)}
- onSwitch={() => setShowLogin(true)}
- />
-
-
- );
-}
diff --git a/frontend-37/src/features/main/index.tsx b/frontend-37/src/features/main/index.tsx
index 993b601e9..3565a982a 100644
--- a/frontend-37/src/features/main/index.tsx
+++ b/frontend-37/src/features/main/index.tsx
@@ -16,20 +16,20 @@ export function Main() {
useEffect(() => {
const run = async () => {
if (!localStorage.getItem("session_id")) {
- const res = await fetch(API_URL + "/session", {
- credentials: "include",
- });
+ const res = await fetch(API_URL + "/session/");
const { session_id } = await res.json();
localStorage.setItem("session_id", session_id);
} else {
- const res = await fetch(API_URL + "/session/valid", {
- credentials: "include",
+ const res = await fetch(API_URL + "/session/valid/", {
+ headers: {
+ Session: localStorage.getItem("session_id")!,
+ },
});
const { valid } = await res.json();
console.log(valid);
if (!valid) {
localStorage.removeItem("session_id");
- run();
+ await run();
}
}
};
diff --git a/frontend-37/src/features/main/index.tsx.bak b/frontend-37/src/features/main/index.tsx.bak
deleted file mode 100644
index c21416d3a..000000000
--- a/frontend-37/src/features/main/index.tsx.bak
+++ /dev/null
@@ -1,63 +0,0 @@
-import { useEffect, useState } from "react";
-import { useNavigate } from "react-router";
-import styles from "./Main.module.css";
-import deltaImg from "../../assets/delta.svg";
-import { API_URL } from "../../config/env";
-import { MainTopBar } from "./TopBar";
-
-export function Main() {
- const navigate = useNavigate();
-
- useEffect(() => {
- const run = async () => {
- if (!localStorage.getItem("session_id")) {
- const res = await fetch(API_URL + "/session", {
- credentials: "include",
- });
- const { session_id } = await res.json();
- localStorage.setItem("session_id", session_id);
- } else {
- const res = await fetch(API_URL + "/session/valid", {
- credentials: "include",
- });
- const { valid } = await res.json();
- console.log(valid);
- if (!valid) {
- localStorage.removeItem("session_id");
- run();
- }
- }
- };
-
- run();
- }, []);
-
- const onClick = async () => {
- await fetch(
- `${API_URL}/session/info/?session_id=${localStorage.getItem("session_id")}`,
- {
- credentials: "include",
- }
- );
- navigate("/template");
- };
-
- return (
-
-
-
-
-
Learn databases
-
- Complete assignments, experiment in playground and become expert!
-
-
-
-
Software Project Team 37
-

-
Delta-Software-Innopolis
-
-
-
- );
-}
diff --git a/frontend-37/src/features/playground/TopBar.tsx b/frontend-37/src/features/playground/TopBar.tsx
index c791e6b32..7d0851bce 100644
--- a/frontend-37/src/features/playground/TopBar.tsx
+++ b/frontend-37/src/features/playground/TopBar.tsx
@@ -2,33 +2,31 @@ import saveImg from "@/assets/save.svg";
import uploadImg from "@/assets/upload.svg";
import { templateStore } from "@/shared/store/templateStore";
import { Button } from "@/shared/ui/Button";
+import { ModalWindow } from "@/shared/ui/ModalWindow";
import { TopBar } from "@/shared/ui/TopBar";
import { TopBarElement } from "@/shared/ui/TopBarElement";
import { useState } from "react";
import styles from "./TopBar.module.css";
import { TemplateChoice } from "../template-choice";
+import { Upload } from "./Upload";
-interface PlaygroundTopBarProps {
- handleUpload: () => void;
- handleSave: () => void;
-}
-
-export function PlaygroundTopBar({
- handleUpload,
- handleSave,
-}: PlaygroundTopBarProps) {
+export function PlaygroundTopBar() {
const { template } = templateStore();
+ const [showUpload, setShowUpload] = useState(false);
const [showTemplateChoice, setShowTemplateChoice] = useState(false);
return (
-
-
+
@@ -40,6 +38,9 @@ export function PlaygroundTopBar({
{template}
+
+ setShowUpload(false)} />
+
{
const run = async () => {
- const res1 = await fetch(
- `${API_URL}/db/schema/?session_id=${session_id}`,
- {
- credentials: "include",
- }
- );
+ const res1 = await fetch(`${API_URL}/db/schema/`, {
+ headers: {
+ Session: session_id!,
+ },
+ });
const json1 = await res1.json();
updateSchemas(json1.tables);
- const res2 = await fetch(
- `${API_URL}/session/info/?session_id=${session_id}`
- );
+ const res2 = await fetch(`${API_URL}/session/info/`, {
+ headers: {
+ Session: session_id!,
+ },
+ });
const json2 = await res2.json();
- const res3 = await fetch(`${API_URL}/template/${json2.template}`);
+ const res3 = await fetch(`${API_URL}/template/${json2.template}/`);
const json3 = await res3.json();
updateTemplate(json3.name);
- setTemplateType(json3.type as DBType);
+ setTemplateType(json3.type);
};
run();
}, []);
@@ -48,12 +45,9 @@ export function Playground() {
<>
{templateType == "PSQL" ? (
-
setShowUpload(true)}
- handleSave={() => {}}
- />
+
-
+
-
+
@@ -91,15 +85,12 @@ export function Playground() {
) : (
-
setShowUpload(true)}
- handleSave={() => {}}
- />
+
-
+
-
+
@@ -120,10 +111,6 @@ export function Playground() {
)}
-
-
-
-
>
);
}
diff --git a/frontend-37/src/features/playground/query-input/HelpButton.module.css b/frontend-37/src/features/playground/query-input/HelpButton.module.css
deleted file mode 100644
index 91f4a482a..000000000
--- a/frontend-37/src/features/playground/query-input/HelpButton.module.css
+++ /dev/null
@@ -1,38 +0,0 @@
-.button {
- width: 76.5px;
- height: 40px;
- border-radius: 5px;
- border: none;
- border: 1px solid #c1c1c1;
- background-color: white;
- padding-top: 10px;
- padding-right: 10px;
- padding-bottom: 10px;
- padding-left: 10px;
- display: flex;
- justify-content: center;
- align-items: center;
-
- z-index: 2;
-
- font-family: "Onest", sans-serif;
- font-size: inherit !important;
-}
-
-.button:hover {
- cursor: pointer;
-}
-
-.button img {
- width: 16.5px;
- height: 16.5px;
- padding-left: 8px;
-}
-
-.button p {
- width: 37px;
- height: 20px;
- margin: auto;
-
- color: #666666;
-}
diff --git a/frontend-37/src/features/playground/query-input/HelpButton.tsx b/frontend-37/src/features/playground/query-input/HelpButton.tsx
deleted file mode 100644
index bab3676b5..000000000
--- a/frontend-37/src/features/playground/query-input/HelpButton.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import infoImg from "@/assets/info.svg";
-import styles from "./HelpButton.module.css";
-
-interface HelpButtonProps {
- handleClick: () => void;
-}
-
-export function HelpButton({ handleClick }: HelpButtonProps) {
- return (
- <>
-
- help
-
-
- >
- );
-}
diff --git a/frontend-37/src/features/playground/query-input/QueryInput.module.css b/frontend-37/src/features/playground/query-input/QueryInput.module.css
index 291c16c85..b26091396 100644
--- a/frontend-37/src/features/playground/query-input/QueryInput.module.css
+++ b/frontend-37/src/features/playground/query-input/QueryInput.module.css
@@ -7,13 +7,6 @@
height: 100%;
position: relative;
-
- font-size: 16px;
- font-weight: 400;
-
- line-height: 19px;
-
- background-color: white;
}
.wrapper {
@@ -37,7 +30,7 @@
flex-direction: column;
flex-basis: 42px;
- color: #c1c1c1;
+ color: #d4d4d4;
margin-top: 10px;
max-height: 100%;
@@ -48,12 +41,11 @@
overflow: hidden;
user-select: none;
-
- background: transparent;
}
.rowcounter div {
text-align: right;
+ line-height: 25px;
}
.textarea {
@@ -64,7 +56,7 @@
font-family: inherit;
font-size: inherit;
font-weight: inherit;
- line-height: inherit !important;
+ line-height: inherit;
color: inherit;
/* Ensure it grows and scrolls correctly */
@@ -85,42 +77,8 @@
z-index: 1;
scrollbar-width: thin;
-
- color: #1f1f1f;
-
- background: transparent;
}
.textarea::selection {
- background-color: rgba(169, 169, 255, 0.3);
-}
-
-.bgImg {
- width: 100%;
- height: 100%;
-}
-
-.bgMongo {
- position: absolute;
- top: 148px;
- width: 410px;
- height: 704px;
-}
-
-.bgPSQL {
- position: absolute;
- top: 49;
- width: 736px;
- height: 862px;
-}
-
-.buttonsWrapper {
- position: absolute;
- right: 15px;
- bottom: 15px;
-
- display: flex;
- flex-direction: row;
-
- gap: 10px;
+ background-color: #dedeff;
}
diff --git a/frontend-37/src/features/playground/query-input/RunButton.module.css b/frontend-37/src/features/playground/query-input/RunButton.module.css
index 43b27e2ab..d9b32639e 100644
--- a/frontend-37/src/features/playground/query-input/RunButton.module.css
+++ b/frontend-37/src/features/playground/query-input/RunButton.module.css
@@ -1,21 +1,22 @@
.button {
- width: 87px;
- height: 40px;
- border-radius: 5px;
- border: 1px transparent;
- background-color: #a9a9ff;
- padding-top: 10px;
- padding-right: 15px;
- padding-bottom: 10px;
- padding-left: 15px;
+ width: 111px;
+ height: 53px;
+ border-radius: 10px;
+ border: 1px solid #c1c1c1;
+ background-color: white;
+ padding-top: 6px;
+ padding-right: 9px;
+ padding-bottom: 6px;
+ padding-left: 9px;
display: flex;
justify-content: center;
align-items: center;
- z-index: 2;
+ position: absolute;
+ right: 10px;
+ bottom: 10px;
- font-family: "Onest", sans-serif;
- font-size: inherit !important;
+ z-index: 2;
}
.button:hover {
@@ -23,15 +24,14 @@
}
.button img {
- width: 12px;
- height: 16px;
- padding-left: 8px;
+ width: 36px;
+ height: 36px;
+ padding-left: 5px;
}
.button p {
+ font-size: 24px;
width: 52px;
height: 28px;
- margin: auto;
-
- color: white;
+ margin-bottom: 32px;
}
diff --git a/frontend-37/src/features/playground/query-input/RunButton.tsx b/frontend-37/src/features/playground/query-input/RunButton.tsx
index da4e14a5d..f3a7de4ae 100644
--- a/frontend-37/src/features/playground/query-input/RunButton.tsx
+++ b/frontend-37/src/features/playground/query-input/RunButton.tsx
@@ -1,4 +1,4 @@
-import runImg from "@/assets/run.svg";
+import triangleJpg from "@/assets/triangle.jpg";
import styles from "./RunButton.module.css";
interface RunButtonProps {
@@ -9,8 +9,8 @@ export function RunButton({ handleClick }: RunButtonProps) {
return (
<>
- send
-
+
+ run
>
);
diff --git a/frontend-37/src/features/playground/query-input/index.tsx b/frontend-37/src/features/playground/query-input/index.tsx
index 18f98136e..41bff53a7 100644
--- a/frontend-37/src/features/playground/query-input/index.tsx
+++ b/frontend-37/src/features/playground/query-input/index.tsx
@@ -1,13 +1,9 @@
-import mongoImg from "@/assets/inputBgMongo.png";
-import psqlImg from "@/assets/inputBgPGSQL.png";
import { API_URL } from "@/config/env";
-import { DBType } from "@/types/DBType";
import { useRef, useState, useEffect } from "react";
import styles from "./QueryInput.module.css";
import { queryResultsStore } from "../queryResultsStore";
import { schemasStore } from "../schemasStore";
import { QueryResult, DBSchema } from "../types";
-import { HelpButton } from "./HelpButton";
import { RunButton } from "./RunButton";
export interface QueryResultsResponse {
@@ -19,11 +15,7 @@ export interface QueryResultsResponse {
};
}
-interface QueryInputProps {
- templateType: DBType;
-}
-
-export function QueryInput({ templateType }: QueryInputProps) {
+export function QueryInput() {
const textareaRef = useRef
(null);
const numbersColumnRef = useRef(null);
const containerRef = useRef(null);
@@ -62,15 +54,19 @@ export function QueryInput({ templateType }: QueryInputProps) {
}
const onRunClicked = async () => {
- const res = await fetch(`${API_URL}/db/query/?session_id=${session_id}`, {
+ const res = await fetch(`${API_URL}/db/query/`, {
method: "POST",
body: query,
- credentials: "include",
+ headers: {
+ Session: session_id!,
+ },
});
const json = (await res.json()) as QueryResultsResponse;
+
if (json.results) updateResults(json.results);
else updateError(json.detail!);
+
if (json.schema) updateSchemas(json.schema.tables);
};
@@ -98,18 +94,11 @@ export function QueryInput({ templateType }: QueryInputProps) {
return (
-
-

-
-
-

-
-
- {}} />
-
-
+
);
}
diff --git a/frontend-37/src/features/template-choice/index.tsx b/frontend-37/src/features/template-choice/index.tsx
index 2f111db36..64409d8f7 100644
--- a/frontend-37/src/features/template-choice/index.tsx
+++ b/frontend-37/src/features/template-choice/index.tsx
@@ -1,7 +1,6 @@
import startTriangleImg from "@/assets/startTriangle.svg";
import { API_URL } from "@/config/env";
import { templateStore } from "@/shared/store/templateStore";
-import { styleText } from "node:util";
import { useEffect, useState } from "react";
import { useNavigate } from "react-router";
import styles from "./TemplateChoice.module.css";
@@ -27,9 +26,7 @@ export function TemplateChoice({
useEffect(() => {
const run = async () => {
- const res = await fetch(API_URL + "/template/", {
- credentials: "include",
- });
+ const res = await fetch(API_URL + "/template/");
const json = (await res.json()) as Template[];
setTemplates(json);
};
@@ -39,17 +36,21 @@ export function TemplateChoice({
const onChoice = async () => {
if (!choice) return;
- await fetch(`${API_URL}/session/info/?session_id=${session_id}`, {
+ await fetch(`${API_URL}/session/info/`, {
method: "PATCH",
body: JSON.stringify({
template: choice.id,
}),
- credentials: "include",
+ headers: {
+ Session: session_id!,
+ },
});
- await fetch(`${API_URL}/db/?session_id=${session_id}`, {
+ await fetch(`${API_URL}/db/`, {
method: "PUT",
- credentials: "include",
+ headers: {
+ Session: session_id!,
+ },
});
updateTemplate(choice.name);