Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
42 changes: 42 additions & 0 deletions BlazorWebAssem/.vs/BlazorWebAssem/xs/UserPrefs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Properties StartupConfiguration="{EE445738-A800-497C-A757-AF2E74488A43}|https">
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.ItemProperties.BlazorWebAssem PreferredExecutionTarget="/Applications/Google Chrome.app" />
<MultiItemStartupConfigurations />
<MonoDevelop.Ide.Workbench ActiveDocument="Shared/NavMenu.razor.css">
<Files>
<File FileName="Program.cs" Line="1" Column="1" />
<File FileName="App.razor" Line="1" Column="1" />
<File FileName="_Imports.razor" Line="1" Column="1" />
<File FileName="Pages/Authentication.razor" Line="1" Column="1" />
<File FileName="Properties/launchSettings.json" Line="15" Column="26" />
<File FileName="Shared/LoginDisplay.razor" Line="1" Column="1" />
<File FileName="Shared/MainLayout.razor" Line="1" Column="1" />
<File FileName="Shared/RedirectToLogin.razor" Line="1" Column="1" />
<File FileName="Shared/SurveyPrompt.razor" Line="1" Column="1" />
<File FileName="Shared/NavMenu.razor" Line="26" Column="15" />
<File FileName="Shared/NavMenu.razor.css" Line="44" Column="34" />
<File FileName="Pages/FetchData.razor" Line="4" Column="29" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="BlazorWebAssem" expanded="True">
<Node name="BlazorWebAssem" expanded="True">
<Node name="Pages" expanded="True" />
<Node name="Properties" expanded="True" />
<Node name="Shared" expanded="True">
<Node name="MainLayout.razor" expanded="True" />
<Node name="NavMenu.razor" expanded="True" />
</Node>
<Node name="wwwroot" expanded="True" />
</Node>
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
</Properties>

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions BlazorWebAssem/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (context.User.Identity?.IsAuthenticated != true)
{
<RedirectToLogin />
}
else
{
<p role="alert">You are not authorized to access this resource.</p>
}
</NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
17 changes: 17 additions & 0 deletions BlazorWebAssem/BlazorWebAssem.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.5" PrivateAssets="all" />
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="7.0.5" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions BlazorWebAssem/BlazorWebAssem.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1705.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssem", "BlazorWebAssem.csproj", "{EE445738-A800-497C-A757-AF2E74488A43}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EE445738-A800-497C-A757-AF2E74488A43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE445738-A800-497C-A757-AF2E74488A43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE445738-A800-497C-A757-AF2E74488A43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE445738-A800-497C-A757-AF2E74488A43}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {959D8E18-C160-43BE-AB92-9802527B6E61}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions BlazorWebAssem/GraphAPIAuthorizationMessageHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;

public class GraphAPIAuthorizationMessageHandler : AuthorizationMessageHandler
{
public GraphAPIAuthorizationMessageHandler(IAccessTokenProvider provider,
NavigationManager navigationManager)
: base(provider, navigationManager)
{
ConfigureHandler(
authorizedUrls: new[] { "https://graph.microsoft.com" },
scopes: new[] { "https://graph.microsoft.com/User.Read", "https://graph.microsoft.com/Mail.Read" });
}
}
7 changes: 7 additions & 0 deletions BlazorWebAssem/Pages/Authentication.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />

@code{
[Parameter] public string? Action { get; set; }
}
18 changes: 18 additions & 0 deletions BlazorWebAssem/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
106 changes: 106 additions & 0 deletions BlazorWebAssem/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
@page "/outlook"
@using System.ComponentModel.DataAnnotations
@using System.Text.Json.Serialization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Microsoft.Extensions.Logging
@inject IAccessTokenProvider TokenProvider
@inject IHttpClientFactory ClientFactory
@inject IHttpClientFactory HttpClientFactory

<style>
.table {
width: 100%;
margin-bottom: 1rem;
color: #212529;
border-collapse: collapse;
table-layout: fixed;
}

.td {
word-wrap: break-word;
}
</style>

