@* 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 UserExceptions(string destinationTag, string url, string limit, string userName = null, string startDate = null, string endDate = null, string jobId = null, string taskState = null, string slaveId=null) { var GetRequest = ""; @if (userName != null) { @:if(@(userName)!=null) { @:if(GetRequest == "") { @:GetRequest += "?userName=" + @userName; @:} @:else { @:GetRequest += "&userName=" + @userName; @:} @:} } @if (startDate != null) { @:if(@(startDate)!=null) { @:if(GetRequest == "") { @:GetRequest += "?start=" + @startDate; @:} @:else { @:GetRequest += "&start=" + @startDate; @:} @:} } @if (endDate != null) { @:if(@(endDate)!=null) { @:if(GetRequest == "") { @:GetRequest += "?end=" + @endDate; @:} @:else { @:GetRequest += "&end=" + @endDate; @:} @:} } @if (jobId != null) { @:if(@(jobId)!=null) { @:if(GetRequest == "") { @:GetRequest += "?jobId=" + @jobId; @:} @:else { @:GetRequest += "&jobId=" + @jobId; @:} @:} } @if (taskState != null) { @:if(@(taskState)!=null) { @:if(GetRequest == "") { @:GetRequest += "?taskState=" + @taskState; @:} @:else { @:GetRequest += "&taskState=" + @taskState; @:} @:} } @if (slaveId != null) { @:if(@(slaveId)!=null) { @:if(GetRequest == "") { @:GetRequest += "?slaveId=" + @slaveId; @:} @:else { @:GetRequest += "&slaveId=" + @slaveId; @:} @:} } $.ajax({async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) { $("#" + "@destinationTag").html(""); if(result.Key.length > 0) { var ErrorHTML = '
' + '

Some tasks were found in error state!

' + '' + ''; for (var i = 0; i < result.Key.length; i++) { ErrorHTML += '' + result.Key[i] + '' + ''; } ErrorHTML += '
'; $("#" + "@destinationTag").append(ErrorHTML); } } });
} @helper ScrollToException() { function ScrollTo(caller) { var taskErrorId = $(caller).parent().parent().attr('id') + $(caller).html() + "PlotTitle"; OpenOnError(document.getElementById(taskErrorId)); $('html, body').animate({ scrollTop: $("#" + taskErrorId).parent().offset().top }, 2000); } $('#ScrollTop').click(function() { $('html, body').animate({ scrollTop: 0 }, 2000); }); $(window).on("scrollstop",function() { var newTop = $(window).scrollTop(); if(newTop==0) { $('#ScrollTop').animate({ top: newTop + 20 }, 800, function() { $('#ScrollTop').css('display','none'); }); } else { $('#ScrollTop').css('display','block'); $('#ScrollTop').animate({ top: newTop + 20 }, 800); } }); } @helper ShowErrors(string destinationTag) { $("#@(destinationTag)").children(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','inline-block'); } @helper ErrorsOnSlaves(string destinationTag, string url, string limit, string startDate = null, string endDate = null, string clientId=null, string functionName=null, string pageNumber=null) { var GetRequest = ""; @if (startDate != null) { @:if(@(startDate)!=null) { @:if(GetRequest == "") { @:GetRequest += "?start=" + @startDate; @:} @:else { @:GetRequest += "&start=" + @startDate; @:} @:} } @if (endDate != null) { @:if(@(endDate)!=null) { @:if(GetRequest == "") { @:GetRequest += "?end=" + @endDate; @:} @:else { @:GetRequest += "&end=" + @endDate; @:} @:} } @if (clientId != null) { @:if(@(clientId)!=null) { @:if(GetRequest == "") { @:GetRequest += "?clientId=" + @clientId; @:} @:else { @:GetRequest += "&clientId=" + @clientId; @:} @:} } $.ajax({ async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) { //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'); for(i = 0; i < result.length; i++) { $("#" + "@(destinationTag)").append( '
' + '

Task ' + result[i][0] + '

' + '' + '' + '' + '' + '' + '
' ); //Re-enables the error display if any of the sections on the page have Ids matching //those of errors $(".errorTask","#" + "@(destinationTag)").each(function() { if($(this).html()==result[i][0]) { $("#@(destinationTag)" + result[i][0] + "PlotTitle").css("color","red"); $("#@(destinationTag)" + result[i][0] + "PlotTitle").append(" - ERROR"); $('.errorContainer, .errorTitle, .underline','#@(destinationTag)').css('display','inline-block'); $(this).css('display','inline-block'); $(this).next().css('display','inline-block'); } }); CollapsedByDefault(document.getElementById("@(destinationTag)" + result[i][0] + "PlotTitle")); } } });
} @helper ShowSlaveInfo(string url, string limit, string startDate=null, string endDate=null) { //Opens a sub-container with slave information function ShowSlaveInfo(caller) { if($(caller).parent().parent().children(".chartContainer").length == 0) { @ChartHelper.SlaveInfoChart("caller.parentNode.parentNode.id",url,limit,true,startDate,endDate,null,null,null,"$(caller).html()") } else { $(caller).parent().parent().children(".chartContainer").remove(); } } }