This commit is contained in:
David Štaleker
2024-03-11 18:22:37 +01:00
parent 172626c8ee
commit dda4b613f8
32 changed files with 442 additions and 76 deletions

View File

@@ -3,7 +3,7 @@
@{
ViewData["Title"] = "Edit board";
Layout = "~/Pages/Shared/_Layout.cshtml";
Layout = "~/Pages/Layouts/_Layout.cshtml";
}
<!-- Editor -->

View File

@@ -3,20 +3,11 @@
@{
ViewData["Title"] = "Oglasne deske - Pregled";
Layout = "~/Pages/Shared/_Layout.cshtml";
Layout = "~/Pages/Layouts/_Layout.cshtml";
}
@section Styles {
<link rel="stylesheet" href="~/vendor/libs/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css">
<style type="text/css">
.table > tbody > tr > td:nth-child(2),
.table > thead > tr > th:nth-child(2),
.table > tbody > tr > td:nth-child(3),
.table > thead > tr > th:nth-child(3) {
width: 100px
}
</style>
<link rel="stylesheet" href="~/css/boards/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">
@@ -27,43 +18,59 @@
</span>
</h4>
<div class="row">
<div class="col-12 mb-2 text-right">
<div class="btn-group">
<input id="inpSearchBoard" class="form-control" type="text" value="" placeholder="Iskanje..." autocomplete="off">
<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>
</div>
</div>
<div class="card">
<h6 class="card-header">
Seznam oglasnih desk
</h6>
<table class="table card-table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Boards[0].Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Boards[0].Ratio)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Boards)
{
<div class="div-boards">
<table class="table card-table table-hover">
<thead>
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Ratio)
</td>
<td>
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="AddEdit" asp-route-guid="@item.Guid" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
</td>
<th>
@Html.DisplayNameFor(model => model.Boards[0].Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Boards[0].Ratio)
</th>
<th></th>
</tr>
}
</tbody>
</table>
</thead>
<tbody>
@foreach (var item in Model.Boards)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Ratio)
</td>
<td>
<a class="btn btn-xs icon-btn btn-outline-success borderless" asp-page="View" asp-route-guid="@item.Guid" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-external-link"></i></a>
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="AddEdit" asp-route-guid="@item.Guid" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="card-footer py-3 text-right">
<a asp-page="AddEdit" class="btn btn-primary">Dodaj novo</a>
</div>
</div>
@section Scripts {
<script src="~/js/boards/index.js" asp-append-version="true"></script>
}

View File

@@ -0,0 +1,26 @@
@page "{handler?}"
@model ZpcBulletinBoard.Pages.Boards.ViewModel
@{
ViewData["Title"] = "Board view";
Layout = "~/Pages/Layouts/_LayoutBlank.cshtml";
}
@section Styles {
<link rel="stylesheet" href="~/css/boards/view.css" asp-append-version="true" />
}
<input id="inpGuidBoard" type="hidden" asp-for="Guid"/>
<div class="div-placeholder">
</div>
<div class="div-no-pages">
<i class="fal fa-exclamation-triangle fa-10x text-danger"></i>
<h2>Ni prosojnic za @Model.Guid</h2>
</div>
@section Scripts {
<script src="~/js/boards/view.js" asp-append-version="true"></script>
}

View File

@@ -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();
}
}
}

View File

