Example #1
0
 /**
  * @param Widget $widget
  *
  * @return Widget
  */
 public function saveWidget(Widget $widget)
 {
     $widget->filters = Input::get("filter", []);
     $widget->name = Input::get("name", "");
     $widget->charttype = Input::get("charttype", "");
     $widget->metric = Input::get("metric", "");
     $widget->submetric = Input::get("submetric", "");
     $widget->timegroup = Input::get("timegroup", "");
     if (!$widget->exists) {
         $widget->col = 0;
         $widget->row = 0;
         $widget->size_x = Input::get("size_x", "");
         $widget->size_y = Input::get("size_y", "");
     }
     $widget->save();
     return $widget;
 }
 public function testCanShowWidgetWithTimeranges()
 {
     $widget = new Widget();
     $widget->name = "New widget";
     $widget->metric = "Users";
     $widget->submetric = "per_time";
     $widget->charttype = "LineChart";
     $widget->filters = [];
     $widget->timegroup = "DAY";
     $widget->col = 0;
     $widget->row = 0;
     $widget->size_x = 1;
     $widget->size_y = 2;
     $widget->save();
     $timeranges = ["all", "today", "yesterday", "last_7", "this_week", "last_week", "this_month", "last_month", "this_year", "last_year"];
     foreach ($timeranges as $timerange) {
         Session::set("cockpit.time_range", $timerange);
         $this->visit("/cockpit/api/" . $widget->getKey());
         $this->seeStatusCode(200);
         $this->assertContains('<div id="chart_' . $widget->getKey() . '">', $this->response->getContent());
     }
 }
Example #3
0
 /**
  * @param Request $request
  */
 public function savePosition(Request $request)
 {
     $grid = $request->get("grid", "[]");
     $grid = json_decode($grid);
     foreach ($grid as $widgetPosition) {
         $widget = Widget::find($widgetPosition->id);
         $widget->col = $widgetPosition->col;
         $widget->row = $widgetPosition->row;
         $widget->size_x = $widgetPosition->size_x;
         $widget->size_y = $widgetPosition->size_y;
         $widget->save();
     }
 }