diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
commit | 8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch) | |
tree | 2492de6f1528dd44eaa169a5c1555026d9cb75ec /modules/setup/application/views/scripts/form | |
parent | Initial commit. (diff) | |
download | icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.tar.xz icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.zip |
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/setup/application/views/scripts/form')
4 files changed, 241 insertions, 0 deletions
diff --git a/modules/setup/application/views/scripts/form/setup-modules.phtml b/modules/setup/application/views/scripts/form/setup-modules.phtml new file mode 100644 index 0000000..e57c7dc --- /dev/null +++ b/modules/setup/application/views/scripts/form/setup-modules.phtml @@ -0,0 +1,33 @@ +<?php + +use Icinga\Web\Wizard; + +?> +<form + id="<?= $this->escape($form->getName()); ?>" + name="<?= $this->escape($form->getName()); ?>" + enctype="<?= $this->escape($form->getEncType()); ?>" + method="<?= $this->escape($form->getMethod()); ?>" + action="<?= $this->escape($form->getAction()); ?>" + class="icinga-controls" + data-progress-element="<?= Wizard::PROGRESS_ELEMENT; ?>" +> +<h2><?= $this->translate('Modules', 'setup.page.title'); ?></h2> +<p><?= $this->translate('The following modules were found in your Icinga Web 2 installation. To enable and configure a module, just tick it and click "Next".'); ?></p> +<?php foreach ($form->getElements() as $element): ?> + <?php if (! in_array($element->getName(), array(Wizard::BTN_PREV, Wizard::BTN_NEXT, Wizard::PROGRESS_ELEMENT, $form->getTokenElementName(), $form->getUidElementName()))): ?> + <div class="module"> + <div class="header"> + <h3><label for="<?= $element->getId(); ?>"><strong><?= $element->getLabel(); ?></strong></label></h3> + <div class="element"> + <?= $element; ?> + </div> + </div> + <label class="description" for="<?= $element->getId(); ?>"><?= $element->getDescription(); ?></label> + </div> + <?php endif ?> +<?php endforeach ?> + <?= $form->getElement($form->getTokenElementName()); ?> + <?= $form->getElement($form->getUidElementName()); ?> + <?= $form->getDisplayGroup('buttons'); ?> +</form> diff --git a/modules/setup/application/views/scripts/form/setup-requirements.phtml b/modules/setup/application/views/scripts/form/setup-requirements.phtml new file mode 100644 index 0000000..544f284 --- /dev/null +++ b/modules/setup/application/views/scripts/form/setup-requirements.phtml @@ -0,0 +1,48 @@ +<?php + +use Icinga\Web\Wizard; + +if (! $form->getWizard()->getRequirements()->fulfilled()) { + $form->getElement(Wizard::BTN_NEXT)->setAttrib('disabled', 1); +} + +?> +<h1>Icinga Web 2</h1> +<?= $form->getWizard()->getRequirements(true); ?> +<?php foreach ($form->getWizard()->getPage('setup_modules')->getModuleWizards() as $moduleName => $wizard): ?> +<h1><?= ucwords($moduleName) . ' ' . $this->translate('Module'); ?></h1> +<?= $wizard->getRequirements(); ?> +<?php endforeach ?> +<form + id="<?= $this->escape($form->getName()); ?>" + name="<?= $this->escape($form->getName()); ?>" + enctype="<?= $this->escape($form->getEncType()); ?>" + method="<?= $this->escape($form->getMethod()); ?>" + action="<?= $this->escape($form->getAction()); ?>" + data-progress-element="<?= Wizard::PROGRESS_ELEMENT; ?>" +> + <?= $form->getElement($form->getTokenElementName()); ?> + <?= $form->getElement($form->getUidElementName()); ?> + <div class="buttons"> + <?php + $double = clone $form->getElement(Wizard::BTN_NEXT); + echo $double->setAttrib('class', 'double'); + ?> + <?= $form->getElement(Wizard::BTN_PREV); ?> + <?= $form->getElement(Wizard::BTN_NEXT); ?> + <?= $form->getElement(Wizard::PROGRESS_ELEMENT); ?> + <div class="requirements-refresh"> + <?php $title = $this->translate('You may also need to restart the web-server for the changes to take effect!'); ?> + <?= $this->qlink( + $this->translate('Refresh'), + null, + null, + array( + 'class' => 'button-link', + 'title' => $title, + 'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title) + ) + ); ?> + </div> + </div> +</form>
\ No newline at end of file diff --git a/modules/setup/application/views/scripts/form/setup-summary.phtml b/modules/setup/application/views/scripts/form/setup-summary.phtml new file mode 100644 index 0000000..3ad0265 --- /dev/null +++ b/modules/setup/application/views/scripts/form/setup-summary.phtml @@ -0,0 +1,40 @@ +<?php + +use Icinga\Web\Wizard; + +$form->getElement(Wizard::BTN_NEXT)->setAttrib( + 'class', + $form->getElement(Wizard::BTN_NEXT)->getAttrib('class') . ' finish' +); + +?> +<p><?= sprintf( + $this->translate( + 'You\'ve configured %1$s successfully. You can review the changes supposed to be made before setting it up.' + . ' Make sure that everything is correct (Feel free to navigate back to make any corrections!) so' + . ' that you can start using %1$s right after it has successfully been set up.' + ), + $form->getSubjectTitle() +); ?></p> +<div class="summary"> +<?php foreach ($form->getSummary() as $pageHtml): ?> + <?php if ($pageHtml): ?> + <div class="page"> + <?= $pageHtml; ?> + </div> + <?php endif ?> +<?php endforeach ?> +</div> +<form + id="<?= $this->escape($form->getName()); ?>" + name="<?= $this->escape($form->getName()); ?>" + enctype="<?= $this->escape($form->getEncType()); ?>" + method="<?= $this->escape($form->getMethod()); ?>" + action="<?= $this->escape($form->getAction()); ?>" + data-progress-element="<?= Wizard::PROGRESS_ELEMENT; ?>" + class="summary" +> + <?= $form->getElement($form->getTokenElementName()); ?> + <?= $form->getElement($form->getUidElementName()); ?> + <?= $form->getDisplayGroup('buttons'); ?> +</form>
\ No newline at end of file diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml new file mode 100644 index 0000000..1be68f3 --- /dev/null +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -0,0 +1,120 @@ +<?php + +use Icinga\Application\Icinga; +use Icinga\Application\Config; +use Icinga\Application\Platform; +use Icinga\Web\Wizard; + +$phpUser = Platform::getPhpUser(); +$configDir = Icinga::app()->getConfigDir(); +$setupTokenPath = rtrim($configDir, '/') . '/setup.token'; +$cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli'); + +$groupadd = null; +$docker = getenv('ICINGAWEB_OFFICIAL_DOCKER_IMAGE'); + +if (! (false === ($distro = Platform::getLinuxDistro(1)) || $distro === 'linux')) { + foreach (array( + 'groupadd -r icingaweb2' => array( + 'redhat', 'rhel', 'centos', 'fedora', + 'suse', 'sles', 'sled', 'opensuse' + ), + 'addgroup --system icingaweb2' => array('debian', 'ubuntu') + ) as $groupadd_ => $distros) { + if (in_array($distro, $distros)) { + $groupadd = $groupadd_; + break; + } + } + + switch ($distro) { + case 'redhat': + case 'rhel': + case 'centos': + case 'fedora': + $usermod = 'usermod -a -G icingaweb2 %s'; + $webSrvUser = 'apache'; + break; + case 'suse': + case 'sles': + case 'sled': + case 'opensuse': + $usermod = 'usermod -A icingaweb2 %s'; + $webSrvUser = 'wwwrun'; + break; + case 'debian': + case 'ubuntu': + $usermod = 'usermod -a -G icingaweb2 %s'; + $webSrvUser = 'www-data'; + break; + default: + $usermod = $webSrvUser = null; + } +} +?> +<div class="welcome-page"> + <h2><?= $this->translate('Welcome to the configuration of Icinga Web 2!') ?></h2> + <?php if (false === file_exists($setupTokenPath) && file_exists(Config::resolvePath('config.ini'))): ?> + <p class="restart-warning"><?= $this->translate( + 'You\'ve already completed the configuration of Icinga Web 2. Note that most of your configuration' + . ' files will be overwritten in case you\'ll re-configure Icinga Web 2 using this wizard!' + ); ?></p> + <?php else: ?> + <p><?= $this->translate( + 'This wizard will guide you through the configuration of Icinga Web 2. Once completed and successfully' + . ' finished you are able to log in and to explore all the new and stunning features!' + ); ?></p> + <?php endif ?> + <form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>" class="icinga-controls"> + <?= $form->getElement('token'); ?> + <?= $form->getElement($form->getTokenElementName()); ?> + <?= $form->getElement($form->getUidElementName()); ?> + <div class="buttons"> + <?= $form->getElement(Wizard::BTN_NEXT); ?> + </div> + </form> + <div class="note"> + <h3><?= $this->translate('Generating a New Setup Token'); ?></h3> + <div> + <p><?= + $this->translate( + 'To run this wizard a user needs to authenticate using a token which is usually' + . ' provided to him by an administrator who\'d followed the instructions below.' + ); ?></p> + <?php if (! $docker): ?> + <p><?= $this->translate('In any case, make sure that all of the following applies to your environment:'); ?></p> + <ul> + <li><?= $this->translate('A system group called "icingaweb2" exists'); ?></li> + <?php if ($phpUser): ?> + <li><?= sprintf($this->translate('The user "%s" is a member of the system group "icingaweb2"'), $phpUser); ?></li> + <?php else: ?> + <li><?= $this->translate('Your webserver\'s user is a member of the system group "icingaweb2"'); ?></li> + <?php endif ?> + </ul> + <?php if (! ($groupadd === null || $usermod === null)) { ?> + <div class="code"> + <span><?= $this->escape($groupadd . ';') ?></span> + <span><?= $this->escape(sprintf($usermod, $phpUser ?: $webSrvUser) . ';') ?></span> + </div> + <?php } ?> + <p><?= $this->translate('If you\'ve got the IcingaCLI installed you can do the following:'); ?></p> + <?php endif; ?> + <div class="code"> + <?php if (! $docker): ?> + <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup config directory --group icingaweb2<?= $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : ''; ?>;</span> + <?php endif; ?> + <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup token create;</span> + </div> + <?php if (! $docker): ?> + <p><?= $this->translate('In case the IcingaCLI is missing you can create the token manually:'); ?></p> + <div class="code"> + <span>su <?= $phpUser ?: $this->translate('<your-webserver-user>'); ?> -s /bin/sh -c "mkdir -m 2770 <?= dirname($setupTokenPath); ?>; chgrp icingaweb2 <?= dirname($setupTokenPath); ?>; head -c 12 /dev/urandom | base64 | tee <?= $setupTokenPath; ?>; chmod 0660 <?= $setupTokenPath; ?>;";</span> + </div> + <?php endif; ?> + <p><?= sprintf( + $this->translate('Please see the %s for an extensive description on how to access and use this wizard.'), + '<a href="http://docs.icinga.com/">' . $this->translate('Icinga Web 2 documentation') . '</a>' // TODO: Add link to iw2 docs which points to the installation topic + ); ?></p> + </div> + </div> +</div> |