@@ -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 @@
</h4>
<div class="card">
<div class="card-header">
<div class="header">
<div class="div-content">
<div class="div-content-boards">
<h6>Oglasne deske</h6>
<input id="inpSearchBoard" class="form-control form-control-sm" placeholder="Iskanje oglasnik desk..." />
</div>
<div class="div-content-pages">
<h6>Strani</h6>
<input id="inpSearchPage" class="form-control form-control-sm" placeholder="Iskanje strani..." />
</div>
</div>
</div>
@@ -48,7 +48,15 @@
@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" />
@if ((int)tmpPage.Type == 3)
{
<div class='img-link'><i class="fas fa-link fa-5x"></i></div>
}
else
{
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/@tmpPage.Image" onerror="this.src='/img/imgNotExists.jpg'" 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> *@

View File

@@ -4,12 +4,9 @@
<div class="app-brand demo">
<span class="app-brand-logo demo bg-secondary">
<i class="fas fa-draw-circle text-white"></i>
<i class="fas fa-thumbtack text-white"></i>
</span>
<a href="/" class="app-brand-text demo sidenav-text font-weight-normal ml-2">Bulletin board</a>
<a href="javascript:void(0)" class="layout-sidenav-toggle sidenav-link text-large ml-auto">
<i class="ion ion-md-menu align-middle"></i>
</a>
<a href="/" class="app-brand-text demo sidenav-text font-weight-normal ml-2">ZPC Bulletin board</a>
</div>
<div class="sidenav-divider mt-0"></div>
@@ -24,5 +21,14 @@
<li class="sidenav-item@(currentPage.StartsWith("/BoardsLinks/") ? " active" : "")">
<a asp-page="/BoardsLinks/Index" class="sidenav-link"><i class="sidenav-icon fas fa-link"></i><div>Povezave</div></a>
</li>
@if (User.IsInRole("Administrator") || User.IsInRole("TransportThingUser"))
{
<li class="sidenav-divider mb-1"></li>
<li class="sidenav-header small font-weight-semibold">ADMINISTRACIJA</li>
<li class="sidenav-item@(currentPage.StartsWith("/TransportLoadingOrder/") ? " active" : "")">
<a asp-page="/TransportLoadingOrder/Index" class="sidenav-link"><i class="sidenav-icon far fa-u"></i><div>Uporabniki</div></a>
</li>
}
</ul>
</div>

View File

@@ -7,7 +7,8 @@
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>ZPC-BB - @ViewData["Title"]</title>
<title>ZPC BB - @ViewData["Title"]</title>
<link rel="icon" type="image/x-icon" href="/pin.ico">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900" rel="stylesheet" crossorigin="anonymous" />

View File

@@ -1,5 +1,5 @@
@{
Layout = "Shared/_Application";
Layout = "Layouts/_Application";
}
@section Styles {

View File

@@ -1,5 +1,5 @@
@{
Layout = "Shared/_Application";
Layout = "Layouts/_Application";
}
@section Styles {

View File

@@ -3,7 +3,7 @@
@{
ViewData["Title"] = "Strani - Pregled";
Layout = "~/Pages/Shared/_Layout.cshtml";
Layout = "~/Pages/Layouts/_Layout.cshtml";
}
@section Styles {
@@ -19,6 +19,17 @@
</span>
</h4>
<div class="row">
<div class="col-12 mb-2 text-right">
<div class="btn-group">
<input id="inpSearchPage" class="form-control" type="text" value="" placeholder="Iskanje..." autocomplete="off">
<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>
</div>
</div>
<div class="card">
<h6 class="card-header">
Strani

View File

@@ -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 = "" });
}
}
}

View File

@@ -2,5 +2,5 @@
@model ZpcBulletinBoard.Pages.SetupNew.SetupModel
@{
ViewData["Title"] = "SetupNew";
Layout = "~/Pages/Shared/_LayoutBlank.cshtml";
Layout = "~/Pages/Layouts/_LayoutBlank.cshtml";
}

View File

@@ -4,7 +4,7 @@
@model ZpcBulletinBoard.Pages.User.LoginModel
@{
ViewData["Title"] = "Prijava";
Layout = "~/Pages/Shared/_LayoutBlank.cshtml";
Layout = "~/Pages/Layouts/_LayoutBlank.cshtml";
}
@section Styles {

View File

@@ -2,5 +2,5 @@
@model ZpcBulletinBoard.Pages.User.LogoutModel
@{
ViewData["Title"] = "Odjava";
Layout = "~/Pages/Shared/_Layout.cshtml";
Layout = "~/Pages/Layouts/_Layout.cshtml";
}

View File

@@ -1,3 +1,3 @@
@{
Layout = "_Layout";
Layout = "~/Pages/Layouts/_Layout.cshtml";
}

View File

@@ -37,6 +37,7 @@
<Folder Include="Properties\PublishProfiles\" />
<Folder Include="wwwroot\bulletin-board-images\notes\" />
<Folder Include="wwwroot\bulletin-board-images\pages\" />
<Folder Include="wwwroot\img\" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 22 MiB

View File

@@ -96,3 +96,26 @@
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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -11,7 +11,6 @@
}
.div-page:hover {
cursor: grab;
/* background-color: rgba(24, 28, 33, 0.06); */
border-color: blue;
}
@@ -36,3 +35,16 @@
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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -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 = `<div class='img-link'><i class="fas fa-link fa-5x"></i></div>`;
} else {
preview = `<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/${link.bulletinBoardPage.image}" onerror="this.src='/img/imgNotExists.jpg'" alt="page image" />`
}
div.append(`<div class="div-page" data-id="${link.idLink}" data-idPage='${link.bulletinBoardPage.idBulletinBoardPage}' data-duration='${link.duration}'>
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/${link.bulletinBoardPage.image}" alt="page image" />
${preview}
<small>${link.bulletinBoardPage.name}</small>
<div class="tools">
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless" onclick="moveLink(this, -1)"><i class="fas fa-chevron-left"></i></a>

View File

@@ -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();
}
});
}

View File

@@ -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 = `<div class='img-link'><i class="fas fa-link fa-5x"></i></div>`;
} else {
preview = `<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/${page.image}" onerror="this.src='/img/imgNotExists.jpg'" alt="page image" />`
}
let element = $(`<div class="div-page" data-id="${page.idBulletinBoardPage}">
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/${page.image}" alt="page image" />
${preview}
<small>${page.name}</small>
<div class="tools">
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless" onclick="pageOpenEditor(this);" data-toggle="tooltip" data-placement="top" title="Urejevalnik" data-state="secondary"><i class="far fa-edit"></i></a>
@@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB