From 5a3fdada8fcc4e2a0344ec311340da362b345631 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 1 Sep 2019 01:31:55 +0100 Subject: [PATCH] fixes GMaps usage & Command creation --- .../Accounting/ManageController.cs | 4 +- src/Yavsc/Hubs/ChatHub.cs | 5 +- src/Yavsc/Services/ChatHubConnexionManager.cs | 2 +- src/Yavsc/Services/YavscMessageSender.cs | 4 +- src/Yavsc/Views/Blogspot/Create.cshtml | 7 + src/Yavsc/Views/Blogspot/Edit.cshtml | 12 +- src/Yavsc/Views/Command/Create.cshtml | 154 +++++++++--------- src/Yavsc/Views/Manage/SetActivity.cshtml | 20 ++- src/Yavsc/Views/Manage/SetAddress.cshtml | 52 +++--- src/Yavsc/Views/Shared/_Layout.cshtml | 8 - .../Views/Shared/_MapScriptsPartial.cshtml | 108 +----------- src/Yavsc/wwwroot/js/google-geoloc.js | 89 +++++----- 12 files changed, 194 insertions(+), 271 deletions(-) diff --git a/src/Yavsc/Controllers/Accounting/ManageController.cs b/src/Yavsc/Controllers/Accounting/ManageController.cs index 2830131b..b17a08d4 100644 --- a/src/Yavsc/Controllers/Accounting/ManageController.cs +++ b/src/Yavsc/Controllers/Accounting/ManageController.cs @@ -705,7 +705,7 @@ namespace Yavsc.Controllers var uid = User.GetUserId(); var user = await _dbContext.Users.Include(u=>u.PostalAddress).SingleAsync(u=>u.Id==uid); ViewBag.GoogleSettings = _googleSettings; - return View (new Yavsc.ViewModels.Manage.SetAddressViewModel { Street1 = user.PostalAddress?.Address } ); + return View (user.PostalAddress ?? new Location()); } [HttpPost] @@ -727,7 +727,7 @@ namespace Yavsc.Controllers return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetAddressSuccess }); } ViewBag.GoogleSettings = _googleSettings; - return View(new Yavsc.ViewModels.Manage.SetAddressViewModel { Street1 = model.Address}); + return View(model); } public async Task PaymentInfo (string id) { diff --git a/src/Yavsc/Hubs/ChatHub.cs b/src/Yavsc/Hubs/ChatHub.cs index c0323cee..0355870f 100644 --- a/src/Yavsc/Hubs/ChatHub.cs +++ b/src/Yavsc/Hubs/ChatHub.cs @@ -303,8 +303,7 @@ namespace Yavsc if (!_cxManager.Kick(Context.ConnectionId, userName, roomName, reason)) return; } var ukeys = _cxManager.GetConnexionIds(userName); - - foreach(var ukey in ukeys) + if (ukeys!=null) foreach(var ukey in ukeys) Groups.Remove(ukey, roomGroupName); Clients.Group(roomGroupName).notifyRoom(NotificationTypes.Kick, roomName, $"{userName}: {reason}"); } @@ -403,7 +402,7 @@ namespace Yavsc } } var cxIds = _cxManager.GetConnexionIds(userName); - + if (cxIds!=null) foreach (var connectionId in cxIds) { var cli = Clients.Client(connectionId); diff --git a/src/Yavsc/Services/ChatHubConnexionManager.cs b/src/Yavsc/Services/ChatHubConnexionManager.cs index 2527961c..712b1f0d 100644 --- a/src/Yavsc/Services/ChatHubConnexionManager.cs +++ b/src/Yavsc/Services/ChatHubConnexionManager.cs @@ -263,7 +263,7 @@ namespace Yavsc.Services public IEnumerable GetConnexionIds(string userName) { - return ChatCxIds[userName]; + return ChatCxIds.ContainsKey(userName) ? ChatCxIds[userName] : null; } /// diff --git a/src/Yavsc/Services/YavscMessageSender.cs b/src/Yavsc/Services/YavscMessageSender.cs index 52061378..c1b9a9c0 100644 --- a/src/Yavsc/Services/YavscMessageSender.cs +++ b/src/Yavsc/Services/YavscMessageSender.cs @@ -111,8 +111,8 @@ namespace Yavsc.Services result.message_id = mailSent.MessageId; response.success++; } - var cxids = _cxManager.GetConnexionIds(user.UserName).ToArray(); - if (cxids.Length == 0) + var cxids = _cxManager.GetConnexionIds(user.UserName); + if (cxids == null) { _logger.LogDebug($"no cx to {user.UserName} <{user.Email}> "); } diff --git a/src/Yavsc/Views/Blogspot/Create.cshtml b/src/Yavsc/Views/Blogspot/Create.cshtml index adc581f3..adf6f77a 100644 --- a/src/Yavsc/Views/Blogspot/Create.cshtml +++ b/src/Yavsc/Views/Blogspot/Create.cshtml @@ -58,4 +58,11 @@ @{ await Html.RenderPartialAsync("_FSScriptsPartial"); } @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } + } diff --git a/src/Yavsc/Views/Blogspot/Edit.cshtml b/src/Yavsc/Views/Blogspot/Edit.cshtml index 1b12a4d5..56afe9c3 100644 --- a/src/Yavsc/Views/Blogspot/Edit.cshtml +++ b/src/Yavsc/Views/Blogspot/Edit.cshtml @@ -4,7 +4,7 @@ ViewData["Title"] = SR["Blog post edition"]; } -@section header{ +@section header { @@ -35,9 +35,18 @@ + + @{ await Html.RenderPartialAsync("_FSScriptsPartial"); } + +} + +@section scripts { @Html.Partial("_ValidationScriptsPartial") + }

@SR["Blog post edition"]

diff --git a/src/Yavsc/Views/Command/Create.cshtml b/src/Yavsc/Views/Command/Create.cshtml index 66a47255..8ef619e0 100644 --- a/src/Yavsc/Views/Command/Create.cshtml +++ b/src/Yavsc/Views/Command/Create.cshtml @@ -1,27 +1,18 @@ -@model RdvQuery -@{ ViewData["Title"] = $"Proposition de rendez-vous à {Model.PerformerProfile.Performer.UserName} [{ViewBag.Activity.Name}]"; } -@section scripts { +@model RdvQuery +@section header { + + - - } +@{ ViewData["Title"] = $"Proposition de rendez-vous à {Model.PerformerProfile.Performer.UserName} [{ViewBag.Activity.Name}]"; }

@ViewData["Title"]

@@ -30,7 +21,7 @@
- Votre évennement + La date de votre évennement @@ -41,80 +32,83 @@
- +
- - + + +
+ + + - - -