Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Code/ExceptionHelper.cshtml @ 11246

Last change on this file since 11246 was 11246, checked in by mroscoe, 10 years ago
File size: 9.2 KB
Line 
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
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)
21{
22  <text>
23  var GetRequest = "";
24  @if (userName != null) {
25    @:if(@(userName)!=null) {
26      @:if(GetRequest == "") {
27        @:GetRequest += "?userName=" + @userName;
28      @:}
29      @:else {
30        @:GetRequest += "&userName=" + @userName;
31      @:}
32    @:}
33  }
34  @if (startDate != null)
35  {
36    @:if(@(startDate)!=null) {
37      @:if(GetRequest == "") {
38        @:GetRequest += "?start=" + @startDate;
39      @:}
40      @:else {
41        @:GetRequest += "&start=" + @startDate;
42      @:}
43    @:}
44  }
45  @if (endDate != null)
46  {
47    @:if(@(endDate)!=null) {
48      @:if(GetRequest == "") {
49        @:GetRequest += "?end=" + @endDate;
50      @:}
51      @:else {
52        @:GetRequest += "&end=" + @endDate;
53      @:}
54    @:}
55  }
56  @if (jobId != null)
57  {
58    @:if(@(jobId)!=null) {
59      @:if(GetRequest == "") {
60        @:GetRequest += "?jobId=" + @jobId;
61      @:}
62      @:else {
63        @:GetRequest += "&jobId=" + @jobId;
64      @:}
65    @:}
66  }
67  @if (taskState != null)
68  {
69    @:if(@(taskState)!=null) {
70      @:if(GetRequest == "") {
71        @:GetRequest += "?taskState=" + @taskState;
72      @:}
73      @:else {
74        @:GetRequest += "&taskState=" + @taskState;
75      @:}
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
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) {
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++) {
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          }
111        }
112        ErrorHTML += '</section>';
113        $("#" + "@destinationTag").append(ErrorHTML);
114      }
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      }
122    }
123  });
124  </text>
125}
126
127@helper ScrollToException() {
128  <text>
129    function ScrollTo(caller) {
130      var taskErrorId = $(caller).parent().parent().attr('id') + $(caller).html() + "PlotTitle";
131      $("#" + taskErrorId).parent().find("button").click();
132      $('html, body').animate({
133          scrollTop: $("#" + taskErrorId).parent().offset().top
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>
160}
161
162@helper ShowErrors(string destinationTag) {
163  <text>
164  $("#@(destinationTag)").find(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','inline-block');
165  </text>
166}
167
168@helper ErrorsOnSlaves(string destinationTag, string url, string limit, string startDate = null, string endDate = null, string clientId=null, string functionName=null, string pageNumber=null) {
169  <text>
170  var GetRequest = "";
171  @if (startDate != null)
172  {
173    @:if(@(startDate)!=null) {
174      @:if(GetRequest == "") {
175        @:GetRequest += "?start=" + @startDate;
176      @:}
177      @:else {
178        @:GetRequest += "&start=" + @startDate;
179      @:}
180    @:}
181  }
182  @if (endDate != null)
183  {
184    @:if(@(endDate)!=null) {
185      @:if(GetRequest == "") {
186        @:GetRequest += "?end=" + @endDate;
187      @:}
188      @:else {
189        @:GetRequest += "&end=" + @endDate;
190      @:}
191    @:}
192  }
193  @if (clientId != null)
194  {
195    @:if(@(clientId)!=null) {
196      @:if(GetRequest == "") {
197        @:GetRequest += "?clientId=" + @clientId;
198      @:}
199      @:else {
200        @:GetRequest += "&clientId=" + @clientId;
201      @:}
202    @:}
203  }
204  $.ajax({
205    async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) {
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
214      for(i = 0; i < result.length; i++) {
215        $("#" + "@(destinationTag)").append(
216          '<section id="@(destinationTag)' + result[i][0] + '" class="chartContainer">' +
217            '<h1 class="title" id="@(destinationTag)' + result[i][0] + 'PlotTitle">Task ' + result[i][0] + '</h1>' +
218            '<button class="collapse" onclick="CollapseSection(this)">+</button>' +
219            '<label id="' + result[i][0] + 'ErrorMessage">Error Message: ' + result[i][1] + '</label>' +
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>' +
224          '</section>'
225        );
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"));
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) {
250    var taskSlaveId = $(caller).attr('id');
251    CheckFilters();
252    if($(caller).parent().parent().children(".chartContainer").length == 0) {
253      var destinationTag = $(caller).parent().parent().attr('id');
254      @ChartHelper.SlaveContainers("destinationTag",url,limit,true,startDate,endDate,null,null,null,"taskSlaveId")
255    }
256    else {
257      $(caller).parent().parent().children(".chartContainer").remove();
258    }
259  }
260  </text>
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>
270}
Note: See TracBrowser for help on using the repository browser.