コード例 #1
0
            <div class="clearfix">
              <label for="dashboard-background_color">Background Color<em>*</em></label>
              <div class="input">             
                  <input id="dashboard-background_color" class="span3" type="text" size="30" name="background_color" value="<?=$dashboard->encodeBackgroundColor(); ?>" />
              </div>
            </div><!-- /clearfix -->            
	    <div class="clearfix">
             <label for="dashboard-refresh_rate">Refresh Rate<em>*</em> (in seconds)</label>
             <div class="input">
               <input id="dashboard-refresh_rate" class="span3" type="text" size="30" name="refresh_rate" value="<?=$dashboard->getRefreshRate(); ?>" />
             </div>
            </div>
            <div class="actions span4">
	      <input class="btn primary" type="submit" value="Save" />
              <input class="btn" type="submit" name="action::delete" value="Delete" />
              <a href="<?=Dashboard::makeUrl('view',$dashboard); ?>" class="btn">View</a>
              <div class="required"><em>*</em> Required field</div>
	      <input type="hidden" name="token" value="<?=fRequest::generateCSRFToken(); ?>" />
              <input type="hidden" name="user_id" value="<?=fSession::get('user_id'); ?>" />
            </div>
         </fieldset>
       </div>       
     </form>
    </div>
    <div class="span10">   
   <? if ($action == 'edit') { ?>
   <p class="info"><a href="<?=Graph::makeURL('add',$dashboard); ?>">Add Graph</a></p>
 <?php
   try {
	$graphs->tossIfEmpty();
	$affected = fMessaging::retrieve('affected', fURL::get());
コード例 #2
0
ファイル: graphs.php プロジェクト: nagyist/Tattle
        $obj = new Graph($graph_id);
        $dashboard = new Dashboard($obj->getDashboardId());
        $delete_text = 'Are you sure you want to delete the graph : <strong>' . $obj->getName() . '</strong>?';
        if (fRequest::isPost()) {
            fRequest::validateCSRFToken(fRequest::get('token'));
            $obj->delete();
            $lines = Line::findAll($graph_id);
            foreach ($lines as $line) {
                $line->delete();
            }
            fMessaging::create('success', Dashboard::makeUrl('edit', $dashboard), 'The graph for ' . $dashboard->getName() . ' was successfully deleted');
            fURL::redirect(Dashboard::makeUrl('edit', $dashboard));
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', Dashboard::makeUrl('edit', $dashboard), 'The line requested could not be found');
        fURL::redirect(Dashboard::makeUrl('edit', $dashboard));
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include VIEW_PATH . '/delete.php';
} elseif ('clone' == $action) {
    if (fRequest::isPost()) {
        $graph_to_clone = new Graph($graph_id);
        $dashboard_id = $graph_to_clone->getDashboardId();
        $dashboard = new Dashboard($dashboard_id);
        try {
            fRequest::validateCSRFToken(fRequest::get('token'));
            Graph::cloneGraph($graph_id);
            fMessaging::create('affected', fURL::get(), $graph_to_clone->getName());
            fMessaging::create('success', fURL::get(), 'The Graph ' . $graph_to_clone->getName() . ' was successfully cloned');
            fURL::redirect(Dashboard::makeURL('edit', $dashboard));
コード例 #3
0
ファイル: dashboard.php プロジェクト: nagyist/Tattle
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header("Content-Disposition: attachment; filename=\"" . $json_name . "\"");
        header("Content-Transfer-Encoding: binary");
        echo $json_to_send, "\n";
    }
} elseif ('import' == $action) {
    if (isset($_FILES['uploadedfile']['tmp_name']) && $_FILES['uploadedfile']['error'] == UPLOAD_ERR_OK) {
        $file = $_FILES['uploadedfile']['tmp_name'];
        $content = fread(fopen($file, "r"), filesize($file));
        $filter_group_id = $_POST['filter_group_id'];
        if ($filter_group_id < 0) {
            $result_ok = Dashboard::import_from_json_to_group($content);
        } else {
            $result_ok = Dashboard::import_from_json_to_group($content, $filter_group_id);
        }
        if ($result_ok) {
            fMessaging::create('success', "/" . Dashboard::makeUrl('list'), 'The Dashboard was successfully imported');
        }
    }
    fURL::redirect(Dashboard::makeUrl('list', $filter_group_id));
} else {
    if ($filter_group_id == -1) {
        $dashboards = Dashboard::findAll();
    } else {
        $dashboards = Dashboard::findAllByFilter($filter_group_id);
    }
    include VIEW_PATH . '/list_dashboards.php';
}
コード例 #4
0
ファイル: add_edit_dashboard.php プロジェクト: nagyist/Tattle
            </div>
            <div class="form-group">
            	<label for="dashboard-group">Group</label>
            		<select name="group_id" class="form-control">
            			<?php 
foreach (Group::findAll() as $group) {
    fHTML::printOption($group->getName(), $group->getGroupId(), $action == 'add' ? $filter_group_id : $dashboard->getGroupId());
}
?>
            		</select>
            </div>
            <div class="actions">
	      <input class="btn btn-primary" type="submit" value="Save" />
              <input class="btn btn-default" type="submit" name="action::delete" value="Delete" onclick="return confirm('Do you really want to delete this dashboard ?');" />
              <a href="<?php 
echo Dashboard::makeUrl('view', $dashboard);
?>
" class="btn btn-default">View</a>
              <a href="<?php 
echo Dashboard::makeURL('export', $dashboard);
?>
" target="_blank" class="btn btn-default">Export</a>
              <div class="required"><em>*</em> Required field</div>
	      <input type="hidden" name="token" value="<?php 
echo fRequest::generateCSRFToken();
?>
" />
              <input type="hidden" name="user_id" value="<?php 
echo fSession::get('user_id');
?>
" />
コード例 #5
0
ファイル: dashboard.php プロジェクト: nleskiw/Graphite-Tattle
} elseif ('delete' == $action) {
    $class_name = 'Dashboard';
    try {
        $obj = new Dashboard($dashboard_id);
        $delete_text = 'Are you sure you want to delete dashboard : <strong>' . $obj->getName() . '</strong>?';
        if (fRequest::isPost()) {
            fRequest::validateCSRFToken(fRequest::get('token'));
            $obj->delete();
            $graphs = Graph::findAll($dashboard_id);
            // Do Dashboard Subelement Cleanup
            foreach ($graphs as $graph) {
                $lines = Line::findAll($graph->getGraphId());
                foreach ($lines as $line) {
                    $line->delete();
                }
                $graph->delete();
            }
            fMessaging::create('success', Dashboard::makeUrl('list'), 'The Dashboard ' . $obj->getName() . ' was successfully deleted');
            fURL::redirect(Dashboard::makeUrl('list'));
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', Dashboard::makeUrl('list'), 'The Dashboard requested could not be found');
        fURL::redirect(Dashboard::makeUrl('list'));
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include VIEW_PATH . '/delete.php';
} else {
    $dashboards = Dashboard::findAll();
    include VIEW_PATH . '/list_dashboards.php';
}
コード例 #6
0
ファイル: view_dashboard.php プロジェクト: nagyist/Tattle
									until_moment = until_moment.add("minutes",1);
									new_until = until_moment.format("HH:mm_YYYYMMDD");
								}

								$(".slider img").each(function(){
									var url_graph_to_zoom = $(this).attr("src");
									var old_from = getParamValue("from",url_graph_to_zoom);
									var old_until = getParamValue("until",url_graph_to_zoom);
									url_graph_to_zoom = url_graph_to_zoom.replace("from="+old_from,"from="+new_from);
									if (old_until == "") {
										url_graph_to_zoom += "&until="+new_until;
									} else {
										url_graph_to_zoom = url_graph_to_zoom.replace("until="+old_until,"until="+new_until);
									}
									$(this).attr("src",url_graph_to_zoom);
								});
							}
						}
					}
				}
			});
		});
		
	});
</script>
<?php 
if (!$full_screen) {
    echo '<a href="' . Dashboard::makeUrl('edit', $dashboard) . '">Edit Dashboard</a> | <a href="' . Graph::makeUrl('add', $dashboard) . '">Add Graph</a> | <a href="?' . fURL::getQueryString() . '&full_screen=true">Full Screen</a>';
    $tmpl->set('show_bubbles', true);
    $tmpl->place('footer');
}
コード例 #7
0
ファイル: Dashboard.php プロジェクト: nagyist/Tattle
 public static function import_from_json_to_group($json, $group_id = NULL)
 {
     $result = true;
     $json_array = json_decode($json, TRUE);
     if (!empty($json_array)) {
         if (array_key_exists("name", $json_array)) {
             // In this case, we only have a dashboard, not an array of dashboard
             // We convert it into an array
             $json_array = array($json_array);
         }
         foreach ($json_array as $dashboard_to_create) {
             $column_to_ignore = array('dashboard_id', 'group_id', 'graphs');
             $new_dashboard = fActiveRecord::array_to_dbentry($dashboard_to_create, __CLASS__, $column_to_ignore);
             if ($new_dashboard !== NULL) {
                 $new_dashboard->setGroupId(empty($group_id) ? $GLOBALS['DEFAULT_GROUP_ID'] : $group_id);
                 $new_dashboard->setUserId(fSession::get('user_id', 1));
                 $new_dashboard->store();
                 if (in_array('graphs', array_keys($dashboard_to_create))) {
                     $new_dashboard_id = $new_dashboard->getDashboardId();
                     foreach ($dashboard_to_create['graphs'] as $graph) {
                         $result_graph = Graph::import_from_array_to_dashboard($graph, $new_dashboard_id);
                         $result = $result && $result_graph;
                     }
                 }
             } else {
                 $result = false;
             }
         }
     } else {
         fMessaging::create('error', "/" . Dashboard::makeUrl('list'), "Empty or malformed file");
         $result = false;
     }
     return $result;
 }
コード例 #8
0
ファイル: fActiveRecord.php プロジェクト: nagyist/Tattle
 public static function array_to_dbentry($input, $class, $columns_to_ignore = NULL)
 {
     try {
         if (!empty($input)) {
             $new_dbentry = new $class();
             $has_at_least_one_column = false;
             foreach ($input as $column => $value) {
                 if (!empty($columns_to_ignore) && !in_array($column, $columns_to_ignore)) {
                     $new_dbentry->set($column, $value);
                     $has_at_least_one_column = true;
                 }
             }
             if ($has_at_least_one_column) {
                 return $new_dbentry;
             }
         }
     } catch (fProgrammerException $e) {
         $messages = fMessaging::retrieve('error', "/" . Dashboard::makeUrl('list'));
         if (!empty($messages)) {
             $messages .= "<br/>";
         } else {
             $messages = "";
         }
         fMessaging::create('error', "/" . Dashboard::makeUrl('list'), $messages . "An error occured by creating a new " . $class . " : " . $e->getMessage());
     }
     return NULL;
 }