Compare commits

...

2 Commits

Author SHA1 Message Date
David Štaleker
073bb88703 dev 2024-03-10 18:58:33 +01:00
David Štaleker
c4883e4296 dev 2024-03-10 18:58:24 +01:00
39 changed files with 2068 additions and 1286 deletions

View File

@@ -16,6 +16,7 @@ namespace ZpcBulletinBoard.Data
public DbSet<Note> Notes { get; set; }
public DbSet<BulletinBoard> BulletinBoards { get; set; }
public DbSet<BulletinBoardPage> BulletinBoardPage { get; set; }
public DbSet<BulletinBoardPageLink> BulletinBoardPageLinks { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -23,10 +24,15 @@ namespace ZpcBulletinBoard.Data
//Relacije
modelBuilder.Entity<BulletinBoard>()
.HasMany(t => t.Pages)
.HasMany(t => t.Links)
.WithOne(t => t.BulletinBoard)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<BulletinBoardPage>()
.HasMany(t => t.Links)
.WithOne(t => t.BulletinBoardPage)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<BulletinBoardPage>()
.HasMany(t => t.Notes)
.WithOne(t => t.BulletinBoardPage)

View File

@@ -1,359 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ZpcBulletinBoard.Data;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240225160626_1")]
partial class _1
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("EveryThing.Models.IdentityApplicationRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<bool>("Active")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("EveryThing.Models.IdentityApplicationUser", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<bool>("Active")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<DateTime>("DateCreated")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DateValidUntil")
.HasColumnType("datetime(6)");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderKey")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Property<int>("IdBulletinBoard")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<Guid>("Guid")
.HasColumnType("char(36)");
b.HasKey("IdBulletinBoard");
b.ToTable("BulletinBoards");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Height")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Width")
.HasColumnType("int");
b.Property<int>("X")
.HasColumnType("int");
b.Property<int>("Y")
.HasColumnType("int");
b.HasKey("IdNote");
b.HasIndex("IdBulletinBoard");
b.ToTable("Notes");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("EveryThing.Models.IdentityApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("EveryThing.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("EveryThing.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("EveryThing.Models.IdentityApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EveryThing.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("EveryThing.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Notes")
.HasForeignKey("IdBulletinBoard")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Notes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,73 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BulletinBoards",
columns: table => new
{
IdBulletinBoard = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Guid = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_BulletinBoards", x => x.IdBulletinBoard);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Notes",
columns: table => new
{
IdNote = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
IdBulletinBoard = table.Column<int>(type: "int", nullable: false),
X = table.Column<int>(type: "int", nullable: false),
Y = table.Column<int>(type: "int", nullable: false),
Width = table.Column<int>(type: "int", nullable: false),
Height = table.Column<int>(type: "int", nullable: false),
Title = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Content = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Notes", x => x.IdNote);
table.ForeignKey(
name: "FK_Notes_BulletinBoards_IdBulletinBoard",
column: x => x.IdBulletinBoard,
principalTable: "BulletinBoards",
principalColumn: "IdBulletinBoard",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Notes_IdBulletinBoard",
table: "Notes",
column: "IdBulletinBoard");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Notes");
migrationBuilder.DropTable(
name: "BulletinBoards");
}
}
}

View File

@@ -1,366 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ZpcBulletinBoard.Data;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240225172529_2")]
partial class _2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderKey")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Property<int>("IdBulletinBoard")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<Guid>("Guid")
.HasColumnType("char(36)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Ratio")
.HasColumnType("int");
b.HasKey("IdBulletinBoard");
b.ToTable("BulletinBoards");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Height")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Width")
.HasColumnType("int");
b.Property<int>("X")
.HasColumnType("int");
b.Property<int>("Y")
.HasColumnType("int");
b.HasKey("IdNote");
b.HasIndex("IdBulletinBoard");
b.ToTable("Notes");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.IdentityApplicationRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<bool>("Active")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.IdentityApplicationUser", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<bool>("Active")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<DateTime>("DateCreated")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DateValidUntil")
.HasColumnType("datetime(6)");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Notes")
.HasForeignKey("IdBulletinBoard")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Notes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Name",
table: "BulletinBoards",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "Ratio",
table: "BulletinBoards",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Name",
table: "BulletinBoards");
migrationBuilder.DropColumn(
name: "Ratio",
table: "BulletinBoards");
}
}
}

View File

