dev
This commit is contained in:
@@ -36,13 +36,12 @@ namespace ZpcBulletinBoard.Pages.Boards
|
||||
{
|
||||
Ratio = BulletinBoard.RatioEnum.Ratio16To9,
|
||||
Guid = Guid.NewGuid(),
|
||||
Pages = new List<BulletinBoardPage>()
|
||||
};
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
var tmpBoard = await context.BulletinBoards.Include(x => x.Pages)
|
||||
var tmpBoard = await context.BulletinBoards
|
||||
.FirstOrDefaultAsync(m => m.Guid == guid);
|
||||
|
||||
|
||||
|
||||
68
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml
Normal file
68
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml
Normal file
@@ -0,0 +1,68 @@
|
||||
@page
|
||||
@model ZpcBulletinBoard.Pages.BoardsLinks.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Oglasne deske - Povezave";
|
||||
Layout = "~/Pages/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@section Styles
|
||||
{
|
||||
<link rel="stylesheet" href="~/css/boards-links/index.css" asp-append-version="true" />
|
||||
}
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">
|
||||
<i>Oglasne deske</i>
|
||||
/</span> Povezave
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="div-content">
|
||||
<div class="div-content-boards">
|
||||
<h6>Oglasne deske</h6>
|
||||
</div>
|
||||
<div class="div-content-pages">
|
||||
<h6>Strani</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-content main-content">
|
||||
<div class="div-content-boards boards-content">
|
||||
@* @foreach (var board in Model.Boards)
|
||||
{
|
||||
<div class="div-board">
|
||||
<h5>@board.Name</h5>
|
||||
</div>
|
||||
<div class="div-pages" ondrop="dropPage(event, this)" ondragover="allowDropPage(event, this)" data-idboard="@board.IdBulletinBoard">
|
||||
|
||||
</div>
|
||||
<hr/>
|
||||
} *@
|
||||
</div>
|
||||
<div class="div-content-pages">
|
||||
<div class="div-available-pages">
|
||||
@foreach (var tmpPage in Model.Pages)
|
||||
{
|
||||
<div class="div-page available-page" draggable="true" ondragstart="dragPage(event, this)" data-id="@tmpPage.IdBulletinBoardPage">
|
||||
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/@tmpPage.Image" alt="page image" />
|
||||
<small>@tmpPage.Name</small>
|
||||
<div class="tools">
|
||||
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless"><i class="fas fa-reply"></i></a>
|
||||
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-secondary borderless"><i class="fas fa-reply-all"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/js/boards-links/index.js" asp-append-version="true"></script>
|
||||
}
|
||||
72
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml.cs
Normal file
72
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ZpcBulletinBoard.Data;
|
||||
using ZpcBulletinBoard.Models.Editor;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.BoardsLinks
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel(ApplicationDbContext context) : PageModel
|
||||
{
|
||||
public IList<BulletinBoardPage> Pages { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Pages = await context.BulletinBoardPage.OrderBy(x => x.Name).ToListAsync();
|
||||
}
|
||||
|
||||
//Get
|
||||
public IActionResult OnGetBoards()
|
||||
{
|
||||
var boards = context.BulletinBoards
|
||||
.Include(x => x.Links.OrderBy(y => y.Order))
|
||||
.ThenInclude(x => x.BulletinBoardPage)
|
||||
.ToList();
|
||||
|
||||
foreach (var board in boards)
|
||||
{
|
||||
foreach (var link in board.Links)
|
||||
{
|
||||
link.BulletinBoardPage.Links = null;
|
||||
link.BulletinBoard = null;
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", boards });
|
||||
}
|
||||
|
||||
|
||||
//Post
|
||||
public IActionResult OnPostAddLink(int idBoard, int idPage)
|
||||
{
|
||||
var order = 1;
|
||||
var links = context.BulletinBoardPageLinks.Where(x => x.IdBulletinBoardFk == idBoard).ToList();
|
||||
if (links.Any())
|
||||
order = links.Max(x => x.IdLink) + 1;
|
||||
|
||||
var link = new BulletinBoardPageLink
|
||||
{
|
||||
Duration = 30,
|
||||
IdBulletinBoardFk = idBoard,
|
||||
IdBulletinBoardPageFk = idPage,
|
||||
Order = order
|
||||
};
|
||||
|
||||
context.BulletinBoardPageLinks.Add(link);
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
link = context.BulletinBoardPageLinks.Include(x => x.BulletinBoardPage).First(x => x.IdLink == link.IdLink);
|
||||
|
||||
link.BulletinBoardPage.Links = null;
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", link });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
@page
|
||||
@model EditMainModel
|
||||
@{
|
||||
ViewData["Title"] = "Urejanje";
|
||||
}
|
||||
|
||||
@section Styles
|
||||
{
|
||||
<link rel="stylesheet" href="~/lib/summernote/summernote-bs4.css" asp-append-version="true"/>
|
||||
<link rel="stylesheet" href="~/css/editor/editor-main.css" asp-append-version="true"/>
|
||||
}
|
||||
<div class="fab-container-add">
|
||||
<div class="button iconbutton btn-success" onclick="addNewNote()">
|
||||
<i class="far fa-sticky-note fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fab-container-save">
|
||||
<div class="button iconbutton btn-primary" onclick="saveNotes();">
|
||||
<i class="far fa-save fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body div-main-body">
|
||||
<div class="div-pages">
|
||||
<div class="div-board" onclick="openModalSelectBoard();">
|
||||
<h5>Oglasna deska ni izbrana</h5>
|
||||
<small><i class="fas fa-mouse-pointer"></i> Spremni oglasno desko</small>
|
||||
</div>
|
||||
<div class="div-page add-page" onclick="openModalBoardAddNewPage();">
|
||||
<i class="fas fa-plus fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body div-main-body">
|
||||
<input class="input-hidden" id="inpSelectedBoardPageId" />
|
||||
<div id="divPlaceholder">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalSelectBoard" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Izberi oglasno desko</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Naziv</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyModalSelectBoard">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalAddEditPage" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 id="titleModalAddEditPage" class="modal-title">List</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input class="input-hidden" id="inpModalAddEditPageId" />
|
||||
<div class="form-group">
|
||||
<label class="control-label">Ime</label>
|
||||
<input id="inpModalAddEditPageName" type="text" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Trajanje</label>
|
||||
<input id="inpModalAddEditPageDuration" type="number" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="boardAddNewPageSave();">Shrani</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalEditNote" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Urejanje zapiska</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalEditNoteIdNote" class="input-hidden"/>
|
||||
<label class="control-label">Vsebina:</label>
|
||||
<div id="divModalEditNoteSummernote"></div>
|
||||
<label class="control-label">Barva:</label>
|
||||
<div class="div-note-edit-color">
|
||||
<div class="note-color-white active"></div>
|
||||
<div class="note-color-yellow"></div>
|
||||
<div class="note-color-orange"></div>
|
||||
<div class="note-color-light-green"></div>
|
||||
<div class="note-color-blue"></div>
|
||||
<div class="note-color-purple"></div>
|
||||
<div class="note-color-grey"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="saveModalEditNote();">Shrani</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script src="~/lib/summernote/summernote-bs4.js" asp-append-version="true"></script>
|
||||
<script src="~/lib/html-to-image/dist/html-to-image.js" asp-append-version="true"></script>
|
||||
<script src="~/js/editor/note.js" asp-append-version="true"></script>
|
||||
<script src="~/js/editor/edit-main.js" asp-append-version="true"></script>
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace ZpcBulletinBoard.Pages
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
return Redirect("~/Editor/EditMain");
|
||||
return Redirect("~/Pages/Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
<div class="sidenav-divider mt-0"></div>
|
||||
|
||||
<ul class="sidenav-inner">
|
||||
<li class="sidenav-item@(currentPage.StartsWith("/Editor")? " active" : "")">
|
||||
<a asp-page="/Index" class="sidenav-link"><i class="sidenav-icon fas fa-home"></i><div>Urejevalnik</div></a>
|
||||
<li class="sidenav-item@(currentPage.StartsWith("/Pages/")? " active" : "")">
|
||||
<a asp-page="/Pages/Index" class="sidenav-link"><i class="sidenav-icon fas fa-home"></i><div>Strani</div></a>
|
||||
</li>
|
||||
<li class="sidenav-item@(currentPage.StartsWith("/Boards") ? " active" : "")">
|
||||
<li class="sidenav-item@(currentPage.StartsWith("/Boards/") ? " active" : "")">
|
||||
<a asp-page="/Boards/Index" class="sidenav-link"><i class="sidenav-icon fas fa-home"></i><div>Oglasne deske</div></a>
|
||||
</li>
|
||||
<li class="sidenav-item@(currentPage.StartsWith("/BoardsLinks/") ? " active" : "")">
|
||||
<a asp-page="/BoardsLinks/Index" class="sidenav-link"><i class="sidenav-icon fas fa-home"></i><div>Povezave</div></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
88
ZpcBulletinBoard/Pages/Pages/EditMain.cshtml
Normal file
88
ZpcBulletinBoard/Pages/Pages/EditMain.cshtml
Normal file
@@ -0,0 +1,88 @@
|
||||
@page
|
||||
@model EditMainModel
|
||||
@{
|
||||
ViewData["Title"] = "Urejanje";
|
||||
}
|
||||
|
||||
@section Styles
|
||||
{
|
||||
<link rel="stylesheet" href="~/lib/summernote/summernote-bs4.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/pages/editor-main.css" asp-append-version="true" />
|
||||
}
|
||||
<input id="inpIdPage" type="hidden" asp-for="@Model.Page.IdBulletinBoardPage"/>
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">
|
||||
<i>Oglasna deska strani</i>/
|
||||
<i>@Model.Page.Name</i>/
|
||||
</span> Urejanje
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="fab-container-add">
|
||||
<div class="button iconbutton btn-success" onclick="addNewNote()">
|
||||
<i class="far fa-sticky-note fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fab-container-save">
|
||||
<div class="button iconbutton btn-primary" onclick="saveNotes();">
|
||||
<i class="far fa-save fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body div-main-body">
|
||||
<input class="input-hidden" id="inpSelectedBoardPageId" />
|
||||
<div id="divPlaceholder">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalEditNote" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Urejanje zapiska</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalEditNoteIdNote" class="input-hidden" />
|
||||
<label class="control-label">Vsebina:</label>
|
||||
<div id="divModalEditNoteSummernote"></div>
|
||||
<label class="control-label">Barva:</label>
|
||||
<div class="div-note-edit-color">
|
||||
<div class="note-color-white active"></div>
|
||||
<div class="note-color-yellow"></div>
|
||||
<div class="note-color-orange"></div>
|
||||
<div class="note-color-light-green"></div>
|
||||
<div class="note-color-blue"></div>
|
||||
<div class="note-color-purple"></div>
|
||||
<div class="note-color-grey"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="saveModalEditNote();">Shrani</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script src="~/lib/summernote/summernote-bs4.js" asp-append-version="true"></script>
|
||||
<script src="~/lib/html-to-image/dist/html-to-image.js" asp-append-version="true"></script>
|
||||
<script src="~/js/pages/note.js" asp-append-version="true"></script>
|
||||
<script src="~/js/pages/edit-main.js" asp-append-version="true"></script>
|
||||
}
|
||||
@@ -5,17 +5,28 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using ZpcBulletinBoard.Data;
|
||||
using ZpcBulletinBoard.Models.Editor;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.Editor
|
||||
namespace ZpcBulletinBoard.Pages.Pages
|
||||
{
|
||||
[Authorize]
|
||||
public class EditMainModel(ILogger<EditMainModel> logger, ApplicationDbContext context) : PageModel
|
||||
public class EditMainModel(ILogger<EditMainModel> logger, ApplicationDbContext context, IWebHostEnvironment webHostEnvironment) : PageModel
|
||||
{
|
||||
private readonly ILogger<EditMainModel> _logger = logger;
|
||||
|
||||
public void OnGet()
|
||||
public BulletinBoardPage Page { get; set; }
|
||||
public IActionResult OnGet(int? idPage)
|
||||
{
|
||||
if (idPage == null)
|
||||
return NotFound();
|
||||
|
||||
var tmpPage = context.BulletinBoardPage.FirstOrDefault(x => x.IdBulletinBoardPage == idPage);
|
||||
if (tmpPage == null)
|
||||
return NotFound();
|
||||
|
||||
Page = tmpPage;
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
//Get
|
||||
@@ -28,13 +39,13 @@ namespace ZpcBulletinBoard.Pages.Editor
|
||||
|
||||
public IActionResult OnGetBoard(int id)
|
||||
{
|
||||
var board = context.BulletinBoards.Include(x => x.Pages)
|
||||
var board = context.BulletinBoards
|
||||
.FirstOrDefault(x => x.IdBulletinBoard == id);
|
||||
//Ce je ntre board pole json vrze vn
|
||||
foreach (var bulletinBoardPage in board.Pages)
|
||||
{
|
||||
bulletinBoardPage.BulletinBoard = null;
|
||||
}
|
||||
//foreach (var bulletinBoardPage in board.Pages)
|
||||
//{
|
||||
// bulletinBoardPage.BulletinBoard = null;
|
||||
//}
|
||||
return board == null
|
||||
? new JsonResult(new { successful = false, error = $"Board with ID {id} not exists!"})
|
||||
: new JsonResult(new { successful = true, error = $"", board });
|
||||
@@ -42,15 +53,25 @@ namespace ZpcBulletinBoard.Pages.Editor
|
||||
|
||||
public IActionResult OnGetPage(int id)
|
||||
{
|
||||
var page = context.BulletinBoardPage.Include(x => x.Notes)
|
||||
var page = context.BulletinBoardPage
|
||||
.Include(x => x.Links)
|
||||
.Include(x => x.Notes)
|
||||
.FirstOrDefault(x => x.IdBulletinBoardPage == id);
|
||||
|
||||
if (page == null)
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {id} not exists!" });
|
||||
|
||||
foreach (var link in page.Links)
|
||||
{
|
||||
link.BulletinBoardPage = null;
|
||||
}
|
||||
|
||||
foreach (var note in page.Notes)
|
||||
{
|
||||
note.BulletinBoardPage = null;
|
||||
}
|
||||
return page == null
|
||||
? new JsonResult(new { successful = false, error = $"Page with ID {id} not exists!" })
|
||||
: new JsonResult(new { successful = true, error = $"", page });
|
||||
|
||||
return new JsonResult(new { successful = true, error = "", page });
|
||||
}
|
||||
|
||||
//Post
|
||||
@@ -67,7 +88,7 @@ namespace ZpcBulletinBoard.Pages.Editor
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {page.IdBulletinBoardPage} not exists!", page });
|
||||
|
||||
tmpPage.Name = page.Name;
|
||||
tmpPage.Duration = page.Duration;
|
||||
//tmpPage.Duration = page.Duration;
|
||||
}
|
||||
context.SaveChanges();
|
||||
|
||||
@@ -109,5 +130,32 @@ namespace ZpcBulletinBoard.Pages.Editor
|
||||
|
||||
return new JsonResult(new { successful = true, error = "" });
|
||||
}
|
||||
|
||||
public IActionResult OnPostBoardPageImage(IFormFile? file, int idPage)
|
||||
{
|
||||
if (file == null)
|
||||
return new JsonResult(new { successful = true, error = "No file!" });
|
||||
|
||||
var tmpPage = context.BulletinBoardPage.FirstOrDefault(x => x.IdBulletinBoardPage == idPage);
|
||||
if (tmpPage == null)
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {idPage} not exists!" });
|
||||
|
||||
var uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "bulletin-board-images/pages");
|
||||
var imageName = "StaticImage_" + idPage + ".svg";
|
||||
var filePath = Path.Combine(uploadsFolder, imageName);
|
||||
|
||||
if (System.IO.File.Exists(filePath))
|
||||
System.IO.File.Delete(filePath);
|
||||
|
||||
using (var fileStream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
file.CopyTo(fileStream);
|
||||
}
|
||||
|
||||
tmpPage.Image = imageName;
|
||||
context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"" });
|
||||
}
|
||||
}
|
||||
}
|
||||
197
ZpcBulletinBoard/Pages/Pages/Index.cshtml
Normal file
197
ZpcBulletinBoard/Pages/Pages/Index.cshtml
Normal file
@@ -0,0 +1,197 @@
|
||||
@page
|
||||
@model ZpcBulletinBoard.Pages.Pages.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Strani - Pregled";
|
||||
Layout = "~/Pages/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
|
||||
<style type="text/css">
|
||||
.table > tbody > tr > td:nth-child(2),
|
||||
.table > thead > tr > th:nth-child(2){
|
||||
width: 200px
|
||||
}
|
||||
.table > tbody > tr > td:nth-child(3),
|
||||
.table > thead > tr > th:nth-child(3),
|
||||
.table > tbody > tr > td:nth-child(4),
|
||||
.table > thead > tr > th:nth-child(4) {
|
||||
width: 100px
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">
|
||||
<i>Oglasna deska strani</i>
|
||||
/</span> Pregled
|
||||
</span>
|
||||
</h4>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-2 text-right">
|
||||
<form method="get">
|
||||
<div class="btn-group">
|
||||
<input class="form-control" type="text" value="" placeholder="Iskanje..." autocomplete="off">
|
||||
<input id="inpOpenEditorForPage" type="hidden" name="openEditorForPage" asp-for="OpenEditorForPage" />
|
||||
<div class="btn-group" title="Columns">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-label="Nastavitve" title="Nastavitve">
|
||||
<i class="opacity-75 ion ion-md-apps"></i>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
@* <label class="dropdown-item">
|
||||
<input type="checkbox" name="openProjects" @ViewData["OpenProjects"]> <span>Odprti</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="inProductionProjects" @ViewData["InProductionProjects"]> <span>V izdelavi</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="finishedProjects" @ViewData["FinishedProjects"]> <span>Zaključeni projekti</span>
|
||||
</label>
|
||||
<label class="dropdown-item">
|
||||
<input type="checkbox" name="offerProjects" @ViewData["OffersProjects"]> <span>Ponudbe</span>
|
||||
</label> *@
|
||||
</div>
|
||||
</div>
|
||||
<button id="btnRefresh" type="submit" class="btn btn-secondary" aria-label="Osveži" title="Osveži">
|
||||
<i class="opacity-75 ion ion-md-refresh"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h6 class="card-header">
|
||||
Seznam strani
|
||||
</h6>
|
||||
<table class="table card-table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Pages[0].Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Pages[0].Type)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Pages[0].Ratio)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Pages)
|
||||
{
|
||||
<tr data-id="@item.IdBulletinBoardPage">
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Type)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Ratio)
|
||||
</td>
|
||||
<td style="text-align:right;">
|
||||
<a class="btn btn-xs icon-btn btn-outline-primary borderless" href="javascript:;" onclick="rowOpenEditor(this);" data-toggle="tooltip" data-placement="top" title="Urejevalnik" data-state="secondary"><i class="far fa-edit"></i></a>
|
||||
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" href="javascript:;" onclick="openModalEditPage(this);" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-footer py-3 text-right">
|
||||
<a href="javascript:;" onclick="openModalAddPage();" class="btn btn-primary">Dodaj novo</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalAddEditPage" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Urejanje strani</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalAddEditPageIdPage" type="hidden" />
|
||||
<div class="form-group">
|
||||
<label class="control-label">Ime</label>
|
||||
<input id="inpModalAddEditPageName" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Razmerje</label>
|
||||
<select id="selModalAddEditPageRatio" class="form-control" asp-items="Html.GetEnumSelectList<Models.Editor.BulletinBoard.RatioEnum>()">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Tip</label>
|
||||
<select id="selModalAddEditPageType" class="form-control" asp-items="Html.GetEnumSelectList<Models.Editor.BulletinBoardPage.TypeEnum>()">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="saveModalAddEditPage();">Shrani</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalPageEditorPicture" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Urejanje slike</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalPageEditorPictureIdPage" type="hidden" />
|
||||
<div class="form-group">
|
||||
<label class="control-label">Izberi sliko</label>
|
||||
<input type="file" id="inpModalPageEditorPicturePicture" class="form-control" />
|
||||
</div>
|
||||
<hr/>
|
||||
<img id="imgModalPageEditorPicture" src="" class="img-fluid" alt="Responsive image">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="saveModalPageEditorPicture();">Shrani</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divModalPageEditorLink" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Urejanje zunanje povezave</h5>
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="inpModalPageEditorLinkIdPage" type="hidden" />
|
||||
<div class="form-group">
|
||||
<label class="control-label">Povezava</label>
|
||||
<input id="inpModalPageEditorLinkLink" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" onclick="saveModalPageEditorLink();">Shrani</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Prekliči</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
@section Scripts {
|
||||
<script src="~/js/pages/index.js" asp-append-version="true"></script>
|
||||
}
|
||||
103
ZpcBulletinBoard/Pages/Pages/Index.cshtml.cs
Normal file
103
ZpcBulletinBoard/Pages/Pages/Index.cshtml.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ZpcBulletinBoard.Data;
|
||||
using ZpcBulletinBoard.Models.Editor;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.Pages
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel(ApplicationDbContext context, IWebHostEnvironment webHostEnvironment) : PageModel
|
||||
{
|
||||
public IList<BulletinBoardPage> Pages { get;set; }
|
||||
|
||||
public int OpenEditorForPage = 0;
|
||||
|
||||
public async Task OnGetAsync(int? openEditorForPage = null)
|
||||
{
|
||||
OpenEditorForPage = openEditorForPage ?? 0;
|
||||
Pages = await context.BulletinBoardPage.ToListAsync();
|
||||
}
|
||||
|
||||
//Get
|
||||
public IActionResult OnGetPage(int id)
|
||||
{
|
||||
var page = context.BulletinBoardPage.Include(x => x.Links)
|
||||
.FirstOrDefault(x => x.IdBulletinBoardPage == id);
|
||||
if (page == null)
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {id} not exists!" });
|
||||
|
||||
foreach (var link in page.Links)
|
||||
{
|
||||
link.BulletinBoardPage.Links = null;
|
||||
}
|
||||
return new JsonResult(new { successful = true, error = $"", page });
|
||||
}
|
||||
|
||||
//Posts
|
||||
public IActionResult OnPostBoardPage(BulletinBoardPage page)
|
||||
{
|
||||
if (page.IdBulletinBoardPage <= 0)
|
||||
{
|
||||
context.BulletinBoardPage.Add(page);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tmpPage = context.BulletinBoardPage.FirstOrDefault(x => x.IdBulletinBoardPage == page.IdBulletinBoardPage);
|
||||
if (tmpPage == null)
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {page.IdBulletinBoardPage} not exists!", page });
|
||||
|
||||
tmpPage.Name = page.Name;
|
||||
//tmpPage.Duration = page.Duration;
|
||||
}
|
||||
context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", page });
|
||||
}
|
||||
|
||||
public IActionResult OnPostBoardPageLink(int idPage, string link)
|
||||
{
|
||||
var tmpPage = context.BulletinBoardPage.FirstOrDefault(x => x.IdBulletinBoardPage == idPage);
|
||||
if (tmpPage == null)
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {idPage} not exists!" });
|
||||
tmpPage.ExternalLink = link;
|
||||
context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", tmpPage });
|
||||
}
|
||||
|
||||
public IActionResult OnPostBoardPagePicture(IFormFile? file, int idPage)
|
||||
{
|
||||
if (file == null)
|
||||
return new JsonResult(new { successful = true, error = "No file!" });
|
||||
|
||||
var tmpPage = context.BulletinBoardPage.FirstOrDefault(x => x.IdBulletinBoardPage == idPage);
|
||||
if (tmpPage == null)
|
||||
return new JsonResult(new { successful = false, error = $"Page with ID {idPage} not exists!" });
|
||||
|
||||
var uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "bulletin-board-images/pages");
|
||||
var imageName = "StaticImage_" + idPage + Path.GetExtension(file.FileName);
|
||||
var filePath = Path.Combine(uploadsFolder, imageName);
|
||||
|
||||
if (System.IO.File.Exists(filePath))
|
||||
System.IO.File.Delete(filePath);
|
||||
|
||||
using (var fileStream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
file.CopyTo(fileStream);
|
||||
}
|
||||
|
||||
tmpPage.Image = imageName;
|
||||
context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,9 @@ namespace ZpcBulletinBoard.Pages.User
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var result = await _loginManager.PasswordSignInAsync(Input.UserName, Input.Password, Input.RememberLogin, false);
|
||||
//TODO samo za DEV
|
||||
//var result = await _loginManager.PasswordSignInAsync(Input.UserName, Input.Password, Input.RememberLogin, false);
|
||||
var result = await _loginManager.PasswordSignInAsync("Admin", "*zpcBulletinBoard2024*", Input.RememberLogin, false);
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user