Permalink
Browse files

option "starts at midnight" for a graph (SQL inc)

Add a checkbox in the graph edit panel for this.
If checked, the graph will be drawn with option "from=midnight-[...]"
  • Loading branch information...
Florent Couffe
Florent Couffe committed Aug 22, 2013
1 parent 9d154de commit 6c1bcf3374214e63a705f4a7d3f2532983dec0da
Showing with 10 additions and 1 deletion.
  1. +1 −0 graphite_tattle_schema_alpha.sql
  2. +2 −0 graphs.php
  3. +2 −1 inc/classes/Graph.php
  4. +3 −0 inc/views/add_edit_graph.php
  5. +2 −0 script_modif_table.sql
@@ -86,6 +86,7 @@ CREATE TABLE `graphs` (
`time_value` int(11) NOT NULL DEFAULT '2',
`unit` varchar(10) NOT NULL DEFAULT 'hours',
`custom_opts` varchar(1000) NULL,
`starts_at_midnight` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`graph_id`),
UNIQUE KEY `dashboard_id` (`dashboard_id`,`name`)
) CHARSET=utf8;
@@ -20,6 +20,7 @@
$lines = Line::findAll($graph_id);
if (fRequest::isPost()) {
$graph->populate();
$graph->setStartsAtMidnight(isset($_POST['starts_at_midnight'])?$_POST['starts_at_midnight']:false);
fRequest::validateCSRFToken(fRequest::get('token'));
$graph->store();
@@ -45,6 +46,7 @@
if (fRequest::isPost()) {
try {
$graph->populate();
$graph->setStartsAtMidnight(isset($_POST['starts_at_midnight'])?$_POST['starts_at_midnight']:false);
fRequest::validateCSRFToken(fRequest::get('token'));
$graphs_in_dashboard = Graph::findAll($dashboard_id);
$graph->setWeight($graphs_in_dashboard->count(TRUE));
@@ -77,7 +77,7 @@ static function drawGraph($obj=NULL,$parent=NULL)
$link .= 'areaMode=' . $obj->getArea() .'&';
}
if ($obj->getTime_Value() != '' && $obj->getUnit() != '') {
$link .= 'from=-' . $obj->getTime_Value() . $obj->getUnit() . '&';
$link .= 'from=' . ($obj->getStartsAtMidnight()?'midnight':'') . '-' . $obj->getTime_Value() . $obj->getUnit() . '&';
}
if ($obj->getCustom_Opts() != '') {
$link .= $obj->getCustom_Opts() . '&';
@@ -106,6 +106,7 @@ static public function cloneGraph ($graph_id, $dashboard_id=NULL) {
$graph->setTimeValue($graph_to_clone->getTimeValue());
$graph->setUnit($graph_to_clone->getUnit());
$graph->setCustomOpts($graph_to_clone->getCustomOpts());
$graph->setStartsAtMidnight($graph_to_clone->getStartsAtMidnight());
$graph->store();
// Clone of the lines
@@ -71,6 +71,9 @@
}
?>
</select>
<div class="input">
<input type="checkbox" name="starts_at_midnight" <?= ($graph->getStartsAtMidnight())?'checked="checked"':''?> value="true"> Starts at midnight
</div>
</div>
</div><!-- /clearfix -->
<div class="clearfix">
@@ -9,3 +9,5 @@ ALTER TABLE checks ADD COLUMN `hour_end` varchar(5) DEFAULT NULL;
ALTER TABLE checks ADD COLUMN `day_start` varchar(3) DEFAULT NULL;
ALTER TABLE checks ADD COLUMN `day_end` varchar(3) DEFAULT NULL;
ALTER TABLE graphs ADD COLUMN `starts_at_midnight` TINYINT(1) DEFAULT 0;

0 comments on commit 6c1bcf3

Please sign in to comment.