@@ -1,94 +0,0 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Notes_BulletinBoards_IdBulletinBoard",
table: "Notes");
migrationBuilder.RenameColumn(
name: "IdBulletinBoard",
table: "Notes",
newName: "IdBulletinBoardPage");
migrationBuilder.RenameIndex(
name: "IX_Notes_IdBulletinBoard",
table: "Notes",
newName: "IX_Notes_IdBulletinBoardPage");
migrationBuilder.CreateTable(
name: "BulletinBoardPage",
columns: table => new
{
IdBulletinBoardPage = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
IdBulletinBoard = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Duration = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BulletinBoardPage", x => x.IdBulletinBoardPage);
table.ForeignKey(
name: "FK_BulletinBoardPage_BulletinBoards_IdBulletinBoard",
column: x => x.IdBulletinBoard,
principalTable: "BulletinBoards",
principalColumn: "IdBulletinBoard",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_BulletinBoardPage_IdBulletinBoard",
table: "BulletinBoardPage",
column: "IdBulletinBoard");
migrationBuilder.AddForeignKey(
name: "FK_Notes_BulletinBoardPage_IdBulletinBoardPage",
table: "Notes",
column: "IdBulletinBoardPage",
principalTable: "BulletinBoardPage",
principalColumn: "IdBulletinBoardPage",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Notes_BulletinBoardPage_IdBulletinBoardPage",
table: "Notes");
migrationBuilder.DropTable(
name: "BulletinBoardPage");
migrationBuilder.RenameColumn(
name: "IdBulletinBoardPage",
table: "Notes",
newName: "IdBulletinBoard");
migrationBuilder.RenameIndex(
name: "IX_Notes_IdBulletinBoardPage",
table: "Notes",
newName: "IX_Notes_IdBulletinBoard");
migrationBuilder.AddForeignKey(
name: "FK_Notes_BulletinBoards_IdBulletinBoard",
table: "Notes",
column: "IdBulletinBoard",
principalTable: "BulletinBoards",
principalColumn: "IdBulletinBoard",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _5 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ColorClass",
table: "Notes",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "Zindex",
table: "Notes",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ColorClass",
table: "Notes");
migrationBuilder.DropColumn(
name: "Zindex",
table: "Notes");
}
}
}

View File

@@ -11,8 +11,8 @@ using ZpcBulletinBoard.Data;
namespace ZpcBulletinBoard.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240227053725_3")]
partial class _3
[Migration("20240308174035_1")]
partial class _1
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -148,29 +148,62 @@ namespace ZpcBulletinBoard.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("ExternalLink")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Ratio")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("IdBulletinBoardPage");
b.HasIndex("IdBulletinBoard");
b.ToTable("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.Property<int>("IdLink")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardFk")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardPageFk")
.HasColumnType("int");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("IdLink");
b.HasIndex("IdBulletinBoardFk");
b.HasIndex("IdBulletinBoardPageFk");
b.ToTable("BulletinBoardPageLinks");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ColorClass")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("longtext");
@@ -181,9 +214,8 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("IdBulletinBoardPage")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<int>("Width")
.HasColumnType("int");
@@ -194,6 +226,9 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("Y")
.HasColumnType("int");
b.Property<int>("Zindex")
.HasColumnType("int");
b.HasKey("IdNote");
b.HasIndex("IdBulletinBoardPage");
@@ -368,21 +403,29 @@ namespace ZpcBulletinBoard.Migrations
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Pages")
.HasForeignKey("IdBulletinBoard")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardPageFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
b.Navigation("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Notes")
.WithMany()
.HasForeignKey("IdBulletinBoardPage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -392,12 +435,12 @@ namespace ZpcBulletinBoard.Migrations
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Pages");
b.Navigation("Links");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Navigation("Notes");
b.Navigation("Links");
});
#pragma warning restore 612, 618
}

View File

@@ -0,0 +1,142 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BulletinBoardPage",
columns: table => new
{
IdBulletinBoardPage = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Ratio = table.Column<int>(type: "int", nullable: false),
Type = table.Column<int>(type: "int", nullable: false),
ExternalLink = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_BulletinBoardPage", x => x.IdBulletinBoardPage);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "BulletinBoards",
columns: table => new
{
IdBulletinBoard = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Guid = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Ratio = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BulletinBoards", x => x.IdBulletinBoard);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Notes",
columns: table => new
{
IdNote = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
IdBulletinBoardPage = table.Column<int>(type: "int", nullable: false),
X = table.Column<int>(type: "int", nullable: false),
Y = table.Column<int>(type: "int", nullable: false),
Width = table.Column<int>(type: "int", nullable: false),
Height = table.Column<int>(type: "int", nullable: false),
Content = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Zindex = table.Column<int>(type: "int", nullable: false),
ColorClass = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notes", x => x.IdNote);
table.ForeignKey(
name: "FK_Notes_BulletinBoardPage_IdBulletinBoardPage",
column: x => x.IdBulletinBoardPage,
principalTable: "BulletinBoardPage",
principalColumn: "IdBulletinBoardPage",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "BulletinBoardPageLinks",
columns: table => new
{
IdLink = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
IdBulletinBoardFk = table.Column<int>(type: "int", nullable: false),
IdBulletinBoardPageFk = table.Column<int>(type: "int", nullable: false),
Duration = table.Column<int>(type: "int", nullable: false),
Order = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BulletinBoardPageLinks", x => x.IdLink);
table.ForeignKey(
name: "FK_BulletinBoardPageLinks_BulletinBoardPage_IdBulletinBoardPage~",
column: x => x.IdBulletinBoardPageFk,
principalTable: "BulletinBoardPage",
principalColumn: "IdBulletinBoardPage",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BulletinBoardPageLinks_BulletinBoards_IdBulletinBoardFk",
column: x => x.IdBulletinBoardFk,
principalTable: "BulletinBoards",
principalColumn: "IdBulletinBoard",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_BulletinBoardPageLinks_IdBulletinBoardFk",
table: "BulletinBoardPageLinks",
column: "IdBulletinBoardFk");
migrationBuilder.CreateIndex(
name: "IX_BulletinBoardPageLinks_IdBulletinBoardPageFk",
table: "BulletinBoardPageLinks",
column: "IdBulletinBoardPageFk");
migrationBuilder.CreateIndex(
name: "IX_Notes_IdBulletinBoardPage",
table: "Notes",
column: "IdBulletinBoardPage");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BulletinBoardPageLinks");
migrationBuilder.DropTable(
name: "Notes");
migrationBuilder.DropTable(
name: "BulletinBoards");
migrationBuilder.DropTable(
name: "BulletinBoardPage");
}
}
}

View File

@@ -11,8 +11,8 @@ using ZpcBulletinBoard.Data;
namespace ZpcBulletinBoard.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240228173917_5")]
partial class _5
[Migration("20240309085239_2")]
partial class _2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -148,23 +148,51 @@ namespace ZpcBulletinBoard.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("ExternalLink")
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Ratio")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("IdBulletinBoardPage");
b.HasIndex("IdBulletinBoard");
b.ToTable("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.Property<int>("IdLink")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardFk")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardPageFk")
.HasColumnType("int");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("IdLink");
b.HasIndex("IdBulletinBoardFk");
b.HasIndex("IdBulletinBoardPageFk");
b.ToTable("BulletinBoardPageLinks");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
@@ -185,6 +213,9 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("IdBulletinBoardPage")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<int>("Width")
.HasColumnType("int");
@@ -371,21 +402,29 @@ namespace ZpcBulletinBoard.Migrations
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Pages")
.HasForeignKey("IdBulletinBoard")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardPageFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
b.Navigation("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Notes")
.WithMany()
.HasForeignKey("IdBulletinBoardPage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -395,12 +434,12 @@ namespace ZpcBulletinBoard.Migrations
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Pages");
b.Navigation("Links");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Navigation("Notes");
b.Navigation("Links");
});
#pragma warning restore 612, 618
}

View File

@@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ExternalLink",
table: "BulletinBoardPage",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "BulletinBoardPage",
keyColumn: "ExternalLink",
keyValue: null,
column: "ExternalLink",
value: "");
migrationBuilder.AlterColumn<string>(
name: "ExternalLink",
table: "BulletinBoardPage",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View File

@@ -11,8 +11,8 @@ using ZpcBulletinBoard.Data;
namespace ZpcBulletinBoard.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240228165943_4")]
partial class _4
[Migration("20240309105503_3")]
partial class _3
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -148,29 +148,64 @@ namespace ZpcBulletinBoard.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<string>("ExternalLink")
.HasColumnType("longtext");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("Image")
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Ratio")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("IdBulletinBoardPage");
b.HasIndex("IdBulletinBoard");
b.ToTable("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.Property<int>("IdLink")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardFk")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardPageFk")
.HasColumnType("int");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("IdLink");
b.HasIndex("IdBulletinBoardFk");
b.HasIndex("IdBulletinBoardPageFk");
b.ToTable("BulletinBoardPageLinks");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ColorClass")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("longtext");
@@ -181,6 +216,9 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("IdBulletinBoardPage")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<int>("Width")
.HasColumnType("int");
@@ -190,6 +228,9 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("Y")
.HasColumnType("int");
b.Property<int>("Zindex")
.HasColumnType("int");
b.HasKey("IdNote");
b.HasIndex("IdBulletinBoardPage");
@@ -364,21 +405,29 @@ namespace ZpcBulletinBoard.Migrations
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Pages")
.HasForeignKey("IdBulletinBoard")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardPageFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
b.Navigation("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Notes")
.WithMany()
.HasForeignKey("IdBulletinBoardPage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -388,12 +437,12 @@ namespace ZpcBulletinBoard.Migrations
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Pages");
b.Navigation("Links");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Navigation("Notes");
b.Navigation("Links");
});
#pragma warning restore 612, 618
}

View File

@@ -5,25 +5,25 @@
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _4 : Migration
public partial class _3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Title",
table: "Notes");
migrationBuilder.AddColumn<string>(
name: "Image",
table: "BulletinBoardPage",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Title",
table: "Notes",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.DropColumn(
name: "Image",
table: "BulletinBoardPage");
}
}
}

View File

@@ -136,7 +136,7 @@ namespace ZpcBulletinBoard.Migrations
b.HasKey("IdBulletinBoard");
b.ToTable("BulletinBoards");
b.ToTable("BulletinBoards", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
@@ -145,21 +145,52 @@ namespace ZpcBulletinBoard.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<string>("ExternalLink")
.HasColumnType("longtext");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("Image")
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Ratio")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("IdBulletinBoardPage");
b.HasIndex("IdBulletinBoard");
b.ToTable("BulletinBoardPage", (string)null);
});
b.ToTable("BulletinBoardPage");
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.Property<int>("IdLink")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardFk")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardPageFk")
.HasColumnType("int");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("IdLink");
b.HasIndex("IdBulletinBoardFk");
b.HasIndex("IdBulletinBoardPageFk");
b.ToTable("BulletinBoardPageLinks", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
@@ -182,6 +213,9 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("IdBulletinBoardPage")
.HasColumnType("int");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<int>("Width")
.HasColumnType("int");
@@ -198,7 +232,7 @@ namespace ZpcBulletinBoard.Migrations
b.HasIndex("IdBulletinBoardPage");
b.ToTable("Notes");
b.ToTable("Notes", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.IdentityApplicationRole", b =>
@@ -368,21 +402,29 @@ namespace ZpcBulletinBoard.Migrations
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPageLink", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Pages")
.HasForeignKey("IdBulletinBoard")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Links")
.HasForeignKey("IdBulletinBoardPageFk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
b.Navigation("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Notes")
.WithMany()
.HasForeignKey("IdBulletinBoardPage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -392,12 +434,12 @@ namespace ZpcBulletinBoard.Migrations
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Pages");
b.Navigation("Links");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Navigation("Notes");
b.Navigation("Links");
});
#pragma warning restore 612, 618
}

View File

@@ -35,6 +35,6 @@ namespace ZpcBulletinBoard.Models.Editor
// InvoicePart
[InverseProperty("BulletinBoard")]
public virtual ICollection<BulletinBoardPage> Pages { get; set; }
public virtual ICollection<BulletinBoardPageLink> Links { get; set; }
}
}

View File

@@ -1,29 +1,46 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using ZpcBulletinBoard.Classes;
using static ZpcBulletinBoard.Models.Editor.BulletinBoard;
namespace ZpcBulletinBoard.Models.Editor
{
public class BulletinBoardPage
{
public enum TypeEnum
{
[Display(Name = "Deska")]
Board = 1,
[Display(Name = "Slika")]
Image = 2,
[Display(Name = "Zunanja povezava")]
ExternalLink = 3
}
[Key]
public int IdBulletinBoardPage { get; set; }
[Required]
[ForeignKey("BulletinBoard")]
public int IdBulletinBoard { get; set; }
[Required]
[Display(Name = "Ime")]
public string Name { get; set; }
[Required]
[Display(Name = "Trajanje")]
public int Duration { get; set; }
[Display(Name = "Razmerje")]
public RatioEnum Ratio { get; set; }
// ForeignKey
public BulletinBoard BulletinBoard { get; set; }
[NotMapped]
public string RatioString => Ratio.GetAttributeOfType<DisplayAttribute>().Name ?? "";
[Required]
[Display(Name = "Tip")]
public TypeEnum Type { get; set; }
public string? Image { get; set; }
public string? ExternalLink { get; set; }
[InverseProperty("BulletinBoardPage")]
public virtual ICollection<BulletinBoardPageLink> Links { get; set; }
[InverseProperty("BulletinBoardPage")]
public virtual ICollection<Note> Notes { get; set; }

View File

@@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ZpcBulletinBoard.Models.Editor
{
public class BulletinBoardPageLink
{
[Key]
public int IdLink { get; set; }
[Required]
[ForeignKey("BulletinBoard")]
public int IdBulletinBoardFk { get; set; }
[Required]
[ForeignKey("BulletinBoardPage")]
public int IdBulletinBoardPageFk { get; set; }
[Required]
[Display(Name = "Trajanje")]
public int Duration { get; set; }
[Required]
[Display(Name = "Vrstni red")]
public int Order { get; set; }
// ForeignKey
public BulletinBoard BulletinBoard { get; set; }
public BulletinBoardPage BulletinBoardPage { get; set; }
}
}

View File

@@ -5,6 +5,13 @@ namespace ZpcBulletinBoard.Models.Editor
{
public class Note
{
public enum TypeEnum
{
Board = 1,
Image = 2,
ExternalLink = 3
}
[Key]
public int IdNote { get; set; }
@@ -33,6 +40,9 @@ namespace ZpcBulletinBoard.Models.Editor
[Required]
public string ColorClass { get; set; }
[Required]
public TypeEnum Type { get; set; }
// ForeignKey
public BulletinBoardPage BulletinBoardPage { get; set; }
}

View File

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

View 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>
}

View 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 });
}
}
}

View File

