PTMagic/Monitor/Pages/SettingsAnalyzer.cshtml

332 lines
18 KiB
Plaintext
Raw Normal View History

2018-05-22 10:11:50 +02:00
@page
@model SettingsAnalyzerModel
@{ ViewData["Title"] = "";
}
@section Styles {
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" />
}
<div class="row">
<div class="col-md-12">
<div class="card-box">
<h4 class="m-t-0 header-title">Analyzer Settings<span></span></h4>
<p>
2019-11-09 15:46:35 +01:00
In this area you may change the settings of your <b>settings.analyzer.json</b> file. <br>Please use this with caution as all settings you saved here will directly affect your PT Magic bot.
2018-05-22 10:11:50 +02:00
</p>
2019-11-09 15:46:35 +01:00
<p class="text-danger">NOTICE: When you save your settings using this interface, any existing comments will be removed from your settings.analyzer.json!</p>
2018-05-22 10:11:50 +02:00
</div>
</div>
</div>
<div class="row">
2019-11-09 15:46:35 +01:00
<div class="col-md-6">
2018-05-22 10:11:50 +02:00
<div class="card-box">
2019-11-09 15:46:35 +01:00
<h4 class="m-t-0 header-title">Restore Backup <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="PT Magic automatically creates a backup when you save your settings.analyzer.json file using this interface. If you want to go back to your previous settings, you may restore your previous settings."></i></h4>
2018-05-22 10:11:50 +02:00
<p>
You messed up your settings?<br />Restore your backup!
</p>
<button class="btn btn-ptmagic text-uppercase waves-effect waves-light" data-toggle="modal" data-target="#modalRestoreBackup" type="submit">
Restore Backup
</button>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card-box">
<div class="row">
<div class="col-md-4">
2019-11-09 15:46:35 +01:00
<h4 class="m-t-0 header-title">Market Trends (@Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends.Count) <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Click a trend to jump to it on the page. Press HOME on your keyboard to return to this list."></i></h4>
2018-05-22 10:11:50 +02:00
<ul>
@foreach (Core.Main.DataObjects.PTMagicData.MarketTrend mt in Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends) {
<li><a href="#MarketTrend_@Core.Helper.SystemHelper.StripBadCode(mt.Name, Core.Main.Constants.WhiteListNames)">@Core.Helper.SystemHelper.SplitCamelCase(mt.Name)</a></li>
}
</ul>
</div>
<div class="col-md-4">
2019-11-09 15:46:35 +01:00
<h4 class="m-t-0 header-title">Global Settings (@Model.PTMagicConfiguration.AnalyzerSettings.GlobalSettings.Count) <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Click a setting to jump to it on the page. Press HOME on your keyboard to return to this list."></i></h4>
2018-05-22 10:11:50 +02:00
<ul>
@foreach (Core.Main.DataObjects.PTMagicData.GlobalSetting gs in Model.PTMagicConfiguration.AnalyzerSettings.GlobalSettings) {
<li><a href="#GlobalSetting_@Core.Helper.SystemHelper.StripBadCode(gs.SettingName, Core.Main.Constants.WhiteListNames)">@Core.Helper.SystemHelper.SplitCamelCase(gs.SettingName)</a></li>
}
</ul>
</div>
<div class="col-md-4">
2019-11-09 15:46:35 +01:00
<h4 class="m-t-0 header-title">Single Market Settings (@Model.PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings.Count) <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Click a setting to jump to it on the page. Press HOME on your keyboard to return to this list."></i></h4>
2018-05-22 10:11:50 +02:00
<ul>
@foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSetting sms in Model.PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings) {
<li><a href="#SingleMarketSetting_@Core.Helper.SystemHelper.StripBadCode(sms.SettingName, Core.Main.Constants.WhiteListNames)">@Core.Helper.SystemHelper.SplitCamelCase(sms.SettingName)</a></li>
}
</ul>
</div>
</div>
<div class="row">
<div class="col-md-4">
<button class="btn btn-ptmagic btn-custom btn-block text-uppercase waves-effect waves-light btn-new" data-datatype="MarketTrend">
Add Market Trend
</button>
</div>
<div class="col-md-4">
2019-11-09 15:46:35 +01:00
<div class="btn-group btn-block">
<button class="btn btn-ptmagic btn-custom btn-block text-uppercase waves-effect waves-light dropdown-toggle" data-toggle="dropdown">
Add Global Setting
</button>
<div class="dropdown-menu">
@foreach (Core.Main.DataObjects.PTMagicData.GlobalSetting gs in Model.PTMagicConfiguration.AnalyzerSettings.GlobalSettings) {
<a class="dropdown-item btn-new" data-datatype="GlobalSetting" data-datatarget="@Core.Helper.SystemHelper.StripBadCode(gs.SettingName, Core.Main.Constants.WhiteListNames)">Add before <i>@Core.Helper.SystemHelper.SplitCamelCase(gs.SettingName)</i></a>
}
</div>
</div>
2018-05-22 10:11:50 +02:00
</div>
<div class="col-md-4">
2019-11-09 15:46:35 +01:00
<div class="btn-group btn-block">
<button class="btn btn-ptmagic btn-custom btn-block text-uppercase waves-effect waves-light dropdown-toggle" data-toggle="dropdown">
Add Single Market Setting
</button>
<div class="dropdown-menu">
@foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSetting sms in Model.PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings) {
<a class="dropdown-item btn-new" data-datatype="SingleMarketSetting" data-datadirection="before" data-datatarget="@Core.Helper.SystemHelper.StripBadCode(sms.SettingName, Core.Main.Constants.WhiteListNames)">Add before <i>@Core.Helper.SystemHelper.SplitCamelCase(sms.SettingName)</i></a>
}
<div class="dropdown-divider"></div>
@foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSetting sms in Model.PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings) {
<a class="dropdown-item btn-new" data-datatype="SingleMarketSetting" data-datadirection="after" data-datatarget="@Core.Helper.SystemHelper.StripBadCode(sms.SettingName, Core.Main.Constants.WhiteListNames)">Add after <i>@Core.Helper.SystemHelper.SplitCamelCase(sms.SettingName)</i></a>
}
</div>
</div>
2018-05-22 10:11:50 +02:00
</div>
</div>
</div>
</div>
</div>
<form class="form-horizontal" method="post">
<div class="row">
<div class="col-md-12">
<div class="card-box">
2019-11-09 15:46:35 +01:00
<h4 class="m-t-0 header-title">Market Analyzer</h4>
2019-11-09 15:46:35 +01:00
<div class="form-group row">
<label class="col-md-4 col-form-label">Store Data Max Hours <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Number of hours to store market data."></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="MarketAnalyzer_StoreDataMaxHours" value="@Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours.ToString()">
</div>
</div>
2019-11-09 15:46:35 +01:00
<div class="form-group row">
<label class="col-md-4 col-form-label">Interval Minutes <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Interval in minutes for PTMagic to check market trends and triggers."></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="MarketAnalyzer_IntervalMinutes" value="@Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.IntervalMinutes.ToString()">
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">Exclude Main Currency <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Excludes the main currency (for example BTC) from market trend analysis."></i></label>
<div class="col-md-8">
<input type="checkbox" name="MarketAnalyzer_ExcludeMainCurrency" checked="@(Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.ExcludeMainCurrency)" data-plugin="switchery" data-color="#81c868" data-size="small" />
2018-05-22 10:11:50 +02:00
</div>
</div>
</div>
</div>
</div>
<div id="MarketAnalyzer_MarketTrends">
@if (Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends.Count > 0) {
@foreach (Core.Main.DataObjects.PTMagicData.MarketTrend mt in Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends) {
2019-11-09 15:46:35 +01:00
<div class="settings-markettrend" data-trendname="@Core.Helper.SystemHelper.StripBadCode(mt.Name, Core.Main.Constants.WhiteListNames)" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>
2018-05-22 10:11:50 +02:00
}
} else {
<div class="row">
<div class="col-md-12">
<div class="card-box">
No Market Trends found!
</div>
</div>
</div>
}
</div>
<div id="MarketAnalyzer_GlobalSettings">
@if (Model.PTMagicConfiguration.AnalyzerSettings.GlobalSettings.Count > 0) {
@foreach (Core.Main.DataObjects.PTMagicData.GlobalSetting gs in Model.PTMagicConfiguration.AnalyzerSettings.GlobalSettings) {
2019-11-09 15:46:35 +01:00
<div class="settings-globalsetting" data-settingname="@Core.Helper.SystemHelper.StripBadCode(gs.SettingName, Core.Main.Constants.WhiteListNames)" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>
2018-05-22 10:11:50 +02:00
}
} else {
<div class="row">
<div class="col-md-12">
<div class="card-box">
No Global Settings found!
</div>
</div>
</div>
}
</div>
<div id="MarketAnalyzer_SingleMarketSettings">
@if (Model.PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings.Count > 0) {
@foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSetting sms in Model.PTMagicConfiguration.AnalyzerSettings.SingleMarketSettings) {
2019-11-09 15:46:35 +01:00
<div class="settings-singlemarketsetting" data-settingname="@Core.Helper.SystemHelper.StripBadCode(sms.SettingName, Core.Main.Constants.WhiteListNames)" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>
2018-05-22 10:11:50 +02:00
}
} else {
<div class="row">
<div class="col-md-12">
<div class="card-box">
No Single Market Settings found!
</div>
</div>
</div>
}
</div>
2019-11-09 15:46:35 +01:00
2018-05-22 10:11:50 +02:00
<div id="div-loading-settings" class="row">
<div class="col-md-12">
<div class="card-box">
<span class="btn btn-danger btn-custom btn-block text-uppercase waves-effect waves-light">
<i class="fa fa-circle-o-notch fa-spin fa-fw"></i> Loading settings, please wait...
</span>
</div>
</div>
</div>
<div id="div-save-settings" class="row hidden">
<div class="col-md-12">
<div class="card-box">
<a class="btn btn-ptmagic btn-block text-uppercase waves-effect waves-light" data-toggle="modal" data-target="#modalSaveSettings" href="#">
Save Settings
</a>
</div>
</div>
</div>
</form>
<!-- Modal -->
<div class="modal fade" id="modalRestoreBackup" tabindex="-1" role="dialog" aria-labelledby="modalRestoreBackupTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalRestoreBackupTitle">Are you sure?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Do you really want to restore a backup of your settings.analyzer.json and overwrite all current settings?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-ptmagic text-uppercase waves-effect waves-light btn-restorebackup" data-datatarget="settings.analyzer.json">Yes, do it!</button>
<button type="button" class="btn btn-secondary text-uppercase" data-dismiss="modal">No...</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="modalSaveSettings" tabindex="-1" role="dialog" aria-labelledby="modalSaveSettingsTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalSaveSettingsTitle">Are you sure?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Do you really want to save the current settings?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-ptmagic text-uppercase waves-effect waves-light btn-savesettings">Yes, do it!</button>
<button type="button" class="btn btn-secondary text-uppercase" data-dismiss="modal">No...</button>
</div>
</div>
</div>
</div>
@section Scripts {
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/switchery/js/switchery.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/js/analyzer-settings.js?v=@Html.Raw(Model.Summary.Version)"></script>
<script type="text/javascript">
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
$('.settings-markettrend').buildMarketTrendSettings();
$('.settings-globalsetting').buildGlobalSettings();
$('.settings-singlemarketsetting').buildSingleMarketSettings();
$('.btn-new').click(function () {
var dataType = $(this).data('datatype');
var dataTarget = $(this).data('datatarget');
var dataDirection = $(this).data('datadirection');
switch (dataType) {
case 'MarketTrend':
$('#MarketAnalyzer_MarketTrends').append('<div class="settings-markettrend new" data-trendname="" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>');
$('html, body').scrollTop($('#MarketAnalyzer_MarketTrends').offset().top + $('#MarketAnalyzer_MarketTrends').height() - 100);
$('.settings-markettrend.new').buildMarketTrendSettings();
break;
case 'GlobalSetting':
2019-11-09 15:46:35 +01:00
$('html, body').scrollTop($('#MarketAnalyzer_GlobalSettings > [data-settingname="' + dataTarget + '"]').offset().top - 100);
$('#MarketAnalyzer_GlobalSettings > [data-settingname="' + dataTarget + '"]').before('<div class="settings-globalsetting new" data-settingname="" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>');
2018-05-22 10:11:50 +02:00
$('.settings-globalsetting.new').buildGlobalSettings();
break;
case 'SingleMarketSetting':
2019-11-09 15:46:35 +01:00
if (dataDirection === 'before') {
$('html, body').scrollTop($('#MarketAnalyzer_SingleMarketSettings > [data-settingname="' + dataTarget + '"]').offset().top - 100);
$('#MarketAnalyzer_SingleMarketSettings > [data-settingname="' + dataTarget + '"]').before('<div class="settings-singlemarketsetting new" data-settingname="" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>');
} else {
$('html, body').scrollTop($('#MarketAnalyzer_SingleMarketSettings > [data-settingname="' + dataTarget + '"]').offset().top + $('#MarketAnalyzer_SingleMarketSettings > [data-settingname="' + dataTarget + '"]').height() - 100);
$('#MarketAnalyzer_SingleMarketSettings > [data-settingname="' + dataTarget + '"]').after('<div class="settings-singlemarketsetting new" data-settingname="" data-rooturl="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>');
}
2018-05-22 10:11:50 +02:00
$('.settings-singlemarketsetting.new').buildSingleMarketSettings();
break;
}
return false;
});
$(document).on('click', '.btn-savesettings', function () {
$('form').submit();
});
$('.btn-restorebackup').click(function () {
var dataTarget = $(this).data('datatarget');
var postValues = { File: dataTarget };
$.ajax({
type: 'POST',
url: "@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_post/RestoreBackup",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(postValues),
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
success: function (data) {
window.location.replace("@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)SettingsAnalyzer?n=BackupRestored");
},
error: function (jqxhr, errorText, thrownError) {
$.Notification.notify('error', 'top left', 'Error restoring backup!', 'Error message: ' + errorText);
}
});
return false;
});
@if (!Model.NotifyType.Equals("") && !Model.NotifyHeadline.Equals("") && !Model.NotifyMessage.Equals("")) {
<text>
$.Notification.notify('@Model.NotifyType', 'top left', '@Model.NotifyHeadline', '@Model.NotifyMessage');
window.history.pushState('@Model.PTMagicConfiguration.GeneralSettings.Application.InstanceName Monitor', '@Model.PTMagicConfiguration.GeneralSettings.Application.InstanceName Monitor', '@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)SettingsAnalyzer');
</text>
}
});
</script>
}