Skip to content

Commit

Permalink
Merge pull request #12 from rbrands/users/rbrands/2020-08-10
Browse files Browse the repository at this point in the history
Users/rbrands/2020 08 10
  • Loading branch information
rbrands authored Aug 13, 2020
2 parents e6d235d + 354aa86 commit 6c294af
Show file tree
Hide file tree
Showing 27 changed files with 636 additions and 37 deletions.
2 changes: 1 addition & 1 deletion MeetUpFunctions/AddParticipantToCalendarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<IActionResult> Run(
ServerSettings serverSettings = await _serverSettingsRepository.GetServerSettings();

string keyWord = req.Headers[Constants.HEADER_KEYWORD];
if (String.IsNullOrEmpty(keyWord) || !serverSettings.IsUser(keyWord))
if (String.IsNullOrEmpty(keyWord) || !(serverSettings.IsUser(keyWord) || _serverSettingsRepository.IsInvitedGuest(keyWord)))
{
return new BadRequestErrorMessageResult("Keyword is missing or wrong.");
}
Expand Down
4 changes: 3 additions & 1 deletion MeetUpFunctions/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public static class Constants
public const string DEFAULT_LINK = "https://robert-brands.com";
public const string DEFAULT_LINK_TITLE = "https://robert-brands.com";

public const string VERSION = "2020-08-02";
public const string VERSION = "2020-08-13";
public const int ADMINOVERBOOKFACTOR = 2;

public const int LOG_TTL = 30 * 24 * 3600; // 30 days TTL for Log items

public const string INVITE_GUEST_KEY_CONFIG = "InviteGuestKey";
}
}
2 changes: 1 addition & 1 deletion MeetUpFunctions/GetExtendedCalendarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task<IActionResult> Run(
ServerSettings serverSettings = await _serverSettingsRepository.GetServerSettings();

string keyWord = req.Headers[Constants.HEADER_KEYWORD];
if (String.IsNullOrEmpty(keyWord) || !serverSettings.IsUser(keyWord))
if (String.IsNullOrEmpty(keyWord) || !(serverSettings.IsUser(keyWord) || _serverSettingsRepository.IsInvitedGuest(keyWord)))
{
_logger.LogWarning("GetExtendedCalendarItem called with wrong keyword.");
return new BadRequestErrorMessageResult("Keyword is missing or wrong.");
Expand Down
2 changes: 1 addition & 1 deletion MeetUpFunctions/RemoveParticipantFromCalendarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task<IActionResult> Run(
ServerSettings serverSettings = await _serverSettingsRepository.GetServerSettings();

string keyWord = req.Headers[Constants.HEADER_KEYWORD];
if (String.IsNullOrEmpty(keyWord) || !serverSettings.IsUser(keyWord))
if (String.IsNullOrEmpty(keyWord) || !(serverSettings.IsUser(keyWord) || _serverSettingsRepository.IsInvitedGuest(keyWord)))
{
return new BadRequestErrorMessageResult("Keyword is missing or wrong.");
}
Expand Down
7 changes: 7 additions & 0 deletions MeetUpFunctions/ServerSettingsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ namespace MeetUpPlanner.Functions
{
public class ServerSettingsRepository : CosmosDBRepository<ServerSettings>
{
private string _inviteGuestKey;
public ServerSettingsRepository(IConfiguration config, CosmosClient cosmosClient) : base(config, cosmosClient)
{
_inviteGuestKey = config[Constants.INVITE_GUEST_KEY_CONFIG];
}
public string InviteGuestKey { get; }

public bool IsInvitedGuest(string keyword)
{
return _inviteGuestKey.Equals(keyword);
}
public async Task<ServerSettings> GetServerSettings()
{
Expand Down
1 change: 1 addition & 0 deletions MeetUpPlanner/Client/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ClientSettings ClientSettings
[MaxLength(120, ErrorMessage = "Die Tel-Nr/Mail-Adresse ist zu lang"), MinLength(8, ErrorMessage = "Die Tel-Nr/Mail-Adresse ist zu kurz.")]
[Required(ErrorMessage = "Tel-Nr/Mail-Adresse fehlen.")]
public string PhoneMail { get; set; }
public Boolean NoAddressNeeded { get; set; } = false;
public bool SaveSettings { get; set; } = true;

public void NotifyStateChanged() => OnChange?.Invoke();
Expand Down
1 change: 1 addition & 0 deletions MeetUpPlanner/Client/MeetUpPlanner.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageReference Include="BlazorDownloadFile" Version="2.0.0" />
<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" />
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 @@ -45,7 +45,7 @@
</div>

@code {
private const string clientVersion = "2020-08-02";
private const string clientVersion = "2020-08-13";
private string serverVersion = "tbd";
private string functionsVersion = "tbd";

Expand Down
102 changes: 100 additions & 2 deletions MeetUpPlanner/Client/Pages/Admin.razor
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
</span>
<span class="ql-formats">
<select class="ql-color"></select>
Expand Down Expand Up @@ -126,7 +125,52 @@
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
</span>
<span class="ql-formats">
<select class="ql-color"></select>
<select class="ql-background"></select>
</span>
<span class="ql-formats">
<button class="ql-list" value="ordered"></button>
<button class="ql-list" value="bullet"></button>
</span>
<span class="ql-formats">
<button class="ql-link"></button>
</span>
</ToolbarContent>
</BlazoredTextEditor>
</div>
<div class="form-group">
<label for="disclaimerMessage">Disclaimer für Teilnehmer</label>
<BlazoredTextEditor @ref="@htmlDisclaimer" Placeholder="Disclaimer">
<ToolbarContent>
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
</span>
<span class="ql-formats">
<select class="ql-color"></select>
<select class="ql-background"></select>
</span>
<span class="ql-formats">
<button class="ql-list" value="ordered"></button>
<button class="ql-list" value="bullet"></button>
</span>
<span class="ql-formats">
<button class="ql-link"></button>
</span>
</ToolbarContent>
</BlazoredTextEditor>
</div>
<div class="form-group">
<label for="guestDisclaimerMessage">Disclaimer für Gast-Teilnehmer</label>
<BlazoredTextEditor @ref="@htmlGuestDisclaimer" Placeholder="Disclaimer für Gäste">
<ToolbarContent>
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
</span>
<span class="ql-formats">
<select class="ql-color"></select>
Expand All @@ -143,6 +187,53 @@
</BlazoredTextEditor>
</div>

<div class="form-group">
<div class="form-check">
<InputCheckbox id="guestsEnabled" class="form-check-input" @bind-Value="@AppStateStore.ClientSettings.GuestsEnabled" />
<label for="guestsEnabled" class="form-checklabel">
Einladen von Gästen möglich?
</label>
</div>
</div>
<div class="form-group">
<div class="form-check">
<InputCheckbox id="onlyScoped" class="form-check-input" @bind-Value="@AppStateStore.ClientSettings.OnlyScopedMeetUpsAllowed" />
<label for="onlyScoped" class="form-checklabel">
Nur MeetUps an den Tagen zulassen, die mit den "Badges" unten gekennzeichnet sind?
</label>
</div>
</div>

<div class="form-row">
<div class="form-group col-md-12">
<label for="mondayBadge">Die Wochentage können mit "Badges" gekennzeichnet werden.</label>
</div>
</div>

<div class="form-row">
<div class="form-group col">
<InputText id="mondayBadge" placeholder="Montag" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.MondayBadge" title="Badge für Montag" />
</div>
<div class="form-group col">
<InputText id="tuesdayBadge" placeholder="Dienstag" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.TuesdayBadge" title="Badge für Dienstag" />
</div>
<div class="form-group col">
<InputText id="wednsesdayBadge" placeholder="Mittwoch" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.WednesdayBadge" title="Badge für Mittwoch" />
</div>
<div class="form-group col">
<InputText id="thursdayBadge" placeholder="Donnerstag" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.ThursdayBadge" title="Badge für Donnerstag" />
</div>
<div class="form-group col">
<InputText id="fridayBadge" placeholder="Freitag" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.FridayBadge" title="Badge für Freitag" />
</div>
<div class="form-group col">
<InputText id="saturdayBadge" placeholder="Samstag" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.SaturdayBadge" title="Badge für Samstag" />
</div>
<div class="form-group col">
<InputText id="sundayBadge" placeholder="Sonntag" class="form-control form-control-sm" @bind-Value="AppStateStore.ClientSettings.SundayBadge" title="Badge für Sonntag" />
</div>
</div>

<button type="submit" id="BtnSaveSettings" class="btn btn-primary">Einstellungen speichern ...</button>
</EditForm>
<br />
Expand Down Expand Up @@ -201,6 +292,8 @@
BlazoredTextEditor htmlWelcomeMessage;
BlazoredTextEditor htmlWhiteboardMessage;
BlazoredTextEditor htmlNewMeetupMessage;
BlazoredTextEditor htmlDisclaimer;
BlazoredTextEditor htmlGuestDisclaimer;


protected override async Task OnInitializedAsync()
Expand All @@ -213,6 +306,8 @@
await htmlWelcomeMessage.LoadHTMLContent(AppStateStore.ClientSettings.WelcomeMessage);
await htmlWhiteboardMessage.LoadHTMLContent(AppStateStore.ClientSettings.WhiteboardMessage);
await htmlNewMeetupMessage.LoadHTMLContent(AppStateStore.ClientSettings.NewMeetupMessage);
await htmlDisclaimer.LoadHTMLContent(AppStateStore.ClientSettings.Disclaimer);
await htmlGuestDisclaimer.LoadHTMLContent(AppStateStore.ClientSettings.GuestDisclaimer);
}
else
{
Expand All @@ -226,6 +321,9 @@
AppStateStore.ClientSettings.WelcomeMessage = StripEmptyHtml(await htmlWelcomeMessage.GetHTML());
AppStateStore.ClientSettings.WhiteboardMessage = StripEmptyHtml(await htmlWhiteboardMessage.GetHTML());
AppStateStore.ClientSettings.NewMeetupMessage = StripEmptyHtml(await htmlNewMeetupMessage.GetHTML());
AppStateStore.ClientSettings.Disclaimer = StripEmptyHtml(await htmlDisclaimer.GetHTML());
AppStateStore.ClientSettings.GuestDisclaimer = StripEmptyHtml(await htmlGuestDisclaimer.GetHTML());

// Write client settings to server
await Http.PostAsJsonAsync<ClientSettings>($"Util/writesettings?adminKeyword={keyword}", AppStateStore.ClientSettings);
AppStateStore.NotifyStateChanged();
Expand Down
54 changes: 51 additions & 3 deletions MeetUpPlanner/Client/Pages/Calendar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@
<div class="row">
@foreach (ExtendedCalendarItem item in calendarItems)
{
<div class="col-md-4">
<div class="col-md-4 mt-2">
<div class="card">
<div class="card-header">
<em>@item.GetStartDateAsString() - @item.Place</em>
@if (!String.IsNullOrEmpty(item.PrivateKeyword))
{
<div class="text-right"><small class="text-muted"><span class="oi oi-key" title="Private Ausfahrt"></span> @item.PrivateKeyword</small></div>
<span class="badge badge-danger"><span class="oi oi-key" title="Private Ausfahrt"></span> @item.PrivateKeyword</span>
}
@{
string badge = GetCalendarBadge(item);
if (!String.IsNullOrEmpty(badge))
{
<span class="badge badge-info">@badge</span>
}
}
</div>
<div class="card-body">
Expand Down Expand Up @@ -85,11 +92,15 @@
<button class="btn btn-sm btn-outline-secondary" title="Abmelden" hidden="@(!CheckIfUserIsAlreadyRegistered(item))" @onclick="@(() => Checkout(item))">Abmelden</button>
}
<button class="btn btn-sm btn-outline-secondary" title="Kommentieren" @onclick="@(() => ShowComment(item))">Kommentieren</button>
@if (AppStateStore.ClientSettings.GuestsEnabled)
{
<button class="btn btn-sm btn-outline-secondary" title="Gast einladen" @onclick="@(() => Invite(item))">Gast einladen</button>
}
</div>
</div>
</div>
</div>
}
}
</div>

<p class="alert-info">
Expand Down Expand Up @@ -207,6 +218,10 @@
{
NavigationManager.NavigateTo($"/Comment/{calendarItem.Id}");
}
protected void Invite(ExtendedCalendarItem calendarItem)
{
NavigationManager.NavigateTo($"/Invite/{calendarItem.Id}");
}
protected void DeleteCalendarItem(ExtendedCalendarItem calendarItem)
{
NavigationManager.NavigateTo($"/ConfirmDelete/{calendarItem.Id}");
Expand All @@ -217,4 +232,37 @@
Timer2.DisableTimer();
}

private string GetCalendarBadge(ExtendedCalendarItem calendarItem)
{
string badge = null;
DayOfWeek weekday = calendarItem.StartDate.DayOfWeek;
switch (weekday)
{
case DayOfWeek.Monday :
badge = AppStateStore.ClientSettings.MondayBadge;
break;
case DayOfWeek.Tuesday:
badge = AppStateStore.ClientSettings.TuesdayBadge;
break;
case DayOfWeek.Wednesday:
badge = AppStateStore.ClientSettings.WednesdayBadge;
break;
case DayOfWeek.Thursday:
badge = AppStateStore.ClientSettings.ThursdayBadge;
break;
case DayOfWeek.Friday:
badge = AppStateStore.ClientSettings.FridayBadge;
break;
case DayOfWeek.Saturday:
badge = AppStateStore.ClientSettings.SaturdayBadge;
break;
case DayOfWeek.Sunday:
badge = AppStateStore.ClientSettings.SundayBadge;
break;
}


return badge;
}

}
3 changes: 1 addition & 2 deletions MeetUpPlanner/Client/Pages/Export.razor
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
}
csvData.WriteLine();
}

await BlazorDownloadFileService.DownloadFileFromText(fileName, csvData.ToString(), "text/csv");
await BlazorDownloadFileService.DownloadFile(fileName, new System.Text.UTF32Encoding().GetBytes(csvData.ToString()), "text/csv");
await ReadData();
}

Expand Down
17 changes: 12 additions & 5 deletions MeetUpPlanner/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
</div>
</div>
<div class="form-group">
<div class="form-check">
<InputCheckbox id="addressNotNeeded" @oninput="@(e => { AppStateStore.PhoneMail = ((bool)e.Value ? "Vereinsmitglied" : String.Empty); })" aria-describedby="addressNotNeededHelp" class="form-check-input" @bind-Value="AppStateStore.NoAddressNeeded"></InputCheckbox>
<label for="addressNotNeeded" class="form-check-label">Vereinsmitglied?</label>
</div>
<small id="addressNotNeededHelp">Als Vereinsmitglied werden keine weiteren Adressinfos benötgt, Vor- und Nachname reichen dann.</small>
</div>
<div class="form-group" hidden="@AppStateStore.NoAddressNeeded">
<label for="Phone">Telefon/Mail</label>
<InputText id="Phone" aria-describedby="phoneHelp" class="form-control" @bind-Value="AppStateStore.PhoneMail" autocomplete="on" placeholder="Telefon-Nr. oder Mail-Adresse" title="Bitte Telefonnummer oder Mailadresse angeben." />
<small id="phoneHelp" class="form-text text-muted">
Expand All @@ -84,11 +91,9 @@
</div>
<div class="form-group">
<div class="form-check">
<InputCheckbox class="form-check-input" @bind-Value="@UsageRightsAccepted" onclic />
<label for="form-check-input" class="form-checklabel">
Hiermit bestätige ich, dass ich damit einverstanden bin, dass die Teilnehmerlisten zu den Ausfahrten mit den Kontaktdaten,
die ich hier angebe, bis zu 4 Wochen für die Nachverfolgbarkeit gespeichert werden. Ich bin auch damit einverstanden,
dass in der Liste der Ausfahrten die Teilnehmer mit Vornamen und abgekürztem Nachnamen (erste Buchstabe) angezeigt werden.
<InputCheckbox id="accept" class="form-check-input" @bind-Value="@UsageRightsAccepted" />
<label for="accept" class="form-checklabel">
@((MarkupString)AppStateStore.ClientSettings.Disclaimer)
</label>
</div>
</div>
Expand Down Expand Up @@ -132,6 +137,7 @@
AppStateStore.PrivateKeyWord1 = permAppState.PrivateKeyWord1;
AppStateStore.PrivateKeyWord2 = permAppState.PrivateKeyWord2;
AppStateStore.PrivateKeyWord2 = permAppState.PrivateKeyWord2;
AppStateStore.NoAddressNeeded = permAppState.NoAddressNeeded;
}

// Get client settings from server
Expand Down Expand Up @@ -167,6 +173,7 @@
permAppState.PrivateKeyWord1 = AppStateStore.PrivateKeyWord1;
permAppState.PrivateKeyWord2 = AppStateStore.PrivateKeyWord2;
permAppState.PrivateKeyWord2 = AppStateStore.PrivateKeyWord2;
permAppState.NoAddressNeeded = AppStateStore.NoAddressNeeded;
await localStorage.SetItemAsync<PermAppState>("permAppState", permAppState);
}
else
Expand Down
Loading

0 comments on commit 6c294af

Please sign in to comment.