Skip to content

Commit d45a5fe

Browse files
author
Christophe Peugnet
committed
add Wasm sample
1 parent f36ff40 commit d45a5fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1390
-23
lines changed

Blazor-Calendar.sln

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,40 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31710.8
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorCalendar-Test", "BlazorCalendar-Test\BlazorCalendar-Test.csproj", "{C61DD137-FEBF-4644-8098-EC4263AF3967}"
7-
EndProject
86
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorCalendar", "BlazorCalendar\BlazorCalendar.csproj", "{D018189F-E4BE-4693-9BF0-FE8325CB0899}"
97
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{9A175C09-D84D-4734-9E6E-00C89C09AA2A}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServer", "samples\BlazorServer\BlazorServer.csproj", "{C61DD137-FEBF-4644-8098-EC4263AF3967}"
11+
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWebAssembly", "samples\BlazorWebAssembly\BlazorWebAssembly.csproj", "{5D3171BB-C17D-462D-AECE-3C8DEAC85441}"
13+
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1216
Debug|Any CPU = Debug|Any CPU
1317
Release|Any CPU = Release|Any CPU
1418
EndGlobalSection
1519
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Release|Any CPU.Build.0 = Release|Any CPU
2020
{D018189F-E4BE-4693-9BF0-FE8325CB0899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2121
{D018189F-E4BE-4693-9BF0-FE8325CB0899}.Debug|Any CPU.Build.0 = Debug|Any CPU
2222
{D018189F-E4BE-4693-9BF0-FE8325CB0899}.Release|Any CPU.ActiveCfg = Release|Any CPU
2323
{D018189F-E4BE-4693-9BF0-FE8325CB0899}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{C61DD137-FEBF-4644-8098-EC4263AF3967}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{5D3171BB-C17D-462D-AECE-3C8DEAC85441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{5D3171BB-C17D-462D-AECE-3C8DEAC85441}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{5D3171BB-C17D-462D-AECE-3C8DEAC85441}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{5D3171BB-C17D-462D-AECE-3C8DEAC85441}.Release|Any CPU.Build.0 = Release|Any CPU
2432
EndGlobalSection
2533
GlobalSection(SolutionProperties) = preSolution
2634
HideSolutionNode = FALSE
2735
EndGlobalSection
36+
GlobalSection(NestedProjects) = preSolution
37+
{C61DD137-FEBF-4644-8098-EC4263AF3967} = {9A175C09-D84D-4734-9E6E-00C89C09AA2A}
38+
{5D3171BB-C17D-462D-AECE-3C8DEAC85441} = {9A175C09-D84D-4734-9E6E-00C89C09AA2A}
39+
EndGlobalSection
2840
GlobalSection(ExtensibilityGlobals) = postSolution
2941
SolutionGuid = {B68E7280-0A03-4BD1-B3B5-AB2A9B68195D}
3042
EndGlobalSection

BlazorCalendar-Test/Pages/Index.razor.css

-1
This file was deleted.
File renamed without changes.

BlazorCalendar-Test/BlazorCalendar-Test.csproj samples/BlazorServer/BlazorServer.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<LangVersion>10.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
8-
<RootNamespace>BlazorCalendarTest</RootNamespace>
8+
<RootNamespace>BlazorServer</RootNamespace>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<ProjectReference Include="..\BlazorCalendar\BlazorCalendar.csproj" />
12+
<ProjectReference Include="..\..\BlazorCalendar\BlazorCalendar.csproj" />
1313
</ItemGroup>
1414

1515
</Project>

BlazorCalendar-Test/Pages/Error.cshtml samples/BlazorServer/Pages/Error.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@page
2-
@model BlazorCalendarTest.Pages.ErrorModel
2+
@model BlazorServer.Pages.ErrorModel
33

44
<!DOCTYPE html>
55
<html lang="en">

BlazorCalendar-Test/Pages/Error.cshtml.cs samples/BlazorServer/Pages/Error.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.AspNetCore.Mvc.RazorPages;
33
using System.Diagnostics;
44

5-
namespace BlazorCalendarTest.Pages
5+
namespace BlazorServer.Pages
66
{
77
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
88
[IgnoreAntiforgeryToken]

BlazorCalendar-Test/Pages/Index.razor samples/BlazorServer/Pages/Index.razor

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
@using BlazorCalendar
33
@using BlazorCalendar.Models
44

5+
6+
<PageTitle>Blazor Calendar Samples</PageTitle>
7+
58
<div class="d-flex flex-row mb-2">
69
<button type="button" @onclick="@(m => ClicMonthNavigate(-1))">◀️</button>
710
<button type="button" @onclick="@(m => ClicMonthNavigate(1))" class="me-2">▶️</button>
@@ -17,13 +20,15 @@
1720
</div>
1821
</div>
1922

23+
2024
<CalendarContainer FirstDate="today" TasksList="TasksList.ToArray()" DisplayedView="DisplayedView.Annual" >
2125
<AnnualView Months="months" Style="height:80vh"
2226
PriorityDisplay="@PriorityDisplay"
2327
TaskClick="TaskClick" EmptyDayClick="EmptyDayClick"
2428
Draggable="@draggable" DragStart="DragStart" DropTask="DropTask" />
2529
</CalendarContainer>
2630

31+
2732
<br />
2833
<div class="console">@fakeConsole</div>
2934

BlazorCalendar-Test/Pages/_Host.cshtml samples/BlazorServer/Pages/_Host.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@page "/"
2-
@namespace BlazorCalendarTest.Pages
2+
@namespace BlazorServer.Pages
33
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
44
@{
55
Layout = "_Layout";

BlazorCalendar-Test/Pages/_Layout.cshtml samples/BlazorServer/Pages/_Layout.cshtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@using Microsoft.AspNetCore.Components.Web
2-
@namespace BlazorCalendarTest.Pages
2+
@namespace BlazorServer.Pages
33
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
44

55
<!DOCTYPE html>
@@ -10,7 +10,7 @@
1010
<base href="~/" />
1111
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
1212
<link href="css/site.css" rel="stylesheet" />
13-
<link href="BlazorCalendar-Test.styles.css" rel="stylesheet" />
13+
<link href="blazorserver.styles.css" rel="stylesheet" />
1414

1515
<link href="_content/BlazorCalendar/BlazorCalendar.css" rel="stylesheet" />
1616

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"profiles": {
3+
"BlazorServer": {
4+
"commandName": "Project",
5+
"dotnetRunMessages": true,
6+
"launchBrowser": true,
7+
"applicationUrl": "http://localhost:5164",
8+
"environmentVariables": {
9+
"ASPNETCORE_ENVIRONMENT": "Development"
10+
}
11+
}
12+
}
13+
}

BlazorCalendar-Test/Shared/MainLayout.razor samples/BlazorServer/Shared/MainLayout.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@inherits LayoutComponentBase
22

3-
<PageTitle>Blazor-Calendar</PageTitle>
3+
<PageTitle>Blazor-Calendar (Server)</PageTitle>
44

55
<div class="page">
66
<div class="sidebar">
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<div class="top-row ps-3 navbar navbar-dark">
2+
<div class="container-fluid">
3+
<a class="navbar-brand" href="">Blazor Server</a>
4+
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
5+
<span class="navbar-toggler-icon"></span>
6+
</button>
7+
</div>
8+
</div>
9+
10+
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
11+
<nav class="flex-column">
12+
<div class="nav-item px-3">
13+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
14+
<span class="oi oi-home" aria-hidden="true"></span> Annual view
15+
</NavLink>
16+
</div>
17+
<div class="nav-item px-3">
18+
<NavLink class="nav-link" href="monthlyview">
19+
<span class="oi oi-calendar" aria-hidden="true"></span> Monthly view
20+
</NavLink>
21+
</div>
22+
<div class="nav-item px-3">
23+
<NavLink class="nav-link" href="switchview">
24+
<span class="oi oi-loop-square" aria-hidden="true"></span> switch views
25+
</NavLink>
26+
</div>
27+
</nav>
28+
</div>
29+
30+
@code {
31+
private bool collapseNavMenu = true;
32+
33+
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
34+
35+
private void ToggleNavMenu()
36+
{
37+
collapseNavMenu = !collapseNavMenu;
38+
}
39+
}

BlazorCalendar-Test/_Imports.razor samples/BlazorServer/_Imports.razor

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
@using Microsoft.AspNetCore.Components.Web
77
@using Microsoft.AspNetCore.Components.Web.Virtualization
88
@using Microsoft.JSInterop
9-
@using BlazorCalendarTest
10-
@using BlazorCalendarTest.Shared
9+
@using BlazorServer
10+
@using BlazorServer.Shared
File renamed without changes.

samples/BlazorWebAssembly/App.razor

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.2" PrivateAssets="all" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\BlazorCalendar\BlazorCalendar.csproj" />
16+
</ItemGroup>
17+
18+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
@page "/"
2+
@using BlazorCalendar
3+
@using BlazorCalendar.Models
4+
5+
6+
<PageTitle>Blazor Calendar Samples</PageTitle>
7+
8+
<div class="d-flex flex-row mb-2">
9+
<button type="button" @onclick="@(m => ClicMonthNavigate(-1))">◀️</button>
10+
<button type="button" @onclick="@(m => ClicMonthNavigate(1))" class="me-2">▶️</button>
11+
<input type="date" class="me-2" value="@(today.ToString("yyyy-MM-dd"))" @onchange="@(e => ChangeFirstDate(e.Value.ToString()))" />
12+
<input type="number" class="me-2" min="1" @bind-value="months">
13+
<select @bind="@PriorityDisplay" class="me-2">
14+
<option value="@PriorityLabel.Code" selected>priority Code</option>
15+
<option value="@PriorityLabel.Caption">priority Caption</option>
16+
</select>
17+
<div>
18+
<input type="checkbox" @bind="draggable" id="is-draggable" />
19+
<label for="is-draggable">Draggable</label>
20+
</div>
21+
</div>
22+
23+
24+
<CalendarContainer FirstDate="today" TasksList="TasksList.ToArray()" DisplayedView="DisplayedView.Annual" >
25+
<AnnualView Months="months" Style="height:80vh"
26+
PriorityDisplay="@PriorityDisplay"
27+
TaskClick="TaskClick" EmptyDayClick="EmptyDayClick"
28+
Draggable="@draggable" DragStart="DragStart" DropTask="DropTask" />
29+
</CalendarContainer>
30+
31+
32+
<br />
33+
<div class="console">@fakeConsole</div>
34+
35+
@code{
36+
private DateTime today = DateTime.Today;
37+
private int months = 12;
38+
private List<Tasks> TasksList;
39+
private string fakeConsole = "";
40+
private BlazorCalendar.PriorityLabel PriorityDisplay = PriorityLabel.Code;
41+
private bool draggable = true;
42+
43+
protected override void OnInitialized()
44+
{
45+
TasksList = new()
46+
{
47+
new Tasks { ID = 1, DateStart = today.AddDays(8), DateEnd = today.AddDays(8), Code = "CP", Color = "#19C319", Caption = "Lorem ipsum dolor sit amet" },
48+
new Tasks { ID = 2, DateStart = today.AddDays(50), DateEnd = today.AddDays(52), Code = "DEV", Color = "#FFD800", Comment="on Teams template", Caption = "Fusce quis purus eu ante" },
49+
new Tasks { ID = 3, DateStart = today.AddDays(40), DateEnd = today.AddDays(41), Code = "FORM", Color = "#FFC3FF", ForeColor = "#FF0000", Caption = "Lorem ipsum dolor sit amet" },
50+
new Tasks { ID = 4, DateStart = today.AddDays(62), DateEnd = today.AddDays(62), Code = "DEV", Color = "#FFD800" },
51+
new Tasks { ID = 5, DateStart = today.AddDays(62), DateEnd = today.AddDays(62), Code = "FORM", Color = "#FFC3FF", Caption = "Ut sit amet turpis eget" } ,
52+
new Tasks { ID = 6, DateStart = today.AddDays(73).AddHours(8), DateEnd = today.AddDays(73).AddHours(9), Code = "MEETING", Color = "#2DD7D7", Comment="Julien's test" }
53+
};
54+
}
55+
56+
private void ChangeFirstDate(string value)
57+
{
58+
if (string.IsNullOrEmpty(value)) return;
59+
today = DateTime.Parse(value.ToString());
60+
}
61+
62+
private void ClicMonthNavigate(int monthToAdd)
63+
{
64+
today = today.AddMonths(monthToAdd);
65+
}
66+
67+
private void TaskClick(ClickTaskParameter clickTaskParameter)
68+
{
69+
fakeConsole = "ID task(s) :" + string.Join(", ", clickTaskParameter.IDList);
70+
}
71+
72+
private void EmptyDayClick(ClickEmptyDayParameter clickEmptyDayParameter)
73+
{
74+
fakeConsole = "Empty day :" + clickEmptyDayParameter.Day.ToShortDateString();
75+
}
76+
77+
private void DragStart(DragDropParameter dragDropParameter)
78+
{
79+
fakeConsole = $"DragStart event :{dragDropParameter.Day.ToShortDateString()} {dragDropParameter.taskID}";
80+
}
81+
82+
private void DropTask(DragDropParameter dragDropParameter)
83+
{
84+
fakeConsole = $"DropTask event :{dragDropParameter.Day.ToShortDateString()} {dragDropParameter.taskID}";
85+
86+
Tasks taskDropped = TasksList.FirstOrDefault(t => t.ID == dragDropParameter.taskID);
87+
88+
var TotalDay = (taskDropped.DateEnd - taskDropped.DateStart).TotalDays;
89+
taskDropped.DateEnd = dragDropParameter.Day.AddDays(TotalDay);
90+
taskDropped.DateStart = dragDropParameter.Day;
91+
}
92+
}

0 commit comments

Comments
 (0)