From e6e87d1571062b54fb72ef34a0beeadb39a54293 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Thu, 20 Oct 2022 18:27:04 +0100 Subject: [PATCH] :sparkles: Dashboard v0.1 - continuous dev. Commit dashboard v0.1 --- plugins/addons/dashboard/class_dashboard.inc | 4 +- plugins/addons/tasks/class_tasksGranular.inc | 98 ++++++++++++++++++++ plugins/admin/tasks/class_tasksDashboard.inc | 81 ++++++++++++++++ 3 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 plugins/addons/tasks/class_tasksGranular.inc create mode 100644 plugins/admin/tasks/class_tasksDashboard.inc diff --git a/plugins/addons/dashboard/class_dashboard.inc b/plugins/addons/dashboard/class_dashboard.inc index 7de55de5f..0b958b9c4 100644 --- a/plugins/addons/dashboard/class_dashboard.inc +++ b/plugins/addons/dashboard/class_dashboard.inc @@ -35,8 +35,8 @@ class dashboard extends simplePlugin 'mainAttr' => FALSE ] ], - 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 30]], - 'plPriority' => 0, + 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 40]], + 'plPriority' => 10, 'plProvidedAcls' => [ 'dashboard' => _('See dashboard') diff --git a/plugins/addons/tasks/class_tasksGranular.inc b/plugins/addons/tasks/class_tasksGranular.inc new file mode 100644 index 000000000..d7b3b0924 --- /dev/null +++ b/plugins/addons/tasks/class_tasksGranular.inc @@ -0,0 +1,98 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + + Copyright (C) 2012-2022 FusionDirectory + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +class tasksGranular extends tasks +{ + + static function plInfo (): array + { + return [ + 'plShortName' => _('Tasks Granular'), + 'plDescription' => _('Granular tasks mangement allowing details reports'), + 'plObjectClass' => ['fdTasks'], + 'plFilter' => '(objectClass=fdTasks)', + 'plPriority' => 41, + 'plObjectType' => ['tasksGranular' => [ + 'name' => _('Tasks'), + 'ou' => get_ou('tasksRDN'), + 'icon' => 'geticon.php?context=applications&icon=dsa&size=16', + ]], + 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) + ]; + } + + static function getAttributesInfo (): array + { + return [ + // Attributes are grouped by section + 'tasks' => [ + 'name' => _('List of sub tasks'), + 'attrs' => [ + new StringAttribute( + _('Task Name'), _('Name for this task'), + 'cn', TRUE + ), + new DateTimeAttribute( + _('Schedule'), '', + 'fdTasksScheduleDate', FALSE + ), + new HiddenAttribute('fdTasksStatus', TRUE, '1', '', 'Status', 'Status of the task'), + new HiddenAttribute('fdTasksCreationDate', TRUE, date("Y-m-d h:i:sa"), '', 'StartDate', 'Start Date And Time Of A Task'), + new SetAttribute( + new CompositeAttribute( + _('Macro definitions'), + 'fdSubTasks', + [ + new SelectAttribute( + '', _('Macro type'), + 'fdSubTasks', TRUE + ), + new StringAttribute( + _('Macros User Definition'), _('Macro that will be used'), + 'fdSubTasks', TRUE, '' + ), + ], + '/^{(.+)}(.*)$/', + '{%s}%s', + '', + _('To be defined properly') + ) + ), + ] + ], + ]; + } + + function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) + { + global $config; + parent::__construct($dn, $object, $parent, $mainTab); + + // As this class inherit from tasks, attributes must not be seen or be modifiable + $this->attributesAccess['cn']->setVisible(FALSE); + $this->attributesAccess['fdTasksScheduleDate']->setVisible(FALSE); + $this->read_only = TRUE; + + } + + + +} diff --git a/plugins/admin/tasks/class_tasksDashboard.inc b/plugins/admin/tasks/class_tasksDashboard.inc new file mode 100644 index 000000000..ffa78bae8 --- /dev/null +++ b/plugins/admin/tasks/class_tasksDashboard.inc @@ -0,0 +1,81 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2011-2022 FusionDirectory + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +class tasksDashboard extends tasksManagement +{ + + // Actions collumn are removed compared to parent + public static $columns = [ + ['LinkColumn', ['attributes' => 'cn', 'label' => 'Tasks']], + //below fdTasksMailObject must be change to have a type defined within task creation (new ldap attributes ?hidden) + ['TasksColumn', ['attributes' => 'fdTasksMailObject', 'label' => 'Types']], + ['TasksColumn', ['attributes' => 'fdTasksScheduleDate', 'label' => 'Schedule']], + //below fdTasksStatus attribute needs to be calculated based on the type of the task. + ['TasksColumn', ['attributes' => 'fdTasksStatus', 'label' => 'Status']], + ['Column', ['attributes' => 'fdTasksCreationDate', 'label' => 'Creation Date']] + ]; + + // No modification tools are required + protected $skipCpHandler = TRUE; + public static $skipSnapshots = TRUE; + public static $skipTemplates = TRUE; + protected $skipConfiguration = TRUE; + + static function plInfo () + { + return [ + 'plShortName' => _('Tasks Dashboard'), + 'plDescription' => _('Provide a reporting mechanism for tasks'), + 'plTitle' => _('Tasks Dashboard'), + 'plIcon' => 'geticon.php?context=applications&icon=argonaut&size=48', + 'plSection' => ['reporting' => ['name' => _('Reporting'), 'priority' => 40]], + 'plPriority' => 10, + 'plManages' => ['tasksGranular'], + 'plProvidedAcls' => [], + ]; + } + + protected function setUpFilter (array $filterElementDefinitions) + { + $this->filter = new tasksDashboardFilter($this, NULL, $filterElementDefinitions); + } + + // Allowing us to add additional actions and remove unrequired ones + protected function configureActions () + { + $this->registerAction( + new Action( + 'edit', _('See Details'), 'geticon.php?context=actions&icon=document-edit&size=16', + '+', 'editEntry' + ) + ); + } + // End of Class +} + +// extending the class allows us to remove the rendering of filter. +class tasksDashboardFilter extends managementFilter +{ + function render () : string + { + // must respect the string return from parent + return ''; + } +} -- GitLab