PTMagic/Monitor/Pages/BuyAnalyzer.cshtml

89 lines
4.0 KiB
Plaintext
Raw Normal View History

2018-05-22 10:11:50 +02:00
@page
@model BuyAnalyzerModel
@{
ViewData["Title"] = "";
}
@section Styles {
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/css/tablesaw.css" rel="stylesheet" type="text/css" />
}
@if (Model.PTData.BuyLog.Count == 0) {
<div class="row">
<div class="col-md-12">
<div class="card-box">
<h4 class="m-t-0 header-title">No possible buys!</h4>
<p>Sorry, but your Profit Trailer did not buy anything so far that's worth buying.</p>
</div>
</div>
</div>
} else {
<div class="row">
<div class="col-md-12">
<div class="card-box">
<h4 class="m-t-0 header-title">Possible Buy Analyzer <small id="buylist-refresh-icon"></small></h4>
<table class="tablesaw table m-b-0" data-tablesaw-sortable data-tablesaw-sortable-switch>
<thead>
<tr>
<th data-fieldid="Market" data-tablesaw-sortable-col data-tablesaw-sortable-default-col>Market</th>
2019-03-17 08:49:19 +01:00
<th data-fieldid="PercChange" data-tablesaw-sortable-col data-tablesaw-sortable-default-col>24H Trend</th>
2018-05-22 10:11:50 +02:00
<th data-toggle="tooltip" data-placement="top" title="Buy strategy for this market">Buy Strategy</th>
<th class="text-right" data-toggle="tooltip" data-placement="top" title="Current value relevant for buying into this market">BT Value</th>
<th class="text-right" data-toggle="tooltip" data-placement="top" title="Buy trigger as specified in your Pairs properties">Buy Trigger</th>
<th data-fieldid="CurrentPrice" data-tablesaw-sortable-col data-sortable-numeric="true" class="text-right" data-toggle="tooltip" data-placement="top" title="Current ask price for this market">Ask Price</th>
</tr>
</thead>
<tbody id="content"><tr><td colspan="10"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></td></tr></tbody>
</table>
</div>
</div>
</div>
}
@section Scripts {
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/js/tablesaw.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/js/tablesaw-init.js"></script>
<script type="text/javascript">
var errCountBuyList = [];
var interval;
var loadBuyList = function () {
$("#buylist-refresh-icon").html('<i class="fa fa-circle-o-notch fa-spin fa-fw" data-toggle="tooltip" data-placement="top" title="Loading fresh data..."></i>');
var sortedField = $("[data-tablesaw-sortable-default-col]");
var sortedFieldId = sortedField.data('fieldid');
var sortedDir = 'ASC';
if (sortedField.hasClass('tablesaw-sortable-descending')) {
sortedDir = 'DESC';
}
$("#content").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/BuyList?s=' + sortedFieldId + '&d=' + sortedDir, '', function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == 'error') {
errCountBuyList["BuyList"]++;
if (errCountBuyList["BuyList"] > 2) {
$.Notification.notify('error', 'top left', 'Buy List update failed!', 'PTMagic Buy List failed to update data. If this error does not go away by itself, please check the connection to your hosting PC.')
}
} else if (responseText == 'returntologin') {
window.location.replace("@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)Login");
} else {
errCountBuyList["BuyList"] = 0;
}
$("#buylist-refresh-icon").html('');
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
});
};
$(document).ready(function () {
errCountBuyList["BuyList"] = 0;
loadBuyList();
interval = setInterval(function () { loadBuyList(); }, @Model.PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds * 1000);
});
</script>
}