Reset All SMS and Tag bug fixes
This commit is contained in:
parent
7dcf8d38c8
commit
78e7e18631
|
@ -156,7 +156,6 @@ namespace Core.Main.DataObjects.PTMagicData
|
||||||
{
|
{
|
||||||
public string SettingName { get; set; }
|
public string SettingName { get; set; }
|
||||||
public string TriggerConnection { get; set; } = "AND";
|
public string TriggerConnection { get; set; } = "AND";
|
||||||
public string TriggerLogic { get; set; } = "";
|
|
||||||
public List<Trigger> Triggers { get; set; } = new List<Trigger>();
|
public List<Trigger> Triggers { get; set; } = new List<Trigger>();
|
||||||
public Dictionary<string, object> PairsProperties { get; set; } = new Dictionary<string, object>();
|
public Dictionary<string, object> PairsProperties { get; set; } = new Dictionary<string, object>();
|
||||||
public Dictionary<string, object> DCAProperties { get; set; } = new Dictionary<string, object>();
|
public Dictionary<string, object> DCAProperties { get; set; } = new Dictionary<string, object>();
|
||||||
|
|
|
@ -1408,15 +1408,15 @@ namespace Core.Main
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// New logic
|
// New logic
|
||||||
string triggerLogic = globalSetting.TriggerConnection;
|
string triggerConnection = globalSetting.TriggerConnection;
|
||||||
foreach (var triggerResult in triggerResults)
|
foreach (var triggerResult in triggerResults)
|
||||||
{
|
{
|
||||||
triggerLogic = triggerLogic.Replace(triggerResult.Key, triggerResult.Value.ToString().ToLower());
|
triggerConnection = triggerConnection.Replace(triggerResult.Key, triggerResult.Value.ToString().ToLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool settingTriggered = (bool)System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(System.Linq.Dynamic.Core.ParsingConfig.Default, new ParameterExpression[0], typeof(bool), triggerLogic).Compile().DynamicInvoke();
|
bool settingTriggered = (bool)System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(System.Linq.Dynamic.Core.ParsingConfig.Default, new ParameterExpression[0], typeof(bool), triggerConnection).Compile().DynamicInvoke();
|
||||||
|
|
||||||
// Setting got triggered -> Activate it!
|
// Setting got triggered -> Activate it!
|
||||||
if (settingTriggered)
|
if (settingTriggered)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<td><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)SettingsAnalyzer#SingleMarketSetting_@sms">@sms</a>: @smsCount    </td>
|
<td><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)SettingsAnalyzer#SingleMarketSetting_@sms">@sms</a>: @smsCount    </td>
|
||||||
}
|
}
|
||||||
@if (Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected) {
|
@if (Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected) {
|
||||||
<a class="btn btn-danger btn-sm btn-custom btn-block text-uppercase btn-deletefile" style="margin-top: 10px;" data-filename="SingleMarketSettingSummary.json" href="#">Reset ALL Single MarketSettings</a>
|
<a class="btn btn-danger btn-sm btn-custom btn-block text-uppercase btn-deleteall" style="margin-top: 10px;" data-filename="SingleMarketSettingSummary.json" href="#">Reset ALL Single MarketSettings</a>
|
||||||
} else {
|
} else {
|
||||||
<a class="btn btn-danger btn-custom btn-block text-uppercase" data-toggle="tooltip" data-placement="top" title="This is only accessible when you protect your monitor with a password!"><i class="fa fa-lock text-danger"></i> Delete File</a>
|
<a class="btn btn-danger btn-custom btn-block text-uppercase" data-toggle="tooltip" data-placement="top" title="This is only accessible when you protect your monitor with a password!"><i class="fa fa-lock text-danger"></i> Delete File</a>
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
Do you really want to reset ALL Single Market Settings for the next Analyzer run?
|
Do you really want to reset this Single Market Settings for the next Analyzer run?
|
||||||
<p class="m-t-10"><span class="text-warning">Please note:</span> Even if you reset a setting, it may get triggered again on the next run depending on current market conditions.</p>
|
<p class="m-t-10"><span class="text-warning">Please note:</span> Even if you reset a setting, it may get triggered again on the next run depending on current market conditions.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
<p class="m-t-10"><span class="text-warning">Please note:</span> Even if you reset your settings, they may get triggered again on the next run depending on current market conditions.</p>
|
<p class="m-t-10"><span class="text-warning">Please note:</span> Even if you reset your settings, they may get triggered again on the next run depending on current market conditions.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-ptmagic text-uppercase waves-effect waves-light btn-resetsetting" data-datatarget="" data-setting="">Yes, do it!</button>
|
<button type="button" class="btn btn-ptmagic text-uppercase waves-effect waves-light btn-confirmdelete" data-datatarget="" data-setting="">Yes, do it!</button>
|
||||||
<button type="button" class="btn btn-secondary text-uppercase" data-dismiss="modal">No...</button>
|
<button type="button" class="btn btn-secondary text-uppercase" data-dismiss="modal">No...</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -236,41 +236,64 @@
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).on('click', '.btn-deletefile', function(e) {
|
$(document).on('click', '.btn-deleteall', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var filename = $(this).data("filename");
|
var filename = $(this).data("filename");
|
||||||
|
|
||||||
|
// Store the filename in the modal's data
|
||||||
|
$('#modalDeleteFile').data('filename', filename);
|
||||||
|
|
||||||
// Show the modal
|
// Show the modal
|
||||||
$('#modalDeleteFile').modal('show');
|
$('#modalDeleteFile').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
// Attach a one-time event handler for the 'Yes, do it!' button in the modal
|
$(document).on('click', '.btn-confirmdelete', function(e) {
|
||||||
$('.btn-deletefile').one('click', function() {
|
e.preventDefault();
|
||||||
var baseUrl = "@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)";
|
|
||||||
var endpoint = "ManageSMS?handler=DeleteFile";
|
|
||||||
var url = baseUrl + endpoint;
|
|
||||||
|
|
||||||
$.ajax({
|
// Retrieve the filename from the modal's data
|
||||||
url: url,
|
var filename = $('#modalDeleteFile').data('filename');
|
||||||
type: 'POST',
|
|
||||||
beforeSend: function(xhr) {
|
var baseUrl = "@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)";
|
||||||
xhr.setRequestHeader("XSRF-TOKEN",
|
var endpoint = "ManageSMS?handler=DeleteFile";
|
||||||
$('input:hidden[name="__RequestVerificationToken"]').val());
|
var url = baseUrl + endpoint;
|
||||||
},
|
|
||||||
data: { filename: filename },
|
$.ajax({
|
||||||
success: function(result) {
|
url: url,
|
||||||
// Update the modal's content
|
type: 'POST',
|
||||||
$('#modalDeleteFile .modal-title').text('Success');
|
beforeSend: function(xhr) {
|
||||||
$('#modalDeleteFile .modal-body').html(result.message);
|
xhr.setRequestHeader("XSRF-TOKEN",
|
||||||
},
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
||||||
error: function(xhr, status, error) {
|
},
|
||||||
var response = JSON.parse(xhr.responseText);
|
data: { filename: filename },
|
||||||
// Show an alert for error
|
success: function(result) {
|
||||||
alert(response.message);
|
if (result.success) {
|
||||||
}
|
// If the server returned success, display the success message
|
||||||
});
|
$.Notification.notify('success', 'top left', 'Success', result.message);
|
||||||
|
// Wait for 5 seconds, then refresh the page
|
||||||
|
setTimeout(function() {
|
||||||
|
location.reload();
|
||||||
|
}, 5000);
|
||||||
|
} else {
|
||||||
|
// If the server returned failure, display the error message
|
||||||
|
$.Notification.notify('error', 'top left', 'Error', result.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the modal
|
||||||
|
$('#modalDeleteFile').modal('hide');
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
var response = JSON.parse(xhr.responseText);
|
||||||
|
// Show an alert for error
|
||||||
|
alert(response.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$('#modalDeleteFile').on('hidden.bs.modal', function (e) {
|
||||||
|
// Reset the modal's content
|
||||||
|
$('#modalDeleteFile .modal-title').text('Are you sure?');
|
||||||
|
$('#modalDeleteFile .modal-body').html('Do you really want to reset ALL Single Market Settings for the next Analyzer run? <p class="m-t-10"><span class="text-warning">Please note:</span> Even if you reset your settings, they may get triggered again on the next run depending on current market conditions.</p>');
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ namespace Monitor.Pages
|
||||||
string webRootParent = Directory.GetParent(_hostingEnvironment.WebRootPath).FullName;
|
string webRootParent = Directory.GetParent(_hostingEnvironment.WebRootPath).FullName;
|
||||||
string ptMagicRoot = Directory.GetParent(webRootParent).FullName;
|
string ptMagicRoot = Directory.GetParent(webRootParent).FullName;
|
||||||
string analyzerStatePath = Path.Combine(ptMagicRoot, "_data", "AnalyzerState");
|
string analyzerStatePath = Path.Combine(ptMagicRoot, "_data", "AnalyzerState");
|
||||||
Console.WriteLine("analyzerStatePath: " + analyzerStatePath);
|
|
||||||
|
|
||||||
// Read the AnalyzerState file
|
// Read the AnalyzerState file
|
||||||
if (System.IO.File.Exists(analyzerStatePath))
|
if (System.IO.File.Exists(analyzerStatePath))
|
||||||
|
|
Loading…
Reference in New Issue