Editor povezava na db
This commit is contained in:
@@ -36,13 +36,13 @@ namespace ZpcBulletinBoard.Pages.Boards
|
||||
{
|
||||
Ratio = BulletinBoard.RatioEnum.Ratio16To9,
|
||||
Guid = Guid.NewGuid(),
|
||||
Notes = new List<Note>()
|
||||
Pages = new List<BulletinBoardPage>()
|
||||
};
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
var tmpBoard = await context.BulletinBoards.Include(x => x.Notes)
|
||||
var tmpBoard = await context.BulletinBoards.Include(x => x.Pages)
|
||||
.FirstOrDefaultAsync(m => m.Guid == guid);
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ using ZpcBulletinBoard.Models.Editor;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.Boards
|
||||
{
|
||||
//[Authorize]
|
||||
[Authorize]
|
||||
public class IndexModel(ApplicationDbContext context) : PageModel
|
||||
{
|
||||
public IList<BulletinBoard> Boards { get;set; }
|
||||
|
||||
@@ -15,13 +15,8 @@
|
||||
<div class="card">
|
||||
<div class="card-body div-main-body">
|
||||
<div class="form-inline div-tools">
|
||||
<select class="form-control input-xs">
|
||||
<option id="1">Prvi board</option>
|
||||
<option id="2">Drugi</option>
|
||||
<option id="3">sad</option>
|
||||
</select>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default btn-sm">
|
||||
<button type="button" class="btn btn-default btn-sm" onclick="addNewNote()">
|
||||
<i class="far fa-plus"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-sm">
|
||||
@@ -42,6 +37,35 @@
|
||||
</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-primary" onclick="saveModalEditNote();">Save changes</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">
|
||||
@@ -63,6 +87,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using System.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using ZpcBulletinBoard.Data;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.Editor
|
||||
{
|
||||
public class EditMainModel(ILogger<EditMainModel> logger) : PageModel
|
||||
[Authorize]
|
||||
public class EditMainModel(ILogger<EditMainModel> logger, ApplicationDbContext context) : PageModel
|
||||
{
|
||||
private readonly ILogger<EditMainModel> _logger = logger;
|
||||
|
||||
@@ -11,5 +15,20 @@ namespace ZpcBulletinBoard.Pages.Editor
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IActionResult OnGetBoards()
|
||||
{
|
||||
var boards= context.BulletinBoards.ToList();
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", boards });
|
||||
}
|
||||
|
||||
public IActionResult OnGetBoard(int id)
|
||||
{
|
||||
var board = context.BulletinBoards.Include(x => x.Pages)
|
||||
.FirstOrDefault(x => x.IdBulletinBoard == id);
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", board });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
|
||||
6
ZpcBulletinBoard/Pages/SetupNew/Index.cshtml
Normal file
6
ZpcBulletinBoard/Pages/SetupNew/Index.cshtml
Normal file
@@ -0,0 +1,6 @@
|
||||
@page
|
||||
@model ZpcBulletinBoard.Pages.SetupNew.SetupModel
|
||||
@{
|
||||
ViewData["Title"] = "SetupNew";
|
||||
Layout = "~/Pages/Shared/_LayoutBlank.cshtml";
|
||||
}
|
||||
113
ZpcBulletinBoard/Pages/SetupNew/Index.cshtml.cs
Normal file
113
ZpcBulletinBoard/Pages/SetupNew/Index.cshtml.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ZpcBulletinBoard.Data;
|
||||
using ZpcBulletinBoard.Models;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.SetupNew
|
||||
{
|
||||
//[Authorize(Roles = "Administrator")]
|
||||
public class SetupModel : PageModel
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
private readonly SignInManager<IdentityApplicationUser> _signInManager;
|
||||
private readonly RoleManager<IdentityApplicationRole> _roleManager;
|
||||
private readonly ILogger<SetupModel> _logger;
|
||||
|
||||
public SetupModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> signInManager, ILogger<SetupModel> logger, RoleManager<IdentityApplicationRole> roleManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
_signInManager = signInManager;
|
||||
_logger = logger;
|
||||
_roleManager = roleManager;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
//Ze obstajajo userji
|
||||
//if (_userManager.Users.Any())
|
||||
// return RedirectToPage("/User/Login");
|
||||
|
||||
var rolesDefinitions = new List<(string RoleName, string RoleDescription)>
|
||||
{
|
||||
("User", "Uporabnik"),
|
||||
("Administrator", "Administratorji"),
|
||||
};
|
||||
|
||||
foreach (var roleDefinition in rolesDefinitions)
|
||||
{
|
||||
if (!_roleManager.RoleExistsAsync(roleDefinition.RoleName).Result)
|
||||
{
|
||||
var role = new IdentityApplicationRole
|
||||
{
|
||||
Name = roleDefinition.RoleName,
|
||||
Description = roleDefinition.RoleDescription
|
||||
};
|
||||
|
||||
_roleManager.CreateAsync(role).Wait();
|
||||
}
|
||||
}
|
||||
|
||||
var user = await _userManager.FindByNameAsync("admin");
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
IdentityApplicationUser identityApplicationUser = new IdentityApplicationUser
|
||||
{
|
||||
Name = "Master",
|
||||
Surname = "Admin",
|
||||
UserName = "admin",
|
||||
NormalizedUserName = "admin",
|
||||
Email = "admin@domain.com",
|
||||
NormalizedEmail = "admin@domain.com",
|
||||
EmailConfirmed = true,
|
||||
DateCreated = DateTime.Now,
|
||||
DateValidUntil = DateTime.MaxValue,
|
||||
PhoneNumber = "070777777",
|
||||
PhoneNumberConfirmed = true,
|
||||
Active = true,
|
||||
};
|
||||
|
||||
var result = await _userManager.CreateAsync(identityApplicationUser, "*zpcBulletinBoard2024*");
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
_userManager.AddToRoleAsync(identityApplicationUser, "Administrator").Wait();
|
||||
//return RedirectToPage("/Administration/Users/Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModelState.AddModelError("", string.Join(",", identityResult.Errors.Select(x => x.Description)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return RedirectToPage("/User/Login");
|
||||
}
|
||||
|
||||
//public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
||||
//{
|
||||
// var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
// await _signInManager.SignOutAsync();
|
||||
|
||||
// _logger.LogInformation($"Logout: {user.Name} {user.Surname} - {user.Company.Title}");
|
||||
|
||||
// if (returnUrl != null)
|
||||
// {
|
||||
// return LocalRedirect(returnUrl);
|
||||
// }
|
||||
|
||||
// return RedirectToPage();
|
||||
//}
|
||||
}
|
||||
}
|
||||
13
ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml
Normal file
13
ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml
Normal file
@@ -0,0 +1,13 @@
|
||||
@{
|
||||
Layout = "Shared/_Application";
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
@await RenderSectionAsync("Styles", required: false)
|
||||
}
|
||||
|
||||
@RenderBody()
|
||||
|
||||
@section Scripts {
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
}
|
||||
48
ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml.css
Normal file
48
ZpcBulletinBoard/Pages/Shared/_LayoutBlank.cshtml.css
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
for details on configuring this project to bundle and minify static web assets. */
|
||||
|
||||
a.navbar-brand {
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0077cc;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||
}
|
||||
|
||||
button.accept-policy {
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
line-height: 60px;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
@model ZpcBulletinBoard.Pages.User.LoginModel
|
||||
@{
|
||||
ViewData["Title"] = "Prijava";
|
||||
Layout = "~/Pages/Shared/_Layout.cshtml";
|
||||
Layout = "~/Pages/Shared/_LayoutBlank.cshtml";
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
@@ -24,10 +24,10 @@
|
||||
<div class="ui-bg-overlay bg-dark opacity-50"></div>
|
||||
<div class="w-100 text-white px-5">
|
||||
<h1 class="display-2 font-weight-bolder mb-4">
|
||||
EveryThing
|
||||
ZPC
|
||||
</h1>
|
||||
<div class="text-large font-weight-light">
|
||||
Oblačna aplikacija
|
||||
Bulletin board
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -64,10 +64,6 @@
|
||||
<button type="submit" class="btn btn-primary">Prijava</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-center text-muted">
|
||||
Ste pozabili geslo? <a href="javascript:void(0)">Kliknite tukaj za ponastavitev</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user