mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°9144 Add buttons "Go to backoffice" & "Ignore and continue"
This commit is contained in:
@@ -1002,6 +1002,7 @@ class SetupDBBackup extends DBBackup
|
||||
|
||||
class DataAuditSequencer extends ApplicationInstallSequencer
|
||||
{
|
||||
public const DATA_AUDIT_FAILED = 100;
|
||||
|
||||
|
||||
protected function GetTempEnv()
|
||||
@@ -1081,7 +1082,7 @@ class DataAuditSequencer extends ApplicationInstallSequencer
|
||||
'message' => '',
|
||||
'next-step' => 'write-config',
|
||||
'next-step-label' => 'Writing audit config',
|
||||
'percentage-completed' => 60,
|
||||
'percentage-completed' => 40,
|
||||
];
|
||||
break;
|
||||
case 'write-config':
|
||||
@@ -1091,7 +1092,7 @@ class DataAuditSequencer extends ApplicationInstallSequencer
|
||||
'message' => '',
|
||||
'next-step' => 'setup-audit',
|
||||
'next-step-label' => 'Checking data consistency with the new data model',
|
||||
'percentage-completed' => 70,
|
||||
'percentage-completed' => 60,
|
||||
];
|
||||
break;
|
||||
case 'setup-audit':
|
||||
@@ -1131,6 +1132,7 @@ class DataAuditSequencer extends ApplicationInstallSequencer
|
||||
'next-step' => '',
|
||||
'next-step-label' => '',
|
||||
'percentage-completed' => 100,
|
||||
'error_code' => $e->getCode(),
|
||||
];
|
||||
|
||||
SetupLog::Error('An exception occurred: '.$e->getMessage().' at line '.$e->getLine().' in file '.$e->getFile());
|
||||
@@ -1181,15 +1183,13 @@ class DataAuditSequencer extends ApplicationInstallSequencer
|
||||
|
||||
$sTargetEnvironment = $this->GetTempEnv();
|
||||
$sPreviousEnvironment = $this->GetTargetEnv();
|
||||
file_put_contents('C:/tmp/uninstall.log', "prev env=".$sPreviousEnvironment."\n", FILE_APPEND);
|
||||
file_put_contents('C:/tmp/uninstall.log', "target env=".$sTargetEnvironment."\n", FILE_APPEND);
|
||||
$oSetupAudit = new SetupAudit($sPreviousEnvironment, $sTargetEnvironment);
|
||||
|
||||
$oSetupAudit->GetIssues(true);
|
||||
$iCount = $oSetupAudit->GetDataToCleanupCount();
|
||||
|
||||
if ($iCount > 0) {
|
||||
throw new Exception("$iCount elements require data adjustments or cleanup in the backoffice prior to upgrading iTop");
|
||||
throw new Exception("$iCount elements require data adjustments or cleanup in the backoffice prior to upgrading iTop", static::DATA_AUDIT_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ class ModelReflectionSerializer
|
||||
}
|
||||
|
||||
$aClasses = json_decode($sOutput[0] ?? null, true);
|
||||
file_put_contents('C:/tmp/uninstall.log', "\n\n".var_export($sOutput, true), FILE_APPEND);
|
||||
if (false === $aClasses) {
|
||||
$this->LogErrorWithProperLogger("Invalid JSON", null, ['env' => $sEnv, "output" => $sOutput]);
|
||||
throw new Exception("cannot get classes");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Combodo\iTop\Setup\FeatureRemoval;
|
||||
|
||||
use MetaModel;
|
||||
use utils;
|
||||
|
||||
require_once __DIR__.'/AbstractSetupAudit.php';
|
||||
require_once APPROOT.'setup/feature_removal/ModelReflectionSerializer.php';
|
||||
@@ -28,14 +29,17 @@ class SetupAudit extends AbstractSetupAudit
|
||||
return;
|
||||
}
|
||||
|
||||
$sCurrentEnvt = MetaModel::GetEnvironment();
|
||||
if ($sCurrentEnvt === $this->sEnvBefore) {
|
||||
$sCurrentEnv = MetaModel::GetEnvironment();
|
||||
|
||||
$sConfFile = utils::GetConfigFilePath($sCurrentEnv);
|
||||
MetaModel::Startup($sConfFile, false /* $bModelOnly */, false /* $bAllowCache */, false /* $bTraceSourceFiles */, $sCurrentEnv);
|
||||
if ($sCurrentEnv === $this->sEnvBefore) {
|
||||
$this->aClassesBefore = MetaModel::GetClasses();
|
||||
} else {
|
||||
$this->aClassesBefore = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvBefore);
|
||||
}
|
||||
|
||||
if ($sCurrentEnvt === $this->sEnvAfter) {
|
||||
if ($sCurrentEnv === $this->sEnvAfter) {
|
||||
$this->aClassesAfter = MetaModel::GetClasses();
|
||||
} else {
|
||||
$this->aClassesAfter = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvAfter);
|
||||
|
||||
@@ -19,7 +19,7 @@ if (is_null($sEnv)) {
|
||||
$sConfFile = utils::GetConfigFilePath($sEnv);
|
||||
|
||||
try {
|
||||
MetaModel::Startup($sConfFile, false /* $bModelOnly */, true /* $bAllowCache */, false /* $bTraceSourceFiles */, $sEnv);
|
||||
MetaModel::Startup($sConfFile, false /* $bModelOnly */, false /* $bAllowCache */, false /* $bTraceSourceFiles */, $sEnv);
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
|
||||
@@ -25,21 +25,17 @@ function WizardAsyncAction(sActionCode, oParams, OnErrorFunction)
|
||||
|
||||
function WizardUpdateButtons()
|
||||
{
|
||||
if (CanMoveForward())
|
||||
{
|
||||
if (CanMoveForward()) {
|
||||
$("#btn_next").prop('disabled', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$("#btn_next").prop('disabled', true);
|
||||
}
|
||||
|
||||
if (CanMoveBackward())
|
||||
{
|
||||
if (CanMoveBackward()) {
|
||||
$("#btn_back").prop('disabled', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$("#btn_back").prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ class WizStepDataAudit extends WizStepInstall
|
||||
|
||||
$sAuthentToken = $this->oWizard->GetParameter('authent', '');
|
||||
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
|
||||
$sApplicationUrl = $this->oWizard->GetParameter('application_url').'pages/UI.php';
|
||||
$oPage->add('<input type="hidden" id="application_url" value="'.$sApplicationUrl.'"/>');
|
||||
|
||||
if (!$this->CheckDependencies()) {
|
||||
$oPage->error($this->sDependencyIssue);
|
||||
@@ -85,4 +87,31 @@ class WizStepDataAudit extends WizStepInstall
|
||||
JS
|
||||
);
|
||||
}
|
||||
|
||||
protected function AddProgressErrorScript($oPage, $aRes){
|
||||
if(isset($aRes['error_code']) && $aRes['error_code'] === DataAuditSequencer::DATA_AUDIT_FAILED){
|
||||
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').before('<td style="text-align:center;"><button class="ibo-button ibo-is-alternative ibo-is-neutral" type="submit" name="operation" value="next"><span class="ibo-button--label">Ignore and continue</span></button></td>');
|
||||
|
||||
$('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').after('<td style="text-align:center;"><a href="'+$('#application_url').val()+'"><button class="default ibo-button ibo-is-regular ibo-is-primary" type="button"><span class="ibo-button--label">Go to backoffice</span></button></a></td>');
|
||||
|
||||
$("#wiz_form").data("installation_status", "cleanup_needed");
|
||||
$('#btn_next').hide();
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return 'return ["completed", "cleanup_needed"].indexOf($("#wiz_form").data("installation_status")) !== -1;';
|
||||
}
|
||||
|
||||
public function JSCanMoveBackward()
|
||||
{
|
||||
return 'return ["not started", "error", "cleanup_needed"].indexOf($("#wiz_form").data("installation_status")) !== -1;';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ class WizStepInstall extends AbstractWizStepInstall
|
||||
$oPage->add('<p class="center"><span id="setup_msg">Ready to start...</span></p><div style="display:block;margin-left: auto; margin-right:auto;" id="progress">0%</div>');
|
||||
$oPage->add('</div>'); // progress_content
|
||||
$oPage->add('</fieldset>');
|
||||
$oPage->add("<div class=\"message message-error ibo-is-html-content\" style=\"display:none;\" id=\"setup_error\"></div>");
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +78,6 @@ class WizStepInstall extends AbstractWizStepInstall
|
||||
|
||||
$sAuthentToken = $this->oWizard->GetParameter('authent', '');
|
||||
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
|
||||
|
||||
if (!$this->CheckDependencies()) {
|
||||
$oPage->error($this->sDependencyIssue);
|
||||
}
|
||||
@@ -128,18 +128,24 @@ EOF
|
||||
EOF
|
||||
);
|
||||
} else {
|
||||
//Error case
|
||||
$sMessage = addslashes(utils::EscapeHtml($aRes['message']));
|
||||
$sMessage = str_replace("\n", '<br>', $sMessage);
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$("#wiz_form").data("installation_status", "error");
|
||||
WizardUpdateButtons();
|
||||
$('#setup_msg').html('$sMessage');
|
||||
$('#setup_error').html('$sMessage').show();
|
||||
EOF
|
||||
);
|
||||
$this->AddProgressErrorScript($oPage, $aRes);
|
||||
}
|
||||
}
|
||||
|
||||
protected function AddProgressErrorScript($oPage, $aRes){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the "Next" button should be enabled interactively
|
||||
* @return string A piece of javascript code returning either true or false
|
||||
|
||||
@@ -90,7 +90,7 @@ class WizStepSummary extends AbstractWizStepInstall
|
||||
if (count($aExtensionsAdded) > 0) {
|
||||
$sExtensionsAdded = '<ul>';
|
||||
foreach ($aExtensionsAdded as $sExtensionCode => $sLabel) {
|
||||
$sExtensionsAdded .= "<li>$sLabel</li>'";
|
||||
$sExtensionsAdded .= '<li>'.$sLabel.'</li>';
|
||||
}
|
||||
$sExtensionsAdded .= '</ul>';
|
||||
} else {
|
||||
@@ -106,9 +106,9 @@ class WizStepSummary extends AbstractWizStepInstall
|
||||
$sExtensionsRemoved = '<ul>';
|
||||
foreach ($aExtensionsRemoved as $sExtensionCode => $sLabel) {
|
||||
if (in_array($sExtensionCode, $aExtensionsNotUninstallable)) {
|
||||
$sExtensionsRemoved .= "<li>$sLabel (forced uninstallation)</li>";
|
||||
$sExtensionsRemoved .= '<li>'.$sLabel.' (forced uninstallation)</li>';
|
||||
} else {
|
||||
$sExtensionsRemoved .= "<li>$sLabel</li>";
|
||||
$sExtensionsRemoved .= '<li>'.$sLabel.'</li>';
|
||||
}
|
||||
}
|
||||
$sExtensionsRemoved .= '</ul>';
|
||||
|
||||
Reference in New Issue
Block a user