diff --git a/ZpcBulletinBoard/Pages/Boards/AddEdit.cshtml b/ZpcBulletinBoard/Pages/Boards/AddEdit.cshtml index 4692e64..59a5488 100644 --- a/ZpcBulletinBoard/Pages/Boards/AddEdit.cshtml +++ b/ZpcBulletinBoard/Pages/Boards/AddEdit.cshtml @@ -3,7 +3,7 @@ @{ ViewData["Title"] = "Edit board"; - Layout = "~/Pages/Shared/_Layout.cshtml"; + Layout = "~/Pages/Layouts/_Layout.cshtml"; } diff --git a/ZpcBulletinBoard/Pages/Boards/Index.cshtml b/ZpcBulletinBoard/Pages/Boards/Index.cshtml index bf3725a..3321b01 100644 --- a/ZpcBulletinBoard/Pages/Boards/Index.cshtml +++ b/ZpcBulletinBoard/Pages/Boards/Index.cshtml @@ -3,20 +3,11 @@ @{ ViewData["Title"] = "Oglasne deske - Pregled"; - Layout = "~/Pages/Shared/_Layout.cshtml"; + Layout = "~/Pages/Layouts/_Layout.cshtml"; } @section Styles { - - - + }

@@ -27,43 +18,59 @@

+
+
+
+ + +
+
+
+
Seznam oglasnih desk
- - - - - - - - - - @foreach (var item in Model.Boards) - { +
+
- @Html.DisplayNameFor(model => model.Boards[0].Name) - - @Html.DisplayNameFor(model => model.Boards[0].Ratio) -
+ - - - + + + - } - -
- @Html.DisplayFor(modelItem => item.Name) - - @Html.DisplayFor(modelItem => item.Ratio) - - - + @Html.DisplayNameFor(model => model.Boards[0].Name) + + @Html.DisplayNameFor(model => model.Boards[0].Ratio) +
+ + + @foreach (var item in Model.Boards) + { + + + @Html.DisplayFor(modelItem => item.Name) + + + @Html.DisplayFor(modelItem => item.Ratio) + + + + + + + } + + +
@section Scripts { + + } \ No newline at end of file diff --git a/ZpcBulletinBoard/Pages/Boards/View.cshtml b/ZpcBulletinBoard/Pages/Boards/View.cshtml new file mode 100644 index 0000000..4632ccd --- /dev/null +++ b/ZpcBulletinBoard/Pages/Boards/View.cshtml @@ -0,0 +1,26 @@ +@page "{handler?}" +@model ZpcBulletinBoard.Pages.Boards.ViewModel + +@{ + ViewData["Title"] = "Board view"; + Layout = "~/Pages/Layouts/_LayoutBlank.cshtml"; +} + +@section Styles { + +} + + + +
+ +
+ +
+ +

Ni prosojnic za @Model.Guid

