mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°9205 - Show progress messages in setup sequencer
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -700,9 +700,12 @@ body {
|
||||
}
|
||||
|
||||
#progress_content {
|
||||
height: 200px;
|
||||
min-height: 200px;
|
||||
overflow: auto;
|
||||
text-align: center;
|
||||
*:not(.message) + .message {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
}
|
||||
#fresh_content{
|
||||
border: 0;
|
||||
|
||||
@@ -51,6 +51,16 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
'create-config' => 'Creating the configuration File',
|
||||
'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
|
||||
@@ -120,7 +130,7 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
|
||||
$this->oRunTimeEnvironment->DoLoadData($this->GetConfig(), $bSampleData, $aSelectedModules);
|
||||
|
||||
return $this->ComputeNextStep($sStep, 'All data loaded');
|
||||
return $this->ComputeNextStep($sStep);
|
||||
|
||||
case 'create-config':
|
||||
$sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0');
|
||||
@@ -144,11 +154,11 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
return $this->GetNextStep('', 'Completed', 100);
|
||||
|
||||
default:
|
||||
return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', self::ERROR);
|
||||
return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', '', self::ERROR);
|
||||
}
|
||||
} catch (Exception $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();
|
||||
return $aResult;
|
||||
} finally {
|
||||
@@ -229,6 +239,7 @@ class ApplicationInstallSequencer extends StepSequencer
|
||||
{
|
||||
[$sNextStep, $iPercent] = $this->GetStepAfterWithPercent($sCurrentStep);
|
||||
$sLabel = self::LABELS[$sNextStep] ?? '';
|
||||
return $this->GetNextStep($sNextStep, $sLabel, $iPercent, $sMessage);
|
||||
$sCurrentStepSuccessMessage = self::SUCCESS_LABELS[$sCurrentStep] ?? '';
|
||||
return $this->GetNextStep($sNextStep, $sLabel, $iPercent, $sMessage, $sCurrentStepSuccessMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class DataAuditSequencer extends StepSequencer
|
||||
|
||||
case 'copy':
|
||||
$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':
|
||||
$aSelectedModules = $this->oParams->Get('selected_modules', []);
|
||||
@@ -65,25 +65,25 @@ class DataAuditSequencer extends StepSequencer
|
||||
);
|
||||
|
||||
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':
|
||||
if ($this->IsDataAuditRequired()) {
|
||||
$this->oRunTimeEnvironment->DataToCleanupAudit();
|
||||
}
|
||||
return $this->GetNextStep('complete', 'Check Completed', 100);
|
||||
return $this->GetNextStep('complete', 'Check Completed', 100, '', 'Data consistency check completed');
|
||||
|
||||
case 'complete':
|
||||
return $this->GetNextStep('', 'Completed', 100);
|
||||
return $this->GetNextStep('', 'Completed', 100, '', 'All checks completed');
|
||||
|
||||
default:
|
||||
return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', self::ERROR);
|
||||
return $this->GetNextStep('', "Unknown setup step '$sStep'.", 100, '', '', self::ERROR);
|
||||
}
|
||||
} catch (Exception $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();
|
||||
return $aResult;
|
||||
} finally {
|
||||
|
||||
@@ -127,13 +127,14 @@ abstract class StepSequencer
|
||||
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 [
|
||||
'status' => $iStatus,
|
||||
'message' => $sMessage,
|
||||
'next-step' => $sNextStep,
|
||||
'next-step-label' => $sNextStepLabel,
|
||||
'prev-step-success-message' => $sPrevStepSuccessMessage,
|
||||
'percentage-completed' => $iPercentComplete,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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>");
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
$aInstallParams = $this->BuildConfig();
|
||||
@@ -121,6 +135,7 @@ JS);
|
||||
ExecuteStep('{$aRes['next-step']}');
|
||||
EOF
|
||||
);
|
||||
static::AddPrevStepSuccessMessage($oPage, $aRes['prev-step-success-message']);
|
||||
} elseif ($aRes['status'] !== StepSequencer::ERROR) {
|
||||
// Installation complete, move to the next step of the wizard
|
||||
$oPage->add_ready_script(
|
||||
@@ -132,6 +147,7 @@ EOF
|
||||
$("#btn_next").trigger('click');
|
||||
EOF
|
||||
);
|
||||
static::AddPrevStepSuccessMessage($oPage, $aRes['prev-step-success-message']);
|
||||
} else {
|
||||
//Error case
|
||||
$sMessage = addslashes(utils::EscapeHtml($aRes['message']));
|
||||
|
||||
Reference in New Issue
Block a user