2018-05-22 10:11:50 +02:00
@page
@model IndexModel
@{
ViewData["Title"] = "";
}
@section Styles {
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/nvd3/nv.d3.min.css" rel="stylesheet" type="text/css" />
}
<div id="dashboardTop"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>
<div id="dashboardBottom"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></div>
<div id="dca-chart" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-full">
<div class="modal-content">
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@section Scripts {
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/d3/d3.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/nvd3/nv.d3.min.js"></script>
<script type="text/javascript">
2024-01-27 18:39:47 +01:00
var errCountIndex = [];
var counterIndex = []; // Add this line
2018-05-22 10:11:50 +02:00
var intervalDashboardTop;
var intervalDashboardBottom;
2019-04-14 08:45:09 +02:00
2024-02-01 12:25:04 +01:00
2018-05-22 10:11:50 +02:00
var loadDashboardTop = function () {
$("#baglist-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>');
$("#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>');
2019-04-14 08:45:09 +02:00
// Clear exisitng interval to stop multiple attempts to load at the same time.
if (intervalDashboardTop != null)
{
clearInterval(intervalDashboardTop);
}
2018-05-22 10:11:50 +02:00
$("#dashboardTop").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/DashboardTop', '', function (responseText, textStatus, XMLHttpRequest) {
$("#baglist-refresh-icon").html('');
$("#buylist-refresh-icon").html('');
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
if (textStatus == 'error') {
errCountIndex["DashboardTop"]++;
if (errCountIndex["DashboardTop"] > 2) {
$.Notification.notify('error', 'top left', 'Dashboard (Top) update failed!', 'PTMagic Monitor 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 {
errCountIndex["DashboardTop"] = 0;
}
2019-04-14 08:45:09 +02:00
// Reinstate interval
intervalDashboardTop = setInterval(function () { loadDashboardTop(); }, 5 * 1000);
2018-05-22 10:11:50 +02:00
});
};
var loadDashboardBottom = function () {
2024-01-23 19:05:28 +01:00
// Clear existing interval to stop multiple attempts to load at the same time.
if (intervalDashboardBottom != null) {
2019-04-14 08:45:09 +02:00
clearInterval(intervalDashboardBottom);
}
2024-02-01 12:25:04 +01:00
console.log(counterIndex["DashboardBottom"]);
// Destroy all d3 svg graph to avoid memory leak every 10 refreshes of Dashboard Bottom
if (counterIndex["DashboardBottom"] >= 10) {
$(".nvtooltip").remove();
$("svg > *").remove();
$("svg").remove();
$("svg").off(); // Remove all event listeners from SVG elements
nv.charts = {};
nv.graphs = [];
nv.logs = {};
nv.tooltip = {};
window.cleanupData();
// Reset the counter
counterIndex["DashboardBottom"] = 0;
console.log("d3 svg graph destroyed");
}
2019-04-14 08:45:09 +02:00
// Load dashboard
2018-05-22 10:11:50 +02:00
$("#dashboardBottom").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/DashboardBottom', '', function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == 'error') {
errCountIndex["DashboardBottom"]++;
if (errCountIndex["DashboardBottom"] > 2) {
$.Notification.notify('error', 'top left', 'Dashboard (Bottom) update failed!', 'PTMagic Monitor 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 {
errCountIndex["DashboardBottom"] = 0;
2024-01-23 19:05:28 +01:00
2024-01-27 18:39:47 +01:00
// Increment the counter
counterIndex["DashboardBottom"] = (counterIndex["DashboardBottom"] || 0) + 1;
2024-02-01 12:25:04 +01:00
2018-05-22 10:11:50 +02:00
}
2019-04-14 08:45:09 +02:00
// Reinstate the interval.
2024-02-02 18:22:39 +01:00
intervalDashboardBottom = setInterval(function () { loadDashboardBottom(); }, @Model.PTMagicConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds * 1000);
2018-05-22 10:11:50 +02:00
});
};
$(document).ready(function () {
errCountIndex["DashboardTop"] = 0;
2019-04-14 08:45:09 +02:00
loadDashboardTop();
2018-05-22 10:11:50 +02:00
errCountIndex["DashboardBottom"] = 0;
loadDashboardBottom();
});
</script>
}