Skip to content

Commit

Permalink
Merge pull request #42 from rbrands/users/rbrands/2020-09-07
Browse files Browse the repository at this point in the history
Users/rbrands/2020 09 07
  • Loading branch information
rbrands authored Sep 19, 2020
2 parents fb271e8 + 15c5d9e commit 48814e8
Show file tree
Hide file tree
Showing 23 changed files with 528 additions and 84 deletions.
4 changes: 2 additions & 2 deletions MeetUpFunctions/AddParticipantToCalendarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public AddParticipantToCalendarItem(ILogger<AddParticipantToCalendarItem> logger

[FunctionName("AddParticipantToCalendarItem")]
[OpenApiOperation(Summary = "Add a participant to the referenced CalendarItem.",
Description = "If the Participants already exists (same id) it it overwritten.")]
Description = "If the Participants already exists (same id) it is overwritten.")]
[OpenApiRequestBody("application/json", typeof(Participant), Description = "New Participant to be written.")]
[OpenApiResponseWithBody(System.Net.HttpStatusCode.OK, "application/json", typeof(BackendResult), Description = "Status of operation.")]
public async Task<IActionResult> Run(
Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task<IActionResult> Run(
}
// Get participant list to check max registrations and if caller is already registered.
IEnumerable<Participant> participants = await _cosmosRepository.GetItems(p => p.CalendarItemId.Equals(calendarItem.Id));
int counter = 1;
int counter = calendarItem.WithoutHost ? 0 : 1;
foreach (Participant p in participants)
{
if (p.ParticipantFirstName.Equals(participant.ParticipantFirstName) && p.ParticipantLastName.Equals(participant.ParticipantLastName))
Expand Down
2 changes: 1 addition & 1 deletion MeetUpFunctions/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class Constants
public const string DEFAULT_DISCLAIMER = "Disclaimer";
public const string DEFAULT_GUEST_DISCLAIMER = "Guest Disclaimer";

public const string VERSION = "2020-09-04";
public const string VERSION = "2020-09-19";
public const int ADMINOVERBOOKFACTOR = 2;

public const int LOG_TTL = 30 * 24 * 3600; // 30 days TTL for Log items
Expand Down
2 changes: 1 addition & 1 deletion MeetUpFunctions/ExportTrackingReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task<IActionResult> Run(
// Read all participants for this calendar item
IEnumerable<Participant> participants = await _participantRepository.GetItems(p => p.CalendarItemId.Equals(item.Id));
// Only events where the person was part of will be used.
if (item.EqualsHost(trackingRequest.TrackFirstName, trackingRequest.TrackLastName) || null != participants.Find(trackingRequest.TrackFirstName, trackingRequest.TrackLastName))
if (!item.WithoutHost && item.EqualsHost(trackingRequest.TrackFirstName, trackingRequest.TrackLastName) || null != participants.Find(trackingRequest.TrackFirstName, trackingRequest.TrackLastName))
{
ExtendedCalendarItem extendedItem = new ExtendedCalendarItem(item);
extendedItem.ParticipantsList = participants;
Expand Down
5 changes: 5 additions & 0 deletions MeetUpFunctions/GetCalendarItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public async Task<IActionResult> Run(
List<CalendarItem> resultCalendarItems = new List<CalendarItem>(10);
foreach (CalendarItem item in rawListOfCalendarItems)
{
if (!serverSettings.IsAdmin(keyWord) && item.PublishDate.CompareTo(DateTime.UtcNow) > 0)
{
// If calendar item is not ready for publishing skip it
continue;
}
if ( String.IsNullOrEmpty(item.PrivateKeyword))
{
// No private keyword for item ==> use it
Expand Down
5 changes: 5 additions & 0 deletions MeetUpFunctions/GetExtendedCalendarItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public async Task<IActionResult> Run(
{
// Create ExtendedCalendarItem and get comments and participants
ExtendedCalendarItem extendedItem = new ExtendedCalendarItem(item);
if (!serverSettings.IsAdmin(keyWord) && extendedItem.PublishDate.CompareTo(DateTime.UtcNow) > 0)
{
// If calendar item is not ready for publishing skip it
continue;
}
if (String.IsNullOrEmpty(extendedItem.PrivateKeyword))
{
// No private keyword for item ==> use it
Expand Down
119 changes: 119 additions & 0 deletions MeetUpFunctions/GetExtendedCalendarItemsForDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using Newtonsoft.Json;
using MeetUpPlanner.Shared;
using System.Web.Http;
using System.Linq;
using Aliencube.AzureFunctions.Extensions.OpenApi.Core.Attributes;

namespace MeetUpPlanner.Functions
{
public class GetExtendedCalendarItemsForDate
{
private readonly ILogger _logger;
private ServerSettingsRepository _serverSettingsRepository;
private CosmosDBRepository<CalendarItem> _cosmosRepository;
private CosmosDBRepository<Participant> _participantRepository;
private CosmosDBRepository<CalendarComment> _commentRepository;

public GetExtendedCalendarItemsForDate(ILogger<GetExtendedCalendarItems> logger, ServerSettingsRepository serverSettingsRepository,
CosmosDBRepository<CalendarItem> cosmosRepository,
CosmosDBRepository<Participant> participantRepository,
CosmosDBRepository<CalendarComment> commentRepository)
{
_logger = logger;
_serverSettingsRepository = serverSettingsRepository;
_cosmosRepository = cosmosRepository;
_participantRepository = participantRepository;
_commentRepository = commentRepository;
}

[FunctionName("GetExtendedCalendarItemsForDate")]
[OpenApiOperation(Summary = "Gets the ExtendedCalendarIitems for the given date",
Description = "Reading current ExtendedCalendarItems (CalendarItem including correpondent participants and comments) for the given date. To be able to read CalenderItems the user keyword must be set as header x-meetup-keyword.")]
[OpenApiResponseWithBody(System.Net.HttpStatusCode.OK, "application/json", typeof(IEnumerable<ExtendedCalendarItem>))]
[OpenApiParameter("privatekeywords", Description = "Holds a list of private keywords, separated by ;")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req)
{
_logger.LogInformation("C# HTTP trigger function GetExtendedCalendarItemsForDate processed a request.");
string tenant = req.Headers[Constants.HEADER_TENANT];
if (String.IsNullOrWhiteSpace(tenant))
{
tenant = null;
}
ServerSettings serverSettings = await _serverSettingsRepository.GetServerSettings(tenant);
string keyWord = req.Headers[Constants.HEADER_KEYWORD];
if (String.IsNullOrEmpty(keyWord) || !serverSettings.IsUser(keyWord))
{
_logger.LogWarning("GetExtendedCalendarItemsForDate called with wrong keyword.");
return new BadRequestErrorMessageResult("Keyword is missing or wrong.");
}
string privateKeywordsString = req.Query["privatekeywords"];
string[] privateKeywords = null;
if (!String.IsNullOrEmpty(privateKeywordsString))
{
privateKeywords = privateKeywordsString.Split(';');
}
string requestedDateArg = req.Query["requesteddate"];
if (String.IsNullOrEmpty(requestedDateArg))
{
_logger.LogWarning("GetExtendedCalendarItemsForDate called without requesteddate.");
return new BadRequestErrorMessageResult("requesteddate is misssing..");
}
DateTime compareDate = DateTime.Parse(requestedDateArg);

// Get a list of all CalendarItems and filter all applicable ones
IEnumerable<CalendarItem> rawListOfCalendarItems;
if (null == tenant)
{
rawListOfCalendarItems = await _cosmosRepository.GetItems(d => d.StartDate > compareDate && d.StartDate < compareDate.AddHours(24.0) && (d.Tenant ?? String.Empty) == String.Empty);
}
else
{
rawListOfCalendarItems = await _cosmosRepository.GetItems(d => d.StartDate > compareDate && d.StartDate < compareDate.AddHours(24.0) && d.Tenant.Equals(tenant));
}
List<ExtendedCalendarItem> resultCalendarItems = new List<ExtendedCalendarItem>(10);
foreach (CalendarItem item in rawListOfCalendarItems)
{
// Create ExtendedCalendarItem and get comments and participants
ExtendedCalendarItem extendedItem = new ExtendedCalendarItem(item);
if (!serverSettings.IsAdmin(keyWord) && extendedItem.PublishDate.CompareTo(DateTime.UtcNow) > 0)
{
// If calendar item is not ready for publishing skip it
continue;
}
if (String.IsNullOrEmpty(extendedItem.PrivateKeyword))
{
// No private keyword for item ==> use it
resultCalendarItems.Add(extendedItem);
}
else if (null != privateKeywords)
{
// Private keyword for item ==> check given keyword list against it
foreach (string keyword in privateKeywords)
{
if (keyword.Equals(extendedItem.PrivateKeyword))
{
resultCalendarItems.Add(extendedItem);
break;
}
}
}
// Read all participants for this calendar item
extendedItem.ParticipantsList = await _participantRepository.GetItems(p => p.CalendarItemId.Equals(extendedItem.Id));
// Read all comments
extendedItem.CommentsList = await _commentRepository.GetItems(c => c.CalendarItemId.Equals(extendedItem.Id));
}
IEnumerable<ExtendedCalendarItem> orderedList = resultCalendarItems.OrderBy(d => d.StartDate);
return new OkObjectResult(orderedList);
}
}
}
2 changes: 1 addition & 1 deletion MeetUpFunctions/MeetUpPlanner.Functions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="Aliencube.AzureFunctions.Extensions.OpenApi.Core" Version="3.1.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.12.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.9" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions MeetUpPlanner/Client/MeetUpPlanner.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorDownloadFile" Version="2.1.1" />
<PackageReference Include="BlazorDownloadFile" Version="2.1.2" />
<PackageReference Include="Blazored.LocalStorage" Version="3.0.0" />
<PackageReference Include="Blazored.TextEditor" Version="1.0.3" />
<PackageReference Include="CurrieTechnologies.Razor.Clipboard" Version="1.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.7" />
<PackageReference Include="Radzen.Blazor" Version="2.11.13" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.8" />
<PackageReference Include="Radzen.Blazor" Version="2.14.1" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion MeetUpPlanner/Client/Pages/About.razor
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>

@code {
private const string clientVersion = "2020-09-05";
private const string clientVersion = "2020-09-19";
private string serverVersion = "tbd";
private string functionsVersion = "tbd";

Expand Down
7 changes: 7 additions & 0 deletions MeetUpPlanner/Client/Pages/Admin.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
Festlegung der maximalen Gruppengröße.
</small>
</div>
<div class="form-group">
<label for="maxGroupForAdmins">Max. Gruppengröße für Administratoren</label>
<InputNumber id="maxGroupForAdmins" aria-describedby="maxGroupForAdminsHelp" class="form-control" @bind-Value="AppStateStore.ClientSettings.MaxGroupSizeForAdmins" autocomplete="on" />
<small id="maxGroupForAdminsHelp" class="form-text text-muted">
Festlegung der maximalen Gruppengröße für Administratoren, die größere Gruppen erlauben dürfen.
</small>
</div>
<div class="form-group">
<label for="welcomeMessage">Welcome Nachricht</label>
<BlazoredTextEditor @ref="@htmlWelcomeMessage" Placeholder="Nachricht für Startseite">
Expand Down
Loading

0 comments on commit 48814e8

Please sign in to comment.