Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions datamodels/2.x/itop-core-update/src/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
use Combodo\iTop\DBTools\Service\DBToolsUtils;
use Combodo\iTop\FilesInformation\Service\FileNotExistException;
use Combodo\iTop\FilesInformation\Service\FilesInformation;
use Config;
use ContextTag;
use Dict;
use Exception;
use IssueLog;
use MetaModel;
use RunTimeEnvironment;
use SecurityException;
use SetupUtils;
use utils;
Expand Down Expand Up @@ -232,29 +230,6 @@ public function OperationUpdateDatabase()
$this->DisplayJSONPage($aParams, $iResponseCode);
}

public function OperationRebuildToolkitEnvironment()
{
$sTransactionId = utils::GetNewTransactionId();
$aParams = [];
$aParams['sTransactionId'] = $sTransactionId;
$aParams['bStatus'] = true;

$iResponseCode = 200;
try {
$aParams['sAjaxURL'] = utils::GetAbsoluteUrlAppRoot().'/pages/UI.php';
$oConfig = new Config(APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE);
$oEnvironment = new RunTimeEnvironment(ITOP_DEFAULT_ENV);
$oEnvironment->WriteConfigFileSafe($oConfig);
$oEnvironment->CompileFrom(ITOP_DEFAULT_ENV);
} catch (Exception $e) {
IssueLog::Error('RebuildToolkitEnvironment: '.$e->getMessage());
$aParams['sError'] = $e->getMessage();
$iResponseCode = 500;
$aParams['bStatus'] = false;
}
$this->DisplayJSONPage($aParams, $iResponseCode);
}

