fixes GMaps usage & Command creation
This commit is contained in:
@ -705,7 +705,7 @@ namespace Yavsc.Controllers
|
|||||||
var uid = User.GetUserId();
|
var uid = User.GetUserId();
|
||||||
var user = await _dbContext.Users.Include(u=>u.PostalAddress).SingleAsync(u=>u.Id==uid);
|
var user = await _dbContext.Users.Include(u=>u.PostalAddress).SingleAsync(u=>u.Id==uid);
|
||||||
ViewBag.GoogleSettings = _googleSettings;
|
ViewBag.GoogleSettings = _googleSettings;
|
||||||
return View (new Yavsc.ViewModels.Manage.SetAddressViewModel { Street1 = user.PostalAddress?.Address } );
|
return View (user.PostalAddress ?? new Location());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -727,7 +727,7 @@ namespace Yavsc.Controllers
|
|||||||
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetAddressSuccess });
|
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetAddressSuccess });
|
||||||
}
|
}
|
||||||
ViewBag.GoogleSettings = _googleSettings;
|
ViewBag.GoogleSettings = _googleSettings;
|
||||||
return View(new Yavsc.ViewModels.Manage.SetAddressViewModel { Street1 = model.Address});
|
return View(model);
|
||||||
}
|
}
|
||||||
public async Task<IActionResult> PaymentInfo (string id)
|
public async Task<IActionResult> PaymentInfo (string id)
|
||||||
{
|
{
|
||||||
|
@ -303,8 +303,7 @@ namespace Yavsc
|
|||||||
if (!_cxManager.Kick(Context.ConnectionId, userName, roomName, reason)) return;
|
if (!_cxManager.Kick(Context.ConnectionId, userName, roomName, reason)) return;
|
||||||
}
|
}
|
||||||
var ukeys = _cxManager.GetConnexionIds(userName);
|
var ukeys = _cxManager.GetConnexionIds(userName);
|
||||||
|
if (ukeys!=null) foreach(var ukey in ukeys)
|
||||||
foreach(var ukey in ukeys)
|
|
||||||
Groups.Remove(ukey, roomGroupName);
|
Groups.Remove(ukey, roomGroupName);
|
||||||
Clients.Group(roomGroupName).notifyRoom(NotificationTypes.Kick, roomName, $"{userName}: {reason}");
|
Clients.Group(roomGroupName).notifyRoom(NotificationTypes.Kick, roomName, $"{userName}: {reason}");
|
||||||
}
|
}
|
||||||
@ -403,7 +402,7 @@ namespace Yavsc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var cxIds = _cxManager.GetConnexionIds(userName);
|
var cxIds = _cxManager.GetConnexionIds(userName);
|
||||||
|
if (cxIds!=null)
|
||||||
foreach (var connectionId in cxIds)
|
foreach (var connectionId in cxIds)
|
||||||
{
|
{
|
||||||
var cli = Clients.Client(connectionId);
|
var cli = Clients.Client(connectionId);
|
||||||
|
@ -263,7 +263,7 @@ namespace Yavsc.Services
|
|||||||
|
|
||||||
public IEnumerable<string> GetConnexionIds(string userName)
|
public IEnumerable<string> GetConnexionIds(string userName)
|
||||||
{
|
{
|
||||||
return ChatCxIds[userName];
|
return ChatCxIds.ContainsKey(userName) ? ChatCxIds[userName] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -111,8 +111,8 @@ namespace Yavsc.Services
|
|||||||
result.message_id = mailSent.MessageId;
|
result.message_id = mailSent.MessageId;
|
||||||
response.success++;
|
response.success++;
|
||||||
}
|
}
|
||||||
var cxids = _cxManager.GetConnexionIds(user.UserName).ToArray();
|
var cxids = _cxManager.GetConnexionIds(user.UserName);
|
||||||
if (cxids.Length == 0)
|
if (cxids == null)
|
||||||
{
|
{
|
||||||
_logger.LogDebug($"no cx to {user.UserName} <{user.Email}> ");
|
_logger.LogDebug($"no cx to {user.UserName} <{user.Email}> ");
|
||||||
}
|
}
|
||||||
|
@ -58,4 +58,11 @@
|
|||||||
<script src="~/js/dropzone.js"></script>
|
<script src="~/js/dropzone.js"></script>
|
||||||
@{ await Html.RenderPartialAsync("_FSScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_FSScriptsPartial"); }
|
||||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
if (typeof(allowCircleToBlog) !== 'undefined') {
|
||||||
|
$('input.Blogcirle[type=checkbox]').on('change', allowCircleToBlog);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
ViewData["Title"] = SR["Blog post edition"];
|
ViewData["Title"] = SR["Blog post edition"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@section header{
|
@section header {
|
||||||
|
|
||||||
<link href="~/css/main/quill.snow.css" rel="stylesheet">
|
<link href="~/css/main/quill.snow.css" rel="stylesheet">
|
||||||
<link href="~/css/main/dropzone.css" rel="stylesheet">
|
<link href="~/css/main/dropzone.css" rel="stylesheet">
|
||||||
@ -35,9 +35,18 @@
|
|||||||
<script src="~/js/dropzone.js"></script>
|
<script src="~/js/dropzone.js"></script>
|
||||||
<script src="~/js/quill.js"></script>
|
<script src="~/js/quill.js"></script>
|
||||||
<script src="~/js/to-markdown.js"></script>
|
<script src="~/js/to-markdown.js"></script>
|
||||||
|
|
||||||
|
|
||||||
@{ await Html.RenderPartialAsync("_FSScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_FSScriptsPartial"); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@section scripts {
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
if (typeof(allowCircleToBlog) !== 'undefined') {
|
||||||
|
$('input.Blogcirle[type=checkbox]').on('change', allowCircleToBlog);
|
||||||
|
}
|
||||||
$(".mdcoding").addClass('hidden');
|
$(".mdcoding").addClass('hidden');
|
||||||
|
|
||||||
var onchange = function(){
|
var onchange = function(){
|
||||||
@ -101,6 +110,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@Html.Partial("_ValidationScriptsPartial")
|
@Html.Partial("_ValidationScriptsPartial")
|
||||||
|
|
||||||
}
|
}
|
||||||
<h2 > @SR["Blog post edition"] </h2>
|
<h2 > @SR["Blog post edition"] </h2>
|
||||||
<label><input type="checkbox" id="vcbtn" />Editer le code source Markdown</label>
|
<label><input type="checkbox" id="vcbtn" />Editer le code source Markdown</label>
|
||||||
|
@ -1,27 +1,18 @@
|
|||||||
@model RdvQuery
|
@model RdvQuery
|
||||||
@{ ViewData["Title"] = $"Proposition de rendez-vous à {Model.PerformerProfile.Performer.UserName} [{ViewBag.Activity.Name}]"; }
|
@section header {
|
||||||
@section scripts {
|
<style>
|
||||||
|
#map {
|
||||||
|
width: 100%;
|
||||||
|
height: 250px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript" src="~/lib/moment/moment-with-locales.min.js"></script>
|
<script type="text/javascript" src="~/lib/moment/moment-with-locales.min.js"></script>
|
||||||
<script type="text/javascript" src="~/lib/eonasdan-bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
<script type="text/javascript" src="~/lib/eonasdan-bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
||||||
<link rel="stylesheet" href="~/lib/eonasdan-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
|
<link rel="stylesheet" href="~/lib/eonasdan-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
|
||||||
<style>
|
|
||||||
#map {
|
|
||||||
width: 100%;
|
|
||||||
height: 250px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
|
|
||||||
$('#datetimepicker2').datetimepicker({
|
|
||||||
locale: 'fr',
|
|
||||||
format: "YYYY/MM/DD HH:mm"
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
}
|
}
|
||||||
|
@{ ViewData["Title"] = $"Proposition de rendez-vous à {Model.PerformerProfile.Performer.UserName} [{ViewBag.Activity.Name}]"; }
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h2>@ViewData["Title"]</h2>
|
||||||
<form asp-action="Create" method="post">
|
<form asp-action="Create" method="post">
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
@ -30,7 +21,7 @@
|
|||||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
||||||
<div class="form-group" has-feedback>
|
<div class="form-group" has-feedback>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Votre évennement</legend>
|
<legend>La date de votre évennement</legend>
|
||||||
<label for="EventDate" class="col-md-2 control-label">
|
<label for="EventDate" class="col-md-2 control-label">
|
||||||
Date de l'évennement
|
Date de l'évennement
|
||||||
</label>
|
</label>
|
||||||
@ -41,80 +32,83 @@
|
|||||||
<div class='input-group date' id='datetimepicker2'>
|
<div class='input-group date' id='datetimepicker2'>
|
||||||
<input class="form-control" name="EventDate" />
|
<input class="form-control" name="EventDate" />
|
||||||
<span class="input-group-addon">
|
<span class="input-group-addon">
|
||||||
<span class="glyphicon glyphicon-calendar"></span>
|
<span class="glyphicon glyphicon-calendar"></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span asp-validation-for="EventDate" class="text-danger">
|
<span asp-validation-for="EventDate" class="text-danger">
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
<div class="form-group">
|
||||||
<label for="Location_Address" class="col-md-2 control-label">
|
<fieldset>
|
||||||
Lieu
|
<label asp-for="Location.Address" class="col-md-2 control-label">@SR["Address"]</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<input asp-for="Location.Address" class="form-control" type="text" data-val-required="Spécifier un lieu" />
|
||||||
|
|
||||||
|
<span id="AddressError" asp-validation-for="Location.Address" class="text-danger"></span>
|
||||||
|
<ul id="LocationCombo" >
|
||||||
|
</ul>
|
||||||
|
<div id="map"></div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<fieldset>
|
||||||
|
<label asp-for="Reason" class="col-md-2 control-label">
|
||||||
|
Donnez ici une raison à cette demande
|
||||||
</label>
|
</label>
|
||||||
<div class="col-md-10">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class='col-sm-6'>
|
|
||||||
<div >
|
|
||||||
<input asp-for="Location.Address" type="text" name="Location.Address" id="Location_Address" class="form-control"
|
|
||||||
data-val-required="Spécifier un lieu" >
|
|
||||||
<span asp-validation-for="Location.Address" class="text-danger"></span>
|
|
||||||
<ul id="loccomb">
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="map" class="map" data-val="valloc" data-addr="Location_Address" data-loccombo="loccomb" data-lat="Location_Latitude" data-lon="Location_Longitude" ></div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<label asp-for="Reason" class="col-md-2 control-label">
|
|
||||||
Donnez ici une raison à cette demande
|
|
||||||
</label>
|
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='col-sm-6'>
|
<div class='col-sm-6'>
|
||||||
<div id='reason1'>
|
<div id='reason1'>
|
||||||
<textarea rows="15" asp-for="Reason" type="text" name="Reason" id="Reason" maxlength="4096" class="form-control"></textarea>
|
<textarea rows="15" asp-for="Reason" type="text" name="Reason" id="Reason" maxlength="4096" class="form-control"></textarea>
|
||||||
<span asp-validation-for="Reason" class="text-danger"></span>
|
<span asp-validation-for="Reason" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
<dl>
|
</div>
|
||||||
<dt>@SR["Coordonées GPS"]
|
</div>
|
||||||
</dt>
|
</div>
|
||||||
<dd>
|
</div>
|
||||||
<input class="text-box" id="Location_Latitude" name="Location.Latitude" type="text" value="@Model.Location.Latitude" readonly/>
|
</fieldset>
|
||||||
<input class="text-box" id="Location_Longitude" name="Location.Longitude" type="text" value="@Model.Location.Longitude" readonly/>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-offset-2 col-md-10">
|
||||||
|
<input type="submit" class="btn btn-default" value="Créer" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@Html.HiddenFor(model=>model.ClientId)
|
||||||
</fieldset>
|
@Html.HiddenFor(model=>model.PerformerId)
|
||||||
</div>
|
@Html.HiddenFor(model=>model.ActivityCode)
|
||||||
<div class="form-group">
|
@Html.HiddenFor(model=>model.Location.Latitude)
|
||||||
<div class="col-md-offset-2 col-md-10">
|
@Html.Hidden("Location.Longitude")
|
||||||
|
|
||||||
<input type="submit" class="btn btn-default" value="Créer" />
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@Html.HiddenFor(model=>model.ClientId)
|
|
||||||
@Html.HiddenFor(model=>model.PerformerId)
|
|
||||||
@Html.HiddenFor(model=>model.ActivityCode)
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@section scripts {
|
||||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
@{ await Html.RenderPartialAsync("_MapScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_MapScriptsPartial"); }
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#Location_Address").googlegeocode({
|
||||||
|
culture: '@System.Globalization.CultureInfo.CurrentCulture.Name',
|
||||||
|
mapsApiKey: '@Startup.GoogleSettings.BrowserApiKey',
|
||||||
|
mapId: 'map',
|
||||||
|
longId: 'Location_Longitude',
|
||||||
|
latId: 'Location_Latitude',
|
||||||
|
addrValidationId: 'AddressError',
|
||||||
|
formValidId: 'ValidationSummary',
|
||||||
|
locComboId: 'LocationCombo'});
|
||||||
|
|
||||||
|
$('#datetimepicker2').datetimepicker({
|
||||||
|
locale: 'fr',
|
||||||
|
format: "YYYY/MM/DD HH:mm"
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
}
|
@ -99,7 +99,7 @@
|
|||||||
<input asp-for="OrganizationAddress.Address" class="form-control" type="text" />
|
<input asp-for="OrganizationAddress.Address" class="form-control" type="text" />
|
||||||
|
|
||||||
<span id="AddressError" asp-validation-for="OrganizationAddress.Address" class="text-danger"></span>
|
<span id="AddressError" asp-validation-for="OrganizationAddress.Address" class="text-danger"></span>
|
||||||
<ul id="loccomb" >
|
<ul id="LocationCombo" >
|
||||||
</ul>
|
</ul>
|
||||||
<div id="map" class="map" data-val="valloc" data-addr="OrganizationAddress_Address" data-loccombo="loccomb" data-lat="OrganizationAddress_Latitude" data-lon="OrganizationAddress_Longitude" data-val-slat="@Model.OrganizationAddress.Latitude" data-val-slon="@Model.OrganizationAddress.Longitude" ></div>
|
<div id="map" class="map" data-val="valloc" data-addr="OrganizationAddress_Address" data-loccombo="loccomb" data-lat="OrganizationAddress_Latitude" data-lon="OrganizationAddress_Longitude" data-val-slat="@Model.OrganizationAddress.Latitude" data-val-slon="@Model.OrganizationAddress.Longitude" ></div>
|
||||||
|
|
||||||
@ -118,8 +118,20 @@
|
|||||||
@Html.Hidden("PerfomerId")
|
@Html.Hidden("PerfomerId")
|
||||||
<button type="submit" class="btn btn-default">@SR["UnsetActivity"]</button>
|
<button type="submit" class="btn btn-default">@SR["UnsetActivity"]</button>
|
||||||
</form>
|
</form>
|
||||||
|
@section scripts {
|
||||||
|
|
||||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
@{ await Html.RenderPartialAsync("_MapScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_MapScriptsPartial"); }
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#OrganizationAddress_Address").googlegeocode({
|
||||||
|
culture: '@System.Globalization.CultureInfo.CurrentCulture.Name',
|
||||||
|
mapsApiKey: '@Startup.GoogleSettings.BrowserApiKey',
|
||||||
|
mapId: 'map',
|
||||||
|
longId: 'OrganizationAddress_Longitude',
|
||||||
|
latId: 'OrganizationAddress_Latitude',
|
||||||
|
addrValidationId: 'AddressError',
|
||||||
|
formValidId: 'ValidationSummary',
|
||||||
|
locComboId: 'LocationCombo'})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
}
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
@model SetAddressViewModel
|
@model Location
|
||||||
|
@section header {
|
||||||
<style>
|
<style>
|
||||||
#map {
|
#amap {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 250px;
|
height: 250px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
}
|
||||||
|
|
||||||
<form asp-action="SetAddress">
|
<form asp-action="SetAddress">
|
||||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger" id="ValidationSummary"></div>
|
<div asp-validation-summary="ValidationSummary.All" class="text-danger" id="ValidationSummary"></div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
<label asp-for="Street1" class="col-md-2 control-label">@SR["Address"]</label>
|
<label asp-for="Address" class="col-md-2 control-label">@SR["Address"]</label>
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<input asp-for="Street1" class="form-control" type="text" />
|
<input asp-for="Address" class="form-control" type="text" data-val-required="Spécifier un lieu" />
|
||||||
|
|
||||||
<span id="AddressError" asp-validation-for="Street1" class="text-danger"></span>
|
<span id="AddressError" asp-validation-for="Address" class="text-danger"></span>
|
||||||
<ul id="LocationCombo" >
|
<ul id="LocationCombo" >
|
||||||
</ul>
|
</ul>
|
||||||
<div id="map"></div>
|
<div id="amap"></div>
|
||||||
|
<input class="text-box" id="Latitude" name="Latitude" type="hidden" value="@Model.Latitude" readonly/>
|
||||||
|
<input class="text-box" id="Longitude" name="Longitude" type="hidden" value="@Model.Longitude" readonly/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="submit" class="btn btn-success" value="Enregistrer" />
|
<input type="submit" class="btn btn-success" value="Enregistrer" />
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@section scripts {
|
||||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
|
@{ await Html.RenderPartialAsync("_MapScriptsPartial"); }
|
||||||
@section scripts {
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?key=@ViewBag.GoogleSettings.BrowserApiKey"></script>
|
$("#Address").googlegeocode({
|
||||||
<script src="~/js/google-geoloc.js" asp-append-version="true"></script>
|
culture: '@System.Globalization.CultureInfo.CurrentCulture.Name',
|
||||||
<script >
|
mapsApiKey: '@Startup.GoogleSettings.BrowserApiKey',
|
||||||
$(document).ready(function(){
|
mapId: 'amap',
|
||||||
$.validator.setDefaults({
|
longId: 'Longitude',
|
||||||
messages: {
|
latId: 'Latitude',
|
||||||
remote: "Ce lieu n'est pas identifié par les services de géo-localisation Google",
|
addrValidationId: 'AddressError',
|
||||||
required: "Veuillez renseigner ce champ"
|
formValidId: 'ValidationSummary',
|
||||||
}
|
locComboId: 'LocationCombo'})
|
||||||
});
|
})
|
||||||
$("#Address").googlegeocode()
|
</script>
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,6 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" href="@Startup.SiteSetup.StyleSheet" asp-append-version="true"/>
|
<link rel="stylesheet" href="@Startup.SiteSetup.StyleSheet" asp-append-version="true"/>
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
if (typeof(allowCircleToBlog) !== 'undefined') {
|
|
||||||
$('input.Blogcirle[type=checkbox]').on('change', allowCircleToBlog);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
@RenderSection("header", required: false)
|
@RenderSection("header", required: false)
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,108 +1,2 @@
|
|||||||
|
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?key=@Yavsc.Startup.GoogleSettings.BrowserApiKey"></script>
|
<script src="https://maps.googleapis.com/maps/api/js?key=@Yavsc.Startup.GoogleSettings.BrowserApiKey"></script>
|
||||||
<script>
|
<script src="~/js/google-geoloc.js" asp-append-version="true"></script>
|
||||||
$(document).ready(function(){
|
|
||||||
|
|
||||||
function setCoord(config, pos)
|
|
||||||
{
|
|
||||||
var culture = '@System.Globalization.CultureInfo.CurrentCulture.Name';
|
|
||||||
$('#'+config.latId).val(pos.lat.toLocaleString(culture, { minimumFractionDigits: 7 }));
|
|
||||||
$('#'+config.lonId).val(pos.lng.toLocaleString(culture, { minimumFractionDigits: 7 }));
|
|
||||||
}
|
|
||||||
var marker=null;
|
|
||||||
function chooseLoc(config, sender, loc) {
|
|
||||||
if (sender === 'user') $('#'+config.addrId).val(loc.formatted_address);
|
|
||||||
var pos = loc.geometry.location;
|
|
||||||
var mapid = '#'+config.addrId;
|
|
||||||
var gmap = config.gmap;
|
|
||||||
gmap.setCenter(pos);
|
|
||||||
setCoord(config, pos);
|
|
||||||
if (marker!=null) {
|
|
||||||
marker.position = pos;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
marker = new google.maps.Marker({
|
|
||||||
map: gmap,
|
|
||||||
draggable: true,
|
|
||||||
animation: google.maps.Animation.DROP,
|
|
||||||
position: pos
|
|
||||||
});
|
|
||||||
google.maps.event.addListener(marker, 'dragend', function() {
|
|
||||||
var pos = marker.getPosition();
|
|
||||||
setCoord(config, { lat: pos.lat(), lng: pos.lng() });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#'+config.addrId).valid();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupInputAddress (mapDiv)
|
|
||||||
{
|
|
||||||
var config = {
|
|
||||||
mapId: $(mapDiv).attr('id'),
|
|
||||||
addrId: $(mapDiv).data('addr'),
|
|
||||||
lonId: $(mapDiv).data('lon'),
|
|
||||||
latId: $(mapDiv).data('lat'),
|
|
||||||
locComboId: $(mapDiv).data('loccombo')
|
|
||||||
};
|
|
||||||
var scenter = { lat: parseFloat($('#'+config.latId).val().replace(',','.')), lng: parseFloat($('#'+config.lonId).val().replace(',','.')) } ;
|
|
||||||
var input = '#'+config.addrId;
|
|
||||||
$(input).data("val-required", '@SR["SpecifyPlace"]') ;
|
|
||||||
$(input).data("val-remote", '@SR[ "GoogleDidntGeoLocalized"]') ;
|
|
||||||
$(input).rules("add",
|
|
||||||
{
|
|
||||||
remote: {
|
|
||||||
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
|
||||||
type: 'get',
|
|
||||||
data: {
|
|
||||||
key: '@Startup.GoogleSettings.BrowserApiKey',
|
|
||||||
sensor: false,
|
|
||||||
address: function () { return $('#'+config.addrId).val() }
|
|
||||||
},
|
|
||||||
dataType: 'json',
|
|
||||||
dataFilter: function(datastr,type) {
|
|
||||||
$('#'+config.locComboId).html("");
|
|
||||||
var data = JSON.parse(datastr);
|
|
||||||
data.results.forEach(function(element) {
|
|
||||||
if (element.formatted_address !== $('#'+config.addrId).val()) {
|
|
||||||
$('<li style="pointer:cursor;">'+element.formatted_address+'</li>')
|
|
||||||
.data("geoloc",element)
|
|
||||||
.click(function() { chooseLoc(config, 'user', $(this).data("geoloc")) })
|
|
||||||
.appendTo($('#'+config.locComboId));}
|
|
||||||
});
|
|
||||||
if ((data.status === 'OK') && (data.results.length == 1))
|
|
||||||
{
|
|
||||||
chooseLoc(config, 'google', data.results[0]);
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
error: function(xhr, textStatus, errorThrown)
|
|
||||||
{
|
|
||||||
console.log('ajax loading error ... '+textStatus+' ... '+ errorThrown);
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var gmap = new google.maps.Map(document.getElementById(config.mapId), {
|
|
||||||
zoom: 8,
|
|
||||||
center: scenter
|
|
||||||
});
|
|
||||||
|
|
||||||
config.gmap = gmap;
|
|
||||||
marker = new google.maps.Marker({
|
|
||||||
map: gmap,
|
|
||||||
draggable: true,
|
|
||||||
animation: google.maps.Animation.DROP,
|
|
||||||
position: scenter
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
$("div.map").each(function(indexMap){
|
|
||||||
setupInputAddress(this)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
@ -1,71 +1,92 @@
|
|||||||
if (typeof jQuery === 'undefined') {
|
if (typeof jQuery === 'undefined') {
|
||||||
throw new Error('Bootstrap\'s JavaScript requires jQuery')
|
throw new Error('This Google maps client script requires jQuery')
|
||||||
|
}
|
||||||
|
if (typeof google === 'undefined') {
|
||||||
|
throw new Error('This Google maps client script requires google')
|
||||||
}
|
}
|
||||||
|
|
||||||
+
|
|
||||||
(function($, maps) {
|
(function($, maps) {
|
||||||
$.widget("psc.googlegeocode", {
|
$.widget('psc.googlegeocode', {
|
||||||
options: {
|
options: {
|
||||||
|
culture: 'fr',
|
||||||
mapId: 'map',
|
mapId: 'map',
|
||||||
longId: 'Longitude',
|
longId: 'Longitude',
|
||||||
latId: 'Latitude',
|
latId: 'Latitude',
|
||||||
addrValidationId: 'AddressError',
|
addrValidationId: 'AddressError',
|
||||||
formValidId: 'ValidationSummary',
|
formValidId: 'ValidationSummary',
|
||||||
locComboId: 'LocationCombo'
|
locComboId: 'LocationCombo',
|
||||||
|
specifyPlaceMsg: 'Specify a place',
|
||||||
|
GoogleDidntGeoLocalizedMsg: 'Google didn\'t reconized this address'
|
||||||
},
|
},
|
||||||
marker: null,
|
marker: null,
|
||||||
gmap: null,
|
gmap: null,
|
||||||
|
onDragEnd: function(_this) {
|
||||||
|
// TODO reverse geo code
|
||||||
|
var npos = _this.marker.getPosition();
|
||||||
|
var nlat = Number(npos.lat());
|
||||||
|
var nlng = Number(npos.lng());
|
||||||
|
$('#' + _this.options.latId).val(nlat.toLocaleString(_this.options.culture, { minimumFractionDigits: 8 }));
|
||||||
|
$('#' + _this.options.longId).val(nlng.toLocaleString(_this.options.culture, { minimumFractionDigits: 8 }));
|
||||||
|
},
|
||||||
_create: function() {
|
_create: function() {
|
||||||
this.element.addClass("googlegeocode");
|
var _this = this;
|
||||||
|
var scenter = { lat: parseFloat($('#' + _this.options.latId).val().replace(',', '.')),
|
||||||
|
lng: parseFloat($('#' + _this.options.longId).val().replace(',', '.')) };
|
||||||
|
this.element.addClass('googlegeocode');
|
||||||
this.gmap = new maps.Map(document.getElementById(this.options.mapId), {
|
this.gmap = new maps.Map(document.getElementById(this.options.mapId), {
|
||||||
zoom: 16,
|
zoom: 16,
|
||||||
center: { lat: 48.862854, lng: 2.2056466 }
|
center: scenter
|
||||||
});
|
});
|
||||||
var _this = this;
|
this.marker = new maps.Marker({
|
||||||
this.element.rules("add", {
|
map: this.gmap,
|
||||||
|
draggable: true,
|
||||||
|
animation: maps.Animation.DROP,
|
||||||
|
position: scenter
|
||||||
|
});
|
||||||
|
maps.event.addListener(this.marker, 'dragend', function() { _this.onDragEnd(_this) });
|
||||||
|
this.element.data('val-required', this.options.specifyPlaceMsg);
|
||||||
|
this.element.data('val-remote', this.options.GoogleDidntGeoLocalizedMsg);
|
||||||
|
this.element.rules('add', {
|
||||||
remote: {
|
remote: {
|
||||||
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: {
|
data: {
|
||||||
|
key: _this.options.mapsApiKey,
|
||||||
sensor: false,
|
sensor: false,
|
||||||
address: function() { return _this.element.val() }
|
address: function() {
|
||||||
|
return _this.element.val();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
dataFilter: function(datastr) {
|
dataFilter: function(datastr) {
|
||||||
$('#' + _this.options.locComboId).html("");
|
var ul = $('#' + _this.options.locComboId);
|
||||||
|
ul.html('');
|
||||||
var data = JSON.parse(datastr);
|
var data = JSON.parse(datastr);
|
||||||
data.results.forEach(function(item) {
|
data.results.forEach(function(item) {
|
||||||
if (item.formatted_address !== _this.element.val()) {
|
$('<li>' + item.formatted_address + '</li>')
|
||||||
$('<li>' + item.formatted_address + '</li>')
|
.data('geoloc', item)
|
||||||
.data("geoloc", item)
|
.click(function() { _this.chooseLoc('user', item) })
|
||||||
.click(function() { _this.chooseLoc('user', item) })
|
.css('cursor', 'pointer')
|
||||||
.css('cursor', 'pointer')
|
.appendTo(ul);
|
||||||
.appendTo($('#' + _this.options.locComboId));
|
|
||||||
} else {}
|
|
||||||
});
|
});
|
||||||
if ((data.status === 'OK') && (data.results.length == 1)) {
|
if ((data.status === 'OK') && (data.results.length >= 1)) {
|
||||||
// _this.chooseLoc('google',data.results[0]);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
// xhr, textStatus, errorThrown console.log('ajax loading error ... '+textStatus+' ... '+ errorThrown);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
chooseLoc: function(sender, loc) {
|
chooseLoc: function(sender, loc) {
|
||||||
|
var _this = this;
|
||||||
if (sender === 'user') this.element.val(loc.formatted_address);
|
if (sender === 'user') this.element.val(loc.formatted_address);
|
||||||
var pos = loc.geometry.location;
|
var pos = loc.geometry.location;
|
||||||
var lat = new Number(pos.lat);
|
var lat = Number(pos.lat);
|
||||||
var lng = new Number(pos.lng);
|
var lng = Number(pos.lng);
|
||||||
$(document.getElementById(this.options.latId)).val(lat.toLocaleString('en'));
|
$(document.getElementById(this.options.latId)).val(lat.toLocaleString(this.options.culture, { minimumFractionDigits: 8 }));
|
||||||
$(document.getElementById(this.options.longId)).val(lng.toLocaleString('en'));
|
$(document.getElementById(this.options.longId)).val(lng.toLocaleString(this.options.culture, { minimumFractionDigits: 8 }));
|
||||||
this.gmap.setCenter(pos);
|
this.gmap.setCenter(pos);
|
||||||
if (this.marker) {
|
if (this.marker) {
|
||||||
this.marker.setMap(null);
|
this.marker.setMap(null);
|
||||||
}
|
}
|
||||||
this.marker = new maps.Marker({
|
this.marker = new maps.Marker({
|
||||||
@ -74,18 +95,12 @@ if (typeof jQuery === 'undefined') {
|
|||||||
animation: maps.Animation.DROP,
|
animation: maps.Animation.DROP,
|
||||||
position: pos
|
position: pos
|
||||||
});
|
});
|
||||||
maps.event.addListener(this.marker, 'dragend', function() {
|
maps.event.addListener(this.marker, 'dragend', function() { _this.onDragEnd(_this) });
|
||||||
// TODO reverse geo code
|
|
||||||
var pos = this.marker.getPosition();
|
|
||||||
$('#' + this.options.latId).val(pos.lat);
|
|
||||||
$('#' + this.options.longId).val(pos.lng);
|
|
||||||
});
|
|
||||||
this.element.valid();
|
this.element.valid();
|
||||||
$('#' + this.options.addrValidationId).empty();
|
$('#' + this.options.addrValidationId).empty();
|
||||||
$('#' + this.options.formValidId).empty();
|
$('#' + this.options.formValidId).empty();
|
||||||
$('#' + this.options.locComboId).empty();
|
$('#' + this.options.locComboId).empty();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})(jQuery, google.maps);
|
})(jQuery, google.maps);
|
||||||
|
Reference in New Issue
Block a user