@if (messages == null)
{
<p><em>Loading...</em></p>
}
else
{
<h1>Hello @userDisplayName</h1>
<table class="table">
<thead>
<tr>
<th style="width:30%">Subject</th>
<th style="width:50%">Message</th>
<th style="width:20%">Received Time</th>
</tr>
</thead>
<tbody>
@foreach (var mail in messages)
{
<tr>
<td>@mail.Subject</td>
<td>@mail.Message</td>
@* <td>@mail.Sender</td> *@
<td>@mail.ReceivedTime</td>
</tr>
}
</tbody>
</table>
}

@code {

private string userDisplayName;
private List<MailMessage> messages = new List<MailMessage>();

private HttpClient _httpClient;

protected override async Task OnInitializedAsync()
{
_httpClient = HttpClientFactory.CreateClient("GraphAPI");
try {
var dataRequest = await _httpClient.GetAsync("https://graph.microsoft.com/beta/me");

if (dataRequest.IsSuccessStatusCode)
{
var userData = System.Text.Json.JsonDocument.Parse(await dataRequest.Content.ReadAsStreamAsync());
userDisplayName = userData.RootElement.GetProperty("displayName").GetString();
}

var mailRequest = await _httpClient.GetAsync("https://graph.microsoft.com/beta/me/messages?$select=subject,receivedDateTime,sender,bodyPreview&$top=10");

if (mailRequest.IsSuccessStatusCode)
{
var mailData = System.Text.Json.JsonDocument.Parse(await mailRequest.Content.ReadAsStreamAsync());
var messagesArray = mailData.RootElement.GetProperty("value").EnumerateArray();

foreach (var m in messagesArray)
{
var message = new MailMessage();
message.Subject = m.GetProperty("subject").GetString();
message.Sender = m.GetProperty("sender").GetProperty("emailAddress").GetProperty("address").GetString();
message.ReceivedTime = m.GetProperty("receivedDateTime").GetDateTime();
message.Message = m.GetProperty("bodyPreview").GetString();
Console.WriteLine(m);
messages.Add(message);
}
}
}
catch (AccessTokenNotAvailableException ex)
{
// Tokens are not valid - redirect the user to log in again
ex.Redirect();
}
}

public class MailMessage
{
public string Subject;
public string Sender;
public DateTime ReceivedTime;

public string Message;
}
}
90 changes: 90 additions & 0 deletions BlazorWebAssem/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
@page "/"

<PageTitle>Index</PageTitle>

<style>
/*.l-grid-container {
display: grid;
height: calc(100vw * 4 / 6);
$row: calc(100% / 4);
$column: calc(100% / 6);
grid-template-rows: $row $row $row $row;
grid-template-columns: $column $column $column $column $column $column;
}*/


.item {
color: #000000;
background: #2a9cb6;
}

.tile {
width: 50px;
height: 30px;
margin: 1%;
padding: 3%
}

.grid-container {
display: grid;
grid-template-columns: auto auto auto;
padding: 10px;
gap: 15px;
height: 600px;
}

.grid-item {
background-color: #98c5ff;
border: 1px solid rgba(190, 190, 190, 0.8);
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
padding: 5px;
font-size: 30px;
text-align: center;
border-radius: 10px;
color: rgba(0, 0, 0, 0.8);
font-size: 1.1rem;
}


</style>
<head>
<mgt-msal2-provider client-id="cde126b9-eb66-4426-8a2a-c654fb2d1aad"></mgt-msal2-provider>
</head>
<body>

<AuthorizeView>
<Authorized>
<h1>Dashboard</h1>

<h2>Today's weather</h2>

<div class="grid-container">
<div class="grid-item">
To Do:
<mgt-todo></mgt-todo>
<mgt-agenda
date="May 7, 2023"
days="7"
group-by-day></mgt-agenda>
</div>
<div class="grid-item">
Calendar

</div>
<div class="grid-item">
Schedule

</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
</div>
</Authorized>
<NotAuthorized>
<h1> Log in to view your dashboard</h1>

</NotAuthorized>

</AuthorizeView>

</body>

Loading