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 limit, string userName = null, string startDate = null, string endDate = null, string jobId = null, string taskState = null)
|
---|
21 | {
|
---|
22 | <text>
|
---|
23 | var GetRequest = "?limit=" + @(limit);
|
---|
24 | @if (userName != null) {
|
---|
25 | @:if(@(userName)!=null) {
|
---|
26 | @:GetRequest += "&userName=" + @userName;
|
---|
27 | @:}
|
---|
28 | }
|
---|
29 | @if(startDate!=null) {
|
---|
30 | @:if(@(startDate)!=null) {
|
---|
31 | @:GetRequest += "&start=" + @startDate;
|
---|
32 | @:}
|
---|
33 | }
|
---|
34 | @if(endDate!=null) {
|
---|
35 | @:if(@(endDate)!=null) {
|
---|
36 | @:GetRequest += "&end=" + @endDate;
|
---|
37 | @:}
|
---|
38 | }
|
---|
39 | @if(jobId!=null) {
|
---|
40 | @:if(@(jobId)!=null) {
|
---|
41 | @:GetRequest += "&jobId=" + @jobId;
|
---|
42 | @:}
|
---|
43 | }
|
---|
44 | @if(taskState!=null) {
|
---|
45 | @:if(@(taskState)==null) {
|
---|
46 | @:GetRequest += "&taskState=" + @taskState;
|
---|
47 | @:}
|
---|
48 | }
|
---|
49 | $.ajax({async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) {
|
---|
50 | $("#" + "@destinationTag").html("");
|
---|
51 | if(result.Key.length > 0) {
|
---|
52 | var ErrorHTML = '<section class="errorContainer">' +
|
---|
53 | '<p class="errorTitle">Some tasks were found in error state!</p>' +
|
---|
54 | '<label class="errorTask underline">Task</label>' +
|
---|
55 | '<label class="errorMessage underline">Error</label>';
|
---|
56 | for (var i = 0; i < result.Key.length; i++) {
|
---|
57 | ErrorHTML += '<a class="errorTask" onclick="ScrollTo(this)">' + result.Key[i] + '</a>' +
|
---|
58 | '<label class="errorMessage">' + result.Value[i] + '</label>';
|
---|
59 | }
|
---|
60 | ErrorHTML += '</section>';
|
---|
61 | $("#" + "@destinationTag").append(ErrorHTML);
|
---|
62 | }
|
---|
63 | }
|
---|
64 | });
|
---|
65 | </text>
|
---|
66 | }
|
---|
67 |
|
---|
68 | @helper ScrollToException() {
|
---|
69 | <text>
|
---|
70 | function ScrollTo(caller) {
|
---|
71 | var taskErrorId = $(caller).parent().parent().attr('id') + $(caller).html();
|
---|
72 | OpenOnError(document.getElementById(taskErrorId));
|
---|
73 | $('html, body').animate({
|
---|
74 | scrollTop: $("#" + taskErrorId).parent().offset().top
|
---|
75 | }, 2000);
|
---|
76 | }
|
---|
77 |
|
---|
78 | $('#ScrollTop').click(function() {
|
---|
79 | $('html, body').animate({
|
---|
80 | scrollTop: 0
|
---|
81 | }, 2000);
|
---|
82 | });
|
---|
83 |
|
---|
84 | $(window).on("scrollstop",function() {
|
---|
85 | var newTop = $(window).scrollTop();
|
---|
86 | if(newTop==0) {
|
---|
87 | $('#ScrollTop').animate({
|
---|
88 | top: newTop + 20
|
---|
89 | }, 800, function() {
|
---|
90 | $('#ScrollTop').css('display','none');
|
---|
91 | });
|
---|
92 | }
|
---|
93 | else {
|
---|
94 | $('#ScrollTop').css('display','block');
|
---|
95 | $('#ScrollTop').animate({
|
---|
96 | top: newTop + 20
|
---|
97 | }, 800);
|
---|
98 | }
|
---|
99 | });
|
---|
100 | </text>
|
---|
101 | }
|
---|
102 |
|
---|
103 | @helper ShowErrors(string destinationTag) {
|
---|
104 | <text>
|
---|
105 | $("#@(destinationTag)").children(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','inline-block');
|
---|
106 | </text>
|
---|
107 | }
|
---|
108 |
|
---|
109 | @helper ErrorsOnSlaves(string destinationTag, string url, string limit, string startDate = null, string endDate = null, string clientId=null) {
|
---|
110 | <text>
|
---|
111 | var GetRequest = "?limit=" + @(limit);
|
---|
112 | @if(startDate!=null) {
|
---|
113 | @:if(@(startDate)!=null) {
|
---|
114 | @:GetRequest += "&start=" + @startDate;
|
---|
115 | @:}
|
---|
116 | }
|
---|
117 | @if(endDate!=null) {
|
---|
118 | @:if(@(endDate)!=null) {
|
---|
119 | @:GetRequest += "&end=" + @endDate;
|
---|
120 | @:}
|
---|
121 | }
|
---|
122 | @if (clientId != null) {
|
---|
123 | @:if(@(clientId)!=null) {
|
---|
124 | @:GetRequest += "&clientId=" + @clientId;
|
---|
125 | @:}
|
---|
126 | }
|
---|
127 | $.ajax({
|
---|
128 | async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) {
|
---|
129 | for(i = 0; i < result.length; i++) {
|
---|
130 | $("#" + "@(destinationTag)").append(
|
---|
131 | '<section id="' + result[i][0] + 'Container" class="chartContainer">' +
|
---|
132 | '<h1 class="title" id="@(destinationTag)' + result[i][0] + '">Task ' + result[i][0] + '</h1>' +
|
---|
133 | '<button class="collapse" onclick="CollapseSection(this)">+</button>' +
|
---|
134 | '<label id="' + result[i][0] + 'ErrorMessage">Error Message: ' + result[i][1] + '</label>' +
|
---|
135 | '<label id="' + result[i][0] + 'Client">Slave: <a onclick="ShowSlaveInfo(this)">' + result[i][2] + '</a></label>' +
|
---|
136 | '<label id="' + result[i][0] + 'User">User Name: ' + result[i][3] + '</label>' +
|
---|
137 | '<label id="' + result[i][0] + 'Date">Date/Time: ' + result[i][4] + '</label>' +
|
---|
138 | '</section>'
|
---|
139 | );
|
---|
140 | CollapsedByDefault(document.getElementById("@(destinationTag)" + result[i][0]));
|
---|
141 | }
|
---|
142 | }
|
---|
143 | });
|
---|
144 | </text>
|
---|
145 | }
|
---|
146 |
|
---|
147 | @helper ShowSlaveInfo(string url, string limit, string startDate=null, string endDate=null) {
|
---|
148 | <text>
|
---|
149 | //Opens a sub-container with slave information
|
---|
150 | function ShowSlaveInfo(caller) {
|
---|
151 | if($(caller).parent().parent().children(".chartContainer").length == 0) {
|
---|
152 | @ChartHelper.SlaveInfoChart("caller.parentNode.parentNode.id",url,limit,true,startDate,endDate,null,null,null,"$(caller).html()")
|
---|
153 | }
|
---|
154 | else {
|
---|
155 | $(caller).parent().parent().children(".chartContainer").remove();
|
---|
156 | }
|
---|
157 | }
|
---|
158 | </text>
|
---|
159 | } |
---|