summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSebastian Wagner2011-10-06 19:48:46 +0200
committerSebastian Wagner2011-10-06 19:48:46 +0200
commit48674fdcb55c9cbda1d21b6609a45113219aedd3 (patch)
tree1f95bf5972915b86258a2d5646978b1aa45c43a0 /application
parentMerge branch 'master' of git.openslx.org:lsfks/projekte/poolctrl (diff)
downloadpoolctrl-48674fdcb55c9cbda1d21b6609a45113219aedd3.tar.gz
poolctrl-48674fdcb55c9cbda1d21b6609a45113219aedd3.tar.xz
poolctrl-48674fdcb55c9cbda1d21b6609a45113219aedd3.zip
successfulPlot implemented
Diffstat (limited to 'application')
-rwxr-xr-xapplication/controllers/StatisticController.php49
-rwxr-xr-xapplication/layouts/default.phtml1
-rwxr-xr-xapplication/models/EventreportMapper.php50
-rw-r--r--application/views/scripts/statistic/success.phtml119
4 files changed, 207 insertions, 12 deletions
diff --git a/application/controllers/StatisticController.php b/application/controllers/StatisticController.php
index da1e56e..3f42944 100755
--- a/application/controllers/StatisticController.php
+++ b/application/controllers/StatisticController.php
@@ -6,12 +6,14 @@ class StatisticController extends Zend_Controller_Action
protected $pbs2host;
protected $eventMapper;
protected $eventcategoryMapper;
+ protected $eventreportMapper;
public function init()
{
$this->eventMapper = new Application_Model_EventMapper();
$this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
+ $this->eventreportMapper = new Application_Model_EventreportMapper();
if (Zend_Auth::getInstance()->hasIdentity()) {
$this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
@@ -48,14 +50,14 @@ class StatisticController extends Zend_Controller_Action
if($this->acl->checkRight('eoo')) {
$eventList = $this->eventMapper->fetchAll();
- } else {
+ } else {
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
- }
+ }
$ret['dataBar'] = $this->eventMapper->getCategoryBarCount($poolID);
$ret['dataPie'] = $this->eventMapper->getCategoryPieCount($poolID);
$ret['color'] = $this->eventcategoryMapper->getCategoryColor($poolID);
-
+
echo json_encode($ret);
}
@@ -70,23 +72,48 @@ class StatisticController extends Zend_Controller_Action
if($this->acl->checkRight('eoo')) {
$eventList = $this->eventMapper->fetchAll();
- } else {
+ } else {
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
- }
+ }
$ret['dataBar'] = $this->eventMapper->getRunningBarCount($poolID);
$ret['dataPie'] = $this->eventMapper->getRunningPieCount($poolID);
echo json_encode($ret);
-
+
+ }
+
+ public function successlistAction() {
+
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ $poolID = $this->getRequest()->getParam('poolID');
+ $userIDsSession = new Zend_Session_Namespace('userIDs');
+ $userIDsSession->poolID = $poolID;
+
+ if($this->acl->checkRight('eoo')) {
+ $eventList = $this->eventMapper->fetchAll();
+ } else {
+ $eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
+ }
+
+ $ret['dataBar'] = $this->eventreportMapper->getSuccessBarCount($poolID);
+ $ret['dataPie'] = $this->eventreportMapper->getSuccessPieCount($poolID);
+
+ echo json_encode($ret);
+
}
-
+
public function categoryAction() {
-
+
}
-
+
public function runningAction() {
-
+
+ }
+
+ public function successAction() {
+
}
-
+
} \ No newline at end of file
diff --git a/application/layouts/default.phtml b/application/layouts/default.phtml
index 85ba46a..53eeedb 100755
--- a/application/layouts/default.phtml
+++ b/application/layouts/default.phtml
@@ -56,6 +56,7 @@ echo $this->headScript()."\n";
<ul class='navTreeLevel1'>
<li class='navTreeItem'><a href='/statistic/category'>Category</a></li>
<li class='navTreeItem'><a href='/statistic/running'>Running</a></li>
+ <li class='navTreeItem'><a href='/statistic/success'>Success</a></li>
</ul>
</li>
<?php } ?>
diff --git a/application/models/EventreportMapper.php b/application/models/EventreportMapper.php
index a78ee73..309dd18 100755
--- a/application/models/EventreportMapper.php
+++ b/application/models/EventreportMapper.php
@@ -114,7 +114,7 @@ class Application_Model_EventreportMapper
if($eventreport == null){
$return = true;
-
+
}
if($return) {
@@ -164,7 +164,55 @@ class Application_Model_EventreportMapper
return array_diff($vv1,$vv2);
}
+ public function getSuccessBarCount($poolID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->setIntegrityCheck(false)
+ ->from(array('pcr' => 'poolctrl_eventreport'),
+ array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))')
+ )
+ ->join(array('pce' => 'poolctrl_event'),
+ 'pce.eventID = pcr.eventID',
+ array())
+ ->where('pce.pbs_poolID = ?', $poolID);
+
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll(PDO::FETCH_NUM);
+
+ foreach ($result as $r) {
+ $ret1 = array((int)$r[0],'Successful');
+ $ret2 = array((int)$r[1],'Failed');
+ $return[] = array($ret1,$ret2);
+ }
+
+ return $return;
+ }
+ public function getSuccessPieCount($poolID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->setIntegrityCheck(false)
+ ->from(array('pcr' => 'poolctrl_eventreport'),
+ array('count1' => 'SUM(IF(pcr.result="successful",1,0))', 'count0' => 'SUM(IF(pcr.result="failed",1,0))')
+ )
+ ->join(array('pce' => 'poolctrl_event'),
+ 'pce.eventID = pcr.eventID',
+ array())
+ ->where('pce.pbs_poolID = ?', $poolID);
+
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll(PDO::FETCH_NUM);
+
+ foreach ($result as $r) {
+ $ret1 = array('Successful', (int)$r[0]);
+ $ret2 = array('Failed', (int)$r[1]);
+ $return[] = array($ret1,$ret2);
+ }
+
+ return $return;
+ }
}
diff --git a/application/views/scripts/statistic/success.phtml b/application/views/scripts/statistic/success.phtml
new file mode 100644
index 0000000..8702291
--- /dev/null
+++ b/application/views/scripts/statistic/success.phtml
@@ -0,0 +1,119 @@
+<h1>Statistic - Success</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>
+
+//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/successlist/poolID/" + poolID, function(data) {
+ if(data.dataBar == '0,Successful,0,Failed' && poolID != 'default') {
+ $( "#noEventsDialog" ).dialog('open');
+ $('#plotBar').empty();
+ $('#plotPie').empty();
+ } else if (poolID == 'default') {
+ $('#plotBar').empty();
+ $('#plotPie').empty();
+ } else refreshPlot(data.dataBar, data.dataPie, data.color);
+ }, "json");
+}
+
+function refreshPlot(dataBar, dataPie, color) {
+ $('#plotBar').empty();
+ $.jqplot('plotBar', dataBar, {
+ seriesDefaults: {
+ //renderer: $.jqplot.PieRenderer,
+ renderer:$.jqplot.BarRenderer,
+ pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
+ shadowAngle: 135,
+ rendererOptions: {
+ //showDataLabels: true,
+ barDirection: 'horizontal',
+ varyBarColor : true
+ }
+ },
+ axes: {
+ yaxis: {
+ renderer: $.jqplot.CategoryAxisRenderer
+ }
+ },
+ seriesColors: color,
+ highlighter: { show: false }
+ });
+ $('#plotPie').empty();
+ $.jqplot('plotPie', dataPie,
+ {
+ seriesDefaults: {
+ // Make this a pie chart.
+ renderer: jQuery.jqplot.PieRenderer,
+ rendererOptions: {
+ // Put data labels on the pie slices.
+ // By default, labels show the percentage of the slice.
+ showDataLabels: true,
+ lineLabels: true,
+ varyBarColor : true
+ }
+ },
+ seriesColors: color
+ //legend: { show:true, location: 'e' }
+ });
+ }
+
+$(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>
+<div id="plotBar" class="spalte"
+ style="height: 250px; width: 250px;"></div>
+<div id="plotPie" class="spalte"
+ style="height: 250px; width: 250px;"></div>
+</div>
+
+<!-- no events -->
+<div id="noEventsDialog" style="display: none">
+<p>There are no events in this pool to plot a statistic.</p>
+</div> \ No newline at end of file