/** * factory to create grid * @param string $name * @return \Ublaboo\DataGrid\DataGrid */ public function createComponentRemoteNodesGrid($name) { $grid = new \Ublaboo\DataGrid\DataGrid($this, $name); $grid->setDataSource($this->model->getTable()); $grid->addColumnText('name', _('Name')); $grid->addColumnText('comment', _('Comment')); $grid->addColumnText('aet', _('AE title')); $grid->addColumnText('ip_address', _('IP address')); $grid->addColumnText('port', _('Port')); return $grid; }
/** * factory to create tabs * @param string $name * @return \Tabs */ public function createComponentTabs($name) { $remoteNodes = $this->remoteNodes->getTable()->where("NOT group", "local"); $tabs = new \Tabs($this, $name); $tabs->setup(); $actualPresenter = $this->getPresenter(); $actualParameters = $actualPresenter->getParameters(); if ($this->isLocal) { $tabs->addItem(_("LOCAL DATABASE"), "Data", "Browser", "default", "data", false); } else { $tabs->addItem(_("LOCAL DATABASE"), "Data", "Browser", "default", "data", true); } foreach ($remoteNodes as $number => $row) { if (array_key_exists("remoteAet", $actualParameters) and $actualParameters["remoteAet"] == $row["aet"]) { $tabs->addItem($row["name"], "Data", "Browser", "default", "data", false, $row["aet"]); } else { $tabs->addItem($row["name"], "Data", "Browser", "default", "data", true, $row["aet"]); } } return $tabs; }
/** * factory to create a grid * @param string $name * @return \Ublaboo\DataGrid\DataGrid */ public function createComponentRemoteNodesGrid($name) { // create object $grid = new \Ublaboo\DataGrid\DataGrid($this, $name); // set data source $grid->setDataSource($this->model->getTable()); // set columns hidable $grid->setColumnsHideable(); //add collumn name which is sortable and may be filtered $grid->addFilterText('name', _("Node name")); $colName = $grid->addColumnText('name', _("Node name"))->setSortable(); if ($this->user->isAllowed("config", "edit")) { $colName->setEditableCallback(function ($id, $value) { $this->model->saveChanges($id, array("name" => $value, "activated" => 0)); $this->flashMessage(_("Name was updated"), "success"); $this->redirect("this"); }); } // add collumn Comment which is sortable and may be filtered $grid->addFilterText('comment', _("Comment")); $colComment = $grid->addColumnText('comment', _("Comment"))->setSortable(); if ($this->user->isAllowed("config", "edit")) { $colComment->setEditableCallback(function ($id, $value) { $this->model->saveChanges($id, array("comment" => $value, "activated" => 0)); $this->flashMessage(_("Comment was updated"), "success"); $this->redirect("this"); }); } // add collumn AET which is sortable and may be filtered $grid->addFilterText('aet', _("AE title")); $colAet = $grid->addColumnText('aet', _("AE title"))->setSortable(); if ($this->user->isAllowed("config", "edit")) { $colAet->setEditableCallback(function ($id, $value) { $this->model->saveChanges($id, array("aet" => $value, "activated" => 0)); $this->flashMessage(_("AE title was updated"), "success"); $this->redirect("this"); }); } // add collumn IP address which is sortable and may be filtered $grid->addFilterText('ip_address', _("IP address")); $colIp = $grid->addColumnText('ip_address', _("IP address"))->setSortable(); if ($this->user->isAllowed("config", "edit")) { $colIp->setEditableCallback(function ($id, $value) { $this->model->saveChanges($id, array("ip_address" => $value, "activated" => 0)); $this->flashMessage(_("IP address was updated"), "success"); $this->redirect("this"); }); } // add collumn port which is sortable and may be filtered $grid->addFilterText('port', _("Port number")); $colPort = $grid->addColumnText('port', _("Port number"))->setSortable(); if ($this->user->isAllowed("config", "edit")) { $colPort->setEditableCallback(function ($id, $value) { $this->model->saveChanges($id, array("port" => $value, "activated" => 0)); $this->flashMessage(_("Port number was updated"), "success"); $this->redirect("this"); }); } // add collumn group which is sortable and may be filtered $grid->addFilterSelect('group', _("Group"), $this->groups); $grid->addColumnText('group', _("Group"))->setSortable(); // add collumn compression $grid->addFilterSelect('compression', _("Compression"), $this->compressions); $grid->addColumnText('compression', _("Compression")); // add column active which may be sortable and filtered if (!$this->user->isAllowed("config", "edit")) { $grid->addFilterSelect('active', _('Active?'), [1 => $this->answers[1], 0 => $this->answers[0], '' => _("All")]); } else { $grid->addColumnStatus('active', _("Active?"))->addOption(1, _("Yes"))->setIcon('check')->setClass('btn-success')->endOption()->addOption(0, _("No"))->setIcon('close')->setClass('btn-danger')->endOption()->onChange[] = function ($id, $newValue) { if (!$this->user->isAllowed("config", "edit")) { $this->flashMessage(_("You are not allowed to do this action."), "danger"); $this->redirect("this"); } try { $this->model->changeActive($id, $newValue); $this->redirect("this"); } catch (RemoteNodesException $exc) { $this->getPresenter()->flashMessage($exc->getMessage(), "danger"); $this->redirect("this"); } }; } // add action - delete if is allowed if ($this->user->isAllowed("config", "delete")) { $grid->addAction("delete!", _("Delete"))->setClass('btn btn-xs btn-danger')->setIcon("trash")->setConfirm(_('Do you really want to delete row') . ' %s?', 'comment'); } $grid->setItemsPerPageList([10, 50, 100, 9999]); return $grid; }