Exemplo n.º 1
0
 public function action_checks()
 {
     $data = array('checks' => array());
     $mem = $this->action_mem();
     $checks = \Debugger\Model_Check::find('all');
     foreach ($checks as $check) {
         $test = \Debugger\Model_Test::find($check->test_id);
         array_push($data['checks'], array('id' => $check->id, 'test_id' => $check->test_id, 'test_name' => $test->name, 'time_taken' => $check->time_taken, 'cpu' => $check->cpu, 'ram' => $check->ram, 'status' => $check->status, 'totram' => $mem['total']));
     }
     echo json_encode($data);
 }
Exemplo n.º 2
0
 public function action_index()
 {
     if ($_POST) {
         $val = \Validation::forge();
         $val->add_field('id', 'Object id', 'required|min_length[1]|max_length[20]');
         $val->add_field('cat', 'Category', 'required|min_length[1]|max_length[20]');
         if ($val->run()) {
             $data = array('group' => array(), 'test' => array(), 'record' => array());
             $cat = $val->validated('cat');
             $id = $val->validated('id');
             switch ($cat) {
                 case 'group':
                     $group = \Debugger\Model_Group::find($id);
                     // find and delete all test
                     $tests = \Debugger\Model_Test::find()->where('group_id', $group->id);
                     foreach ($tests as $test) {
                         // find and delete all records
                         $records = \Debugger\Model_Record::find()->where('test_id', $test->id);
                         foreach ($records as $record) {
                             $record->delete();
                         }
                         $test->delete();
                     }
                     $group->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
                 case 'test':
                     $test = \Debugger\Model_Test::find($id);
                     // find and delete all records
                     $records = \Debugger\Model_Record::find()->where('test_id', $test->id);
                     foreach ($records as $record) {
                         $record->delete();
                     }
                     $test->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
                 case 'record':
                     $record = \Debugger\Model_Record::find($id);
                     $record->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
                 case 'check':
                     $check = \Debugger\Model_Check::find($id);
                     $check->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
             }
         }
     }
 }
Exemplo n.º 3
0
 public function getData()
 {
     $data = array('data' => array());
     // get groups
     $groups = \Debugger\Model_Group::find()->get();
     foreach ($groups as $group) {
         $group_data = array('id' => $group['id'], 'name' => $group['name'], 'description' => $group['description'], 'tests' => array());
         // get tests
         $tests = \Debugger\Model_Test::find()->where('group_id', $group->id)->get();
         foreach ($tests as $test) {
             $test_data = array('id' => $test->id, 'name' => $test->name, 'description' => $test->description, 'group_id' => $test->group_id, 'records' => array());
             // get records
             $records = \Debugger\Model_Record::find()->where('test_id', $test->id)->get();
             foreach ($records as $record) {
                 array_push($test_data['records'], array('id' => $record->id, 'type' => $record->type, 'object' => $record->object, 'action' => $record->action, 'test_id' => $record->test_id));
             }
             array_push($group_data['tests'], $test_data);
         }
         array_push($data['data'], $group_data);
     }
     return $data;
 }
Exemplo n.º 4
0
[
<?php 
$data = array();
foreach ($groups as $group) {
    $tests = \Debugger\Model_Test::find()->where('group_id', $group->id)->get();
    $b = array('attr' => array('id' => 'group_' . $group->id, 'rel' => 'group'), 'data' => $group->name, 'state' => count($tests) == 0 ? '' : 'closed');
    array_push($data, $b);
}
echo json_encode($data);
?>
]