mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°3712 - Activity panel: Improve history entries to have a different icon depending the origin (interactive, webservices, csv, ...)
This commit is contained in:
@@ -56,7 +56,10 @@ $ibo-activity-entry--sub-information--margin-top: 4px !default;
|
||||
$ibo-activity-entry--sub-information--margin-bottom: $ibo-activity-entry--sub-information--margin-top !default;
|
||||
$ibo-activity-entry--sub-information--text-color: $ibo-color-grey-700 !default;
|
||||
|
||||
$ibo-activity-entry--author-name--sibling-spacing: 0.2rem !default;
|
||||
$ibo-activity-entry--sub-information--sibling-spacing: 0.5rem !default;
|
||||
$ibo-activity-entry--sub-information-sibling-separator--size: 4px !default;
|
||||
$ibo-activity-entry--sub-information-sibling-separator--border-radius: 100% !default;
|
||||
$ibo-activity-entry--sub-information-sibling-separator--background-color: $ibo-color-grey-600 !default;
|
||||
|
||||
$ibo-activity-panel--load-entries-button--size: 32px !default;
|
||||
$ibo-activity-panel--load-entries-button--border-radius: $ibo-border-radius-full !default;
|
||||
@@ -230,13 +233,17 @@ $ibo-activity-panel--load-all-entries--is-hover--margin-left: ($ibo-activity-pan
|
||||
color: $ibo-activity-entry--sub-information--text-color;
|
||||
|
||||
@extend %ibo-font-size-50;
|
||||
}
|
||||
|
||||
.ibo-activity-entry--author-name {
|
||||
&:after {
|
||||
content: "-";
|
||||
margin-left: $ibo-activity-entry--author-name--sibling-spacing;
|
||||
margin-right: $ibo-activity-entry--author-name--sibling-spacing;
|
||||
> *:not(:last-child):after {
|
||||
content: " ";
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
margin-left: $ibo-activity-entry--sub-information--sibling-spacing;
|
||||
margin-right: $ibo-activity-entry--sub-information--sibling-spacing;
|
||||
width: $ibo-activity-entry--sub-information-sibling-separator--size;
|
||||
height: $ibo-activity-entry--sub-information-sibling-separator--size;
|
||||
border-radius: $ibo-activity-entry--sub-information-sibling-separator--border-radius;
|
||||
background-color: $ibo-activity-entry--sub-information-sibling-separator--background-color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -40,7 +40,6 @@ class ActivityEntry extends UIBlock
|
||||
public const BLOCK_CODE = 'ibo-activity-entry';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/activity-panel/activity-entry/layout';
|
||||
|
||||
// Specific constants
|
||||
/** @var string DEFAULT_ORIGIN */
|
||||
public const DEFAULT_ORIGIN = 'unknown';
|
||||
/** @var string DEFAULT_TYPE */
|
||||
@@ -286,7 +285,7 @@ class ActivityEntry extends UIBlock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function SetOrigin(string $sOrigin)
|
||||
public function SetOrigin(string $sOrigin)
|
||||
{
|
||||
$this->sOrigin = $sOrigin;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
|
||||
|
||||
|
||||
use AttributeDateTime;
|
||||
use CMDBChange;
|
||||
use CMDBChangeOp;
|
||||
use DateTime;
|
||||
use DBObject;
|
||||
@@ -43,11 +44,13 @@ class ActivityEntryFactory
|
||||
* Make an ActivityEntry entry (for ActivityPanel) based on the $oChangeOp.
|
||||
*
|
||||
* @param \CMDBChangeOp $oChangeOp
|
||||
* @param \CMDBChange $oChange
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry
|
||||
* @throws \ReflectionException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function MakeFromCmdbChangeOp(CMDBChangeOp $oChangeOp)
|
||||
public static function MakeFromCmdbChangeOp(CMDBChangeOp $oChangeOp, CMDBChange $oChange)
|
||||
{
|
||||
$sFactoryFqcn = static::GetFactoryClass($oChangeOp, 'CMDBChangeOp');
|
||||
|
||||
@@ -59,6 +62,7 @@ class ActivityEntryFactory
|
||||
/** @var \Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry $oEntry */
|
||||
/** @noinspection PhpUndefinedMethodInspection Call static method from the $sFactoryFqcn class */
|
||||
$oEntry = $sFactoryFqcn::MakeFromCmdbChangeOp($oChangeOp);
|
||||
$oEntry->SetOrigin($oChange->Get('origin'));
|
||||
|
||||
return $oEntry;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
|
||||
|
||||
|
||||
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
|
||||
use DateTime;
|
||||
use Dict;
|
||||
use Exception;
|
||||
@@ -222,4 +223,40 @@ class EditsEntry extends ActivityEntry
|
||||
|
||||
return $sDescriptionAsHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null The CSS decoration classes for the origin of the entry
|
||||
* @see \CMDBChangeOrigin
|
||||
*/
|
||||
public function GetOriginDecorationClasses(): ?string
|
||||
{
|
||||
$sDecorationClasses = null;
|
||||
|
||||
// Note: We put fa-fw on all cases instead of just in the template as one of the cases could (in the future) not use FA icons. This will ensure that any use of the FA icons are always the same width.
|
||||
switch($this->GetOrigin()) {
|
||||
case CMDBChangeOrigin::CSV_INTERACTIVE:
|
||||
case CMDBChangeOrigin::CSV_IMPORT:
|
||||
$sDecorationClasses = 'fas fa-fw fa-file-import';
|
||||
break;
|
||||
|
||||
case CMDBChangeOrigin::EMAIL_PROCESSING:
|
||||
$sDecorationClasses = 'fas fa-fw fa-envelope-open';
|
||||
break;
|
||||
|
||||
case CMDBChangeOrigin::SYNCHRO_DATA_SOURCE:
|
||||
$sDecorationClasses = 'fas fa-fw fa-lock';
|
||||
break;
|
||||
|
||||
case CMDBChangeOrigin::WEBSERVICE_REST:
|
||||
case CMDBChangeOrigin::WEBSERVICE_SOAP:
|
||||
$sDecorationClasses = 'fas fa-fw fa-cloud';
|
||||
break;
|
||||
|
||||
case CMDBChangeOrigin::CUSTOM_EXTENSION:
|
||||
$sDecorationClasses = 'fas fa-fw fa-parachute-box';
|
||||
break;
|
||||
}
|
||||
|
||||
return $sDecorationClasses;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class ActivityPanelHelper
|
||||
|
||||
// - Prepare query to retrieve changes
|
||||
// N°3924: The "CO.objkey > 0" clause is there to avoid retrieving orphan elements from objects that have not been completely created / cleaned. There seem to be a lot of them due to some cron tasks.
|
||||
$oSearch = DBObjectSearch::FromOQL('SELECT CO FROM CMDBChangeOp AS CO WHERE CO.objclass = :obj_class AND CO.objkey = :obj_key AND CO.objkey > 0 AND CO.finalclass NOT IN (:excluded_optypes)');
|
||||
$oSearch = DBObjectSearch::FromOQL('SELECT CO, C FROM CMDBChangeOp AS CO JOIN CMDBChange AS C ON CO.change = C.id WHERE CO.objclass = :obj_class AND CO.objkey = :obj_key AND CO.objkey > 0 AND CO.finalclass NOT IN (:excluded_optypes)');
|
||||
$aArgs = ['obj_class' => $sObjectClass, 'obj_key' => $sObjectId, 'excluded_optypes' => ['CMDBChangeOpSetAttributeCaseLog']];
|
||||
|
||||
// - Optional offset condition
|
||||
@@ -132,7 +132,7 @@ class ActivityPanelHelper
|
||||
|
||||
// Note: We can't order by date (only) as something multiple CMDBChangeOp rows are inserted at the same time (eg. Delivery model of the "Demo" Organization in the sample data).
|
||||
// As the DB returns rows "chronologically", we get the older first and it messes with the processing. Ordering by the ID is way much simpler and less DB CPU consuming.
|
||||
$oSet = new DBObjectSet($oSearch, ['id' => false], $aArgs);
|
||||
$oSet = new DBObjectSet($oSearch, ['CO.id' => false], $aArgs);
|
||||
|
||||
// - Limit history entries to display
|
||||
if ($bLimitResultsLength) {
|
||||
@@ -149,7 +149,10 @@ class ActivityPanelHelper
|
||||
$oPreviousEditsEntry = null;
|
||||
|
||||
/** @var \CMDBChangeOp $oChangeOp */
|
||||
while ($oChangeOp = $oSet->Fetch()) {
|
||||
while ($aElements = $oSet->FetchAssoc()) {
|
||||
$oChange = $aElements['C'] ?? null;
|
||||
$oChangeOp = $aElements['CO'];
|
||||
|
||||
// Skip case log changes as they are handled directly from the attributes themselves (most of them should have been excluded by the OQL above, but some derivated classes could still be retrieved)
|
||||
if ($oChangeOp instanceof CMDBChangeOpSetAttributeCaseLog) {
|
||||
continue;
|
||||
@@ -158,7 +161,7 @@ class ActivityPanelHelper
|
||||
// Make entry from CMDBChangeOp
|
||||
$iChangeId = $oChangeOp->Get('change');
|
||||
try {
|
||||
$oEntry = ActivityEntryFactory::MakeFromCmdbChangeOp($oChangeOp);
|
||||
$oEntry = ActivityEntryFactory::MakeFromCmdbChangeOp($oChangeOp, $oChange);
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
IssueLog::Debug(static::class.': Could not create entry from CMDBChangeOp #'.$oChangeOp->GetKey().' related to '.$oChangeOp->Get('objclass').'::'.$oChangeOp->Get('objkey').': '.$oException->getMessage());
|
||||
|
||||
@@ -19,4 +19,13 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block iboActivityEntrySubInformation %}
|
||||
{% if oUIBlock.GetOrigin() is not null and oUIBlock.GetOrigin != constant('Combodo\\iTop\\Core\\CMDBChange\\CMDBChangeOrigin::INTERACTIVE') %}
|
||||
<span class="ibo-activity-entry--origin" data-role="ibo-activity-entry--origin" data-tooltip-content="{{ ('Class:CMDBChange/Attribute:origin/Value:' ~ oUIBlock.GetOrigin())|dict_s }}">
|
||||
<span class="{{ oUIBlock.GetOriginDecorationClasses() }}"></span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{{ parent() }}
|
||||
{% endblock %}
|
||||
@@ -1,8 +1,10 @@
|
||||
{% spaceless %}
|
||||
<div class="ibo-activity-entry {% if oUIBlock.IsFromCurrentUser() %}ibo-is-current-user{% endif %} {% block iboActivityEntryExtraClasses %}{% endblock %}"
|
||||
data-role="ibo-activity-entry"
|
||||
data-entry-type="{% block iboActivityEntryType %}{{ oUIBlock.GetType() }}{% endblock %}"
|
||||
data-entry-datetime-raw="{{ oUIBlock.GetRawDateTime() }}"
|
||||
data-entry-author-login="{{ oUIBlock.GetAuthorLogin() }}"
|
||||
data-entry-origin="{{ oUIBlock.GetOrigin() }}"
|
||||
{% block iboActivityEntryExtraDataAttributes %}{% endblock %}>
|
||||
<div class="ibo-activity-entry--medallion {% if oUIBlock.GetAuthorPictureAbsUrl() is not empty %}ibo-has-image{% endif %}" data-role="ibo-activity-entry--medallion" data-tooltip-content="{{ oUIBlock.GetAuthorFriendlyname() }}">
|
||||
{% block iboActivityEntryMedallion %}
|
||||
@@ -33,9 +35,7 @@
|
||||
<div class="ibo-activity-entry--sub-information" data-role="ibo-activity-entry--sub-information">
|
||||
{% block iboActivityEntrySubInformation %}
|
||||
{% if get_config_parameter('activity_panel.show_author_name_below_entries') %}
|
||||
<span class="ibo-activity-entry--author-name ibo-is-hidden" data-role="ibo-activity-entry--author-name">
|
||||
{{ oUIBlock.GetAuthorFriendlyname() }}
|
||||
</span>
|
||||
<span class="ibo-activity-entry--author-name ibo-is-hidden" data-role="ibo-activity-entry--author-name">{{ oUIBlock.GetAuthorFriendlyname() }}</span>
|
||||
{% endif %}
|
||||
<span class="ibo-activity-entry--datetime" data-role="ibo-activity-entry--datetime"
|
||||
data-tooltip-content="{{ oUIBlock.GetFormattedDateTime() }}"
|
||||
@@ -45,4 +45,5 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
@@ -3,8 +3,7 @@
|
||||
{# Otherwise when the page is loaded, all the entry groups are displayed for a brief moment, then they are filtered on the options of the currently displayed tab #}
|
||||
<div class="ibo-activity-panel--entry-group {% if oFirstEntry.IsFromCurrentUser() %}ibo-is-current-user{% endif %} ibo-is-hidden"
|
||||
data-role="ibo-activity-panel--entry-group"
|
||||
data-entry-group-author-login="{{ oFirstEntry.GetAuthorLogin() }}"
|
||||
data-entry-group-origin="{{ oFirstEntry.GetOrigin() }}">
|
||||
data-entry-group-author-login="{{ oFirstEntry.GetAuthorLogin() }}">
|
||||
{% for oEntry in aEntryGroup.entries %}
|
||||
{{ render_block(oEntry) }}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user