diff --git a/.gitignore b/.gitignore index 2f7a57b323..7256d04fad 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ plugins/SLAModule plugins/ChangecalendarModule plugins/MSTeamsModule plugins/IsarFlowModule +plugins/ScmModule diff --git a/config/Migrations/20241017080049_UpdateTypeOfObjecttypeIdColumn.php b/config/Migrations/20241017080049_UpdateTypeOfObjecttypeIdColumn.php new file mode 100644 index 0000000000..a23babebc3 --- /dev/null +++ b/config/Migrations/20241017080049_UpdateTypeOfObjecttypeIdColumn.php @@ -0,0 +1,61 @@ +table('changelogs') + ->changeColumn('objecttype_id', 'biginteger', [ + 'limit' => 20, + 'signed' => false + ]) + ->update(); + + $this->table('customvariables') + ->changeColumn('objecttype_id', 'biginteger', [ + 'limit' => 20, + 'signed' => false + ]) + ->update(); + + $this->table('systemdowntimes') + ->changeColumn('objecttype_id', 'biginteger', [ + 'limit' => 20, + 'signed' => false + ]) + ->update(); + } + + public function down(): void { + $this->table('changelogs') + ->changeColumn('objecttype_id', 'integer', [ + 'limit' => 11, + 'signed' => false + ]) + ->update(); + + $this->table('customvariables') + ->changeColumn('objecttype_id', 'integer', [ + 'limit' => 11, + 'signed' => false + ]) + ->update(); + + $this->table('systemdowntimes') + ->changeColumn('objecttype_id', 'integer', [ + 'limit' => 11, + 'signed' => false + ]) + ->update(); + } +} diff --git a/package.json b/package.json index 083210f084..98c59b8268 100755 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "rangyinputs": "^1.2.0", "raphael": "^2.3.0", "spectrum-colorpicker2": "^2.0.4", + "sunburst-chart": "^1.20.2", "timsort": "^0.3.0", "tsparticles": "^1.18.0", "underscore": "^1.11.0", diff --git a/src/Controller/ContainersController.php b/src/Controller/ContainersController.php index b07475556f..a8afb14400 100644 --- a/src/Controller/ContainersController.php +++ b/src/Controller/ContainersController.php @@ -47,6 +47,7 @@ use DistributeModule\Model\Table\SatellitesTable; use itnovum\openITCOCKPIT\Core\AngularJS\Api; use itnovum\openITCOCKPIT\Core\ValueObjects\User; +use ScmModule\Model\Table\ResourcegroupsTable; /** @@ -235,6 +236,11 @@ public function loadContainersByContainerId($id = null) { /** @var $ServicetemplategroupsTable ServicetemplategroupsTable */ $ServicetemplategroupsTable = TableRegistry::getTableLocator()->get('Servicetemplategroups'); + if (Plugin::isLoaded('ScmModule')) { + /** @var $ResourcegroupsTable ResourcegroupsTable */ + $ResourcegroupsTable = TableRegistry::getTableLocator()->get('ScmModule.Resourcegroups'); + } + if (!$ContainersTable->existsById($id)) { throw new NotFoundException(__('Container not found')); } @@ -312,6 +318,17 @@ public function loadContainersByContainerId($id = null) { $containers[$key]['servicetemplates'] = sizeof($serviceTemplateGroup['servicetemplates']); } break; + //ScmModule + case CT_RESOURCEGROUP: + if (Plugin::isLoaded('ScmModule')) { + $resourceGroup = $ResourcegroupsTable->getResourcegroupByContainerId($container['id']); + if (!empty($resourceGroup)) { + $containers[$key]['linkedId'] = $resourceGroup['id']; + $containers[$key]['resources'] = sizeof($resourceGroup['resources']); + $containers[$key]['users'] = sizeof($resourceGroup['users']); + } + } + break; } } } diff --git a/src/Lib/Constants.php b/src/Lib/Constants.php index e56607de63..a82182d8b1 100644 --- a/src/Lib/Constants.php +++ b/src/Lib/Constants.php @@ -109,6 +109,7 @@ private function defineContainerTypeIds() { 'CT_HOSTGROUP' => 7, 'CT_SERVICEGROUP' => 8, 'CT_SERVICETEMPLATEGROUP' => 9, + 'CT_RESOURCEGROUP' => 10 ]); } @@ -142,17 +143,18 @@ private function defineObjects() { 'OBJECT_SERVICEESCALATION' => 1 << 18, 'OBJECT_HOSTDEPENDENCY' => 1 << 19, 'OBJECT_SERVICEDEPENDENCY' => 1 << 20, - 'OBJECT_EXPORT' => 1 << 21, // Changelog only - 'OBJECT_HOSTDEFAULT' => 1 << 22, // Changelog only - 'OBJECT_IMPORTER' => 1 << 23, // Changelog only - 'OBJECT_IMPORTEDHOST' => 1 << 24, // Changelog only - 'OBJECT_EXTERNALSYSTEM' => 1 << 25, // Changelog only - 'OBJECT_EXTERNALMONITORING' => 1 << 26, // Changelog only - 'OBJECT_STARTIMPORTDATA' => 1 << 27, // Changelog only - 'OBJECT_SYNCHRONIZEWITHMONITORING' => 1 << 28, // Changelog only - 'OBJECT_AGENTCHECK' => 1 << 29, // Changelog only - 'OBJECT_IMPORTEDHOSTGROUP' => 1 << 30 // Changelog only - + 'OBJECT_EXPORT' => 1 << 21, // Changelog only ImportModule + 'OBJECT_HOSTDEFAULT' => 1 << 22, // Changelog only ImportModule + 'OBJECT_IMPORTER' => 1 << 23, // Changelog only ImportModule + 'OBJECT_IMPORTEDHOST' => 1 << 24, // Changelog only ImportModule + 'OBJECT_EXTERNALSYSTEM' => 1 << 25, // Changelog only ImportModule + 'OBJECT_EXTERNALMONITORING' => 1 << 26, // Changelog only ImportModule + 'OBJECT_STARTIMPORTDATA' => 1 << 27, // Changelog only ImportModule + 'OBJECT_SYNCHRONIZEWITHMONITORING' => 1 << 28, // Changelog only ImportModule + 'OBJECT_AGENTCHECK' => 1 << 29, // Changelog only ImportModule + 'OBJECT_IMPORTEDHOSTGROUP' => 1 << 30, // Changelog only ImportModule + 'OBJECT_RESOURCE' => 1 << 31, // ScmModule + 'OBJECT_RESOURCEGROUP' => 1 << 32, // ScmModule ]); } @@ -202,26 +204,27 @@ public function getModuleConstants() { 'AUTOREPORT_MODULE' => 1 << 0, 'EVENTCORRELATION_MODULE' => 1 << 1, 'IMPORT_MODULE' => 1 << 2, - 'SLA_MODULE' => 1 << 3 + 'SLA_MODULE' => 1 << 3, + 'SCM_MODULE' => 1 << 4 ]; } private function attachContainerpropertiesToContainers() { $this->containersWithProperties = [ "GLOBAL_CONTAINER" => [ - 'properties' => OBJECT_TENANT ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTTEMPLATE ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_SERVICETEMPLATEGROUP ^ OBJECT_HOSTESCALATION ^ OBJECT_SERVICEESCALATION ^ OBJECT_HOSTDEPENDENCY ^ OBJECT_SERVICEDEPENDENCY, + 'properties' => OBJECT_TENANT ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTTEMPLATE ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_SERVICETEMPLATEGROUP ^ OBJECT_HOSTESCALATION ^ OBJECT_SERVICEESCALATION ^ OBJECT_HOSTDEPENDENCY ^ OBJECT_SERVICEDEPENDENCY ^ OBJECT_RESOURCEGROUP, 'container_type' => CT_GLOBAL, ], "TENANT_CONTAINER" => [ - 'properties' => OBJECT_LOCATION ^ OBJECT_NODE ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTTEMPLATE ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_SERVICETEMPLATEGROUP ^ OBJECT_HOSTESCALATION ^ OBJECT_SERVICEESCALATION ^ OBJECT_HOSTDEPENDENCY ^ OBJECT_SERVICEDEPENDENCY, + 'properties' => OBJECT_LOCATION ^ OBJECT_NODE ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTTEMPLATE ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_SERVICETEMPLATEGROUP ^ OBJECT_HOSTESCALATION ^ OBJECT_SERVICEESCALATION ^ OBJECT_HOSTDEPENDENCY ^ OBJECT_SERVICEDEPENDENCY ^ OBJECT_RESOURCEGROUP, 'container_type' => CT_TENANT, ], "LOCATION_CONTAINER" => [ - 'properties' => OBJECT_LOCATION ^ OBJECT_NODE ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_HOSTTEMPLATE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICETEMPLATEGROUP, + 'properties' => OBJECT_LOCATION ^ OBJECT_NODE ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_HOSTTEMPLATE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICETEMPLATEGROUP ^ OBJECT_RESOURCEGROUP, 'container_type' => CT_LOCATION, ], "NODE_CONTAINER" => [ - 'properties' => OBJECT_LOCATION ^ OBJECT_NODE ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_HOSTTEMPLATE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICETEMPLATEGROUP, + 'properties' => OBJECT_LOCATION ^ OBJECT_NODE ^ OBJECT_USER ^ OBJECT_CONTACT ^ OBJECT_CONTACTGROUP ^ OBJECT_TIMEPERIOD ^ OBJECT_HOST ^ OBJECT_HOSTGROUP ^ OBJECT_SERVICEGROUP ^ OBJECT_SATELLITE ^ OBJECT_HOSTTEMPLATE ^ OBJECT_SERVICETEMPLATE ^ OBJECT_SERVICETEMPLATEGROUP ^ OBJECT_RESOURCEGROUP, 'container_type' => CT_NODE, ], 'CONTACTGROUP_CONTAINER' => [ @@ -240,6 +243,10 @@ private function attachContainerpropertiesToContainers() { 'properties' => OBJECT_SERVICETEMPLATE, 'container_type' => CT_SERVICETEMPLATEGROUP, ], + 'RESOURCEGROUP_CONTAINER' => [ + 'properties' => OBJECT_USER ^ OBJECT_RESOURCE, + 'container_type' => CT_RESOURCEGROUP, + ], ]; } diff --git a/src/Model/Table/ChangelogsTable.php b/src/Model/Table/ChangelogsTable.php index 44e7104c26..75e0d23745 100644 --- a/src/Model/Table/ChangelogsTable.php +++ b/src/Model/Table/ChangelogsTable.php @@ -179,7 +179,6 @@ public function getChangelogIndex(ChangelogsFilter $ChangelogsFilter, $PaginateO if (!empty($MY_RIGHTS)) { $where['Containers.id IN'] = $MY_RIGHTS; } - $where['Changelogs.created >='] = date('Y-m-d H:i:s', $ChangelogsFilter->getFrom()); $where['Changelogs.created <='] = date('Y-m-d H:i:s', $ChangelogsFilter->getTo()); @@ -217,6 +216,7 @@ public function getChangelogIndex(ChangelogsFilter $ChangelogsFilter, $PaginateO $query->where([ 'Changelogs.module_flag' => $moduleFlag ]); + $query->where($where); $query->order( array_merge( diff --git a/src/Model/Table/ContainersTable.php b/src/Model/Table/ContainersTable.php index 3bfc8f0fbc..1fb8fac198 100644 --- a/src/Model/Table/ContainersTable.php +++ b/src/Model/Table/ContainersTable.php @@ -2,6 +2,7 @@ namespace App\Model\Table; +use App\Lib\Traits\PluginManagerTableTrait; use AutoreportModule\Model\Table\AutoreportsTable; use Cake\Cache\Cache; use Cake\Core\Plugin; @@ -70,6 +71,7 @@ * @mixin \Cake\ORM\Behavior\TreeBehavior */ class ContainersTable extends Table { + use PluginManagerTableTrait; /** * @var null|array @@ -1165,6 +1167,7 @@ public function allowDelete($id, int $containertype_id): bool { case CT_HOSTGROUP: case CT_SERVICEGROUP: case CT_SERVICETEMPLATEGROUP: + case CT_RESOURCEGROUP: return true; } diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php index bd8ea1d340..1194132aca 100644 --- a/src/Model/Table/UsersTable.php +++ b/src/Model/Table/UsersTable.php @@ -32,6 +32,7 @@ use App\Lib\Traits\Cake2ResultTableTrait; use App\Lib\Traits\PaginationAndScrollIndexTrait; +use App\Lib\Traits\PluginManagerTableTrait; use App\Model\Entity\Changelog; use App\Model\Entity\User; use Authentication\PasswordHasher\DefaultPasswordHasher; @@ -71,6 +72,7 @@ class UsersTable extends Table { use Cake2ResultTableTrait; use PaginationAndScrollIndexTrait; + use PluginManagerTableTrait; /** * Password validation regex. @@ -1891,4 +1893,30 @@ public function getContainerIdsOfUserContainerRoles(array $user): array { } + public function getUsersAsList($ids = []) { + if (empty($ids)) { + return []; + } + if (!is_array($ids)) { + $ids = [$ids]; + } + $query = $this->find() + ->select([ + 'Users.id', + 'Users.lastname', + 'Users.firstname' + ]); + if (!empty($ids)) { + $query->where([ + 'Users.id IN' => $ids + ]); + } + $query->disableHydration() + ->all(); + + foreach ($query->toArray() as $user) { + $return[$user['id']] = $user['lastname'] . ', ' . $user['firstname']; + } + return $return; + } } diff --git a/src/Template/Changelogs/index.php b/src/Template/Changelogs/index.php index 6ba49fd2d0..c90bddac0e 100755 --- a/src/Template/Changelogs/index.php +++ b/src/Template/Changelogs/index.php @@ -76,6 +76,13 @@ + Acl->hasPermission('index', 'scmchangelogs', 'ScmModule')): ?> +