Поправил схему, добавил инфу поля в навбар если пользователь админ
This commit is contained in:
parent
f721d16ace
commit
a287fec381
4 changed files with 32 additions and 10 deletions
|
|
@ -55,8 +55,8 @@ model timetable {
|
||||||
model users {
|
model users {
|
||||||
id Int @id(map: "pk_users") @default(autoincrement())
|
id Int @id(map: "pk_users") @default(autoincrement())
|
||||||
login String @unique @db.VarChar(25)
|
login String @unique @db.VarChar(25)
|
||||||
pass String? @db.VarChar(100)
|
pass String @db.VarChar(100)
|
||||||
is_admin Boolean? @default(false)
|
is_admin Boolean @default(false)
|
||||||
timetable timetable[]
|
timetable timetable[]
|
||||||
user_session user_session[]
|
user_session user_session[]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
---
|
---
|
||||||
|
export interface Props {
|
||||||
|
is_user_admin: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { is_user_admin } = Astro.props;
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
href: "/",
|
href: "/",
|
||||||
|
|
@ -8,6 +14,14 @@ const items = [
|
||||||
href: "/timetable",
|
href: "/timetable",
|
||||||
title: "Расписание",
|
title: "Расписание",
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
if (is_user_admin) {
|
||||||
|
items.push({
|
||||||
|
href: "/users",
|
||||||
|
title: "Пользователи",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const itemsRight = [
|
||||||
{
|
{
|
||||||
href: "/logout",
|
href: "/logout",
|
||||||
title: "Выйти",
|
title: "Выйти",
|
||||||
|
|
@ -28,5 +42,17 @@ const items = [
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="flex-grow-1"></div>
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0 text-white">
|
||||||
|
{
|
||||||
|
itemsRight.map((e) => (
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href={e.href} class="active nav-link text-white" aria-current="page">
|
||||||
|
{e.title}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ if (articleId) {
|
||||||
|
|
||||||
<Layout title="Создание новости">
|
<Layout title="Создание новости">
|
||||||
<main data-article={article?.message} data-articleId={articleId}>
|
<main data-article={article?.message} data-articleId={articleId}>
|
||||||
<Navbar />
|
<Navbar is_user_admin={user.is_admin} />
|
||||||
<div class="container mt-5" style="max-width: 650px;">
|
<div class="container mt-5" style="max-width: 650px;">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<button type="button" class="btn btn-sm btn-success flex-fill" id="saveBtn">Сохранить</button>
|
<button type="button" class="btn btn-sm btn-success flex-fill" id="saveBtn">Сохранить</button>
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,13 @@ if (Astro.cookies.has("session")) {
|
||||||
return Astro.redirect("/login");
|
return Astro.redirect("/login");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { news, alerts } = await getNewsAndAlerts();
|
const sessId = Astro.cookies.get("session").value!;
|
||||||
|
const user = (await getSessionUser(sessId))!;
|
||||||
const items: NavbarItemType[] = [
|
|
||||||
{ text: "Новости", href: "/" },
|
|
||||||
{ text: "Расписание", href: "/timetable" },
|
|
||||||
];
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="Новости">
|
<Layout title="Новости">
|
||||||
<main>
|
<main>
|
||||||
<Navbar />
|
<Navbar is_user_admin={user.is_admin} />
|
||||||
<NewsBlock />
|
<NewsBlock />
|
||||||
</main>
|
</main>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue