<? $page_title = $action == 'add' ? 'Add a Subscription' : 'Edit Subscription'; $tmpl->set('title', $page_title); $breadcrumbs[] = array('name' => 'Checks', 'url' => Check::makeUrl('list'),'active' => false); $breadcrumbs[] = array('name' => $check->getName(),'url'=> Check::makeUrl('edit',$check),'active' => false); $breadcrumbs[] = array('name' => $page_title , 'url' => fURL::getWithQueryString(),'active' => false); $tmpl->set('breadcrumbs',$breadcrumbs); $tmpl->place('header'); $query_string = ''; if (isset($check_id)) { $query_string .= "&check_id=$check_id"; } if (isset($subscription_id)) { $query_string .= "&subscription_id=$subscription_id"; } ?> <div class="row"> <div class="span4"> <form class="form-stacked" action="<?php echo fURL::get(); ?> ?action=<?php echo $action . $query_string; ?> " method="post"> <div class="main" id="main"> <fieldset> <div class="clearfix"> <label for="check-threshold">Alert State<em>*</em></label> <div class="input">
<?php $tmpl->set('title', 'Self Service Alerts based on Graphite metrics'); $active_tab_alerts = " class=active"; $tmpl->set('breadcrumbs',$breadcrumbs); $tmpl->place('header'); try { $checks->tossIfEmpty(); $affected = fMessaging::retrieve('affected', fURL::get()); ?> <a class="small btn primary" href="<?= Check::makeUrl('add');?>">Add Check</a> <table class="zebra-striped"> <thead> <tr> <th><?=fCRUD::printSortableColumn('name','Name'); ?></th> <th><?=fCRUD::printSortableColumn('target','Target'); ?></th> <th><?=fCRUD::printSortableColumn('warn','Warn'); ?></th> <th><?=fCRUD::printSortableColumn('error','Error'); ?></th> <th><?=fCRUD::printSortableColumn('sample','Sample'); ?></th> <th><?=fCRUD::printSortableColumn('baseline','Baseline'); ?></th> <th><?=fCRUD::printSortableColumn('over_under','Over/Under'); ?></th> <th><?=fCRUD::printSortableColumn('visiblity','Visibility'); ?></th> <th>Action</th> </tr></thead><tbody> <?php $first = TRUE; foreach ($checks as $check) { ?> <tr> <td><?='<a href="' . CheckResult::makeUrl('list',$check) . '">' . $check->prepareName(); ?></a></td> <td><?=$check->prepareTarget(); ?></td>
<?php include 'inc/init.php'; fAuthorization::requireLoggedIn(); fRequest::overrideAction(); $breadcrumbs[] = array('name' => 'Checks', 'url' => Check::makeUrl('list'), 'active' => false); $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); $sort = fCRUD::getSortColumn(array('name', 'target', 'warn', 'error', 'status', 'timestamp', 'count')); $sort_dir = fCRUD::getSortDirection('asc'); $check_id = fRequest::get('check_id', 'integer'); $check_list_url = Check::makeURL('list'); // --------------------------------- // if ('delete' == $action) { try { $obj = new Check($check_id); $delete_text = 'Are you sure you want to delete the check : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); // Do our own Subscription and CheckResult cleanup instead of using ORM $subscriptions = Subscription::findAll($check_id); foreach ($subscriptions as $subscription) { $subscription->delete(); } $check_results = CheckResult::findAll($check_id); foreach ($check_results as $check_result) { $check_result->delete(); } fMessaging::create('success', fURL::get(), 'The check ' . $obj->getName() . ' was successfully deleted'); fURL::redirect($check_list_url); }