summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/statistic/index.phtml
blob: 17bcc152d9583dcdbcb93c2bcf8e5ce8ac20f66d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<h1>Category - Statistic</h1>

<link
	rel="stylesheet" type="text/css"
	href="/media/css/jquery.jqplot.min.css" />

<select id="poolselectbox" name="PoolSelectbox"
	onclick="setPoolIDtmp();" onChange="fetchPoolEvents();">
	<option value="default">Please choose a Pool</option>
</select>

<script>

var lecture = 0;
var boot = 0;
var shutdown = 0;
var maintenance = 0;
var foo;

//fetch all poolevents of the selected #poolselectbox value
function fetchPoolEvents() {
  poolID = $("#poolselectbox option:selected").val();
  plot();
}

function setPoolIDtmp() {
    poolIDtmp = $("#poolselectbox option:selected").val();
  }

function plot() {
	poolID = $("#poolselectbox option:selected").val();
  $.get("/statistic/categorylist/poolID/" + poolID, function(data) {
	  if(data == '') {
		  $( "#noEventsDialog" ).dialog('open');
		  $('#plot').empty();
	  } else refreshPlot(data);
	  }, "json");
}

function refreshPlot(data) {
	$('#plot').empty();
	$.jqplot('plot', data, {
        seriesDefaults: {
        renderer:$.jqplot.BarRenderer,
        pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
        shadowAngle: 135,
        rendererOptions: {
            barDirection: 'horizontal'
        }
    },
    axes: {
        yaxis: {
            renderer: $.jqplot.CategoryAxisRenderer
        }
    }
    });
}

$(document).ready(function(){

	 //fetch poollist from pbs database
	  $.get("/event/getpoollist/", function(getpoollistresult){
	    $("#poolselectbox").append(getpoollistresult);
	    poolIDtmp = $("#poolselectbox option:selected").val();
	    fetchPoolEvents();
	    });
});

$(function() {
    $( "#noEventsDialog" ).dialog({
            autoOpen: false,
            width: 600,
      modal: true,
      title: "No Events",
            buttons: { 
              "OK": function() { 
                $(this).dialog("close");
              }
            },
      open: function () {
                $(".ui-dialog-titlebar-close").hide();
                //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
            }
    });
  }); 

</script>

<div id="plot"
	style="height: 400px; width: 700px;"></div>

<!-- no events -->
<div id="noEventsDialog" style="display: none">
<p>There are no events in this pool to plot the statistic</p>
</div>