N°9205 - Show progress messages in setup sequencer

This commit is contained in:
lenaick.moreira
2026-05-06 15:31:36 +02:00
parent c5b678b4cf
commit 0b150217da
6 changed files with 45 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@@ -700,9 +700,12 @@ body {
} }
#progress_content { #progress_content {
height: 200px; min-height: 200px;
overflow: auto; overflow: auto;
text-align: center; text-align: center;
*:not(.message) + .message {
margin-top: 1.5rem;
}
} }
#fresh_content{ #fresh_content{
border: 0; border: 0;

View File

@@ -51,6 +51,16 @@ class ApplicationInstallSequencer extends StepSequencer
'create-config' => 'Creating the configuration File', 'create-config' => 'Creating the configuration File',
'commit' => 'Finalize', 'commit' => 'Finalize',
]; ];
protected const SUCCESS_LABELS = [
'log-parameters' => 'Parameters logged',
'backup' => 'Database backup completed',
'migrate-before' => 'Pre-upgrade data migration completed',
'db-schema' => 'Database schema updated',
'migrate-after' => 'Post-upgrade data migration completed',
'after-db-create' => 'Post-creation data loaded',
'load-data' => 'Data loaded',
'create-config' => 'Configuration file created',
];
/** /**
* @inherit * @inherit
@@ -120,7 +130,7 @@ class ApplicationInstallSequencer extends StepSequencer
$this->oRunTimeEnvironment->DoLoadData($this->GetConfig(), $bSampleData, $aSelectedModules); $this->oRunTimeEnvironment->DoLoadData($this->GetConfig(), $bSampleData, $aSelectedModules);
return $this->ComputeNextStep($sStep, 'All data loaded'); return $this->ComputeNextStep($sStep);
case 'create-config': case 'create-config':
$sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0'); $sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0');
@@ -144,11 +154,11 @@ class ApplicationInstallSequencer extends StepSequencer
return $this->GetNextStep('', 'Completed', 100); return $this->GetNextStep('', 'Completed', 100);
default: default:
return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', self::ERROR); return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', '', self::ERROR);
} }
} catch (Exception $e) { } catch (Exception $e) {
SetupLog::Exception("$sStep failed", $e); SetupLog::Exception("$sStep failed", $e);
$aResult = $this->GetNextStep('', '', 100, $e->getMessage(), self::ERROR); $aResult = $this->GetNextStep('', '', 100, $e->getMessage(), '', self::ERROR);
$aResult['error_code'] = $e->getCode(); $aResult['error_code'] = $e->getCode();
return $aResult; return $aResult;
} finally { } finally {
@@ -229,6 +239,7 @@ class ApplicationInstallSequencer extends StepSequencer
{ {
[$sNextStep, $iPercent] = $this->GetStepAfterWithPercent($sCurrentStep); [$sNextStep, $iPercent] = $this->GetStepAfterWithPercent($sCurrentStep);
$sLabel = self::LABELS[$sNextStep] ?? ''; $sLabel = self::LABELS[$sNextStep] ?? '';
return $this->GetNextStep($sNextStep, $sLabel, $iPercent, $sMessage); $sCurrentStepSuccessMessage = self::SUCCESS_LABELS[$sCurrentStep] ?? '';
return $this->GetNextStep($sNextStep, $sLabel, $iPercent, $sMessage, $sCurrentStepSuccessMessage);
} }
} }

View File

@@ -47,7 +47,7 @@ class DataAuditSequencer extends StepSequencer
case 'copy': case 'copy':
$this->oRunTimeEnvironment->CopySetupFiles(); $this->oRunTimeEnvironment->CopySetupFiles();
return $this->GetNextStep('compile', 'Compiling the data model', 20, 'Copying...'); return $this->GetNextStep('compile', 'Compiling the data model', 20, 'Copying...', 'Data model files copied');
case 'compile': case 'compile':
$aSelectedModules = $this->oParams->Get('selected_modules', []); $aSelectedModules = $this->oParams->Get('selected_modules', []);
@@ -65,25 +65,25 @@ class DataAuditSequencer extends StepSequencer
); );
if ($this->IsDataAuditRequired()) { if ($this->IsDataAuditRequired()) {
return $this->GetNextStep('setup-audit', 'Checking data consistency with the new data model', 70, $sMessage); return $this->GetNextStep('setup-audit', 'Checking data consistency with the new data model', 70, $sMessage, 'Data model compilation completed');
} }
return $this->GetNextStep('complete', 'Check Completed', 100); return $this->GetNextStep('complete', 'Check Completed', 100, '', 'Data model compilation completed');
case 'setup-audit': case 'setup-audit':
if ($this->IsDataAuditRequired()) { if ($this->IsDataAuditRequired()) {
$this->oRunTimeEnvironment->DataToCleanupAudit(); $this->oRunTimeEnvironment->DataToCleanupAudit();
} }
return $this->GetNextStep('complete', 'Check Completed', 100); return $this->GetNextStep('complete', 'Check Completed', 100, '', 'Data consistency check completed');
case 'complete': case 'complete':
return $this->GetNextStep('', 'Completed', 100); return $this->GetNextStep('', 'Completed', 100, '', 'All checks completed');
default: default:
return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', self::ERROR); return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', '', self::ERROR);
} }
} catch (Exception $e) { } catch (Exception $e) {
SetupLog::Exception("$sStep failed", $e); SetupLog::Exception("$sStep failed", $e);
$aResult = $this->GetNextStep('', '', 100, $e->getMessage(), self::ERROR); $aResult = $this->GetNextStep('', '', 100, $e->getMessage(), '', self::ERROR);
$aResult['error_code'] = $e->getCode(); $aResult['error_code'] = $e->getCode();
return $aResult; return $aResult;
} finally { } finally {

View File

@@ -127,13 +127,14 @@ abstract class StepSequencer
return ($iOverallStatus == self::OK); return ($iOverallStatus == self::OK);
} }
protected function GetNextStep(string $sNextStep, string $sNextStepLabel, int $iPercentComplete, string $sMessage = '', int $iStatus = self::OK): array protected function GetNextStep(string $sNextStep, string $sNextStepLabel, int $iPercentComplete, string $sMessage = '', string $sPrevStepSuccessMessage = '', int $iStatus = self::OK): array
{ {
return [ return [
'status' => $iStatus, 'status' => $iStatus,
'message' => $sMessage, 'message' => $sMessage,
'next-step' => $sNextStep, 'next-step' => $sNextStep,
'next-step-label' => $sNextStepLabel, 'next-step-label' => $sNextStepLabel,
'prev-step-success-message' => $sPrevStepSuccessMessage,
'percentage-completed' => $iPercentComplete, 'percentage-completed' => $iPercentComplete,
]; ];
} }

View File

@@ -70,6 +70,20 @@ class WizStepInstall extends AbstractWizStepInstall
$oPage->add("<div class=\"message message-error ibo-is-html-content\" style=\"display:none;\" id=\"setup_error\"></div>"); $oPage->add("<div class=\"message message-error ibo-is-html-content\" style=\"display:none;\" id=\"setup_error\"></div>");
} }
protected function AddPrevStepSuccessMessage(WebPage $oPage, string $sPrevStepSuccessMessage): void
{
if ($sPrevStepSuccessMessage === '') {
return;
}
$sPrevStepSuccessMessage = addslashes(utils::EscapeHtml($sPrevStepSuccessMessage));
$oPage->add_ready_script(
<<<EOF
$('<div class="message message-valid ibo-is-html-content">').html('$sPrevStepSuccessMessage').appendTo("#progress_content");
EOF
);
}
public function Display(SetupPage $oPage): void public function Display(SetupPage $oPage): void
{ {
$aInstallParams = $this->BuildConfig(); $aInstallParams = $this->BuildConfig();
@@ -121,6 +135,7 @@ JS);
ExecuteStep('{$aRes['next-step']}'); ExecuteStep('{$aRes['next-step']}');
EOF EOF
); );
static::AddPrevStepSuccessMessage($oPage, $aRes['prev-step-success-message']);
} elseif ($aRes['status'] !== StepSequencer::ERROR) { } elseif ($aRes['status'] !== StepSequencer::ERROR) {
// Installation complete, move to the next step of the wizard // Installation complete, move to the next step of the wizard
$oPage->add_ready_script( $oPage->add_ready_script(
@@ -132,6 +147,7 @@ EOF
$("#btn_next").trigger('click'); $("#btn_next").trigger('click');
EOF EOF
); );
static::AddPrevStepSuccessMessage($oPage, $aRes['prev-step-success-message']);
} else { } else {
//Error case //Error case
$sMessage = addslashes(utils::EscapeHtml($aRes['message'])); $sMessage = addslashes(utils::EscapeHtml($aRes['message']));