Embedded toolbar

This commit is contained in:
Latif Khalifa
2013-10-13 14:24:48 +02:00
parent d3d9866354
commit fa680c9623
4 changed files with 138 additions and 26 deletions

View File

@@ -1 +1,9 @@
php_flag display_errors on
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType text/css "access plus 1 hour"
</IfModule>

View File

@@ -12,7 +12,7 @@ function lk($id, $txt)
$filter = new SearchFilter();
$total = CrashReport::getTotal($filter);
$reports = CrashReport::getReports($filter);
Layout::header();
Layout::header($filter->renderPaginator($total));
$filter->render();
?>
@@ -110,9 +110,11 @@ $filter->render();
}
});
});
});
</script>
<p>Reports <strong><?php echo $total ?></strong></p>
<br/>
<table width="100%" class="jtable">
<tr>
@@ -134,6 +136,7 @@ $filter->render();
</tr>
<?php endfor ?>
</table>
<?php
Layout::footer();

View File

@@ -78,7 +78,7 @@ class Layout
return $print;
}
function header()
function header($toolbar = "")
{
global $S;
@@ -132,28 +132,44 @@ class Layout
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php print URL_ROOT ?>/css/singularity/jquery-ui-1.10.3.custom.css"/>
<link rel="stylesheet" type="text/css" href="<?php print URL_ROOT ?>/css/singularity/singularity.css"/>
<link rel="shortcut icon" href="<?php print IMG_ROOT ?>/favicon.ico" type="image/x-icon" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="shortcut icon" href="<?php print IMG_ROOT ?>/favicon.ico" type="image/x-icon" />
<title>Singularity Viewer - Automated Crash Report Processing System</title>
<script type="text/javascript">
//<![CDATA[
$(function() {
$( ".toolbarbutton" ).button();
/*
$( ".rowhighlight" ).on("mousedown", function(e) {
$(this).addClass("ui-state-disabled");
});
*/
});
//]]>
</script>
<style type="text/css">
#menubar {
text-align: justify;
margin: 10px 0px 10px 0px;
padding: .5em;
}
#menubar div {
display: inline-block;
}
#menubar:after {
content: '';
display: inline-block;
width: 100%;
}
</style>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
$(function() {
$( ".toolbarbutton" ).button();
/*
$( ".rowhighlight" ).on("mousedown", function(e) {
$(this).addClass("ui-state-disabled");
});
*/
});
//]]>
</script>
<div style="padding-top:20px;">
<div style="display: inline-block;">
<a href="<?php echo URL_ROOT ?>"><img src="images/singularity_icon.png" width="150px" height="150px"/></a>
@@ -164,10 +180,15 @@ $(function() {
<span style="font-size: 1.6em;">Automated Crash Report Processing</span>
</div>
</div>
<div id="menubar" style="text-align: right; margin-top:10px; margin-bottom:10px; padding: 5px;" class="ui-widget-header ui-corner-all">
<?php for ($i=0; $i<count($menu); $i++): ?>
<a class="toolbarbutton" href="<?php echo $menu[$i]->link; ?>"><?php echo htmlspecialchars($menu[$i]->label) ?></a>
<?php endfor ?>
<div id="menubar" class="ui-widget-header ui-corner-all">
<div><?php echo $toolbar ?></div>
<div>
<?php for ($i=0; $i<count($menu); $i++): ?>
<a class="toolbarbutton" href="<?php echo $menu[$i]->link; ?>"><?php echo htmlspecialchars($menu[$i]->label) ?></a>
<?php endfor ?>
</div>
</div>
<?php

View File

@@ -19,7 +19,7 @@ class SearchFilter
public $offset = 0;
public $page = 0;
var $fields = array("os", "chan", "version", "grid", "region", "gpu", "stacktrace", "signature_id");
var $fields = array("os", "chan", "version", "grid", "region", "gpu", "stacktrace", "signature_id", "limit", "offset");
function __construct()
{
@@ -156,7 +156,7 @@ class SearchFilter
</script>
<form method="get">
<form id="filter_form" method="get">
<div class="ui-widget ui-corner-all ui-widget-content">
<div class="ui-widget-header" style="padding: 5px">Filter</div>
@@ -226,9 +226,89 @@ for($i = 0; $i < count($grids); $i++)
<input type="hidden" name="signature_id" value="<?php echo htmlentities($this->signature_id) ?>" />
<?php endif ?>
<input type="hidden" id="limit" name="limit" value="<?php echo (int)($this->limit) ?>" />
<input type="hidden" id="offset" name="offset" value="<?php echo (int)($this->offset) ?>" />
</form>
<?php
}
function renderPaginator($total)
{
ob_start();
?>
<script>
$(function() {
var $filter = $("#filter_form");
var $offset = Number($("#offset").val());
var $limit = Number($("#limit").val());
var $total = Number(<?php echo $total ?>);
var $max_offset = (Math.floor($total / $limit)) * $limit;
//console.log("Offset: " + $offset + "; Max offset: " + $max_offset);
$("#first").button({
disabled: $offset == 0,
text: false,
icons: { primary: "ui-icon-seek-start" },
})
.on("click", function() {
$("#offset").val(0);
$filter.submit();
});
$("#previous").button({
disabled: $offset == 0,
text: false,
icons: { primary: "ui-icon-seek-prev" },
})
.on("click", function() {
$offset -= $limit;
if ($offset < 0 ) $offset = 0;
$("#offset").val($offset);
$filter.submit();
});
$("#next").button({
disabled: $offset >= $max_offset,
text: false,
icons: { primary: "ui-icon-seek-next" },
})
.on("click", function() {
$offset += $limit;
if ($offset > $total ) $offset = $total;
$("#offset").val($offset);
$filter.submit();
});
$("#last").button({
disabled: $offset >= $max_offset,
text: false,
icons: { primary: "ui-icon-seek-end" },
})
.on("click", function() {
$("#offset").val($max_offset);
$filter.submit();
});
});
</script>
<!--div id="paginator" class="ui-widget-header ui-corner-all" style="display: inline-block; padding: 4px"-->
<button id="first">First</button>
<button id="previous">Previous</button>
<div style="display: inline-block; text-align: center; width: 175px;">
<?php echo $this->offset + 1 ?> -
<?php echo $this->offset + $this->limit > $total ? $total : $this->offset + $this->limit ?> out of
<?php echo $total ?>
</div>
<button id="next">Next</button>
<button id="last">Last</button>
<!--/div-->
<?php
return ob_get_clean();
}
}