Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Sep 6, 2023
1 parent 3452a33 commit fb60421
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 30 deletions.
21 changes: 7 additions & 14 deletions application/controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ public function cloneAction()
->on(ReportForm::ON_SUCCESS, function () {
Notification::success($this->translate('Cloned report successfully'));

// Refresh the col1 container after cloning a report
$this->sendExtraUpdates(['#col1']);

$this->redirectNow(Url::fromPath('reporting/report', ['id' => $this->report->getId()]));
$this->closeCurrentAndRefreshRelatedView();
})
->handleRequest($this->getServerRequest());

Expand Down Expand Up @@ -142,19 +139,15 @@ public function editAction()
->setAction((string) Url::fromRequest())
->populate($values)
->on(ReportForm::ON_SUCCESS, function (ReportForm $form) {
$url = '__CLOSE__';
if ($form->getPressedSubmitElement()->getName() === 'remove') {
Notification::success($this->translate('Removed report successfully'));
} else {
$url = Url::fromPath('reporting/report', ['id' => $this->report->getId()]);

// Refresh the col1 container after editing a report
$this->sendExtraUpdates(['#col1']);

$this->switchToLayout1Column();
} else {
Notification::success($this->translate('Updated report successfully'));
}

$this->redirectNow($url);
$this->closeCurrentAndRefreshRelatedView();
}
})
->handleRequest($this->getServerRequest());

Expand All @@ -172,7 +165,7 @@ public function sendAction()
->setReport($this->report)
->setAction((string) Url::fromRequest())
->on(SendForm::ON_SUCCESS, function () {
$this->redirectNow(Url::fromPath('reporting/report', ['id' => $this->report->getId()]));
$this->closeCurrentAndRefreshRelatedView();
})
->handleRequest($this->getServerRequest());

Expand All @@ -198,7 +191,7 @@ public function scheduleAction()
Notification::success($this->translate('Created schedule successfully'));
}

$this->redirectNow(Url::fromPath('reporting/report', ['id' => $this->report->getId()]));
$this->closeCurrentAndRefreshRelatedView();
})
->handleRequest($this->getServerRequest());

Expand Down
9 changes: 2 additions & 7 deletions application/controllers/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,17 @@ public function newAction()
->on(ReportForm::ON_SUCCESS, function (ReportForm $form) use ($class) {
Notification::success($this->translate('Created report successfully'));

$url = Url::fromPath('reporting/reports');
$url = null;
if ($form->getPressedSubmitElement()->getName() === 'create_show') {
$url = Url::fromPath(
sprintf(
'reporting/reports#!%s',
Url::fromPath('reporting/report', ['id' => $form->getId()])->getAbsoluteUrl()
)
);
} elseif ($class !== null) {
$url = '__CLOSE__';

// This will close only the modal view and leave the object detail view of Icinga DB Web untouched.
$this->getResponse()->setHeader('X-Icinga-Container', 'modal', true);
}

$this->redirectNow($url);
$this->closeCurrentAndRefreshRelatedView($url);
})
->handleRequest($this->getServerRequest());

Expand Down
9 changes: 4 additions & 5 deletions application/controllers/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ public function editAction()
$form = TemplateForm::fromTemplate($this->template)
->setAction((string) Url::fromRequest())
->on(TemplateForm::ON_SUCCESS, function (Form $form) {
$url = '__CLOSE__';
if ($form->getPressedSubmitElement()->getName() === 'remove') {
Notification::success($this->translate('Removed template successfully'));
} else {
$url = Url::fromPath('reporting/template', ['id' => $this->template->id]);

$this->switchToLayout1Column();
} else {
Notification::success($this->translate('Updated template successfully'));
}

$this->redirectNow($url);
$this->closeCurrentAndRefreshRelatedView();
}
})
->handleRequest(ServerRequest::fromGlobals());

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/TemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function newAction()
->on(TemplateForm::ON_SUCCESS, function () {
Notification::success($this->translate('Created template successfully'));

$this->redirectNow(Url::fromPath('reporting/templates'));
$this->closeCurrentAndRefreshRelatedView();
})
->handleRequest($this->getServerRequest());

Expand Down
6 changes: 4 additions & 2 deletions application/controllers/TimeframeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ public function editAction()
->on(TimeframeForm::ON_SUCCESS, function (Form $form) {
if ($form->getPressedSubmitElement()->getName() === 'remove') {
Notification::success($this->translate('Removed timeframe successfully'));

$this->switchToLayout1Column();
} else {
Notification::success($this->translate('Update timeframe successfully'));
}

$this->redirectNow('reporting/timeframes');
$this->closeCurrentAndRefreshRelatedView();
}
})->handleRequest($this->getServerRequest());

$this->addContent($form);
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/TimeframesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function newAction()
->on(TimeframeForm::ON_SUCCESS, function () {
Notification::success($this->translate('Created timeframe successfully'));

$this->redirectNow('reporting/timeframes');
$this->closeCurrentAndRefreshRelatedView();
})->handleRequest($this->getServerRequest());

$this->addContent($form);
Expand Down

0 comments on commit fb60421

Please sign in to comment.