Merge pull request #282 from PTMagicians/develop

2.5.7
This commit is contained in:
HojouFotytu 2021-03-01 00:46:41 +09:00 committed by GitHub
commit 381eb072c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 93 additions and 77 deletions

View File

@ -35,7 +35,6 @@ namespace Core.Main.DataObjects.PTMagicData
public bool IsEnabled { get; set; } = true;
public bool TestMode { get; set; } = true;
public bool EnableBetaFeatures { get; set; } = false;
public string ProfitTrailerPath { get; set; }
public string ProfitTrailerLicense { get; set; } = "";
public string ProfitTrailerServerAPIToken { get; set; }
public string ProfitTrailerMonitorURL { get; set; } = "http://localhost:8081/";

View File

@ -542,7 +542,7 @@ namespace Core.Helper
}
else
{
result = "https://uk.tradingview.com/?symbol=" + exchange.ToUpper() + ":" + market.ToUpper();
result = "https://uk.tradingview.com/chart/?symbol=" + exchange.ToUpper() + ":" + market.ToUpper();
}
}
else

View File

@ -703,20 +703,11 @@ namespace Core.Main
{
try
{
if (this.PTMagicConfiguration.GeneralSettings.Application.TestMode) this.Log.DoLogInfo("TESTMODE ENABLED - No files will be changed!");
// Check for PT Directory
DirectoryInfo ptRoot = new DirectoryInfo(this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath);
if (ptRoot.Exists)
if (this.PTMagicConfiguration.GeneralSettings.Application.TestMode)
{
this.Log.DoLogInfo("Profit Trailer directory found");
result = RunProfitTrailerSettingsAPIChecks();
}
else
{
this.Log.DoLogError("Profit Trailer directory not found (" + this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + ")");
result = false;
this.Log.DoLogInfo("TESTMODE ENABLED - No files will be changed!");
}
result = RunProfitTrailerSettingsAPIChecks();
// Check for CoinMarketCap API Key
if (!String.IsNullOrEmpty(this.PTMagicConfiguration.GeneralSettings.Application.CoinMarketCapAPIKey))
@ -1142,14 +1133,7 @@ namespace Core.Main
}
}
private void GetProfitTrailerPropertiesPaths(out string pairsPropertiesPath, out string dcaPropertiesPath, out string indicatorsPropertiesPath)
{
// Get current PT properties
pairsPropertiesPath = this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + Constants.PTPathTrading + Path.DirectorySeparatorChar + this.PairsFileName;
dcaPropertiesPath = this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + Constants.PTPathTrading + Path.DirectorySeparatorChar + this.DCAFileName;
indicatorsPropertiesPath = this.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath + Constants.PTPathTrading + Path.DirectorySeparatorChar + this.IndicatorsFileName;
}
// Get current PT properties
private void LoadCurrentProfitTrailerProperties()
{
// Load current PT properties from API (Valid for PT 2.x and above)
@ -2143,9 +2127,6 @@ namespace Core.Main
private void SaveProfitTrailerProperties()
{
// Get current PT properties
string pairsPropertiesPath, dcaPropertiesPath, indicatorsPropertiesPath;
GetProfitTrailerPropertiesPaths(out pairsPropertiesPath, out dcaPropertiesPath, out indicatorsPropertiesPath);
if (this.GlobalSettingWritten || this.SingleMarketSettingChanged)
{
// Save current PT properties to API (Valid for PT 2.x and above)

View File

@ -47,11 +47,6 @@ namespace Core.Main
AnalyzerSettingsWrapper asw = JsonConvert.DeserializeObject<AnalyzerSettingsWrapper>(File.ReadAllText(basePath + "settings.analyzer.json"));
_analyzerSettings = asw.AnalyzerSettings;
if (!_generalSettings.Application.ProfitTrailerPath.EndsWith(Path.DirectorySeparatorChar))
{
_generalSettings.Application.ProfitTrailerPath += Path.DirectorySeparatorChar;
}
if (!_generalSettings.Application.ProfitTrailerMonitorURL.EndsWith("/"))
{
_generalSettings.Application.ProfitTrailerMonitorURL += "/";
@ -83,6 +78,28 @@ namespace Core.Main
return result;
}
public string GetProfitTrailerServerAPITokenMasked()
{
string result = "";
if (!this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Equals(""))
{
int tokenLength = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length;
if (tokenLength == 1)
{
result = "*";
}
else
result = this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Substring(0, 1);
for (int i = 1; i < this.GeneralSettings.Application.ProfitTrailerServerAPIToken.Length; i++)
{
result += "*";
}
}
return result;
}
public GeneralSettings GeneralSettings
{
get

View File

@ -30,7 +30,8 @@ namespace Monitor.Pages
if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword))
{
HttpContext.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected = true;
PTMagicConfiguration.WriteGeneralSettings();
if (cbRememberMe != null)
{
if (cbRememberMe.Equals("on", StringComparison.InvariantCultureIgnoreCase))

View File

@ -68,12 +68,6 @@
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">Profit Trailer Path <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Path to your Profit Trailer main directory."></i></label>
<div class="col-md-8">
@Model.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerPath
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">Profit Trailer License <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Your Profit Trailer license key (needed to change your settings for PT 2.0 and above)"></i></label>
@ -92,7 +86,7 @@
<div class="form-group row">
<label class="col-md-4 col-form-label">Profit Trailer Server API Token <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The API token needed to communicate with Profit Trailer - set in Profit Trailer Server Settings"></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="Application_ProfitTrailerServerAPIToken" value="@Model.PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken">
@Model.PTMagicConfiguration.GetProfitTrailerServerAPITokenMasked()
</div>
</div>
@ -139,14 +133,14 @@
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">CoinMarketCap API Key <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The API Key that will be used to get Coin Data from CoinMarketCap."></i></label>
<label class="col-md-4 col-form-label">CoinMarketCap API Key <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The API Key that will be used to get Coin Data from CoinMarketCap (optional)."></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="Application_CoinMarketCapAPIKey" value="@Model.PTMagicConfiguration.GeneralSettings.Application.CoinMarketCapAPIKey">
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">FreeCurrencyConverter API Key <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The api key needed for currency conversions for non-USD currency users."></i></label>
<label class="col-md-4 col-form-label">FreeCurrencyConverter API Key <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The api key needed for currency conversions for non-USD currency users (optional)."></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="Application_FreeCurrencyConverterAPIKey" value="@Model.PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey">
</div>
@ -169,9 +163,9 @@
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="form-group row">
<label class="col-md-4 col-form-label">Is Password Protected <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Defines if your monitor will be asking to setup a password on its first start."></i></label>
<label class="col-md-4 col-form-label">Is Password Protected <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="A password is required to view and edit settings via the GUI."></i></label>
<div class="col-md-8">
<input type="checkbox" name="Monitor_IsPasswordProtected" checked="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected)" data-plugin="switchery" data-color="#81c868" data-size="small" />
<input type="checkbox" name="Monitor_IsPasswordProtected" checked="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected)" data-plugin="switchery" data-color="#81c868" data-size="small" /><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)SetupPassword" label class="col-md-4 col-form-label">(Change Password)</a> <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Change the password required to log in, and view the settings pages"></i></label>
</div>
</div>

View File

@ -71,7 +71,6 @@ namespace Monitor.Pages
PTMagicConfiguration.GeneralSettings.Application.StartBalance = SystemHelper.TextToDouble(HttpContext.Request.Form["Application_StartBalance"], PTMagicConfiguration.GeneralSettings.Application.StartBalance, "en-US");
PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerDefaultSettingName = HttpContext.Request.Form["Application_ProfitTrailerDefaultSettingName"];
PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken = HttpContext.Request.Form["Application_ProfitTrailerServerAPIToken"];
PTMagicConfiguration.GeneralSettings.Application.TimezoneOffset = HttpContext.Request.Form["Application_TimezoneOffset"];
PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency = HttpContext.Request.Form["Application_MainFiatCurrency"];

View File

@ -14,29 +14,30 @@
<h3 class="text-center"> <strong class="text-custom">PT Magic</strong> </h3>
<p class="text-center">Setup your password.</p>
</div>
<div class="p-20">
<form class="form-horizontal m-t-20" method="post">
<div class="form-group">
<div class="col-12">
<input name="Password" class="form-control" type="password" required="" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-12">
<input name="PasswordConfirm" class="form-control" type="password" required="" compare="Password" placeholder="Confirm Password">
@if (System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "/settings.secure.json"))
{
<div class="form-group">
<div class="col-12">
<input name="OldPassword" class="form-control" type="password" required="" placeholder="Old Password">
</div>
</div>
</div>
@if (!Model.ValidationMessage.Equals("")) {
<div class="form-group">
<div class="text-danger m-l-10">
@Model.ValidationMessage
</div>
</div>
}
<div class="form-group">
<div class="col-12">
<input name="Password" class="form-control" type="password" required="" placeholder="New Password">
</div>
</div>
<div class="form-group">
<div class="col-12">
<input name="PasswordConfirm" class="form-control" type="password" required="" compare="Password" placeholder="Confirm New Password">
</div>
</div>
<div class="form-group text-center m-t-40">
<div class="col-12">
<button class="btn btn-ptmagic btn-block text-uppercase waves-effect waves-light" type="submit">
@ -44,9 +45,12 @@
</button>
</div>
</div>
<div class="form-group">
<div class="text-danger m-l-10">
@Model.ValidationMessage
</div>
</div>
</form>
</div>
</div>

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Core.Main;
using Core.Helper;
namespace Monitor.Pages
{
@ -16,19 +17,39 @@ namespace Monitor.Pages
base.PreInit();
}
public void OnPost(string password, string passwordConfirm)
public void OnPost(string OldPassword, string Password, string PasswordConfirm)
{
if (!password.Equals(passwordConfirm))
base.PreInit();
ValidationMessage = "Test";
string encryptedOldPassword = null;
if (OldPassword != null)
{
ValidationMessage = "Password does not match the confirmation!";
encryptedOldPassword = EncryptionHelper.Encrypt(OldPassword);
if (!Password.Equals(PasswordConfirm) || !encryptedOldPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword) && System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "/settings.secure.json"))
{
ValidationMessage = "Old Password wrong or new Password does not match with confirmation";
}
else if (ModelState.IsValid)
{
PTMagicConfiguration.WriteSecureSettings(Password);
ValidationMessage = "";
Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login");
}
}
if (ModelState.IsValid)
else
{
base.PreInit();
PTMagicConfiguration.WriteSecureSettings(password);
Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login");
if (!Password.Equals(PasswordConfirm) && !System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory().Split("Monitor")[0] + "/settings.secure.json"))
{
ValidationMessage = "New Password does not match with confirmation";
}
else if (ModelState.IsValid)
{
PTMagicConfiguration.WriteSecureSettings(Password);
ValidationMessage = "";
Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login");
}
}
}

View File

@ -107,7 +107,7 @@
</li>
} else {
<li>
<a data-toggle="tooltip" data-placement="top" title="Settings menu is only accessible when you protect your monitor with a password!"><i class="fa fa-lock text-danger"></i> <span> Settings</span></a>
<a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)Login" data-toggle="tooltip" data-placement="top" title="Settings menu is only accessible when you protect your monitor with a password!"><i class="fa fa-lock text-danger"></i> <span> Settings</span></a>
</li>
}

View File

@ -1,4 +1,5 @@
using System;
using System.Net;
using System;
using Microsoft.AspNetCore.Http;
using Core.Main;
using Core.Helper;
@ -27,7 +28,8 @@ namespace Monitor._Internal
// Security check
if (!IsLoggedIn(this.HttpContext))
{
HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + _redirectUrl);
this.HttpContext.Response.Clear();
this.HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + _redirectUrl);
}
}

View File

@ -6,7 +6,7 @@ using Core.Helper;
using Microsoft.Extensions.DependencyInjection;
[assembly: AssemblyVersion("2.5.6")]
[assembly: AssemblyVersion("2.5.7")]
[assembly: AssemblyProduct("PT Magic")]
namespace PTMagic

View File

@ -3,7 +3,6 @@
"Application": {
"IsEnabled": true, // Enables the PTMagic bot (needs restart to take effect)
"TestMode": false, // If TestMode is active, no properties files will be changed
"ProfitTrailerPath": "YOUR PROFIT TRAILER PATH", // Path to your Profit Trailer main directory (use double backslashes for windows like C:\\ProfitTrailer\\)
"ProfitTrailerLicense": "YOUR PROFIT TRAILER LICENSE KEY", // Your Profit Trailer license key (needed to change your settings for PT 2.0 and above)
"ProfitTrailerServerAPIToken": "", //Your Profit Trailer Server API Token
"ProfitTrailerMonitorURL": "http://localhost:8081/", // The URL to your profit trailer monitor (needed to change your settings for PT 2.0 and above)

View File

@ -3,7 +3,6 @@
"Application": {
"IsEnabled": true, // Enables the PTMagic bot (needs restart to take effect)
"TestMode": false, // If TestMode is active, no properties files will be changed
"ProfitTrailerPath": "YOUR PROFIT TRAILER PATH", // Path to your Profit Trailer main directory (use double backslashes for windows like C:\\ProfitTrailer\\)
"ProfitTrailerLicense": "YOUR PROFIT TRAILER LICENSE KEY", // Your Profit Trailer license key (needed to change your settings for PT 2.0 and above)
"ProfitTrailerServerAPIToken": "", //Your Profit Trailer Server API Token
"ProfitTrailerMonitorURL": "http://localhost:8081/", // The URL to your profit trailer monitor (needed to change your settings for PT 2.0 and above)