Skip to content
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

ITC-3388 ServiceCapacityManagementModule #1732

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ plugins/SLAModule
plugins/ChangecalendarModule
plugins/MSTeamsModule
plugins/IsarFlowModule
plugins/ScmModule
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);

use Migrations\AbstractMigration;

/**
* Class UpdateTypeOfObjecttypeIdColumn
*
* Created:
* oitc migrations create UpdateTypeOfObjecttypeIdColumn
*
* Usage:
* openitcockpit-update
*/
class UpdateTypeOfObjecttypeIdColumn extends AbstractMigration {
public function up(): void {
$this->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();
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions src/Controller/ContainersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand Down Expand Up @@ -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'));
}
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
39 changes: 23 additions & 16 deletions src/Lib/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private function defineContainerTypeIds() {
'CT_HOSTGROUP' => 7,
'CT_SERVICEGROUP' => 8,
'CT_SERVICETEMPLATEGROUP' => 9,
'CT_RESOURCEGROUP' => 10
]);
}

Expand Down Expand Up @@ -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
]);
}

Expand Down Expand Up @@ -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' => [
Expand All @@ -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,
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Table/ChangelogsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -217,6 +216,7 @@ public function getChangelogIndex(ChangelogsFilter $ChangelogsFilter, $PaginateO
$query->where([
'Changelogs.module_flag' => $moduleFlag
]);

$query->where($where);
$query->order(
array_merge(
Expand Down
3 changes: 3 additions & 0 deletions src/Model/Table/ContainersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,6 +71,7 @@
* @mixin \Cake\ORM\Behavior\TreeBehavior
*/
class ContainersTable extends Table {
use PluginManagerTableTrait;

/**
* @var null|array
Expand Down Expand Up @@ -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;
}

Expand Down
28 changes: 28 additions & 0 deletions src/Model/Table/UsersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,6 +72,7 @@
class UsersTable extends Table {
use Cake2ResultTableTrait;
use PaginationAndScrollIndexTrait;
use PluginManagerTableTrait;

/**
* Password validation regex.
Expand Down Expand Up @@ -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;
}
}
7 changes: 7 additions & 0 deletions src/Template/Changelogs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
</a>
</li>
<?php endif; ?>
<?php if (Plugin::isLoaded('ScmModule') && $this->Acl->hasPermission('index', 'scmchangelogs', 'ScmModule')): ?>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" ui-sref="ScmChangelogsIndex" role="tab">
<i class="fas fa-people-roof">&nbsp;</i> <?php echo __('Scm Module Changes'); ?>
</a>
</li>
<?php endif; ?>
</ul>
<button class="btn btn-xs btn-default mr-1 shadow-0" ng-click="load()">
<i class="fas fa-sync"></i> <?php echo __('Refresh'); ?>
Expand Down
Loading