parent
2a2966fc56
commit
6e68826da6
|
@ -8,7 +8,6 @@ use Icinga\Config\Config as IcingaConfig;
|
|||
use Icinga\Form\Dashboard\AddUrlForm;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
|
||||
/**
|
||||
* Handle creation, removal and displaying of dashboards, panes and components
|
||||
*
|
||||
|
@ -45,7 +44,7 @@ class DashboardController extends ActionController
|
|||
$this->_getParam('component')
|
||||
)->store();
|
||||
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $pane)));
|
||||
} catch(ConfigurationError $exc ) {
|
||||
} catch (ConfigurationError $exc ) {
|
||||
|
||||
$this->_helper->viewRenderer('show_configuration');
|
||||
$this->view->exceptionMessage = $exc->getMessage();
|
||||
|
@ -74,7 +73,7 @@ class DashboardController extends ActionController
|
|||
try {
|
||||
$dashboard->store();
|
||||
$this->redirectNow(
|
||||
Url::fromPath('dashboard',array('pane' => $form->getValue('pane')))
|
||||
Url::fromPath('dashboard', array('pane' => $form->getValue('pane')))
|
||||
);
|
||||
} catch (ConfigurationError $exc) {
|
||||
$this->_helper->viewRenderer('show_configuration');
|
||||
|
@ -100,12 +99,14 @@ class DashboardController extends ActionController
|
|||
$dashboard->activate($dashboardName);
|
||||
}
|
||||
$this->view->tabs = $dashboard->getTabs();
|
||||
$this->view->tabs->add('Add', array(
|
||||
$this->view->tabs->add(
|
||||
'Add',
|
||||
array(
|
||||
'title' => 'Add Url',
|
||||
'iconCls' => 'plus',
|
||||
'url' => Url::fromPath('dashboard/addurl')
|
||||
));
|
||||
)
|
||||
);
|
||||
$this->view->dashboard = $dashboard;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,18 +25,24 @@ class AddUrlForm extends Form
|
|||
private function addPaneSelectionBox(Dashboard $dashboard)
|
||||
{
|
||||
|
||||
$selectPane = new Zend_Form_Element_Select('pane', array(
|
||||
$selectPane = new Zend_Form_Element_Select(
|
||||
'pane',
|
||||
array(
|
||||
'label' => 'Dashboard',
|
||||
'required' => true,
|
||||
'style' => 'display:inline-block',
|
||||
'multiOptions' => $dashboard->getPaneKeyTitleArray()
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$newDashboardBtn = new Zend_Form_Element_Submit('create_new_pane', array(
|
||||
$newDashboardBtn = new Zend_Form_Element_Submit(
|
||||
'create_new_pane',
|
||||
array(
|
||||
'label' => '+',
|
||||
'required' => false,
|
||||
'style' => 'display:inline-block'
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$newDashboardBtn->removeDecorator('DtDdWrapper');
|
||||
$selectPane->removeDecorator('DtDdWrapper');
|
||||
|
@ -54,23 +60,32 @@ class AddUrlForm extends Form
|
|||
*/
|
||||
private function addNewPaneTextField()
|
||||
{
|
||||
$txtCreatePane = new Zend_Form_Element_Text('pane', array(
|
||||
$txtCreatePane = new Zend_Form_Element_Text(
|
||||
'pane',
|
||||
array(
|
||||
'label' => 'New dashboard title',
|
||||
'required' => true,
|
||||
'style' => 'display:inline-block'
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
// Marks this field as a new pane (and prevents the checkbox being displayed when validation errors occur)
|
||||
$markAsNewPane = new Zend_Form_Element_Hidden('create_new_pane', array(
|
||||
$markAsNewPane = new Zend_Form_Element_Hidden(
|
||||
'create_new_pane',
|
||||
array(
|
||||
'required' => true,
|
||||
'value' => 1
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$cancelDashboardBtn = new Zend_Form_Element_Submit('use_existing_dashboard', array(
|
||||
$cancelDashboardBtn = new Zend_Form_Element_Submit(
|
||||
'use_existing_dashboard',
|
||||
array(
|
||||
'label' => 'X',
|
||||
'required' => false,
|
||||
'style' => 'display:inline-block'
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$cancelDashboardBtn->removeDecorator('DtDdWrapper');
|
||||
$txtCreatePane->removeDecorator('DtDdWrapper');
|
||||
|
@ -89,10 +104,14 @@ class AddUrlForm extends Form
|
|||
{
|
||||
$dashboard = new Dashboard();
|
||||
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
|
||||
$this->addElement('text', 'url', array(
|
||||
$this->addElement(
|
||||
'text',
|
||||
'url',
|
||||
array(
|
||||
'label' => 'Url',
|
||||
'required' => true,
|
||||
));
|
||||
)
|
||||
);
|
||||
$elems = $dashboard->getPaneKeyTitleArray();
|
||||
|
||||
if (empty($elems) || // show textfield instead of combobox when no pane is available
|
||||
|
@ -104,11 +123,14 @@ class AddUrlForm extends Form
|
|||
$this->addPaneSelectionBox($dashboard);
|
||||
}
|
||||
|
||||
$this->addElement('text', 'component', array(
|
||||
$this->addElement(
|
||||
'text',
|
||||
'component',
|
||||
array(
|
||||
'label' => 'Title',
|
||||
'required' => true,
|
||||
));
|
||||
)
|
||||
);
|
||||
$this->setSubmitLabel("Add to dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,11 +75,14 @@ class Dashboard implements Widget
|
|||
$this->tabs = new Tabs();
|
||||
|
||||
foreach ($this->panes as $key => $pane) {
|
||||
$this->tabs->add($key, array(
|
||||
$this->tabs->add(
|
||||
$key,
|
||||
array(
|
||||
'title' => $pane->getTitle(),
|
||||
'url' => clone($url),
|
||||
'urlParams' => array($this->tabParam => $key)
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $this->tabs;
|
||||
|
@ -113,7 +116,7 @@ class Dashboard implements Widget
|
|||
}
|
||||
if (!@file_put_contents($file, $iniString)) {
|
||||
$error = error_get_last();
|
||||
if ($error == NULL) {
|
||||
if ($error == null) {
|
||||
$error = 'Unknown error';
|
||||
} else {
|
||||
$error = $error['message'];
|
||||
|
@ -340,4 +343,3 @@ class Dashboard implements Widget
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,10 +103,7 @@ class Pane implements Widget
|
|||
if ($this->hasComponent($title)) {
|
||||
return $this->components[$title];
|
||||
}
|
||||
throw new ProgrammingError(sprintf(
|
||||
'Trying to access invalid component: %s',
|
||||
$title
|
||||
));
|
||||
throw new ProgrammingError(sprintf('Trying to access invalid component: %s', $title));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,7 +145,8 @@ class Pane implements Widget
|
|||
/**
|
||||
* Add a component to this pane, optionally creating it if $component is a string
|
||||
*
|
||||
* @param string|Component $component The component object or title (if a new component will be created)
|
||||
* @param string|Component $component The component object or title
|
||||
* (if a new component will be created)
|
||||
* @param string|null $url An Url to be used when component is a string
|
||||
*
|
||||
* @return Pane $this
|
||||
|
@ -160,7 +158,7 @@ class Pane implements Widget
|
|||
$this->components[$component->getTitle()] = $component;
|
||||
} elseif (is_string($component) && $url !== null) {
|
||||
$this->components[$component] = new Component($component, $url, $this);
|
||||
} else{
|
||||
} else {
|
||||
throw new ConfigurationError('Invalid component added: '.$component);
|
||||
}
|
||||
return $this;
|
||||
|
@ -173,8 +171,7 @@ class Pane implements Widget
|
|||
*/
|
||||
public function toIni()
|
||||
{
|
||||
if (empty($this->components))
|
||||
{
|
||||
if (empty($this->components)) {
|
||||
return '';
|
||||
}
|
||||
$ini = '['.$this->getName().']'.PHP_EOL.
|
||||
|
|
|
@ -149,7 +149,7 @@ class Tab implements Widget
|
|||
*/
|
||||
public function __construct(array $properties = array())
|
||||
{
|
||||
foreach ($properties as $name=>$value) {
|
||||
foreach ($properties as $name => $value) {
|
||||
$setter = 'set'.ucfirst($name);
|
||||
if (method_exists($this, $setter)) {
|
||||
$this->$setter($value);
|
||||
|
@ -185,11 +185,14 @@ class Tab implements Widget
|
|||
$class = $this->active ? ' class="active"' : '';
|
||||
$caption = $this->title;
|
||||
if ($this->icon !== null) {
|
||||
$caption = $view->img($this->icon, array(
|
||||
$caption = $view->img(
|
||||
$this->icon,
|
||||
array(
|
||||
'width' => 16,
|
||||
'height' => 16
|
||||
)) . ' ' . $caption;
|
||||
} else if ($this->iconCls !== null) {
|
||||
)
|
||||
) . ' ' . $caption;
|
||||
} elseif ($this->iconCls !== null) {
|
||||
$caption = '<i class="icon-'.$this->iconCls.'"></i> ' . $caption;
|
||||
}
|
||||
if ($this->url !== null) {
|
||||
|
@ -205,5 +208,4 @@ class Tab implements Widget
|
|||
|
||||
return '<li '.$class.'>'.$tab.'</li>'.PHP_EOL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue