Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/20/14 16:20:02 (10 years ago)
Author:
mroscoe
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Code/ChartHelper.cshtml

    r11020 r11030  
    110110}
    111111
    112 @helper TasksForUser(string container, string destinationTag, string url, string userName, string startDate = null, string endDate = null)
    113 {
    114   <text>
    115     $.ajax({url: "@(new HtmlString(url))?userName=" + @(userName) + "&start=" + @startDate + "&end=" + @endDate, datatype: "json", success: function(result) {
    116       $("#@container").html("");
    117       if(result[0].length==0) {
     112@helper TasksForUser(string container, string destinationTag, string pageUrl, string taskUrl, string functionName, string userName, string limit, string startDate = null, string endDate = null, string jobId=null, string taskState=null, string pageNumber=null)
     113{
     114  <text>
     115    var GetRequest = "?userName=" + @(userName) + "&limit=" + @(limit);
     116    @if(startDate!=null) {
     117      @:if(@(startDate)!=null) {
     118        @:GetRequest += "&start=" + @startDate;
     119      @:}
     120    }
     121    @if(endDate!=null) {
     122      @:if(@(endDate)!=null) {
     123        @:GetRequest += "&end=" + @endDate;
     124      @:}
     125    }
     126    @if(jobId!=null) {
     127      @:if(@(jobId)!=null) {
     128        @:GetRequest += "&jobId=" + @jobId;
     129      @:}
     130    }
     131    @if(taskState!=null) {
     132      @:if(@(taskState)!=null) {
     133        @:GetRequest += "&taskState=" + @taskState;
     134      @:}
     135    }
     136    $.ajax({async: false, url: "@(new HtmlString(pageUrl))" + GetRequest, datatype: "json", success: function(result) {
     137      if(result > 1) {
     138        $("#@container").append('<label class="pageTitle">Page: </label>')
     139        for(var i=0; i < result; i++) {
     140          $("#" + "@container").append('<a id="Page' + (i + 1) + '" class="page">' + (i + 1) + '</a>')
     141        }
     142        if(@pageNumber != null) {
     143          $("#Page" + @pageNumber).css('color','#F7921D');
     144        }
     145        else {
     146          $("#Page1").css('color','#F7921D');
     147        }
     148      }
     149    }});
     150    @if(pageNumber!=null) {
     151      @:if(@(pageNumber)!=null) {
     152        @:GetRequest += "&currentPage=" + @pageNumber;
     153      @:}
     154    }
     155    $.ajax({url: "@(new HtmlString(taskUrl))" + GetRequest, datatype: "json", success: function(result) {
     156      if(result.Key.length==0) {
    118157        $("#@container").append(
    119           '<section class="chartContainer"><h1 class="title">' + @userName + ' has no tasks for the given time period!</h1></section>'
     158          '<section class="chartContainer"><h1 class="title">' + @userName + ' has no tasks for the specified filters!</h1></section>'
    120159        )
    121160      }
     
    126165
    127166      //Globally accesible, for use when resizing, eliminates extra DB request
    128       window["numberTasks"] = result[0].length;
     167      window["numberTasks"] = result.Key.length;
     168
     169      //Set display of all errors to none, errors matching the tasks will be reset below
     170      $(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','none');
    129171
    130172      //For each result create a seperate collapsable section with a chart and info label
    131       for(var i = 0; i < result[0].length; i++){
     173      for(var i = 0; i < result.Key.length; i++){
    132174        $("#" + "@container").append(
    133           '<section class="chartContainer"><h1 class="title">Task ' + (i + 1) +
    134           '</h1><button class="collapse" onclick="collapseSection(this)">-</button><div id="@(destinationTag)' + i +
     175          '<section class="chartContainer"><h1 class="title" id="' + result.Key[i] + '">Task ' + result.Key[i] +
     176          '</h1><button class="collapse" onclick="collapseSection(this)">+</button><div id="@(destinationTag)' + i +
    135177          '"></div><label id="@(destinationTag)' + i + 'Info"></label></section>'
    136178        )
    137         waitTime = [result[0][i]];
    138         transferTime = [result[1][i]];
    139         runTime = [result[2][i]];
     179        $(".errorTask").each(function() {
     180          if($(this).html()==result.Key[i]) {
     181            $("#" + result.Key[i]).css("color","red");
     182            $("#" + result.Key[i]).append(" - ERROR");
     183            $(".errorContainer, .errorTitle, .underline").css('display','inline-block');
     184            $(this).css('display','inline-block');
     185            $(this).next().css('display','inline-block');
     186          }
     187        });
     188        waitTime = [result.Value[0][i]];
     189        transferTime = [result.Value[1][i]];
     190        runTime = [result.Value[2][i]];
    140191        window["@(destinationTag)Plot" + i] = $.jqplot("@destinationTag" + i, [waitTime,transferTime,runTime], {
    141           //stackSeries: true,
    142192          seriesDefaults:{
    143193            renderer:$.jqplot.BarRenderer,
    144194            shadowAngle: 135,
    145             //rendererOptions: {
    146             //  barDirection: 'horizontal'
    147             //},
    148195            pointLabels: {show: true, formatString: '%.3f'}
    149196          },
     
    176223        $("#" + "@(destinationTag)" + i).bind('jqplotDataClick', function (ev, seriesIndex, pointIndex, data) {
    177224          $("#" + $(this).attr('id') + "Info").html(seriesDescriptions[seriesIndex] + ': ' + data[1]);
    178         });
     225        });
     226
     227        window["@(destinationTag)Plot" + i].replot({ resetAxes: true });
     228
     229        $('#@destinationTag' + i).contextmenu(function() {
     230          window["@(destinationTag)Plot" + i].resetZoom();
     231          window["@(destinationTag)Plot" + i].replot({ resetAxes: true });
     232          return false;
     233        });
     234
     235        collapsedByDefault(document.getElementById("@(destinationTag)" + i));
    179236      }
    180237    }});
     238
     239    $(".page").click(function () {
     240      pageNumber = $(this).html();
     241      @(functionName)();
     242    });
    181243  </text>
    182244}
     
    187249  $(window).resize(function() {
    188250    for(var i = 0; i < numberTasks; i++) {
    189       window[ "@(destinationTag)Plot" + i].replot({ resetAxes: true });
     251      $.each(window[ "@(destinationTag)Plot" + i].series, function(index, series) {
     252        series.barWidth = undefined;
     253      });
     254      window["@(destinationTag)Plot" + i].replot({ resetAxes: true });
    190255    }
    191256  });
    192257  </text>
    193258}
    194 
    195 @* OLD SMOOTHIE CHART FUNCTIONS *@
    196 @*@helper CreateSmoothieChart(string destinationTag, string stroke, string fill, string label)
    197 {
    198   <text>
    199     var @(destinationTag)Smoothie = new SmoothieChart({
    200       grid: {
    201         strokeStyle: '@stroke', fillStyle: '@fill',
    202         lineWidth: 1, millisPerLine: 450, verticalSections: 4,
    203       },
    204       labels: {
    205         fillStyle: '@label'
    206       }
    207     });
    208 
    209     var @(destinationTag)TimeSeries = new Array()
    210   </text>
    211 }
    212 
    213 @helper SetSmoothieCanvas(string destinationTag, string delay)
    214 {
    215   <text>
    216   @(destinationTag)Smoothie.streamTo(document.getElementById("@destinationTag"), @delay);
    217   </text>
    218 }
    219 
    220 @helper AssignTimeSeries(string seriesName, string destinationTag, string stroke, string fill)
    221 {
    222   <text>
    223   var @(seriesName)TS = new TimeSeries();
    224   @(destinationTag)Smoothie.addTimeSeries(@(seriesName)TS, { strokeStyle: '@stroke', fillStyle: '@fill', lineWidth: 3 });
    225   @(destinationTag)TimeSeries.push(@(seriesName)TS);
    226   </text>
    227 }
    228 
    229 @helper UpdateChartData(string destinationTag, string url)
    230 {
    231   <text>
    232   $.ajax({
    233     url: '@(url)', datatype: "json", success: function (result) {
    234       var i
    235       for (i = 0; i < @(destinationTag)TimeSeries.length; i++) {
    236         @(destinationTag)TimeSeries[i].append(new Date().getTime(), result[i]);
    237       }
    238     }
    239   });
    240   </text>
    241 }*@
    242259
    243260@helper SetStreamingProperties(int refresh, int chartLength, int upperY) {
     
    376393  </text>
    377394}
    378 
    379 @helper MakeCollapsable()
    380 {
    381   <text>
    382   $(document).ready(function() {
    383     $(".collapse").click(function () {
    384       if ($(this).html() == "-") {
    385         $(this).parent().children("canvas, div, fieldset, label").fadeOut();
    386         $(this).html("+");
    387       }
    388       else {
    389         $(this).parent().children("canvas, div, fieldset, label").fadeIn();
    390         $(this).html("-");
    391       }
    392     });
    393   });
    394   </text>
    395 }
Note: See TracChangeset for help on using the changeset viewer.