@@ -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>&nbsp;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">&times;</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">&times;</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">&times;</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>
}

View File

@@ -16,7 +16,7 @@ namespace ZpcBulletinBoard.Pages
public IActionResult OnGet()
{
return Redirect("~/Editor/EditMain");
return Redirect("~/Pages/Index");
}
}
}

View File

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

View 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">&times;</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>
}

View File

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

View 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">&times;</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">&times;</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">&times;</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>
}

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

View File

@@ -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)
{

View File

@@ -35,7 +35,8 @@
<ItemGroup>
<Folder Include="Migrations\" />
<Folder Include="Properties\PublishProfiles\" />
<Folder Include="wwwroot\bulletin-board-images\" />
<Folder Include="wwwroot\bulletin-board-images\notes\" />
<Folder Include="wwwroot\bulletin-board-images\pages\" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 22 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,102 @@
.main-content{
height: calc(100vh - 300px);
}
.div-content{
width: 100%;
}
.div-content-boards{
float: left;
width: calc(100% - 240px);
max-width: calc(100% - 240px);
}
.div-content-pages{
float: left;
width: 240px;
height: 100%;
}
.boards-content > hr{
margin-top: 0px;
margin-bottom: 0px;
}
.div-board{
float: left;
text-align: center;
width: 50px;
height: 230px;
border: 1px solid rgba(24, 28, 33, 0.06);
border-radius: 0.25rem;
margin: 5px;
margin-right: 15px;
writing-mode: vertical-lr;
background-color: rgba(111, 111, 143, 0.171);
}
.div-board > h5 {
margin: 2px;
margin-left:15px;
text-orientation: mixed;
}
.div-pages {
width: calc(100% - 70px);
margin: 5px;
height: 230px;
margin-left: 10px;
margin-bottom: 5px;
overflow-x: auto;
}
.div-page {
float: left;
text-align: center;
width: 200px;
height: 230px;
border: 1px solid rgba(24, 28, 33, 0.06);
border-radius: 0.25rem;
margin-right: 5px;
}
.div-page:hover {
cursor: grab;
/* background-color: rgba(24, 28, 33, 0.06); */
border-color: blue;
}
.page-active {
background-color: rgba(128, 171, 226, 0.5);
}
.div-page > h5 {
margin-top: 5px;
margin-bottom: 2px;
}
.div-page > i {
margin-top: 10px;
}
.div-available-pages{
overflow-y: scroll;
height: 100%;
}
.div-available-pages>.div-page{
margin-top: 5px;
margin-left: 10px;
}
.img-thumbnail{
height: 170px;
width: 170px;
margin-left: 15px;
margin-top: 5px;
}
.btn-tool{
/* padding: 1px; */
}

View File

@@ -39,74 +39,30 @@
cursor: nwse-resize;
}
.div-board{
float: left;
text-align: center;
width: 200px;
height: 50px;
border: 1px solid rgba(24, 28, 33, 0.06);
border-radius: 0.25rem;
margin-right: 15px;
}
.div-board > h5 {
margin-top: 5px;
margin-bottom: 2px;
}
.div-board:hover {
cursor: pointer;
background-color: rgba(24, 28, 33, 0.06);
}
.div-note {
position: absolute !important;
float: left;
}
.div-note.active{
border-color: blue;
}
.note-content{
overflow: hidden;
max-width: 100%;
max-height: 100%;
}
.note-body{
width: 100%;
height: calc(100% - 15px);
}
.input-hidden {
display: none;
}
.div-pages {
margin: 5px;
height: 50px;
margin-left: 10px;
margin-bottom: 10px;
}
.div-page {
float: left;
text-align: center;
width: 100px;
height: 50px;
border: 1px solid rgba(24, 28, 33, 0.06);
border-radius: 0.25rem;
margin-right: 5px;
}
.div-page:hover {
cursor: pointer;
background-color: rgba(24, 28, 33, 0.06);
}
.page-active {
background-color: rgba(128, 171, 226, 0.5);
}
.div-page > h5 {
margin-top: 5px;
margin-bottom: 2px;
}
.div-page > i {
margin-top: 10px;
}
#lblBoardPageName {
margin-right: 5px;;
}
.div-note-edit-color {
margin: 5px;
height: 50px;

View File

@@ -0,0 +1,109 @@
$(function(){
loadBoards();
});
function loadBoards(){
$.blockUI();
$.ajax({
type: "GET",
url: "/BoardsLinks/Index/?handler=Boards",
data: {
},
success: function (data) {
if (data.successful){
let boardContent = $('.boards-content');
boardContent.empty();
if (data.boards){
data.boards.forEach((board) => {
console.log(board);
boardContent.append(`<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/>`);
if (board.links){
board.links.forEach((link) => {
addPageToBoard(board.idBulletinBoard, link);
});
}
});
}
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function allowDropPage(ev) {
console.log('allowDrop');
if (ev.dataTransfer.getData("idPage")){
ev.preventDefault();
}
}
function dragPage(ev, el) {
console.log('drag');
ev.dataTransfer.setData("idPage", $(el).attr('data-id'));
}
function dropPage(ev, el) {
console.log('drop');
ev.preventDefault();
let idPage = parseInt(ev.dataTransfer.getData("idPage"));
let idBoard = parseInt($(el).attr('data-idboard'));
$.blockUI();
$.ajax({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
url: "/BoardsLinks/Index/?handler=AddLink",
data: {
idBoard,
idPage
},
success: function(data) {
if (data.successful){
addPageToBoard(idBoard, data.link);
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log({xhr, ajaxOptions, thrownError});
alert(xhr.responseText);
$.unblockUI();
}
});
}
function addPageToBoard(idBoard, link){
let div = $('.div-pages[data-idboard="' + idBoard + '"]');
div.append(`<div class="div-page" data-id="${link.idLink}" data-idPage='${link.bulletinBoardPage.idBulletinBoardPage}'>
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/${link.bulletinBoardPage.image}" alt="page image" />
<small>${link.bulletinBoardPage.name}</small>
<div class="tools">
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless"><i class="fas fa-chevron-left"></i></a>
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-secondary borderless"><i class="far fa-clock"></i></a>
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-danger borderless"><i class="fas fa-trash-alt"></i></a>
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless"><i class="fas fa-chevron-right"></i></a>
</div>
</div>`);
}

View File

@@ -0,0 +1,307 @@
$(function () {
$('.div-note-edit-color>div').on('click', function(){
$('.div-note-edit-color>div').removeClass('active');
$(this).addClass('active');
});
$(document).on('keyup', function(e){
if (e.originalEvent.key === 'Delete' || e.originalEvent.key === 'Backspace'){
let id = parseInt($('.div-note.active').attr('data-id'));
if (isNaN(id)){
return;
}
deleteNote(id);
}
});
loadPage();
});
let divCanvas;
let canWidth;
let canHeight;
let notes = [];
function addNewNote(){
let idPage = parseInt($('#inpIdPage').val());
if (isNaN(idPage) || idPage <= 0){
Swal.fire('Stran ni izbrana', '', 'warning');
return;
}
let tmpId = -1;
let tmpZindex = 50;
notes.forEach(note => {
if (note.id <= tmpId){
tmpId = note.id -1;
}
if (note.zindex >= tmpZindex){
tmpZindex = note.zindex + 1;
}
});
let note = new Note(tmpId, divCanvas, 0, 0, 400, 240, 'Vnesi besedilo', 'note-color-white', tmpZindex);
notes.push(note);
note.refresh();
}
function noteChangeZindex(id, front){
let note = getNote(id);
let maxIndex = 0;
let minIndex = 999999999999;
notes.forEach(tmpNote => {
if (tmpNote.zindex > maxIndex){
maxIndex = tmpNote.zindex;
}
if (tmpNote.zindex < minIndex){
minIndex = tmpNote.zindex;
}
});
if (front){
//ce je isti ga potem ne premikam
if (note.zindex != maxIndex){
note.zindex = maxIndex + 1;
}
} else {
if (note.zindex != minIndex){
note.zindex = minIndex - 1;
}
}
note.refresh();
}
function deleteNote(id){
let note = getNote(id);
note.element.remove();
let newArray = [];
notes.forEach(tmpNote => {
if (tmpNote.id != note.id){
newArray.push(tmpNote);
}
});
notes = newArray;
}
function openModalEditNote(id){
$('#inpModalEditNoteIdNote').val(id);
note = getNote(id);
$('#divModalEditNote').modal('show');
$('#divModalEditNoteSummernote').summernote('destroy');
$('#divModalEditNoteSummernote').html(note.content);
$('#divModalEditNoteSummernote').summernote({height: 400,});
$('.div-note-edit-color>div').removeClass('active');
$('.div-note-edit-color>.' + note.colorClass).addClass('active');
}
function saveModalEditNote(){
let idNote = parseInt($('#inpModalEditNoteIdNote').val());
note = getNote(idNote);
note.content = $('#divModalEditNoteSummernote').summernote('code');
note.colorClass = $('.div-note-edit-color>.active').attr('class').replace(' active', '');
note.refresh();
$('#divModalEditNote').modal('hide');
}
function getNote(id){
let note;
notes.forEach(e => {
if (e.id === id){
note = e;
}
});
return note;
}
function loadBoard(id){
$.blockUI();
$.ajax({
type: "GET",
url: "/Pages/EditMain/?handler=Board",
data: {
id
},
success: function (data) {
if (data.successful){
$('.div-board>h5').text(data.board.name);
$('.div-board').attr('data-idboard', data.board.idBulletinBoard);
$('[data-idpage]').remove();
if (data.board.pages){
data.board.pages.forEach(element => {
boardAddPage(element);
});
}
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function loadPage(){
let id = parseInt($('#inpIdPage').val());
$.blockUI();
$.ajax({
type: "GET",
url: "/Pages/EditMain/?handler=Page",
data: {
id
},
success: function (data) {
if (data.successful){
let placeholder = $('#divPlaceholder');
placeholder.empty();
let tmpSplit = data.page.ratioString.split(':');
canWidth = placeholder.width();
canHeight = canWidth / (parseFloat(tmpSplit[0]) / parseFloat(tmpSplit[1]));
divCanvas = $(`<div id='divCanvas'></div>`);
placeholder.append(divCanvas);
divCanvas.css({
'width': '100%',
'height': canHeight + 'px',
'background-color': 'white',
'padding': '5px'
});
notes = [];
$('.div-note').remove();
if (data.page.notes){
data.page.notes.forEach(el => {
let note = new Note(el.idNote, divCanvas, el.x, el.y, el.width, el.height, el.content, el.colorClass, el.zindex);
notes.push(note);
note.refresh();
});
}
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function saveNotes(){
let idBulletinBoardPage = parseInt($('#inpIdPage').val());
if (isNaN(idBulletinBoardPage) || idBulletinBoardPage <= 0){
Swal.fire('Stran ni izbrana', '', 'warning');
return;
}
//skrijemo okvirje
$('.div-note.active').removeClass('active');
let array = [];
notes.forEach(note => {
array.push({
idNote: note.id,
idBulletinBoardPage,
x: note.x,
y: note.y,
width: note.width,
height: note.height,
content: note.content,
colorClass: note.colorClass,
zindex: note.zindex
})
});
$.blockUI();
$.ajax({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
url: "EditMain/?handler=Notes",
data: {
idBulletinBoardPage,
notes: array
},
success: function(data) {
if (data.successful){
savePageImage();
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
$.unblockUI();
}
});
}
function savePageImage(){
let idPage = parseInt($('#inpIdPage').val());
if (isNaN(idPage) || idPage <= 0){
Swal.fire('Stran ni izbrana', '', 'warning');
return;
}
$.blockUI();
var node = document.getElementById('divCanvas');
htmlToImage.toSvg(node)
.then(function (base64String) {
fetch(base64String)
.then(res => res.blob())
.then(blob => {
let formData = new FormData();
formData.append("file", blob);
formData.append("idPage", idPage);
$.ajax({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
url: "/Pages/EditMain/?handler=BoardPageImage",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(data) {
if (data.successful){
loadPage(idPage);
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
$.unblockUI();
}
});
});
})
.catch(function (error) {
$.unblockUI();
console.error('oops, something went wrong!', error);
});
}
function selectNote(id){
$('.div-note.active').removeClass('active');
$('.div-note[data-id="' + id + '"]').addClass('active');
}

View File

@@ -0,0 +1,216 @@
$(function(){
let openEditorForPage = parseInt($('#inpOpenEditorForPage').val());
if (!isNaN(openEditorForPage) && openEditorForPage > 0){
$('#inpOpenEditorForPage').val(0);
openEditor(openEditorForPage);
}
$('[data-toggle="tooltip"]').tooltip();
});
function openModalAddPage(){
$('#inpModalAddEditPageIdPage').val(0);
$('#inpModalAddEditPageName').val('');
$('#divModalAddEditPage').modal('show');
}
function openModalEditPage(el){
let idBulletinBoardPage = parseInt($(el).parent().parent().attr('data-id'));
if (isNaN(idBulletinBoardPage)){
Swal.fire('Napaka ni id strani!', '', 'error');
return;
}
$.blockUI();
$.ajax({
type: "GET",
url: "/Pages/Index/?handler=Page",
data: {
id: idBulletinBoardPage
},
success: function (data) {
if (data.successful){
$('#inpModalAddEditPageIdPage').val(data.page.idBulletinBoardPage);
$('#inpModalAddEditPageName').val(data.page.name);
$('#selModalAddEditPageRatio').val(data.page.ratio).trigger('change');
$('#selModalAddEditPageType').val(data.page.type).trigger('change');
$('#divModalAddEditPage').modal('show');
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function saveModalAddEditPage(){
let name = $('#inpModalAddEditPageName').val();
let ratio = parseInt($('#selModalAddEditPageRatio').val());
let type = parseInt($('#selModalAddEditPageType').val());
let idBulletinBoardPage = parseInt($('#inpModalAddEditPageIdPage').val());
if (name === ''){
Swal.fire('Ime ni vneseno', '', 'warning');
return;
}
if (isNaN(ratio)){
Swal.fire('Razmerje ni vneseno', '', 'warning');
return;
}
if (isNaN(type)){
Swal.fire('Tip ni vnesen', '', 'warning');
return;
}
$.blockUI();
$.ajax({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
url: "/Pages/Index/?handler=BoardPage",
data: { page : {
idBulletinBoardPage,
name,
ratio,
type
}},
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);
}
$('#btnRefresh').trigger('click');
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
$.unblockUI();
}
});
}
function rowOpenEditor(el){
openEditor(parseInt($(el).parent().parent().attr('data-id')));
}
function openEditor(id){
$.blockUI();
$.ajax({
type: "GET",
url: "/Pages/Index/?handler=Page",
data: {
id
},
success: function (data) {
if (data.successful){
switch (data.page.type){
case 1: //Editor notes
window.location.href = "/Pages/EditMain?idPage=" + data.page.idBulletinBoardPage;
break;
case 2: //Picture
$('#inpModalPageEditorPictureIdPage').val(data.page.idBulletinBoardPage);
$('#imgModalPageEditorPicture').attr("src","/bulletin-board-images/pages/" + data.page.image);
$('#divModalPageEditorPicture').modal('show');
break;
case 3: //Link
$('#inpModalPageEditorLinkIdPage').val(data.page.idBulletinBoardPage);
$('#inpModalPageEditorLinkLink').val(data.page.externalLink);
$('#divModalPageEditorLink').modal('show');
break;
}
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function saveModalPageEditorLink(){
let link = $('#inpModalPageEditorLinkLink').val();
let idPage = parseInt($('#inpModalPageEditorLinkIdPage').val());
$.blockUI();
$.ajax({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
url: "/Pages/Index/?handler=BoardPageLink",
data: { idPage, link},
success: function(data) {
if (data.successful){
$('#divModalAddEditPage').modal('hide');
$('#btnRefresh').trigger('click');
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
$.unblockUI();
}
});
}
function saveModalPageEditorPicture(){
let idPage = parseInt($('#inpModalPageEditorPictureIdPage').val());
let files = $('#inpModalPageEditorPicturePicture').prop("files");
let formData = new FormData();
formData.append("file", files[0]);
formData.append("idPage", idPage);
$.blockUI();
$.ajax({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
url: "/Pages/Index/?handler=BoardPagePicture",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(data) {
if (data.successful){
$('#divModalPageEditorPicture').modal('hide');
$('#btnRefresh').trigger('click');
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
$.unblockUI();
}
});
}

View File

@@ -0,0 +1,127 @@
class Note{
constructor(id, divCanvas, x, y, width, height, content, colorClass, zindex) {
this.id = id;
this.divCanvas = divCanvas;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.element = null;
this.content = content;
this.colorClass = colorClass;
this.zindex = zindex;
}
refresh(){
if (this.element !== null){
this.element.remove();
}
this.element = $(`
<div class="card div-note ${this.colorClass}" data-id="${this.id}">
<div class="card-body note-body">
<div class='note-content'>
${this.content}
</div>
</div>
</div>`);
this.element.draggable({
containment: "parent",
stop: function( event, ui ) {
let id = parseInt($(this).attr('data-id'));
let note = getNote(id);
note.x = ui.position.left;
note.y = ui.position.top;
}
});
this.element.resizable({
handles: 'se',
autoHide: true,
minHeight: 240,
minWidth: 300,
stop: function( event, ui ) {
let id = parseInt($(this).attr('data-id'));
let note = getNote(id);
note.width = ui.size.width;
note.height = ui.size.height;
}
});
this.element.css({
'width': this.width + 'px',
'height': this.height + 'px',
'position': 'relative',
'z-index': this.zindex
});
this.element.on("dblclick", function() {
openModalEditNote(parseInt($(this).attr('data-id')));
});
this.element.on('mousedown', function(){
selectNote(parseInt($(this).attr('data-id')));
})
$.contextMenu({
selector: '.card[data-id="' + this.id + '"]',
callback: function(key, options) {
let id = parseInt($(this).attr('data-id'));
switch (key){
case 'toFront':
noteChangeZindex(id, true)
break;
case 'toBack':
noteChangeZindex(id, false)
break;
case 'edit':
openModalEditNote(id);
break;
case 'delete':
deleteNote(id);
break;
}
},
items: {
"toFront": {
icon: function(opt, $itemElement, itemKey, item){
$itemElement.html('<i class="fas fa-reply"></i>&nbsp;V odspredje');
return 'context-menu-icon-updated';
}
},
"toBack": {
icon: function(opt, $itemElement, itemKey, item){
$itemElement.html('<i class="fas fa-share"></i>&nbsp;V ozadje');
return 'context-menu-icon-updated';
}
},
"edit": {
icon: function(opt, $itemElement, itemKey, item){
$itemElement.html('<i class="fas fa-edit"></i>&nbsp;Uredi');
return 'context-menu-icon-updated';
}
},
"delete": {
icon: function(opt, $itemElement, itemKey, item){
$itemElement.html('<i class="fas fa-trash-alt"></i>&nbsp;Izbriši');
return 'context-menu-icon-updated';
}
},
}
});
this.divCanvas.append(this.element);
this.setPosition();
}
setPosition(){
this.element.css({
'left': this.x + 'px',
'top': this.y + 'px'
});
}
}