🌐 dico

This commit is contained in:
Eric Espie
2026-03-11 14:26:59 +01:00
parent 781be345b8
commit b35dca7150
7 changed files with 85 additions and 25 deletions

View File

@@ -39,6 +39,7 @@ Dict::Add('EN US', 'English', 'English', [
'UI:Button:PlanDeletion' => 'Prepare deletion plan',
'UI:Button:DoDeletion' => 'Delete data',
'UI:Button:BackToMain' => 'Back to Feature Removal',
'UI:Button:Setup' => 'Back to setup',
'UI:Action:ForceUninstall' => 'Force uninstall',
'UI:Action:MoreInfo' => 'More information',
@@ -52,4 +53,4 @@ Dict::Add('EN US', 'English', 'English', [
'DataFeatureRemoval:Column:DeletedCount' => 'Deleted entries',
'DataFeatureRemoval:Column:UpdatedCount' => 'Updated entries',
]);
]);

View File

@@ -39,6 +39,7 @@ Dict::Add('FR FR', 'French', 'Français', [
'UI:Button:PlanDeletion' => 'Prepare deletion plan',
'UI:Button:DoDeletion' => 'Delete data',
'UI:Button:BackToMain' => 'Back to Feature Removal',
'UI:Button:Setup' => 'Back to setup',
'UI:Action:ForceUninstall' => 'Force uninstall',
'UI:Action:MoreInfo' => 'More information',
@@ -46,8 +47,8 @@ Dict::Add('FR FR', 'French', 'Français', [
'DataFeatureRemoval:Table:Empty' => 'No data to remove',
'DataFeatureRemoval:Column:Class' => 'Class',
'DataFeatureRemoval:Column:DeleteCount' => 'Delete count',
'DataFeatureRemoval:Column:UpdateCount' => 'Update count',
'DataFeatureRemoval:Column:DeleteCount' => 'Entries to delete',
'DataFeatureRemoval:Column:UpdateCount' => 'Entries to update',
'DataFeatureRemoval:Column:Issue' => 'Issue',
'DataFeatureRemoval:Column:DeletedCount' => 'Deleted entries',

View File

@@ -33,6 +33,7 @@ class DataFeatureRemovalController extends Controller
{
$aParams = [];
$this->ReadRemovedExtensions();
$this->AddAnalyzeParams();
$aParams['sTransactionId'] = utils::GetNewTransactionId();
$aParams['aExtensions'] = $this->GetExtensionsTable();
@@ -40,6 +41,7 @@ class DataFeatureRemovalController extends Controller
$aParams['aClasses'] = array_keys($this->aCountClassesToCleanup);
$aParams['DataFeatureRemovalErrorMessage'] = $sErrorMessage;
$aParams['bHasData'] = count($aParams['aClasses']) > 0;
$aParams['sSetupUrl'] = utils::GetAbsoluteUrlAppRoot().'setup';
$this->AddLinkedStylesheet(utils::GetAbsoluteUrlModulesRoot().DataFeatureRemovalHelper::MODULE_NAME.'/assets/css/DataFeatureRemoval.css');
$this->AddLinkedScript(utils::GetAbsoluteUrlModulesRoot().DataFeatureRemovalHelper::MODULE_NAME.'/assets/js/DataFeatureRemoval.js');
@@ -73,22 +75,7 @@ HTML,
public function OperationAnalyze(): void
{
$this->ValidateTransactionId();
$aSelectedExtensionsFromUI = utils::ReadPostedParam('aExtensions', []);
$this->aSelectedExtensionsForCheck = [];
foreach ($aSelectedExtensionsFromUI as $sCode => $aData) {
$sValue = $aData['enable'] ?? 'off';
if (($sValue) === 'on') {
$this->aSelectedExtensionsForCheck[] = $sCode;
}
}
// Add source removed to check
foreach (DataFeatureRemoverExtensionService::GetInstance()->ReadItopExtensions() as $sCode => $oExtension) {
if ($oExtension->bRemovedFromDisk) {
$this->aSelectedExtensionsForCheck[] = $sCode;
}
}
$this->ReadRemovedExtensions();
$this->m_sOperation = 'Main';
@@ -249,4 +236,30 @@ HTML,
throw new DataFeatureRemovalException(Dict::S("iTopUpdate:Error:InvalidToken"));
}
}
/**
* @return void
*/
public function ReadRemovedExtensions(): void
{
if (count($this->aSelectedExtensionsForCheck) > 0) {
return;
}
$aSelectedExtensionsFromUI = utils::ReadPostedParam('aExtensions', []);
IssueLog::Error(__METHOD__, null, $aSelectedExtensionsFromUI);
foreach ($aSelectedExtensionsFromUI as $sCode => $aData) {
$sValue = $aData['enable'] ?? 'off';
if (($sValue) === 'on') {
$this->aSelectedExtensionsForCheck[] = $sCode;
}
}
// Add source removed to check
foreach (DataFeatureRemoverExtensionService::GetInstance()->ReadItopExtensions() as $sCode => $oExtension) {
if ($oExtension->bRemovedFromDisk) {
$this->aSelectedExtensionsForCheck[] = $sCode;
}
}
}
}

View File

@@ -24,4 +24,12 @@
{% include 'Features.html.twig' %}
{% include 'ExtensionRemovalData.html.twig' %}
{% if not bHasData %}
{% UIToolbar ForButton {} %}
<a href="{{ sSetupUrl }}">
{% UIButton ForPrimaryAction {sLabel:'UI:Button:Setup'|dict_s, sName:'btn_setup', sId:'btn_setup', bIsSubmit:false} %}
</a>
{% EndUIToolbar %}
{% endif %}
{% EndUIPanel %}

View File

@@ -16,7 +16,6 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Application\WebPage\WebPage;
require_once(APPROOT.'setup/setuputils.class.inc.php');
require_once(APPROOT.'setup/parameters.class.inc.php');
@@ -243,6 +242,7 @@ HTML;
}
$oPage->add('</tr></table>');
$oPage->add("</form>");
$oStep->PostFormDisplay($oPage);
$oPage->add('<div id="async_action" style="display:none;overflow:auto;max-height:100px;color:#F00;font-size:small;"></div>'); // The div may become visible in case of error
// Hack to have the "Next >>" button, be the default button, since the first submit button in the form is the default one

View File

@@ -17,6 +17,7 @@
*
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\WebPage\WebPage;
require_once(APPROOT.'setup/sequencers/DataAuditSequencer.php');
@@ -51,7 +52,6 @@ class WizStepDataAudit extends WizStepInstall
} else {
return false;
}
}
public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState
@@ -76,8 +76,6 @@ 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/exec.php?exec_module=combodo-data-feature-removal&exec_page=index.php';
$oPage->add('<input type="hidden" id="application_url" value="'.$sApplicationUrl.'"/>');
if (!$this->CheckDependencies()) {
$oPage->error($this->sDependencyIssue);
$oPage->add_ready_script(<<<JS
@@ -90,7 +88,35 @@ JS);
ExecuteStep("");
JS);
}
}
/**
* Add extra form to go to the feature removal backend page
* @param \SetupPage $oPage
*
* @return void
*/
public function PostFormDisplay(SetupPage $oPage)
{
$sApplicationUrl = utils::GetAbsoluteUrlModulePage('combodo-data-feature-removal', 'index.php');
$aRemovedExtensions = json_decode($this->oWizard->GetParameter('removed_extensions', "[]"), true);
$aHiddenRemovedExtensionInputs = "";
$i = 0;
foreach ($aRemovedExtensions as $sExtCode => $sExtLabel) {
$aHiddenRemovedExtensionInputs .= <<<INPUT
<input type="hidden" name="aExtensions[$sExtCode][enable]" value="on"/>
INPUT;
}
$oPage->add(
<<<HTML
<form id="data-feature-removal" class="ibo-setup--wizard ibo-is-hidden" method="post" action="$sApplicationUrl">
<input type="hidden" name="operation" value="Analyze"/>
$aHiddenRemovedExtensionInputs
</form>
HTML
);
}
protected function AddProgressErrorScript($oPage, $aRes)
@@ -101,8 +127,9 @@ JS);
<<<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>');
$('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').after('<td style="text-align:center;"><button id="goto-data-feature-removal" class="default ibo-button ibo-is-regular ibo-is-primary" type="button"><span class="ibo-button--label">Go to backoffice</span></button></td>');
$('#goto-data-feature-removal').on("click", function() { $('#data-feature-removal').submit();})
$("#wiz_form").data("installation_status", "cleanup_needed");
$('#btn_next').hide();
EOF

View File

@@ -66,6 +66,16 @@ abstract class WizardStep
protected $bDependencyCheck = null;
protected $sDependencyIssue = null;
/**
* Add post display stuff to the setup screen
* @param \SetupPage $oPage
*
* @return void
*/
public function PostFormDisplay(SetupPage $oPage)
{
}
protected function CheckDependencies()
{
if (is_null($this->bDependencyCheck)) {