Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°5554 Add refresh button for iTop 3.x #6

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
13 changes: 9 additions & 4 deletions ajax.toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,11 +827,16 @@ function InitDataModel($sConfigFileName, $bModelOnly = true)

if (count($aSQLFixesTables) > 0)
{
$oButtonUpCodeAndDb = ButtonUIBlockFactory::MakeForPrimaryAction("Compile + Update DB tables and views","e","📀 Update iTop code and Database! ", true,"bt_up_code_and_db");
$oButtonUpCodeAndDb = ButtonUIBlockFactory::MakeForPrimaryAction("📀 Update iTop code and Database!",null,null, true,"bt_up_code_and_db");
$oButtonUpCodeAndDb->SetOnClickJsCode("doApply(true);");
$oButtonUpCodeAndDb->SetTooltip("Compile + Update DB tables and views");
$oPage->AddSubBlock($oButtonUpCodeAndDb);
}

$oButtonSchema = ButtonUIBlockFactory::MakeForPrimaryAction("⟳ Refresh",null, null,false, "bt_content_schema");
$oButtonSchema->SetOnClickJsCode('CheckDBSchema(true);');
$oButtonSchema->SetIconClass("fas fa-redo");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to use this FontAwesome icon, but it doesn't seem to work. Any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The FA stylesheet doesn't seem to be included in the page

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh.. Is that something that should be?

Copy link
Contributor

Choose a reason for hiding this comment

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

To use the icons through CSS classes yes.

Looks like the font file is already included which might actually be a mistake actually. It should be the stylesheet not the font file. Font file will be brought by the stylesheet.

You can check how it is done in the backoffice and make a PR for the toolkit if you feel like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its just /css/font-awesome/css/all.min.css right? Do you mean this url changes across versions?

Copy link
Contributor

Choose a reason for hiding this comment

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

To me it would be ok to test for the existence of the file and include it. The toolkit is supposed to work with several versions of iTop as are some extensions, so it seems fair to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its just /css/font-awesome/css/all.min.css right? Do you mean this url changes across versions?

It could change yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But only as much as any other linked file from iTop core I guess?

Examples:

  • ../images/indicator.gif
  • js/jquery.ba-bbq.min.js
  • ../images/itop-logo.png

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's why we can consider it as an extension from my PoV. It relies on the iTop version installed and its resources, so it's ok to check if the file exists.

$oPage->AddSubBlock($oButtonSchema);

break;

Expand All @@ -844,14 +849,14 @@ function InitDataModel($sConfigFileName, $bModelOnly = true)

if ($bUpdateNeeded)
{
$oButtonBuildHK = ButtonUIBlockFactory::MakeForPrimaryAction("Compute HKeys","e","Compute HKeys ", false,"bt_compute_hk");
$oButtonBuildHK = ButtonUIBlockFactory::MakeForPrimaryAction("Compute HKeys",null,null, false,"bt_compute_hk");
$oButtonBuildHK->SetOnClickJsCode("BuildHK(false);");
$oButtonBuildHK->AddCSSClass("mb-5");
$oPage->AddSubBlock($oButtonBuildHK);
}
else
{
$oButtonBuildHK = ButtonUIBlockFactory::MakeForPrimaryAction("Rebuild HKeys Anyway","e","Rebuild HKeys Anyway ", false,"bt_compute_hk");
$oButtonBuildHK = ButtonUIBlockFactory::MakeForPrimaryAction("Rebuild HKeys Anyway",null,null, false,"bt_compute_hk");
$oButtonBuildHK->SetOnClickJsCode("BuildHK(true);");
$oButtonBuildHK->AddCSSClass("mb-5");
$oPage->AddSubBlock($oButtonBuildHK);
Expand Down Expand Up @@ -884,7 +889,7 @@ function InitDataModel($sConfigFileName, $bModelOnly = true)
ob_end_clean();
if ($bUpdateNeeded)
{
$oButtonBuildHK = ButtonUIBlockFactory::MakeForPrimaryAction("Fix Data Sources","e","Fix Data Sources ", false,"bt_fix_DS");
$oButtonBuildHK = ButtonUIBlockFactory::MakeForPrimaryAction("Fix Data Sources",null,null, false,"bt_fix_DS");
$oButtonBuildHK->SetOnClickJsCode("FixDataSources();");
$oPage->AddSubBlock($oButtonBuildHK);
}
Expand Down
15 changes: 8 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function CheckConsistency()
$oDivAction=UIContentBlockUIBlockFactory::MakeStandard("content_php",['ibo-is-html-content']);
$oBlock->AddSubBlock($oDivAction);

$oButton=ButtonUIBlockFactory::MakeForPrimaryAction("Check Consistency","a","b",false,"bt_content_php");
$oButton=ButtonUIBlockFactory::MakeForPrimaryAction("Check Consistency",null,null,false,"bt_content_php");
$oButton->SetOnClickJsCode('CheckConsistency(true);');
$oBlock->AddSubBlock($oButton);
return $oBlock;
Expand All @@ -74,7 +74,7 @@ function CheckDBSchema()
$oDivAction=UIContentBlockUIBlockFactory::MakeStandard("content_schema",['ibo-is-visible']);
$oFieldSetDB->AddSubBlock($oDivAction);

$oButtonSchema=ButtonUIBlockFactory::MakeForPrimaryAction("📀 Check DB Schema","a","b",false, "bt_content_schema");
$oButtonSchema=ButtonUIBlockFactory::MakeForPrimaryAction("📀 Check DB Schema",null,null,false, "bt_content_schema");
$oButtonSchema->SetOnClickJsCode('CheckDBSchema(true);');
$oDivAction->AddSubBlock($oButtonSchema);

Expand All @@ -100,8 +100,9 @@ function CheckDBSchema()
}
$oDivButton = UIContentBlockUIBlockFactory::MakeStandard("div_bt_compilation",['ibo-is-visible','mt-5','mb-5']);
$oFieldSetCompile->AddSubBlock($oDivButton);
$oButtonCompile=ButtonUIBlockFactory::MakeForPrimaryAction("📄 Update iTop code","Compile from $sSourceDirHtml to env-production","b",false, "bt_content_apply_sql");
$oButtonCompile=ButtonUIBlockFactory::MakeForPrimaryAction("📄 Update iTop code",null,null,false, "bt_content_apply_sql");
$oButtonCompile->SetOnClickJsCode('doApply(false);');
$oButtonCompile->SetTooltip("Compile from $sSourceDirHtml to env-production");
$oDivButton->AddSubBlock($oButtonCompile);

