As descripbed here https://www.itophub.io/wiki/page?id=2_7_0:customization:highlight-critical-objects
I want to add some more colours to highlight different objects in different colours.
I did some tests but I cannot find out where the "HIGHLIGHT_CLASS_xxx" and colours are defined.
Has anybody tried to add some more colours?
Thanks, best regards,
Nico
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That link belongs (I think only) to the portal view.
For the backend/console view the "highlights" are set up differently.
I think at least at ./application/cmdbabstract.class.inc.php and in addition in some CSS definition.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've added some cide snippets and got some results but don't understand yet why only the even rows are coloured. On page reload I can see that all rows are coloured for a short time. The odd ones then fade to grey.
./css/light-grey.scss
Hi Nico, I would simply add a custom CSS and avoid the highlight stuff altogether as newer iTop versions will always override the existing (edited) files.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That is working, thanks :-)
Do you have another hint how to add my Class into that protected static $m_highlightComparison = array
in file cmdbabstract.class.inc.php using an extension?
Thanks again,
Nico
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But I need do define the new hilight class to select it in the function GetHilightClass.
That is needed to colour only results based on an OQL, e.g. tickets with a specific caller:
Hi,
I found a way to edit the file application/cmdbabstract.class.inc.php by running the setup.
I am using the function AfterDatabaseCreation within ModuleInstallerAPI:
publicstaticfunctionAfterDatabaseCreation(Config$oConfiguration,$sPreviousVersion,$sCurrentVersion){// Added own Hilight Class to cmdbabstract.class.inc.php to color results$sFile=APPROOT."application/cmdbabstract.class.inc.php";$sBackupFile=APPROOT."application/cmdbabstract.class.inc.php.backup";$sSearchString='/protectedstatic\$m_highlightComparison.*\);/msU';$sReplaceString=" protected static \$m_highlightComparison = array(HILIGHT_CLASS_CRITICAL=>array(HILIGHT_CLASS_CRITICAL=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_WARNING=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_OK=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_NONE=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_NMvip=>HILIGHT_CLASS_CRITICAL,),HILIGHT_CLASS_WARNING=>array(HILIGHT_CLASS_CRITICAL=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_WARNING=>HILIGHT_CLASS_WARNING,HILIGHT_CLASS_OK=>HILIGHT_CLASS_WARNING,HILIGHT_CLASS_NONE=>HILIGHT_CLASS_WARNING,HILIGHT_CLASS_NMvip=>HILIGHT_CLASS_WARNING,),HILIGHT_CLASS_OK=>array(HILIGHT_CLASS_CRITICAL=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_WARNING=>HILIGHT_CLASS_WARNING,HILIGHT_CLASS_OK=>HILIGHT_CLASS_OK,HILIGHT_CLASS_NONE=>HILIGHT_CLASS_OK,HILIGHT_CLASS_NMvip=>HILIGHT_CLASS_NMvip,),HILIGHT_CLASS_NONE=>array(HILIGHT_CLASS_CRITICAL=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_WARNING=>HILIGHT_CLASS_WARNING,HILIGHT_CLASS_OK=>HILIGHT_CLASS_OK,HILIGHT_CLASS_NONE=>HILIGHT_CLASS_NONE,HILIGHT_CLASS_NMvip=>HILIGHT_CLASS_NMvip,),HILIGHT_CLASS_NMvip=>array(HILIGHT_CLASS_CRITICAL=>HILIGHT_CLASS_CRITICAL,HILIGHT_CLASS_WARNING=>HILIGHT_CLASS_WARNING,HILIGHT_CLASS_OK=>HILIGHT_CLASS_NMvip,HILIGHT_CLASS_NONE=>HILIGHT_CLASS_NMvip,HILIGHT_CLASS_NMvip=>HILIGHT_CLASS_NMvip,),);";$content=file_get_contents($sFile);copy($sFile,$sBackupFile);file_put_contents($sFile,preg_replace($sSearchString,$sReplaceString,$content));}
The CSS code is injected by another extension.
My GetHilightClass function now looks like this:
Now I can add Persons to that team and all tickets in every list having that person as caller are colored as defined in the CSS.
I know I must be aware of the risk changing core files.
Using newer versions always will be tested in lab environment.
Thanks for the support.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As descripbed here https://www.itophub.io/wiki/page?id=2_7_0:customization:highlight-critical-objects
I want to add some more colours to highlight different objects in different colours.
I did some tests but I cannot find out where the "HIGHLIGHT_CLASS_xxx" and colours are defined.
Has anybody tried to add some more colours?
Thanks, best regards,
Nico
Which iTop version are you currently using?
Haven't tried it, but it seems quite doable.
We still use the LTR 2.7.7 since we have a lot of customizations and own extensions.
The options are limited.
https://github.com/Combodo/iTop/blob/a61734a6f858d360cd615063fd744645803df66b/datamodels/2.x/itop-portal-base/portal/templates/bricks/manage/layout-table.html.twig#L280 ( snippet from a newer version, but still. )
You could consider overriding it with CSS perhaps.
That link belongs (I think only) to the portal view.
For the backend/console view the "highlights" are set up differently.
I think at least at ./application/cmdbabstract.class.inc.php and in addition in some CSS definition.
Hi,
I've added some cide snippets and got some results but don't understand yet why only the even rows are coloured. On page reload I can see that all rows are coloured for a short time. The odd ones then fade to grey.
./css/light-grey.scss
./application/cmdbabstract.class.inc.php
26:
define('HILIGHT_CLASS_NICO', 'nico');
3333:
In addition I had to find out how to make these changes persistent using an extension. But as workaround it would be okay to do it like that.
Hi Nico, I would simply add a custom CSS and avoid the highlight stuff altogether as newer iTop versions will always override the existing (edited) files.
Yes, that would be the perfect way.
But I still did not find out where is the difference between the odd and even rows.
It wouldn't matter anymore if you add a new CSS rule with ´!important´ in the style specification.
That is working, thanks :-)
Do you have another hint how to add my Class into that
protected static $m_highlightComparison = array
in file cmdbabstract.class.inc.php using an extension?
Thanks again,
Nico
Mind that this is quite some old code. If you're going to edit iTop's own files, you'll need to do so each time you'll upgrade.
Why not inject CSS in another way, avoiding this altogether? Or is it related to your logic/condition?
The CSS code is now injected by the datamodel.
In a seperate extension I created a new theme where this is included now:
But I need do define the new hilight class to select it in the function GetHilightClass.
That is needed to colour only results based on an OQL, e.g. tickets with a specific caller:
Hi,
I found a way to edit the file
application/cmdbabstract.class.inc.php
by running the setup.I am using the function AfterDatabaseCreation within ModuleInstallerAPI:
The CSS code is injected by another extension.
My GetHilightClass function now looks like this:
Now I can add Persons to that team and all tickets in every list having that person as caller are colored as defined in the CSS.
I know I must be aware of the risk changing core files.
Using newer versions always will be tested in lab environment.
Thanks for the support.