[11030] | 1 | @* HeuristicLab
|
---|
| 2 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 3 | *
|
---|
| 4 | * This file is part of HeuristicLab.
|
---|
| 5 | *
|
---|
| 6 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 7 | * it under the terms of the GNU General Public License as published by
|
---|
| 8 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 9 | * (at your option) any later version.
|
---|
| 10 | *
|
---|
| 11 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | * GNU General Public License for more details.
|
---|
| 15 | *
|
---|
| 16 | * You should have received a copy of the GNU General Public License
|
---|
| 17 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 18 | *@
|
---|
| 19 |
|
---|
[11246] | 20 | @helper UserExceptions(string destinationTag, string url, string userName = null, string startDate = null, string endDate = null, string jobId = null, string taskState = null, string slaveId=null)
|
---|
[11053] | 21 | {
|
---|
| 22 | <text>
|
---|
[11084] | 23 | var GetRequest = "";
|
---|
| 24 | @if (userName != null) {
|
---|
| 25 | @:if(@(userName)!=null) {
|
---|
| 26 | @:if(GetRequest == "") {
|
---|
| 27 | @:GetRequest += "?userName=" + @userName;
|
---|
| 28 | @:}
|
---|
| 29 | @:else {
|
---|
[11053] | 30 | @:GetRequest += "&userName=" + @userName;
|
---|
| 31 | @:}
|
---|
[11084] | 32 | @:}
|
---|
| 33 | }
|
---|
| 34 | @if (startDate != null)
|
---|
| 35 | {
|
---|
| 36 | @:if(@(startDate)!=null) {
|
---|
| 37 | @:if(GetRequest == "") {
|
---|
| 38 | @:GetRequest += "?start=" + @startDate;
|
---|
| 39 | @:}
|
---|
| 40 | @:else {
|
---|
[11053] | 41 | @:GetRequest += "&start=" + @startDate;
|
---|
| 42 | @:}
|
---|
[11084] | 43 | @:}
|
---|
| 44 | }
|
---|
| 45 | @if (endDate != null)
|
---|
| 46 | {
|
---|
| 47 | @:if(@(endDate)!=null) {
|
---|
| 48 | @:if(GetRequest == "") {
|
---|
| 49 | @:GetRequest += "?end=" + @endDate;
|
---|
| 50 | @:}
|
---|
| 51 | @:else {
|
---|
[11053] | 52 | @:GetRequest += "&end=" + @endDate;
|
---|
| 53 | @:}
|
---|
[11084] | 54 | @:}
|
---|
| 55 | }
|
---|
| 56 | @if (jobId != null)
|
---|
| 57 | {
|
---|
| 58 | @:if(@(jobId)!=null) {
|
---|
| 59 | @:if(GetRequest == "") {
|
---|
| 60 | @:GetRequest += "?jobId=" + @jobId;
|
---|
| 61 | @:}
|
---|
| 62 | @:else {
|
---|
[11053] | 63 | @:GetRequest += "&jobId=" + @jobId;
|
---|
| 64 | @:}
|
---|
[11084] | 65 | @:}
|
---|
| 66 | }
|
---|
| 67 | @if (taskState != null)
|
---|
| 68 | {
|
---|
| 69 | @:if(@(taskState)!=null) {
|
---|
| 70 | @:if(GetRequest == "") {
|
---|
| 71 | @:GetRequest += "?taskState=" + @taskState;
|
---|
| 72 | @:}
|
---|
| 73 | @:else {
|
---|
[11053] | 74 | @:GetRequest += "&taskState=" + @taskState;
|
---|
| 75 | @:}
|
---|
[11084] | 76 | @:}
|
---|
| 77 | }
|
---|
| 78 | @if (slaveId != null)
|
---|
| 79 | {
|
---|
| 80 | @:if(@(slaveId)!=null) {
|
---|
| 81 | @:if(GetRequest == "") {
|
---|
| 82 | @:GetRequest += "?slaveId=" + @slaveId;
|
---|
| 83 | @:}
|
---|
| 84 | @:else {
|
---|
| 85 | @:GetRequest += "&slaveId=" + @slaveId;
|
---|
| 86 | @:}
|
---|
| 87 | @:}
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[11246] | 90 | $.ajax({async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json",
|
---|
| 91 | error: function(xhr,err) {
|
---|
| 92 | alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
|
---|
| 93 | alert("responseText: "+xhr.responseText);
|
---|
| 94 | },
|
---|
| 95 | success: function(result) {
|
---|
[11084] | 96 | $("#" + "@destinationTag").html("");
|
---|
| 97 | if(result.Key.length > 0) {
|
---|
| 98 | var ErrorHTML = '<section class="errorContainer">' +
|
---|
| 99 | '<p class="errorTitle">Some tasks were found in error state!</p>' +
|
---|
| 100 | '<label class="errorTask underline">Task</label>' +
|
---|
| 101 | '<label class="errorMessage underline">Error</label>';
|
---|
| 102 | for (var i = 0; i < result.Key.length; i++) {
|
---|
[11246] | 103 | ErrorHTML += '<a class="errorTask" onclick="ScrollTo(this)">' + result.Key[i] + '</a>';
|
---|
| 104 | if(result.Value[i].length > 100) {
|
---|
| 105 | ErrorHTML += '<a class="errorMessage shortVerison" onclick="ShowFullError(this)">Click to show full message</a>';
|
---|
| 106 | ErrorHTML += '<label class="errorMessage longVersion">' + result.Value[i] + '</label>';
|
---|
| 107 | }
|
---|
| 108 | else {
|
---|
| 109 | ErrorHTML += '<label class="errorMessage">' + result.Value[i] + '</label>';
|
---|
| 110 | }
|
---|
[11030] | 111 | }
|
---|
[11084] | 112 | ErrorHTML += '</section>';
|
---|
| 113 | $("#" + "@destinationTag").append(ErrorHTML);
|
---|
[11053] | 114 | }
|
---|
[11222] | 115 | else if("@(destinationTag)" == "ExceptionContainer") {
|
---|
| 116 | $("#@(destinationTag)").append(
|
---|
| 117 | '<section class="chartContainer">' +
|
---|
| 118 | '<h1 class="title">No errors found for the specified filters!</h1>' +
|
---|
| 119 | '</section>'
|
---|
| 120 | )
|
---|
| 121 | }
|
---|
[11084] | 122 | }
|
---|
| 123 | });
|
---|
[11053] | 124 | </text>
|
---|
[11030] | 125 | }
|
---|
| 126 |
|
---|
| 127 | @helper ScrollToException() {
|
---|
| 128 | <text>
|
---|
[11053] | 129 | function ScrollTo(caller) {
|
---|
[11084] | 130 | var taskErrorId = $(caller).parent().parent().attr('id') + $(caller).html() + "PlotTitle";
|
---|
[11246] | 131 | $("#" + taskErrorId).parent().find("button").click();
|
---|
[11030] | 132 | $('html, body').animate({
|
---|
[11053] | 133 | scrollTop: $("#" + taskErrorId).parent().offset().top
|
---|
[11030] | 134 | }, 2000);
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | $('#ScrollTop').click(function() {
|
---|
| 138 | $('html, body').animate({
|
---|
| 139 | scrollTop: 0
|
---|
| 140 | }, 2000);
|
---|
| 141 | });
|
---|
| 142 |
|
---|
| 143 | $(window).on("scrollstop",function() {
|
---|
| 144 | var newTop = $(window).scrollTop();
|
---|
| 145 | if(newTop==0) {
|
---|
| 146 | $('#ScrollTop').animate({
|
---|
| 147 | top: newTop + 20
|
---|
| 148 | }, 800, function() {
|
---|
| 149 | $('#ScrollTop').css('display','none');
|
---|
| 150 | });
|
---|
| 151 | }
|
---|
| 152 | else {
|
---|
| 153 | $('#ScrollTop').css('display','block');
|
---|
| 154 | $('#ScrollTop').animate({
|
---|
| 155 | top: newTop + 20
|
---|
| 156 | }, 800);
|
---|
| 157 | }
|
---|
| 158 | });
|
---|
| 159 | </text>
|
---|
[11053] | 160 | }
|
---|
| 161 |
|
---|
| 162 | @helper ShowErrors(string destinationTag) {
|
---|
| 163 | <text>
|
---|
[11222] | 164 | $("#@(destinationTag)").find(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','inline-block');
|
---|
[11053] | 165 | </text>
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[11084] | 168 | @helper ErrorsOnSlaves(string destinationTag, string url, string limit, string startDate = null, string endDate = null, string clientId=null, string functionName=null, string pageNumber=null) {
|
---|
[11053] | 169 | <text>
|
---|
[11084] | 170 | var GetRequest = "";
|
---|
| 171 | @if (startDate != null)
|
---|
| 172 | {
|
---|
[11053] | 173 | @:if(@(startDate)!=null) {
|
---|
[11084] | 174 | @:if(GetRequest == "") {
|
---|
| 175 | @:GetRequest += "?start=" + @startDate;
|
---|
| 176 | @:}
|
---|
| 177 | @:else {
|
---|
| 178 | @:GetRequest += "&start=" + @startDate;
|
---|
| 179 | @:}
|
---|
[11053] | 180 | @:}
|
---|
| 181 | }
|
---|
[11084] | 182 | @if (endDate != null)
|
---|
| 183 | {
|
---|
[11053] | 184 | @:if(@(endDate)!=null) {
|
---|
[11084] | 185 | @:if(GetRequest == "") {
|
---|
| 186 | @:GetRequest += "?end=" + @endDate;
|
---|
| 187 | @:}
|
---|
| 188 | @:else {
|
---|
| 189 | @:GetRequest += "&end=" + @endDate;
|
---|
| 190 | @:}
|
---|
[11053] | 191 | @:}
|
---|
| 192 | }
|
---|
[11084] | 193 | @if (clientId != null)
|
---|
| 194 | {
|
---|
[11053] | 195 | @:if(@(clientId)!=null) {
|
---|
[11084] | 196 | @:if(GetRequest == "") {
|
---|
| 197 | @:GetRequest += "?clientId=" + @clientId;
|
---|
| 198 | @:}
|
---|
| 199 | @:else {
|
---|
| 200 | @:GetRequest += "&clientId=" + @clientId;
|
---|
| 201 | @:}
|
---|
[11053] | 202 | @:}
|
---|
| 203 | }
|
---|
| 204 | $.ajax({
|
---|
| 205 | async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) {
|
---|
[11084] | 206 |
|
---|
| 207 | //Checks if multipage display, if it is then trims results to
|
---|
| 208 | //the results for the page to be displayed
|
---|
| 209 | @ChartHelper.NumberPages("result",limit,destinationTag,functionName,pageNumber)
|
---|
| 210 |
|
---|
| 211 | //Set display of all errors to none, errors matching the tasks will be reset below
|
---|
| 212 | $("#" + "@(destinationTag)").find(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','none');
|
---|
| 213 |
|
---|
[11053] | 214 | for(i = 0; i < result.length; i++) {
|
---|
| 215 | $("#" + "@(destinationTag)").append(
|
---|
[11084] | 216 | '<section id="@(destinationTag)' + result[i][0] + '" class="chartContainer">' +
|
---|
| 217 | '<h1 class="title" id="@(destinationTag)' + result[i][0] + 'PlotTitle">Task ' + result[i][0] + '</h1>' +
|
---|
[11053] | 218 | '<button class="collapse" onclick="CollapseSection(this)">+</button>' +
|
---|
| 219 | '<label id="' + result[i][0] + 'ErrorMessage">Error Message: ' + result[i][1] + '</label>' +
|
---|
[11222] | 220 | '<label id="' + result[i][0] + 'Client">Slave: <a id="' + result[i][2] + '" onclick="ShowSlaveInfo(this)">' + result[i][3] + '</a></label>' +
|
---|
| 221 | '<label id="' + result[i][0] + 'User">User Name: ' + result[i][4] + '</label>' +
|
---|
| 222 | '<label id="' + result[i][0] + 'Job">Job Name: ' + result[i][5] + '</label>' +
|
---|
| 223 | '<label id="' + result[i][0] + 'Date">Date/Time: ' + result[i][6] + '</label>' +
|
---|
[11053] | 224 | '</section>'
|
---|
| 225 | );
|
---|
[11084] | 226 |
|
---|
| 227 | //Re-enables the error display if any of the sections on the page have Ids matching
|
---|
| 228 | //those of errors
|
---|
| 229 | $(".errorTask","#" + "@(destinationTag)").each(function() {
|
---|
| 230 | if($(this).html()==result[i][0]) {
|
---|
| 231 | $("#@(destinationTag)" + result[i][0] + "PlotTitle").css("color","red");
|
---|
| 232 | $("#@(destinationTag)" + result[i][0] + "PlotTitle").append(" - ERROR");
|
---|
| 233 | $('.errorContainer, .errorTitle, .underline','#@(destinationTag)').css('display','inline-block');
|
---|
| 234 | $(this).css('display','inline-block');
|
---|
| 235 | $(this).next().css('display','inline-block');
|
---|
| 236 | }
|
---|
| 237 | });
|
---|
| 238 |
|
---|
| 239 | CollapsedByDefault(document.getElementById("@(destinationTag)" + result[i][0] + "PlotTitle"));
|
---|
[11053] | 240 | }
|
---|
| 241 | }
|
---|
| 242 | });
|
---|
| 243 | </text>
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | @helper ShowSlaveInfo(string url, string limit, string startDate=null, string endDate=null) {
|
---|
| 247 | <text>
|
---|
| 248 | //Opens a sub-container with slave information
|
---|
| 249 | function ShowSlaveInfo(caller) {
|
---|
[11222] | 250 | var taskSlaveId = $(caller).attr('id');
|
---|
[11246] | 251 | CheckFilters();
|
---|
[11059] | 252 | if($(caller).parent().parent().children(".chartContainer").length == 0) {
|
---|
[11246] | 253 | var destinationTag = $(caller).parent().parent().attr('id');
|
---|
| 254 | @ChartHelper.SlaveContainers("destinationTag",url,limit,true,startDate,endDate,null,null,null,"taskSlaveId")
|
---|
[11059] | 255 | }
|
---|
| 256 | else {
|
---|
| 257 | $(caller).parent().parent().children(".chartContainer").remove();
|
---|
| 258 | }
|
---|
[11053] | 259 | }
|
---|
| 260 | </text>
|
---|
[11246] | 261 | }
|
---|
| 262 |
|
---|
| 263 | @helper ShowFullError() {
|
---|
| 264 | <text>
|
---|
| 265 | function ShowFullError(caller) {
|
---|
| 266 | $(caller).css('display','none');
|
---|
| 267 | $(caller).next().css('display','inline-block');
|
---|
| 268 | }
|
---|
| 269 | </text>
|
---|
[11030] | 270 | } |
---|