$oFieldSetCompile->AddSubBlock(new Html('<span id="apply_sql_indicator"></span>'));
Expand Down Expand Up @@ -134,15 +135,15 @@ function CheckDataIntegrity()
$oBlock->AddSubBlock($oFieldSetDatasources);
$oDivDatasources=UIContentBlockUIBlockFactory::MakeStandard("content_datasources",['ibo-is-visible']);
$oFieldSetDatasources->AddSubBlock($oDivDatasources);
$oButtonDatasources=ButtonUIBlockFactory::MakeForPrimaryAction("Check Data Sources","a","b", false, "bt_content_datasources");
$oButtonDatasources=ButtonUIBlockFactory::MakeForPrimaryAction("Check Data Sources",null,null, false, "bt_content_datasources");
$oButtonDatasources->SetOnClickJsCode('CheckDataSources(true);');
$oFieldSetDatasources->AddSubBlock($oButtonDatasources);

$oFieldSetKeys = FieldSetUIBlockFactory::MakeStandard('Hierarchical Keys');
$oBlock->AddSubBlock($oFieldSetKeys);
$oDivKeys=UIContentBlockUIBlockFactory::MakeStandard("content_hk",['ibo-is-html-content']);
$oFieldSetKeys->AddSubBlock($oDivKeys);
$oButtonKeys=ButtonUIBlockFactory::MakeForPrimaryAction("Check Hierarchical Keys","a","b", false, "bt_content_hk");
$oButtonKeys=ButtonUIBlockFactory::MakeForPrimaryAction("Check Hierarchical Keys",null,null, false, "bt_content_hk");
$oButtonKeys->SetOnClickJsCode('CheckHK(true);');
$oFieldSetKeys->AddSubBlock($oButtonKeys);

Expand All @@ -166,7 +167,7 @@ function CheckDictionary()
$oDivAction=UIContentBlockUIBlockFactory::MakeStandard("content_dictionary",['ibo-is-visible']);
$oTabComplete->AddSubBlock($oDivAction);

$oButton=ButtonUIBlockFactory::MakeForPrimaryAction("🌐 Check Dictionary","a","b");
$oButton=ButtonUIBlockFactory::MakeForPrimaryAction("🌐 Check Dictionary");
$oButton->SetOnClickJsCode('CheckDictionary(true);');
$oButton->AddCSSClass('mt-5');
$oTabComplete->AddSubBlock($oButton);
Expand Down Expand Up @@ -198,7 +199,7 @@ function CheckDictionary()
$oInputLocalized->GetInput()->SetPlaceholder("eg. Français");
$oFormPrepare->AddSubBlock($oInputLocalized);

$oButtonGenerate=ButtonUIBlockFactory::MakeForPrimaryAction("Generate","a","b",false, "bt_prepare_new_dictionary");
$oButtonGenerate=ButtonUIBlockFactory::MakeForPrimaryAction("Generate",null,null,false, "bt_prepare_new_dictionary");
$oButtonGenerate->SetOnClickJsCode(' PrepareNewDictionary(true);');
$oButtonGenerate->AddCSSClass('mb-5');
$oFormPrepare->AddSubBlock($oButtonGenerate);
Expand Down