@* HeuristicLab
* Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*@
@helper AjaxDataRenderer()
{
}
@helper LineChartTime(string destinationTag, string url, string title = "", double? minY = null, double? maxY = null, string axisYFormat = null)
{
}
@helper RefreshChart(string destinationTag, string url, string startDate, string endDate, double? minY = null, double? maxY = null)
{
$.ajax({url: "@(new HtmlString(url))?start=" + @startDate + "&end=" + @endDate, datatype: "json", success: function(result) {
for (var i = 0; i < result.length; i++) {
@(destinationTag)Plot.series[i].data = result[i];
}
//Resets only the xaxis, still need to resize y with given min/max
@(destinationTag)Plot.replot({resetAxes:true});
@if (minY != null)
{
//If min Y was provided set the plot's min Y value
@:@(destinationTag)Plot.axes.yaxis.min = @minY;
}
@if (maxY != null)
{
//If max Y was provided set the plot's max Y value
@:@(destinationTag)Plot.axes.yaxis.max = @maxY;
}
@(destinationTag)Plot.axes.yaxis.reset();
//A final replot to redraw possible new Y axis values
@(destinationTag)Plot.replot({resetAxes:['xaxis']});
@* @(destinationTag)Plot.replot({ resetAxes:true });*@
}});
}
@helper ResizeCharts()
{
function resizeCharts(caller) {
//If current plot is collapsed
if($(caller).css("display") == "none") {
//Display the contents of chartContainer
ResizeOpenClose($(caller).siblings(".collapse"));
//Reset barWidth for bar charts
$.each(window[caller.id].series, function(index, series) {
series.barWidth = undefined;
});
//Replot the chart with same name as element id
window[caller.id].replot({ resetAxes: false });
//Hide the contents of the current div
ResizeOpenClose($(caller).siblings(".collapse"));
}
//Current plot is expanded
else {
//Reset barWidth for bar charts
$.each(window[caller.id].series, function(index, series) {
series.barWidth = undefined;
});
//Replot the chart with same name as element id
window[caller.id].replot({ resetAxes: false });
}
}
$(window).resize(function() {
$("div.jqplot-target",".chartContainer").each(function() {
var potentialTab = $(this).parent().parent().parent();
//If the section is tabular and currently hidden
if(potentialTab.hasClass("tabSection") && potentialTab.css("display") == "none") {
ResizeOpenCloseTabular(potentialTab);
resizeCharts(this);
ResizeOpenCloseTabular(potentialTab);
}
else {
resizeCharts(this);
}
});
});
}
@helper NumberPages(string records, string limit, string container, string functionName, string currentPage = null)
{
if(@(records).length > @limit) {
var appendPages = '';
var pages = Math.floor(@(records).length/@(limit)) + 1;
for(var i=0; i < pages; i++) {
appendPages += '' + (i + 1) + '';
}
appendPages += '';
$("#@container").append(appendPages);
if(@currentPage != null) {
$("#@(container)Page" + @currentPage).css('color','#F7921D');
}
else {
$("#@(container)Page1").css('color','#F7921D');
}
$(".page").click(function () {
pageNumber = $(this).html();
@(functionName)();
});
if(@currentPage != null) {
@(records).splice(0,(@(currentPage)-1)*@(limit));
if (@(records).length > @(limit)) {
@(records).splice(@(limit), @(records).length - @(limit));
}
}
else {
@(records).splice(@(limit), @(records).length - @(limit));
}
}
}
@helper TaskContainers(string destinationTag, string url, string functionName, string userName, string limit, string startDate = null, string endDate = null, string jobId = null, string taskState = null, string pageNumber = null)
{
var GetRequest = "?userName=" + @(userName);
@if (startDate != null)
{
@:if(@(startDate)!=null) {
@:GetRequest += "&start=" + @startDate;
@:}
}
@if (endDate != null)
{
@:if(@(endDate)!=null) {
@:GetRequest += "&end=" + @endDate;
@:}
}
@if (jobId != null)
{
@:if(@(jobId)!=null) {
@:GetRequest += "&jobId=" + @jobId;
@:}
}
@if (taskState != null)
{
@:if(@(taskState)!=null) {
@:GetRequest += "&taskState=" + @taskState;
@:}
}
$.ajax({
async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) {
if(@(userName) == null) {
$("#@(destinationTag)").append(
'' +
'
' + @userName + ' has no tasks for the specified filters!
' +
''
)
}
else {
//Checks if multipage display, if it is then trims results to
//the results for the page to be displayed
@ChartHelper.NumberPages("result", limit, destinationTag, functionName, pageNumber)
//Set display of all errors to none, errors matching the tasks will be reset below
$("#@(destinationTag)").find(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','none');
//Set variable for tracking jobId and open first job grouping
var currentJob = result[0].JobId;
//For each result create a seperate collapsable section with a chart and info label
for(var i = 0; i < result.length; i++){
if(currentJob != result[i].JobId || i == 0) {
$("#@(destinationTag)").append(
'' +
'