Compare commits

..

7 Commits

Author SHA1 Message Date
katamaz 4cca273db4 fix: update editor delete animations 2026-09-05 11:17:44 +03:00
katamaz 761e623a56 fix(ui): properly hide indicator 2026-09-05 11:17:15 +03:00
katamaz 21d3a588b9 fix(auth): correct sql select 2026-09-03 21:07:15 +03:00
katamaz 2765d76500 fix: add alternative logo to everywhere 2026-09-03 20:58:35 +03:00
katamaz 794e2447c0 perf: specify sql select 2026-09-01 21:01:29 +03:00
katamaz ff437d082c remove db=null 2026-09-01 20:51:57 +03:00
katamaz 22e3776892 cleanup config 2026-09-01 20:26:39 +03:00
12 changed files with 79 additions and 88 deletions
+1 -1
View File
@@ -16,6 +16,6 @@
- change `base` in `vite.config.ts`
- change `API_BASE_URL` and `CLIENT_FRONTEND_URL` in `src/App.jsx`
- **backend !!**
- change `ADMIN_PASS` and `API_PATH` in `admin_api.php`
- change `ADMIN_PASS` in `admin_api.php`
- change `$password` in `adm/phpliteadmin.config.php`
- **block http requests to `data.db`!!!**
+2 -1
View File
@@ -1,8 +1,9 @@
<?php
include 'k-api.php';
// CHANGE THIS
const ADMIN_PASS = "superdengipassword4";
const API_PATH = "./";
function db()
+23 -46
View File
@@ -112,8 +112,8 @@ CreateApi(function ($api) {
$classId = substr(strtoupper($req->data['classId']), 0, 10);
// according docs (UPPERCASE, MIN 3 MAX 10)
$db = db();
$results = FastDBReq($db, "SELECT * FROM classes WHERE classid = ?", [$classId]);
$db = null;
$results = FastDBReq($db, "SELECT classid, userclassname FROM classes WHERE classid = ?", [$classId]);
if (count($results) != 0) {
return $results[0];
} else {
@@ -130,7 +130,7 @@ CreateApi(function ($api) {
// according docs (UPPERCASE, MIN 3 MAX 10)
$db = db();
$results = FastDBReq($db, "SELECT userclassname FROM classes WHERE classid = ?", [$classId]);
$db = null;
if (count($results) != 0) {
return $results[0];
@@ -147,7 +147,7 @@ CreateApi(function ($api) {
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT adminName FROM admins where adminid = ?", [$adminId]);
$db = null;
if (count($results) != 0) {
return $results[0];
@@ -164,7 +164,7 @@ CreateApi(function ($api) {
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT adminPrems FROM admins where adminid = ?", [$adminId]);
$db = null;
if (count($results) != 0) {
return $results[0];
@@ -181,7 +181,7 @@ CreateApi(function ($api) {
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminid = ?", [$adminId]);
$db = null;
if (count($results) != 0) {
return $results[0];
@@ -203,7 +203,7 @@ CreateApi(function ($api) {
if (!preg_match('/\d{1,2}-\d{1,2}-(\d{2}|\d{4})$/', $day)) return "wrong date format";
$db = db();
$results = FastDBReq($db, "SELECT * FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
$results = FastDBReq($db, "SELECT content FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
if (count($results) > 0) {
@@ -218,37 +218,33 @@ CreateApi(function ($api) {
}
}
if ($has_full_rings) {
$db = null;
// with rings
return ['data' => $content, 'type' => 2];
} else {
// without rings
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
$results = FastDBReq($db, "SELECT content, fromDate FROM RINGS WHERE classId = ?", [$classId]);
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
$out = $content;
if ($rings !== null) {
$out = joinArraysByKey($content, $rings, true);
}
$db = null;
return ['data' => $out, 'type' => 1];
}
} else {
// return shedules + calls
$dayOfWeek = getDayOfWeek($day);
$results = FastDBReq($db, "SELECT * FROM schedules WHERE classId = ? AND dayOfWeek = ?", [$classId, $dayOfWeek]);
$results = FastDBReq($db, "SELECT content, fromDate FROM schedules WHERE classId = ? AND dayOfWeek = ?", [$classId, $dayOfWeek]);
if (count($results) > 0) {
$out = [];
$schedule = json_decode(findClosestDateSort($results, $day)['content'], true);
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
$results = FastDBReq($db, "SELECT content, fromDate FROM RINGS WHERE classId = ?", [$classId]);
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
$out = $schedule;
if ($rings !== null) {
$out = joinArraysByKey($schedule, $rings);
}
$db = null;
return ['data' => $out, 'type' => 0];
} else {
$db = null;
return ['data' => []];
}
}
@@ -260,9 +256,8 @@ CreateApi(function ($api) {
}
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
$results = FastDBReq($db, "SELECT adminClass FROM admins WHERE adminId=?", [$adminId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "админ не найден";
# end
@@ -277,23 +272,22 @@ CreateApi(function ($api) {
if ($tab != 2) {
if ($tab == 0) {
$results = FastDBReq($db, "SELECT * FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
$results = FastDBReq($db, "SELECT content FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
if (count($results) > 0) {
$changes = json_decode($results[0]['content'], true);
}
}
$dayOfWeek = getDayOfWeek($day);
$results = FastDBReq($db, "SELECT * FROM schedules WHERE classId = ? AND dayOfWeek = ?", [$classId, $dayOfWeek]);
$results = FastDBReq($db, "SELECT content, fromDate FROM schedules WHERE classId = ? AND dayOfWeek = ?", [$classId, $dayOfWeek]);
if (count($results) > 0) {
$schedule = json_decode(findClosestDateSort($results, $day)['content'], true);
}
} else {
$results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]);
$results = FastDBReq($db, "SELECT content, fromDate FROM RINGS WHERE classId = ?", [$classId]);
if (count($results) > 0) {
$rings = json_decode(findClosestDateSort($results, $day)['content'], true);
}
}
$db = null;
switch ($tab) {
case 0:
@@ -321,9 +315,8 @@ CreateApi(function ($api) {
}
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
$results = FastDBReq($db, "SELECT adminClass FROM admins WHERE adminId=?", [$adminId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "админ не найден";
# end
@@ -334,7 +327,6 @@ CreateApi(function ($api) {
$newDataRaw = $req->data['newData'];
$newData = json_decode($newDataRaw, true);
// im too lazy to close db
switch ($tab) {
case 0: // changes
@@ -342,7 +334,7 @@ CreateApi(function ($api) {
// if no chnages skip, else publish
$dayOfWeek = getDayOfWeek($day);
$results = FastDBReq($db, "SELECT * FROM schedules WHERE classId = ? AND dayOfWeek = ?", [$classId, $dayOfWeek]);
$results = FastDBReq($db, "SELECT fromDate, content FROM schedules WHERE classId = ? AND dayOfWeek = ?", [$classId, $dayOfWeek]);
$publish = true;
if (count($results) > 0) {
$schedule = json_decode(findClosestDateSort($results, $day)['content'], true);
@@ -352,7 +344,7 @@ CreateApi(function ($api) {
}
if ($publish) {
// removing changes for today if they are exists
$results = FastDBReq($db, "SELECT * FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
$results = FastDBReq($db, "SELECT content FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
if (count($results) > 0) {
$changes = json_decode($results[0]['content'], true);
if ($newData === $changes) {
@@ -395,9 +387,8 @@ CreateApi(function ($api) {
}
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
$results = FastDBReq($db, "SELECT adminClass FROM admins WHERE adminId=?", [$adminId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "админ не найден";
# end
@@ -417,10 +408,8 @@ CreateApi(function ($api) {
FastDBReq($db, 'DELETE FROM rings WHERE classId=? AND fromDate=?', [$classId, $day]);
break;
default:
$db = null;
return "you saved your live because you didn't know what tabs are here";
}
$db = null;
return true;
});
$api->on('/update_admin', "POST", function ($req) {
@@ -436,14 +425,12 @@ CreateApi(function ($api) {
}
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
$results = FastDBReq($db, "SELECT adminPrems FROM admins WHERE adminId=?", [$adminId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "админ не найден";
}
if (!$withSelf && !in_array($results[0]['adminPrems'], [-1, 2])) {
$db = null;
$req->res->code(400);
return 'нету прав';
}
@@ -462,7 +449,6 @@ CreateApi(function ($api) {
try {
FastDBReq($db, 'UPDATE admins SET adminName = ? WHERE adminId = ?', [$value, $adminId]);
} catch (PDOException) {
$db = null;
return "egor";
}
break;
@@ -483,16 +469,13 @@ CreateApi(function ($api) {
try {
FastDBReq($db, 'UPDATE admins SET adminName = ? WHERE adminId = ?', [$value, $person]);
} catch (PDOException) {
$db = null;
return "egor";
}
break;
default:
$db = null;
return "?";
}
}
$db = null;
return true;
});
@@ -503,29 +486,26 @@ CreateApi(function ($api) {
}
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
$results = FastDBReq($db, "SELECT adminPrems, adminClass FROM admins WHERE adminId=?", [$adminId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "админ не найден";
}
if (!in_array($results[0]['adminPrems'], [-1, 2])) {
$db = null;
$req->res->code(400);
return "недостаточно прав";
}
$classId = $results[0]['adminClass'];
$results = FastDBReq($db, "SELECT * FROM classes WHERE classId=?", [$classId]);
$results = FastDBReq($db, "SELECT classid FROM classes WHERE classid=?", [$classId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "класса не существует";
}
$classData = $results[0];
$adminsData = FastDBReq($db, "SELECT * FROM admins WHERE adminClass=?", [$classId]);
$db = null;
return ["status" => 1, "class" => $classData, "admins" => $adminsData];
});
@@ -537,14 +517,12 @@ CreateApi(function ($api) {
}
$adminId = $req->data['adminId'];
$db = db();
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
$results = FastDBReq($db, "SELECT adminPrems, adminClass FROM admins WHERE adminId=?", [$adminId]);
if (count($results) == 0) {
$db = null;
$req->res->code(400);
return "админ не найден";
}
if (!in_array($results[0]['adminPrems'], [-1, 2])) {
$db = null;
$req->res->code(400);
return "недостаточно прав";
}
@@ -610,7 +588,6 @@ CreateApi(function ($api) {
FastDBReq($db, "DELETE FROM admins WHERE adminId=?", [$person]);
return true;
default:
$db = null;
return "?";
}
});
+1 -4
View File
@@ -1,11 +1,8 @@
// CHANGE TO YOUR API DESTINATION
export const API_BASE_URL = "http://localhost:8321/admin_api.php";
// export const API_BASE_URL = "http://192.168.3.10:8321/admin_api.php";
// export const API_BASE_URL = "http://x90620bx.beget.tech/dx4back/admin_api.php"
// TYPE: url/dx4/
export const CLIENT_FRONTEND_URL = "http://localhost:5173/dx4/";
// export const CLIENT_FRONTEND_URL = "http://x90620bx.beget.tech/dx4/";
export const CLIENT_FRONTEND_URL = "http://localhost:5173/";
import { atom, useAtom } from "jotai";
import { atomWithStorage } from "jotai/utils";
+1 -1
View File
@@ -11,5 +11,5 @@ export default defineConfig({
}),
tailwindcss(),
],
base: "/dx4dashboard",
base: "/",
});
-2
View File
@@ -1,7 +1,5 @@
// CHANGE TO YOUR API DESTINATION
export const API_BASE_URL = "http://localhost:8321/api.php";
// export const API_BASE_URL = "http://192.168.3.10:8321/api.php";
// export const API_BASE_URL = "http://x90620bx.beget.tech/dx4back/api.php"
import { atom, useAtom } from "jotai";
import { atomWithStorage } from "jotai/utils";
+7 -1
View File
@@ -2,6 +2,7 @@ import { useAtom } from "jotai";
import { motion } from "motion/react";
import { BiCopy, BiError, BiLeftArrowAlt, BiLink, BiX } from "react-icons/bi";
import Logo from "../assets/logo.svg";
import LogoAlternative from "../assets/fully_alternative_logo.svg";
import { AdminReq, AdminUpdateRequest } from "../trash/req_mgr";
import { API_BASE_URL } from "../App";
import { useEffect, useState } from "react";
@@ -205,7 +206,12 @@ const Header = ({ setsetRoute, setRoute, pickmeMode }) => {
" lg:hover:scale-105 transition cursor-pointer"
}
/>
<img src={Logo} alt="logo" width={100} draggable={false} />
<img
src={pickmeMode ? LogoAlternative : Logo}
alt="logo"
width={100}
draggable={false}
/>
</span>
</div>
);
+10 -4
View File
@@ -11,6 +11,7 @@ import {
BiX,
} from "react-icons/bi";
import Logo from "../assets/logo.svg";
import LogoAlternative from "../assets/fully_alternative_logo.svg";
import {
AdminUpdateRequest,
ClassUpdateRequest,
@@ -176,8 +177,8 @@ export function ClassProfileEditor({
setAdminFrId: (v) => {
setAdminsData((prev) =>
prev.map((a) =>
a.adminId === i.adminId ? { ...a, adminName: v } : a
)
a.adminId === i.adminId ? { ...a, adminName: v } : a,
),
);
},
}}
@@ -244,7 +245,7 @@ function CreateAdmin({ editorAdminId, update }) {
{
action: "create_admin",
value: `${adminId};${b64e(adminName)}`,
}
},
);
if (c[1] == true) {
update();
@@ -511,7 +512,12 @@ const Header = ({ setsetRoute, setRoute, pickmeMode }) => {
" lg:hover:scale-105 transition cursor-pointer"
}
/>
<img src={Logo} alt="logo" width={100} draggable={false} />
<img
src={pickmeMode ? LogoAlternative : Logo}
alt="logo"
width={100}
draggable={false}
/>
</span>
</div>
);
+3 -4
View File
@@ -4,6 +4,7 @@ import { useAtom } from "jotai";
import { useState, useEffect } from "react";
import Logo from "../assets/logo.svg";
import { AdminUserFRequest, classUserFRequest } from "../trash/req_mgr";
import LogoAlternative from "../assets/fully_alternative_logo.svg";
import {
BiCalendar,
BiCalendarEdit,
@@ -145,14 +146,12 @@ export default function EditorPage(props) {
>
<motion.div
className="flex items-center w-full justify-between px-5"
layout="position"
>
<motion.img
src={Logo}
src={pickmeMode ? LogoAlternative : Logo}
alt="logo"
width={100}
draggable={false}
layout="position"
/>
<motion.div className="flex gap-5 items-center">
<motion.span
@@ -218,7 +217,7 @@ export default function EditorPage(props) {
setTabDiagRequestTab(404);
setTabDiagShow(true);
} else {
window['DX_OPEN_DATE'] = date
window["DX_OPEN_DATE"] = date;
}
}}
>
+4 -6
View File
@@ -530,7 +530,7 @@ export function TableEditor({
show={deleteDiag}
/>
</div>
<div className="w-full overflow-hidden my-1 flex flex-col gap-3">
<div className="w-full overflow-hidden my-1 flex flex-col gap-3 pb-40">
<div className="flex gap-2 flex-wrap">
<DengiButton onClick={handleUndo} disabled={undoItems.length == 0}>
<BiUndo />
@@ -603,8 +603,8 @@ export function TableEditor({
strategy={verticalListSortingStrategy}
>
<div>
<AnimatePresence mode={items.length > 0 ? "sync" : "wait"}>
{items.map((item) => (
<AnimatePresence mode="popLayout">
{items.map((item, idx) => (
<motion.div
initial={{
x: -15,
@@ -632,12 +632,10 @@ export function TableEditor({
initial={{
filter: "blur(5px)",
opacity: 0,
scale: 0.8,
}}
animate={{
filter: "blur(0px)",
opacity: 1,
scale: 1,
}}
className={`border-2 border-dashed ${
pickmeMode ? "border-pink-700" : "border-gray-700"
@@ -658,7 +656,7 @@ export function TableEditor({
<LoadingSpinner size={35} />
</div>
)}
<motion.div className="flex w-full justify-end gap-2 fixed pr-20 bottom-2 left-0">
<motion.div layout="position" className="flex w-full justify-end gap-2">
<DengiButton
onClick={handleDeleteAll}
className="border-red-600! md:not-disabled:not-hover:border-red-400!"
+13 -4
View File
@@ -165,18 +165,27 @@ export const DatePicker = (props) => {
props.setDate(new Date());
}}
>
<AnimatePresence>
{props.indicator && (
<motion.span
className={
"block min-w-2 min-h-2 rounded-full mx-1 transition-colors" +
(props.indicator
? props.pink
(props.pink
? " bg-pink-500 animate-pulse"
: " bg-zinc-300 animate-pulse"
: " bg-transparent")
: " bg-zinc-300 animate-pulse")
}
variants={{
a: { opacity: 0 },
b: { opacity: 1 },
}}
initial="a"
animate="b"
exit="a"
layoutId="datepicker_indicator"
layout="position"
/>
)}
</AnimatePresence>
<motion.span
layoutId="datepicker_date"
layout="position"
+4 -4
View File
@@ -5,7 +5,7 @@ import { VitePWA } from "vite-plugin-pwa";
// https://vite.dev/config/
export default defineConfig({
base: "/dx4/",
base: "/",
plugins: [
react({
babel: {
@@ -19,11 +19,11 @@ export default defineConfig({
name: "dx 4",
short_name: "dx4",
description: "dnevnik-x app",
theme_color: "#eee",
theme_color: "#000",
background_color: "#000",
display: "standalone",
scope: "/dx4/",
start_url: "/dx4/",
scope: "/",
start_url: "/",
icons: [
{
src: "icons/windows11/SmallTile.scale-100.png",