+
+ +@section Scripts { + +} \ No newline at end of file diff --git a/ZpcBulletinBoard/Pages/Boards/View.cshtml.cs b/ZpcBulletinBoard/Pages/Boards/View.cshtml.cs new file mode 100644 index 0000000..9618213 --- /dev/null +++ b/ZpcBulletinBoard/Pages/Boards/View.cshtml.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.EntityFrameworkCore; +using ZpcBulletinBoard.Data; +using ZpcBulletinBoard.Models; +using ZpcBulletinBoard.Models.Editor; + +namespace ZpcBulletinBoard.Pages.Boards + +{ + [AllowAnonymous] + public class ViewModel(ApplicationDbContext context) + : PageModel + { + [BindProperty] public string Guid { get; set; } = ""; + public IActionResult OnGet(string? guid) + { + if (string.IsNullOrEmpty(guid)) + { + return NotFound(); + } + + Guid = guid; + + return Page(); + } + + + } +} diff --git a/ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml b/ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml index 7881179..a486569 100644 --- a/ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml +++ b/ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml @@ -3,7 +3,7 @@ @{ ViewData["Title"] = "Oglasne deske - Povezave"; - Layout = "~/Pages/Shared/_Layout.cshtml"; + Layout = "~/Pages/Layouts/_Layout.cshtml"; } @section Styles @@ -20,13 +20,13 @@
-
+
-
Oglasne deske
+
-
Strani
+
@@ -48,7 +48,15 @@ @foreach (var tmpPage in Model.Pages) {
- page image + @if ((int)tmpPage.Type == 3) + { + + } + else + { + page image + + } @tmpPage.Name
@* *@ diff --git a/ZpcBulletinBoard/Pages/Layouts/Partials/_LayoutSidenav.cshtml b/ZpcBulletinBoard/Pages/Layouts/Partials/_LayoutSidenav.cshtml index 19f9dd6..6425878 100644 --- a/ZpcBulletinBoard/Pages/Layouts/Partials/_LayoutSidenav.cshtml +++ b/ZpcBulletinBoard/Pages/Layouts/Partials/_LayoutSidenav.cshtml @@ -4,12 +4,9 @@
@@ -24,5 +21,14 @@
  • Povezave
  • + @if (User.IsInRole("Administrator") || User.IsInRole("TransportThingUser")) + { +
  • +
  • ADMINISTRACIJA
  • + +
  • +
    Uporabniki
    +
  • + }
    \ No newline at end of file diff --git a/ZpcBulletinBoard/Pages/Shared/_Application.cshtml b/ZpcBulletinBoard/Pages/Layouts/_Application.cshtml similarity index 97% rename from ZpcBulletinBoard/Pages/Shared/_Application.cshtml rename to ZpcBulletinBoard/Pages/Layouts/_Application.cshtml index 6a4d415..eedd011 100644 --- a/ZpcBulletinBoard/Pages/Shared/_Application.cshtml +++ b/ZpcBulletinBoard/Pages/Layouts/_Application.cshtml @@ -7,7 +7,8 @@ - ZPC-BB - @ViewData["Title"] + ZPC BB - @ViewData["Title"] + diff --git a/ZpcBulletinBoard/Pages/Shared/_Layout.cshtml b/ZpcBulletinBoard/Pages/Layouts/_Layout.cshtml similarity index 95% rename from ZpcBulletinBoard/Pages/Shared/_Layout.cshtml rename to ZpcBulletinBoard/Pages/Layouts/_Layout.cshtml index 4236c5b..0cac15e 100644 --- a/ZpcBulletinBoard/Pages/Shared/_Layout.cshtml +++ b/ZpcBulletinBoard/Pages/Layouts/_Layout.cshtml @@ -1,5 +1,5 @@ @{ - Layout = "Shared/_Application"; + Layout = "Layouts/_Application"; } @section Styles { diff --git a/ZpcBulletinBoard/Pages/Shared/_Layout.cshtml.css b/ZpcBulletinBoard/Pages/Layouts/_Layout.cshtml.css similarity index 100% rename from ZpcBulletinBoard/Pages/Shared/_Layout.cshtml.css rename to ZpcBulletinBoard/Pages/Layouts/_Layout.cshtml.css diff --git a/ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml b/ZpcBulletinBoard/Pages/Layouts/_LayoutBlank.cshtml similarity index 82% rename from ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml rename to ZpcBulletinBoard/Pages/Layouts/_LayoutBlank.cshtml index be2dcfd..f323aa1 100644 --- a/ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml +++ b/ZpcBulletinBoard/Pages/Layouts/_LayoutBlank.cshtml @@ -1,5 +1,5 @@ @{ - Layout = "Shared/_Application"; + Layout = "Layouts/_Application"; } @section Styles { diff --git a/ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml.css b/ZpcBulletinBoard/Pages/Layouts/_LayoutBlank.cshtml.css similarity index 100% rename from ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml.css rename to ZpcBulletinBoard/Pages/Layouts/_LayoutBlank.cshtml.css diff --git a/ZpcBulletinBoard/Pages/Pages/Index.cshtml b/ZpcBulletinBoard/Pages/Pages/Index.cshtml index 32b0fd4..6885f15 100644 --- a/ZpcBulletinBoard/Pages/Pages/Index.cshtml +++ b/ZpcBulletinBoard/Pages/Pages/Index.cshtml @@ -3,7 +3,7 @@ @{ ViewData["Title"] = "Strani - Pregled"; - Layout = "~/Pages/Shared/_Layout.cshtml"; + Layout = "~/Pages/Layouts/_Layout.cshtml"; } @section Styles { @@ -19,6 +19,17 @@ +
    +
    +
    + + +
    +
    +
    +
    Strani diff --git a/ZpcBulletinBoard/Pages/Pages/Index.cshtml.cs b/ZpcBulletinBoard/Pages/Pages/Index.cshtml.cs index ed6a769..762c8fb 100644 --- a/ZpcBulletinBoard/Pages/Pages/Index.cshtml.cs +++ b/ZpcBulletinBoard/Pages/Pages/Index.cshtml.cs @@ -99,7 +99,25 @@ namespace ZpcBulletinBoard.Pages.Pages tmpPage.Image = imageName; context.SaveChanges(); - return new JsonResult(new { successful = true, error = $"" }); + return new JsonResult(new { successful = true, error = $"", page = tmpPage }); + } + + //Delete + public IActionResult OnDeleteBoardPage(int idPage) + { + var tmpPage = context.BulletinBoardPage + .Include(x => x.Links) + .FirstOrDefault(x => x.IdBulletinBoardPage == idPage); + if (tmpPage == null) + return new JsonResult(new { successful = false, error = $"Page with ID {idPage} not exists!"}); + + if (tmpPage.Links.Any()) + return new JsonResult(new { successful = false, error = $"Stran je v uporabi!\nBrisanje ni možno!" }); + + context.BulletinBoardPage.Remove(tmpPage); + context.SaveChanges(); + + return new JsonResult(new { successful = true, error = "" }); } } } diff --git a/ZpcBulletinBoard/Pages/SetupNew/Index.cshtml b/ZpcBulletinBoard/Pages/SetupNew/Index.cshtml index dc6ee1b..2d7bfc6 100644 --- a/ZpcBulletinBoard/Pages/SetupNew/Index.cshtml +++ b/ZpcBulletinBoard/Pages/SetupNew/Index.cshtml @@ -2,5 +2,5 @@ @model ZpcBulletinBoard.Pages.SetupNew.SetupModel @{ ViewData["Title"] = "SetupNew"; - Layout = "~/Pages/Shared/_LayoutBlank.cshtml"; + Layout = "~/Pages/Layouts/_LayoutBlank.cshtml"; } diff --git a/ZpcBulletinBoard/Pages/User/Login.cshtml b/ZpcBulletinBoard/Pages/User/Login.cshtml index 64d4040..0c99d9b 100644 --- a/ZpcBulletinBoard/Pages/User/Login.cshtml +++ b/ZpcBulletinBoard/Pages/User/Login.cshtml @@ -4,7 +4,7 @@ @model ZpcBulletinBoard.Pages.User.LoginModel @{ ViewData["Title"] = "Prijava"; - Layout = "~/Pages/Shared/_LayoutBlank.cshtml"; + Layout = "~/Pages/Layouts/_LayoutBlank.cshtml"; } @section Styles { diff --git a/ZpcBulletinBoard/Pages/User/Logout.cshtml b/ZpcBulletinBoard/Pages/User/Logout.cshtml index b54e739..6c75e6b 100644 --- a/ZpcBulletinBoard/Pages/User/Logout.cshtml +++ b/ZpcBulletinBoard/Pages/User/Logout.cshtml @@ -2,5 +2,5 @@ @model ZpcBulletinBoard.Pages.User.LogoutModel @{ ViewData["Title"] = "Odjava"; - Layout = "~/Pages/Shared/_Layout.cshtml"; + Layout = "~/Pages/Layouts/_Layout.cshtml"; } diff --git a/ZpcBulletinBoard/Pages/_ViewStart.cshtml b/ZpcBulletinBoard/Pages/_ViewStart.cshtml index a5f1004..e2aca7b 100644 --- a/ZpcBulletinBoard/Pages/_ViewStart.cshtml +++ b/ZpcBulletinBoard/Pages/_ViewStart.cshtml @@ -1,3 +1,3 @@ @{ - Layout = "_Layout"; + Layout = "~/Pages/Layouts/_Layout.cshtml"; } diff --git a/ZpcBulletinBoard/ZpcBulletinBoard.csproj b/ZpcBulletinBoard/ZpcBulletinBoard.csproj index 9e0fc95..2df772f 100644 --- a/ZpcBulletinBoard/ZpcBulletinBoard.csproj +++ b/ZpcBulletinBoard/ZpcBulletinBoard.csproj @@ -37,6 +37,7 @@ + diff --git a/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_13.png b/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_13.png new file mode 100644 index 0000000..8018629 Binary files /dev/null and b/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_13.png differ diff --git a/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_8.png b/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_8.png new file mode 100644 index 0000000..8018629 Binary files /dev/null and b/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_8.png differ diff --git a/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_9.svg b/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_9.svg new file mode 100644 index 0000000..f70accd --- /dev/null +++ b/ZpcBulletinBoard/wwwroot/bulletin-board-images/pages/StaticImage_9.svg @@ -0,0 +1,79 @@ +
    +
    +
    + Vnesi besedilo +
    +
    +
    \ No newline at end of file diff --git a/ZpcBulletinBoard/wwwroot/css/boards-links/index.css b/ZpcBulletinBoard/wwwroot/css/boards-links/index.css index 872d0f4..ccb534e 100644 --- a/ZpcBulletinBoard/wwwroot/css/boards-links/index.css +++ b/ZpcBulletinBoard/wwwroot/css/boards-links/index.css @@ -95,4 +95,27 @@ width: 170px; margin-left: 15px; margin-top: 5px; +} + +.img-link{ + height: 170px; + width: 170px; + margin-left: 15px; + margin-top: 5px; + padding-top: 50px; +} + +#inpSearchBoard{ + width: 40%; +} + +.header{ + padding: 5px 5px 5px 5px; + margin-bottom: 5px; + border-bottom: 1px solid rgba(24, 28, 33, 0.06); +} + +.div-boards{ + height: 63vh; + overflow-x: auto; } \ No newline at end of file diff --git a/ZpcBulletinBoard/wwwroot/css/boards/index.css b/ZpcBulletinBoard/wwwroot/css/boards/index.css new file mode 100644 index 0000000..6c13109 --- /dev/null +++ b/ZpcBulletinBoard/wwwroot/css/boards/index.css @@ -0,0 +1,14 @@ +.table > tbody > tr > td:nth-child(2), +.table > thead > tr > th:nth-child(2) { + width: 100px +} +.table > tbody > tr > td:nth-child(3), +.table > thead > tr > th:nth-child(3) { + width: 100px; + text-align: right; +} + +.div-boards { + height: 63vh; + overflow-x: auto; +} \ No newline at end of file diff --git a/ZpcBulletinBoard/wwwroot/css/boards/view.css b/ZpcBulletinBoard/wwwroot/css/boards/view.css new file mode 100644 index 0000000..64418ef --- /dev/null +++ b/ZpcBulletinBoard/wwwroot/css/boards/view.css @@ -0,0 +1,13 @@ +.div-placeholder{ + height: 100%; + width: 100%; +} + +.div-no-pages{ + padding: 20%; + text-align: center; +} + +.div-no-pages > h2{ + margin-top: 10px; +} \ No newline at end of file diff --git a/ZpcBulletinBoard/wwwroot/css/pages/index.css b/ZpcBulletinBoard/wwwroot/css/pages/index.css index 47d2b98..717990b 100644 --- a/ZpcBulletinBoard/wwwroot/css/pages/index.css +++ b/ZpcBulletinBoard/wwwroot/css/pages/index.css @@ -11,7 +11,6 @@ } .div-page:hover { - cursor: grab; /* background-color: rgba(24, 28, 33, 0.06); */ border-color: blue; } @@ -35,4 +34,17 @@ width: 170px; margin-left: 15px; margin-top: 5px; +} + +.img-link{ + height: 170px; + width: 170px; + margin-left: 15px; + margin-top: 5px; + padding-top: 50px; +} + +.div-pages{ + height: 63vh; + overflow-x: auto; } \ No newline at end of file diff --git a/ZpcBulletinBoard/wwwroot/favicon.ico b/ZpcBulletinBoard/wwwroot/favicon.ico deleted file mode 100644 index 63e859b..0000000 Binary files a/ZpcBulletinBoard/wwwroot/favicon.ico and /dev/null differ diff --git a/ZpcBulletinBoard/wwwroot/img/imgNotExists.jpg b/ZpcBulletinBoard/wwwroot/img/imgNotExists.jpg new file mode 100644 index 0000000..2b7e566 Binary files /dev/null and b/ZpcBulletinBoard/wwwroot/img/imgNotExists.jpg differ diff --git a/ZpcBulletinBoard/wwwroot/js/boards-links/index.js b/ZpcBulletinBoard/wwwroot/js/boards-links/index.js index 818a140..1fdf684 100644 --- a/ZpcBulletinBoard/wwwroot/js/boards-links/index.js +++ b/ZpcBulletinBoard/wwwroot/js/boards-links/index.js @@ -1,7 +1,43 @@ $(function(){ + $('#inpSearchBoard').on('keyup', function(){ + searchBoards(); + }); + + $('#inpSearchPage').on('keyup', function(){ + searchPages(); + }); + loadBoards(); }); +function searchBoards(){ + let value = $('#inpSearchBoard').val().toLowerCase(); + + $(".div-board").each(function(i, e) { + let boardText = $(e).find('h5').text().toLowerCase(); + if (boardText.indexOf(value) < 0){ + $(e).hide(); + $(e).next().hide(); + } else { + $(e).show(); + $(e).next().show(); + } + }); +} + +function searchPages(){ + let value = $('#inpSearchPage').val().toLowerCase(); + + $(".available-page").each(function(i, e) { + let pageText = $(e).find('small').text().toLowerCase(); + if (pageText.indexOf(value) < 0){ + $(e).hide(); + } else { + $(e).show(); + } + }); +} + function loadBoards(){ $.blockUI(); $.ajax({ @@ -112,8 +148,15 @@ function addPageToAllBoards(el){ function addPageToBoard(idBoard, link){ let div = $('.div-pages[data-idboard="' + idBoard + '"]'); + let preview; + if (link.bulletinBoardPage.type == 3){ + preview = ``; + } else { + preview = `page image` + } + div.append(`
    - page image + ${preview} ${link.bulletinBoardPage.name}
    diff --git a/ZpcBulletinBoard/wwwroot/js/boards/index.js b/ZpcBulletinBoard/wwwroot/js/boards/index.js new file mode 100644 index 0000000..a3eea23 --- /dev/null +++ b/ZpcBulletinBoard/wwwroot/js/boards/index.js @@ -0,0 +1,18 @@ +$(function(){ + $('#inpSearchBoard').on('keyup', function(){ + searchBoards(); + }); +}); + +function searchBoards(){ + let value = $('#inpSearchBoard').val().toLowerCase(); + + $("table > tbody > tr").each(function(i, e) { + let boardText = $(e).find('td:first').text().toLowerCase(); + if (boardText.indexOf(value) < 0){ + $(e).hide(); + } else { + $(e).show(); + } + }); +} \ No newline at end of file diff --git a/ZpcBulletinBoard/wwwroot/js/boards/view.js b/ZpcBulletinBoard/wwwroot/js/boards/view.js new file mode 100644 index 0000000..e69de29 diff --git a/ZpcBulletinBoard/wwwroot/js/pages/index.js b/ZpcBulletinBoard/wwwroot/js/pages/index.js index 166502f..0070269 100644 --- a/ZpcBulletinBoard/wwwroot/js/pages/index.js +++ b/ZpcBulletinBoard/wwwroot/js/pages/index.js @@ -1,12 +1,24 @@ $(function(){ - let openEditorForPage = parseInt($('#inpOpenEditorForPage').val()); - if (!isNaN(openEditorForPage) && openEditorForPage > 0){ - $('#inpOpenEditorForPage').val(0); - openEditor(openEditorForPage); - } + $('#inpSearchPage').on('keyup', function(){ + searchPages(); + }); + loadPages(); }); +function searchPages(){ + let value = $('#inpSearchPage').val().toLowerCase(); + + $(".div-page").each(function(i, e) { + let pageText = $(e).find('small').text().toLowerCase(); + if (pageText.indexOf(value) < 0){ + $(e).hide(); + } else { + $(e).show(); + } + }); +} + function loadPages(){ $.blockUI(); $.ajax({ @@ -39,8 +51,14 @@ function loadPages(){ } function addPageToDiv(page){ + let preview; + if (page.type == 3){ + preview = ``; + } else { + preview = `page image` + } let element = $(`
    - page image + ${preview} ${page.name}
    @@ -129,14 +147,12 @@ function saveModalAddEditPage(){ }}, success: function(data) { if (data.successful){ - $('#divModalAddEditPage').modal('hide'); - if (idBulletinBoardPage > 0){ - //Ce je edit ne odprem editorja - $('#inpOpenEditorForPage').val(0); - } else { - $('#inpOpenEditorForPage').val(data.page.idBulletinBoardPage); + if (idBulletinBoardPage <= 0){ + //Ce je nova dodam in odprem editor + addPageToDiv(data.page); + openEditor(data.page.idBulletinBoardPage); } - $('#btnRefresh').trigger('click'); + $('#divModalAddEditPage').modal('hide'); } else { Swal.fire('Napaka', data.error, 'error'); console.log(data); @@ -208,8 +224,7 @@ function saveModalPageEditorLink(){ data: { idPage, link}, success: function(data) { if (data.successful){ - $('#divModalAddEditPage').modal('hide'); - $('#btnRefresh').trigger('click'); + $('#divModalPageEditorLink').modal('hide'); } else { Swal.fire('Napaka', data.error, 'error'); console.log(data); @@ -245,8 +260,39 @@ function saveModalPageEditorPicture(){ processData: false, success: function(data) { if (data.successful){ + let date = new Date(); + $('.div-page[data-id="' + idPage + '"] > img').attr('src', '/bulletin-board-images/pages/' + data.page.image + '?' + date.getTime()); $('#divModalPageEditorPicture').modal('hide'); - $('#btnRefresh').trigger('click'); + $.unblockUI(); + } else { + Swal.fire('Napaka', data.error, 'error'); + console.log(data); + } + $.unblockUI(); + }, + error: function (xhr, ajaxOptions, thrownError) { + alert(xhr.responseText); + $.unblockUI(); + } + }); +} + +function deletePage(el){ + let idPage = parseInt($(el).parent().parent().attr('data-id')); + $.blockUI(); + $.ajax({ + type: "DELETE", + beforeSend: function(xhr) { + xhr.setRequestHeader("XSRF-TOKEN", + $('input:hidden[name="__RequestVerificationToken"]').val()); + }, + url: "/Pages/Index/?handler=BoardPage", + data: { + idPage + }, + success: function(data) { + if (data.successful){ + $(el).parent().parent().remove(); } else { Swal.fire('Napaka', data.error, 'error'); console.log(data); diff --git a/ZpcBulletinBoard/wwwroot/pin.ico b/ZpcBulletinBoard/wwwroot/pin.ico new file mode 100644 index 0000000..f804c3e Binary files /dev/null and b/ZpcBulletinBoard/wwwroot/pin.ico differ