-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add new dashboard cards and filter #152
base: main
Are you sure you want to change the base?
Conversation
Hi @bessantoy can you fix CI ? |
Hi @stonebuzz i just fixed CI |
|
||
return [ | ||
'number' => $nb_items, | ||
'url' => '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A URL is required for the card to be clickable and open the corresponding search.
To be done on other cards too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a problem with the If I choose a credit in particular, the widgets in the plugin are correctly reloaded, but the ‘native’ GLPI widgets drop to 0, as if the credit criterion had also been assigned to them. |
global $DB; | ||
return $DB->fieldExists($table, self::FIELD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is always applied on all table (because id
field always exist in table)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just updated the FIELD constant to "plugin_credit_types_id" so that the filter only applies to new cards linked to credits
3dde920
use Session; | ||
use Glpi\Dashboard\Provider; | ||
|
||
class PluginCreditDashboardCards extends CommonDBTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when the recursion on the entity is active we must recursively take into account the credits on the sub-entities of the active entity.
I thought about using the function PluginCreditEntity::getAllForEntity(...) but it does not return the credits on the sub-entities.
Entité racine :
So I think that a function like :
/**
* Get all sub entities ID's of an entity
* @param mixed $entityId
* @return array
*/
private static function getSubEntities($entityId): array
{
/** @var \DBmysql $DB */
global $DB;
$subEntities = [];
$fetchSubEntities = function($parentId) use (&$fetchSubEntities, &$subEntities, $DB) {
$query = "SELECT id FROM glpi_entities WHERE entities_id = $parentId";
foreach ($DB->request($query) as $row) {
$subEntities[] = $row['id'];
$fetchSubEntities($row['id']);
}
};
$fetchSubEntities($entityId);
return $subEntities;
}
in dashboardcards.class.php can be useful to retrieve the IDs of the sub-entities and use them in the query.
In addition, I imagine that we must on a sub-entity recursively take into account the credits of the parent entity if on these credits "Child entities" is set to "yes" ? And besides, this is the behavior of the function PluginCreditEntity::getAllForEntity(...)
SubEntity :
* | ||
* @return array | ||
*/ | ||
public static function getCreditsConsumption(array $params = []): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
We would like the Credit plugin to integrate new cards for the dashboards :
In addition, we would like to add a new “credit type” filter to the dashboards which can take effect on the cards mentioned above.
We have already developed a plugin that allows you to add these new cards and this new filter but it would be great if this is directly integrated into the Credit plugin. Please let us know if this is possible.
Anthony from IT Gouvernance.