/**
* @throws \SecurityException if CSRF token invalid
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@
{% UIForm Standard {'sId':'launch-setup-form', Action:sLaunchSetupUrl} %}
{% UIButton ForDestructiveAction {'sLabel':'iTopUpdate:UI:SetupLaunch'|dict_s, 'sName':'launch-setup', 'sValue':'launch-setup', 'bIsSubmit':true, 'sId':'launch-setup'} %}
{% EndUIForm %}
{% UIAlert ForInformation {sId:'fast-setup-alert', AddCSSClass:'ibo-is-hidden'} %}
{% UIContentBlock Standard {sId:'fast-setup-content', aContainerClasses:['ibo-fast-setup-content']} %}
{{ 'iTopUpdate:UI:SetupMessage:Compile'|dict_s }}
{% EndUIContentBlock %}
{% EndUIAlert %}
{% UIButton ForDestructiveAction {sLabel:'iTopUpdate:UI:FastSetupLaunch'|dict_s, sName:'launch-fast-setup', sValue:'launch-fast-setup', sId:'launch-fast-setup'} %}
{% UISpinner Standard {sId:'fast-setup-wait', IsHidden:true} %}
{% EndUIFieldSet %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,51 +116,4 @@ $("#launch-setup-form").on("submit", function () {
return window.confirm("{{ 'iTopUpdate:UI:SetupLaunchConfirm'|dict_s }}");
});

$("#launch-fast-setup").on("click", function(e) {
var oMessage = $("#fast-setup-alert");
var oContent = $("#fast-setup-content");
oMessage.removeClass("ibo-is-hidden");
oMessage.removeClass("ibo-is-failure");
oMessage.removeClass("ibo-is-success");
oMessage.addClass("ibo-is-information");
oContent.html("{{ 'iTopUpdate:UI:SetupMessage:Compile'|dict_s }}");

let fast_setup_wait = $("#fast-setup-wait");
fast_setup_wait.removeClass("ibo-is-hidden");
$(this).prop("disabled", true);

$.ajax({
method: "POST",
url: "{{ sAjaxURL|raw }}",
data: {
route: "core_update_ajax.rebuild_toolkit_environment"
},
dataType: "json",
complete: function(jqXHR, textStatus) {
$("#fast-setup-wait").addClass("ibo-is-hidden");
$("#launch-fast-setup").prop("disabled", false);
fast_setup_wait.addClass("ibo-is-hidden");
},
success: function (data) {
oMessage.removeClass("ibo-is-information");

if (data.bStatus) {
oMessage.removeClass("ibo-is-failure");
oMessage.addClass("ibo-is-success");
oContent.html("{{ 'iTopUpdate:UI:SetupMessage:UpdateDone'|dict_s }}");
} else {
oMessage.removeClass("ibo-is-success");
oMessage.addClass("ibo-is-failure");
oContent.html(data.sError);
}
},
error: function(jqXHR, textStatus, errorThrown) {
oMessage.removeClass("ibo-is-information");
oMessage.removeClass("ibo-is-success");
oMessage.addClass("ibo-is-failure");
oContent.html(textStatus + ' ' + errorThrown);
}
});

});

1 change: 1 addition & 0 deletions setup/ajax.dataloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ function FatalErrorCatcher($sOutput)
// Never cache this page
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past
$oCtx = new ContextTag(ContextTag::TAG_SETUP);

/**
* Main program
Expand Down
1 change: 1 addition & 0 deletions setup/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function json_decode($json, $assoc = null)
//N°3671 setup context: force $bForceTrustProxy to be persisted in next calls
utils::GetAbsoluteUrlAppRoot(true);
$oWizard = new WizardController('WizStepWelcome');
$oCtx = new ContextTag(ContextTag::TAG_SETUP);
//N°3952
if (SetupUtils::IsSessionSetupTokenValid()) {
// Normal operation
Expand Down
6 changes: 4 additions & 2 deletions setup/wizardcontroller.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ protected function DisplayStep(WizardStep $oStep): void
SetupLog::Info("=== Setup screen: ".$oStep->GetTitle().' ('.get_class($oStep).')');
$oPage = new SetupPage($oStep->GetTitle());
$oPage->LinkScriptFromAppRoot('setup/setup.js');
$oStep->PreFormDisplay($oPage);

$oPage->add('<form id="wiz_form" class="ibo-setup--wizard" method="post">');
$oPage->add('<div class="ibo-setup--wizard--content">');
$oStep->Display($oPage);
Expand Down Expand Up @@ -263,8 +265,8 @@ protected function DisplayStep(WizardStep $oStep): void
$oPage->output();
}
/**
* Make the wizard run: Start, Next or Back depending WizardUpdateButtons();
on the page's parameters
* Make the wizard run: 'Start', 'Next' or 'Back' depending WizardUpdateButtons();
* on the page's parameters
*/
public function Run()
{
Expand Down
11 changes: 11 additions & 0 deletions setup/wizardsteps/WizStepLandingBeforeAudit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ public function Display(SetupPage $oPage): void
*/
public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState
{
if ($this->oWizard->GetParameter('skip_wizard', false)) {
$oRuntimeEnv = new RunTimeEnvironment();
$sBuildConfigFile = APPCONF.$oRuntimeEnv->GetBuildEnv().'/'.ITOP_CONFIG_FILE;
$oConfig = new Config($sBuildConfigFile);
$oExtensionMap = iTopExtensionsMap::GetExtensionsMap($oRuntimeEnv->GetBuildEnv());
$aExtensionsFromDatabase = $oExtensionMap->GetChoicesFromDatabase($oConfig);
$this->oWizard->SetParameter('selected_extensions', json_encode($aExtensionsFromDatabase));
$adModulesFromDatabase = ModuleInstallationRepository::GetInstance()->ReadComputeInstalledModules($oConfig);
$this->oWizard->SetParameter('selected_modules', json_encode(array_keys($adModulesFromDatabase)));
Comment on lines +55 to +63

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Extension diff missing

When the fast-track path is used, this branch only restores selected_extensions and selected_modules from the current database. It skips the normal GetAddedAndRemovedExtensions() finalization, so downstream audit and cleanup forms receive removed_extensions as the default empty list. If an installed extension is no longer present or should be treated as removed during the update, the compatibility compile and feature-removal flow can run without the required removal set and miss cleanup work before the upgrade continues.

}

$aWizardSteps = $this->GetWizardSteps();
$this->oWizard->SetWizardSteps($aWizardSteps);
$this->sCurrentState = count($aWizardSteps) - 1;
Expand Down
108 changes: 76 additions & 32 deletions setup/wizardsteps/WizStepWelcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
class WizStepWelcome extends WizardStep
{
protected $bCanMoveForward;
private array $aInfo;
private array $aWarnings;
private array $aErrors;

public function __construct(WizardController $oWizard, $sCurrentState)
{
parent::__construct($oWizard, $sCurrentState);
$this->CheckInstallation();
}

public function GetTitle()
{
Expand Down Expand Up @@ -66,39 +75,14 @@ public function Display(SetupPage $oPage): void
EOF
);
$oPage->add('<h1>'.ITOP_APPLICATION.' Installation Wizard</h1>');
$aResults = SetupUtils::CheckPhpAndExtensions();
$this->bCanMoveForward = true;
$aInfo = [];
$aWarnings = [];
$aErrors = [];
foreach ($aResults as $oCheckResult) {
switch ($oCheckResult->iSeverity) {
case CheckResult::ERROR:
$aErrors[] = $oCheckResult->sLabel;
$this->bCanMoveForward = false;
break;

case CheckResult::WARNING:
$aWarnings[] = $oCheckResult->sLabel;
break;

case CheckResult::INFO:
$aInfo[] = $oCheckResult->sLabel;
break;

case CheckResult::TRACE:
SetupLog::Ok($oCheckResult->sLabel);
break;
}
}
$sStyle = 'style="display:none;overflow:auto;"';
$sToggleButtons = '<button type="button" id="show_details" class="ibo-button ibo-is-alternative ibo-is-neutral" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#hide_details\').toggle();"><span class="ibo-button--icon fa fa-caret-down"></span><span class="ibo-button--label">Show details</span></button><button type="button" id="hide_details" class="ibo-button ibo-is-alternative ibo-is-neutral" style="display:none;" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#show_details\').toggle();"><span class="ibo-button--icon fa fa-caret-up"></span><span class="ibo-button--label">Hide details</span></button>';
if (count($aErrors) > 0) {
if (count($this->aErrors) > 0) {
$sStyle = 'style="overflow:auto;"';
$sTitle = count($aErrors).' Error(s), '.count($aWarnings).' Warning(s).';
$sTitle = count($this->aErrors).' Error(s), '.count($this->aWarnings).' Warning(s).';
$sH2Class = 'text-error';
} elseif (count($aWarnings) > 0) {
$sTitle = count($aWarnings).' Warning(s) '.$sToggleButtons;
} elseif (count($this->aWarnings) > 0) {
$sTitle = count($this->aWarnings).' Warning(s) '.$sToggleButtons;
$sH2Class = 'text-warning';
} else {
$sTitle = 'Ok. '.$sToggleButtons;
Expand All @@ -110,13 +94,13 @@ public function Display(SetupPage $oPage): void
<div id="details" $sStyle>
HTML
);
foreach ($aErrors as $sText) {
foreach ($this->aErrors as $sText) {
$oPage->error($sText);
}
foreach ($aWarnings as $sText) {
foreach ($this->aWarnings as $sText) {
$oPage->warning($sText);
}
foreach ($aInfo as $sText) {
foreach ($this->aInfo as $sText) {
$oPage->ok($sText);
}
$oPage->add('</div>');
Expand All @@ -127,8 +111,68 @@ public function Display(SetupPage $oPage): void
$oPage->add_ready_script('CheckDirectoryConfFilesPermissions("'.utils::GetItopVersionWikiSyntax().'")');
}

/**
* Add post display stuff to the setup screen
* @param \SetupPage $oPage
*
* @return void
*/
public function PostFormDisplay(SetupPage $oPage)
{
if ($this->bCanMoveForward) {
$sBuildConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE;
if (file_exists($sBuildConfigFile)) {
$oPage->add(
<<<HTML
<form method="post">
<input type="hidden" name="_class" value="WizStepLandingBeforeAudit"/>
<input type="hidden" name="operation" value="next"/>
<input type="hidden" name="_params[skip_wizard]" value="1"/>
<table style="width:100%;" class="ibo-setup--wizard--buttons-container">
<tr>
<td style="text-align: right"><button type="submit" class="ibo-button ibo-is-regular ibo-is-secondary">Keep current choices</button></td>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a tooltip to detail what will happen if user clicks on this button?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this button is so powerfull that I would change his color to highlight it!

</tr>
</table>
</form>
HTML
);
}
}
}

public function CanMoveForward()
{
return $this->bCanMoveForward;
}

/**
*/
public function CheckInstallation(): void
{
$aResults = SetupUtils::CheckPhpAndExtensions();
$this->bCanMoveForward = true;
$this->aInfo = [];
$this->aWarnings = [];
$this->aErrors = [];
foreach ($aResults as $oCheckResult) {
switch ($oCheckResult->iSeverity) {
case CheckResult::ERROR:
$this->aErrors[] = $oCheckResult->sLabel;
$this->bCanMoveForward = false;
break;

case CheckResult::WARNING:
$this->aWarnings[] = $oCheckResult->sLabel;
break;

case CheckResult::INFO:
$this->aInfo[] = $oCheckResult->sLabel;
break;

case CheckResult::TRACE:
SetupLog::Ok($oCheckResult->sLabel);
break;
}
}
}
}
4 changes: 4 additions & 0 deletions setup/wizardsteps/WizardStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public function PostFormDisplay(SetupPage $oPage)
{
}

public function PreFormDisplay(SetupPage $oPage)
{
}

protected function CheckDependencies()
{
if (is_null($this->bDependencyCheck)) {
Expand Down