Use sendMultipartUpdate() for drag&drop actions & adjust some css styles

This commit is contained in:
Yonas Habteab 2022-04-08 10:35:53 +02:00
parent 936079b7c5
commit 49267d6fa3
3 changed files with 7 additions and 21 deletions

View File

@ -20,7 +20,6 @@ use Icinga\Web\Dashboard\Settings;
use Icinga\Web\Dashboard\Setup\SetupNewDashboard; use Icinga\Web\Dashboard\Setup\SetupNewDashboard;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Web\Widget\Tabextension\DashboardSettings; use Icinga\Web\Widget\Tabextension\DashboardSettings;
use ipl\Html\HtmlElement;
use ipl\Web\Compat\CompatController; use ipl\Web\Compat\CompatController;
use ipl\Web\Url; use ipl\Web\Url;
use ipl\Web\Widget\ActionLink; use ipl\Web\Widget\ActionLink;
@ -58,6 +57,7 @@ class DashboardsController extends CompatController
$this->redirectNow($welcomeForm->getRedirectUrl()); $this->redirectNow($welcomeForm->getRedirectUrl());
})->handleRequest(ServerRequest::fromGlobals()); })->handleRequest(ServerRequest::fromGlobals());
$this->content->getAttributes()->add('class', 'welcome-view');
$this->dashboard->setWelcomeForm($welcomeForm); $this->dashboard->setWelcomeForm($welcomeForm);
} else { } else {
$pane = $this->getParam('pane'); $pane = $this->getParam('pane');
@ -131,8 +131,6 @@ class DashboardsController extends CompatController
$homeForm = (new HomePaneForm($this->dashboard)) $homeForm = (new HomePaneForm($this->dashboard))
->on(HomePaneForm::ON_SUCCESS, function () { ->on(HomePaneForm::ON_SUCCESS, function () {
$this->getResponse()->setAutoRefreshInterval(1);
$this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings')); $this->redirectNow(Url::fromPath(Dashboard::BASE_ROUTE . '/settings'));
}) })
->handleRequest(ServerRequest::fromGlobals()); ->handleRequest(ServerRequest::fromGlobals());
@ -288,8 +286,6 @@ class DashboardsController extends CompatController
$dashboards = Json::decode($dashboards['dashboardData'], true); $dashboards = Json::decode($dashboards['dashboardData'], true);
$originals = $dashboards['originals']; $originals = $dashboards['originals'];
$widgetType = $dashboards['Type'];
unset($dashboards['Type']);
unset($dashboards['originals']); unset($dashboards['originals']);
$orgHome = null; $orgHome = null;
@ -305,9 +301,6 @@ class DashboardsController extends CompatController
} }
} }
$reroutePath = $dashboards['redirectPath'];
unset($dashboards['redirectPath']);
foreach ($dashboards as $home => $value) { foreach ($dashboards as $home => $value) {
if (! $this->dashboard->hasEntry($home)) { if (! $this->dashboard->hasEntry($home)) {
Notification::error(sprintf(t('Dashboard home "%s" not found'), $home)); Notification::error(sprintf(t('Dashboard home "%s" not found'), $home));
@ -384,13 +377,9 @@ class DashboardsController extends CompatController
} }
} }
if ($widgetType !== 'Dashlets' || ($orgHome && $orgPane)) { $this->createTabs();
$this->redirectNow($reroutePath); $this->dashboard->activate('dashboard_settings');
} $this->sendMultipartUpdate();
// Just create a dummy content and ignore it, as we don't have any view scripts and aren't redirecting
$this->getResponse()->setHeader('X-Icinga-Container', 'ignore');
$this->addContent(new HtmlElement('p'));
} }
/** /**
@ -442,6 +431,7 @@ class DashboardsController extends CompatController
] ]
)); ));
$this->content->getAttributes()->add('class', 'dashboard-manager');
$this->addContent(new Settings($this->dashboard)); $this->addContent(new Settings($this->dashboard));
} }

View File

@ -235,7 +235,7 @@ class Dashboard extends BaseHtmlElement implements DashboardEntry
{ {
$activeHome = $this->getActiveHome(); $activeHome = $this->getActiveHome();
if (! $activeHome || (! $activeHome->hasEntries() && $activeHome->getName() === DashboardHome::DEFAULT_HOME)) { if (! $activeHome || (! $activeHome->hasEntries() && $activeHome->getName() === DashboardHome::DEFAULT_HOME)) {
$this->setAttribute('class', 'dashboard-introduction welcome-view'); $this->setAttribute('class', 'dashboard-introduction');
$this->addHtml(HtmlElement::create('h1', null, t('Welcome to Icinga Web 2!'))); $this->addHtml(HtmlElement::create('h1', null, t('Welcome to Icinga Web 2!')));
$this->addHtml(HtmlElement::create( $this->addHtml(HtmlElement::create(

View File

@ -137,7 +137,7 @@
} }
// Dashboard manager // Dashboard manager
:not(.dashboard) > .container > .content { :not(.dashboard) > .container > .content.dashboard-manager {
padding-top: 0; padding-top: 0;
} }
@ -332,10 +332,6 @@ form.icinga-form .control-group.form-controls .remove-button {
width: calc(85% + 1.4em); width: calc(85% + 1.4em);
} }
.drag-active * {
pointer-events: none;
}
.draggable-element { .draggable-element {
opacity: .4; opacity: .4;
} }