docs: #272 enabling and disabling user tracking UI
This commit is contained in:
parent
101135da81
commit
cfc3d37656
@ -33,6 +33,38 @@ else
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function switchTracking(start) {
|
||||
if(start == false){
|
||||
if (!confirm('آیا از توقف ذخیرهٔ تاریخچه و حذف تاریخچهٔ بازدیدها اطمینان دارید؟'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '?handler=StopTracking',
|
||||
error: function() {
|
||||
alert('خطا رخ داد.');
|
||||
},
|
||||
success: function () {
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '?handler=StartTracking',
|
||||
error: function() {
|
||||
alert('خطا رخ داد.');
|
||||
},
|
||||
success: function () {
|
||||
location.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<p style="text-align:center">
|
||||
@foreach (var paginationLink in Model.PaginationLinks)
|
||||
|
||||
@ -12,6 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
@ -163,5 +164,43 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
}
|
||||
return new JsonResult(true);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostStopTracking()
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var response = await secureClient.PutAsync($"{APIRoot.Url}/api/tracking", new StringContent(JsonConvert.SerializeObject(false), Encoding.UTF8, "application/json"));
|
||||
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
return Redirect($"/login?redirect={Request.Path}&error={JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync())}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return new JsonResult(true);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostStartTracking()
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var response = await secureClient.PutAsync($"{APIRoot.Url}/api/tracking", new StringContent(JsonConvert.SerializeObject(true), Encoding.UTF8, "application/json"));
|
||||
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
return Redirect($"/login?redirect={Request.Path}&error={JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync())}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return new JsonResult(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"GoogleAnalyticsCode": "",
|
||||
"APIRoot": "http://localhost:3439",
|
||||
"GlobalAPIRoot": "http://localhost:3439",
|
||||
"APIRoot": "https://api.ganjoor.net",
|
||||
"GlobalAPIRoot": "https://api.ganjoor.net",
|
||||
"SiteUrl": "http://localhost:33081",
|
||||
"AggressiveCacheEnabled": "False",
|
||||
"ReadOnlyMode": "False",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user