parent
a5411c7a1c
commit
a40f357f3c
|
@ -44,7 +44,8 @@ class DashboardController extends ActionController
|
|||
$params['url'] = rawurldecode($this->_request->getParam('url'));
|
||||
$form->populate($params);
|
||||
}
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard) {
|
||||
$action = $this;
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard, $action) {
|
||||
try {
|
||||
$pane = $dashboard->getPane($form->getValue('pane'));
|
||||
} catch (ProgrammingError $e) {
|
||||
|
@ -55,7 +56,14 @@ class DashboardController extends ActionController
|
|||
$component = new Dashboard\Component($form->getValue('component'), $form->getValue('url'), $pane);
|
||||
$component->setUserWidget();
|
||||
$pane->addComponent($component);
|
||||
$dashboard->write();
|
||||
try {
|
||||
$dashboard->write();
|
||||
} catch (\Zend_Config_Exception $e) {
|
||||
$action->view->error = $e;
|
||||
$action->view->config = $dashboard->createWriter();
|
||||
$action->render('error');
|
||||
return false;
|
||||
}
|
||||
Notification::success(t('Component created'));
|
||||
return true;
|
||||
});
|
||||
|
@ -83,7 +91,8 @@ class DashboardController extends ActionController
|
|||
400
|
||||
);
|
||||
}
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard) {
|
||||
$action = $this;
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard, $action) {
|
||||
try {
|
||||
$pane = $dashboard->getPane($form->getValue('pane'));
|
||||
} catch (ProgrammingError $e) {
|
||||
|
@ -108,7 +117,14 @@ class DashboardController extends ActionController
|
|||
$oldPane = $dashboard->getPane($form->getValue('org_pane'));
|
||||
$oldPane->removeComponent($component->getTitle());
|
||||
}
|
||||
$dashboard->write();
|
||||
try {
|
||||
$dashboard->write();
|
||||
} catch (\Zend_Config_Exception $e) {
|
||||
$action->view->error = $e;
|
||||
$action->view->config = $dashboard->createWriter();
|
||||
$action->render('error');
|
||||
return false;
|
||||
}
|
||||
Notification::success(t('Component updated'));
|
||||
return true;
|
||||
});
|
||||
|
@ -140,13 +156,19 @@ class DashboardController extends ActionController
|
|||
}
|
||||
$pane = $this->_request->getParam('pane');
|
||||
$component = $this->_request->getParam('component');
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard, $component, $pane) {
|
||||
$action = $this;
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard, $component, $pane, $action) {
|
||||
try {
|
||||
$pane = $dashboard->getPane($pane);
|
||||
$pane->removeComponent($component);
|
||||
$dashboard->write();
|
||||
Notification::success(t('Component has been removed from') . ' ' . $pane->getTitle());
|
||||
return true;
|
||||
} catch (\Zend_Config_Exception $e) {
|
||||
$action->view->error = $e;
|
||||
$action->view->config = $dashboard->createWriter();
|
||||
$action->render('error');
|
||||
return false;
|
||||
} catch (ProgrammingError $e) {
|
||||
Notification::error($e->getMessage());
|
||||
return false;
|
||||
|
@ -172,13 +194,19 @@ class DashboardController extends ActionController
|
|||
);
|
||||
}
|
||||
$pane = $this->_request->getParam('pane');
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard, $pane) {
|
||||
$action = $this;
|
||||
$form->setOnSuccess(function (Form $form) use ($dashboard, $pane, $action) {
|
||||
try {
|
||||
$pane = $dashboard->getPane($pane);
|
||||
$dashboard->removePane($pane->getTitle());
|
||||
$dashboard->write();
|
||||
Notification::success(t('Pane has been removed') . ': ' . $pane->getTitle());
|
||||
return true;
|
||||
} catch (\Zend_Config_Exception $e) {
|
||||
$action->view->error = $e;
|
||||
$action->view->config = $dashboard->createWriter();
|
||||
$action->render('error');
|
||||
return false;
|
||||
} catch (ProgrammingError $e) {
|
||||
Notification::error($e->getMessage());
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<div class="content">
|
||||
<h1><?= t('Could not persist dashboard'); ?></h1>
|
||||
<p>
|
||||
<?= t('Please copy the following dashboard snippet to '); ?>
|
||||
<strong><?= $this->config->getFilename(); ?>;</strong>.
|
||||
<br>
|
||||
<?= t('Make sure that the webserver can write to this file.'); ?>
|
||||
</p>
|
||||
<pre><?= (string) $this->config->render(); ?></pre>
|
||||
<hr>
|
||||
<h2><?= t('Error details') ?></h2>
|
||||
<p><?= $this->error->getMessage(); ?></p>
|
||||
</div>
|
|
@ -1,7 +1,6 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<h1><?= t('Add Component To Dashboard'); ?></h1>
|
||||
<?= $this->form; ?>
|
||||
|
|
|
@ -229,4 +229,14 @@ class IniWriter extends Zend_Config_Writer_FileAbstract
|
|||
|
||||
return $combinations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
return $this->_filename;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,11 @@ class Dashboard extends AbstractWidget
|
|||
}
|
||||
|
||||
/**
|
||||
* Write user specific dashboards to disk
|
||||
* Create a writer object
|
||||
*
|
||||
* @return IniWriter
|
||||
*/
|
||||
public function write()
|
||||
public function createWriter()
|
||||
{
|
||||
$configFile = $this->getConfigFile();
|
||||
$output = array();
|
||||
|
@ -105,8 +107,15 @@ class Dashboard extends AbstractWidget
|
|||
|
||||
$co = new ConfigObject($output);
|
||||
$config = new Config($co);
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $configFile));
|
||||
$writer->write();
|
||||
return new IniWriter(array('config' => $config, 'filename' => $configFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write user specific dashboards to disk
|
||||
*/
|
||||
public function write()
|
||||
{
|
||||
$this->createWriter()->write();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue