Skip to content

Commit 9c77ffc

Browse files
Alexander AskinAlexander Askin
authored andcommitted
Initial implementation of Nextcloud iTop integration
- Added complete app structure with proper info.xml and routes - Implemented iTop API service with personal token authentication - Created dashboard widget for assigned tickets - Added unified search provider for tickets and CIs - Implemented reference provider for rich link previews - Added background job for ticket notifications - Created admin and personal settings with templates - Basic styling and icons included Features: - Dashboard widget showing user's assigned tickets - Search integration for tickets and configuration items - Rich previews when sharing iTop links - Notifications for newly assigned tickets - Admin configuration for instance URL - User configuration for personal API tokens
0 parents  commit 9c77ffc

25 files changed

+2118
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
vendor/
2+
.DS_Store
3+
*.log
4+
.idea/
5+
.vscode/
6+
node_modules/
7+
/build/
8+
/js/
9+
/css/*.css
10+
/css/*.css.map
11+
krankerl.toml

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Nextcloud iTop integration
2+
3+
🎫 iTop integration into Nextcloud
4+
5+
This app provides integration between Nextcloud and iTop IT Service Management platform. It allows users to:
6+
7+
- View assigned tickets on the Nextcloud dashboard
8+
- Search for tickets and configuration items from Nextcloud's unified search
9+
- Get notifications for new assigned tickets
10+
- Rich previews of iTop links in Nextcloud apps
11+
12+
## Features
13+
14+
- **Dashboard widget**: Shows your assigned tickets and recent activity
15+
- **Unified search**: Search tickets, incidents, and CIs directly from Nextcloud
16+
- **Notifications**: Get notified when new tickets are assigned to you
17+
- **Rich references**: Share iTop links with rich previews in Talk and other apps
18+
19+
## Configuration
20+
21+
### Admin settings
22+
1. Go to Settings > Administration > Connected accounts
23+
2. Configure your iTop server URL and admin settings
24+
25+
### User settings
26+
1. Go to Settings > Connected accounts
27+
2. Enter your iTop server URL (if not set by admin)
28+
3. Configure your personal API token from iTop
29+
30+
### iTop API Token Setup
31+
1. Log into your iTop instance
32+
2. Go to "My Account" menu
33+
3. Generate a personal API token with appropriate scopes
34+
4. Copy and paste the token into Nextcloud settings
35+
36+
## Requirements
37+
38+
- Nextcloud 30+
39+
- iTop with REST/JSON API enabled
40+
- iTop Authentication by Token extension installed

appinfo/info.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<info>
3+
<id>integration_itop</id>
4+
<name>iTop integration</name>
5+
<summary>Integration of iTop IT Service Management platform</summary>
6+
<description><![CDATA[iTop integration provides a dashboard widget displaying your assigned tickets,
7+
a search provider for tickets and configuration items, and notifications for new assigned tickets.]]></description>
8+
<version>1.0.0</version>
9+
<licence>agpl</licence>
10+
<author>Integration Bot</author>
11+
<namespace>Itop</namespace>
12+
<documentation>
13+
<developer>https://github.com/nextcloud/integration_itop</developer>
14+
</documentation>
15+
<category>integration</category>
16+
<category>dashboard</category>
17+
<website>https://github.com/nextcloud/integration_itop</website>
18+
<bugs>https://github.com/nextcloud/integration_itop/issues</bugs>
19+
<screenshot>https://github.com/nextcloud/integration_itop/raw/main/img/screenshot1.jpg</screenshot>
20+
<dependencies>
21+
<nextcloud min-version="30" max-version="32"/>
22+
</dependencies>
23+
<background-jobs>
24+
<job>OCA\Itop\BackgroundJob\CheckOpenTickets</job>
25+
</background-jobs>
26+
<settings>
27+
<admin>OCA\Itop\Settings\Admin</admin>
28+
<admin-section>OCA\Itop\Settings\AdminSection</admin-section>
29+
<personal>OCA\Itop\Settings\Personal</personal>
30+
<personal-section>OCA\Itop\Settings\PersonalSection</personal-section>
31+
</settings>
32+
</info>

appinfo/routes.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
return [
4+
'routes' => [
5+
// Configuration routes
6+
['name' => 'config#setConfig', 'url' => '/config', 'verb' => 'PUT'],
7+
['name' => 'config#setAdminConfig', 'url' => '/admin-config', 'verb' => 'PUT'],
8+
9+
// API routes
10+
['name' => 'itopAPI#getTickets', 'url' => '/tickets', 'verb' => 'GET'],
11+
['name' => 'itopAPI#getTicket', 'url' => '/tickets/{ticketId}', 'verb' => 'GET'],
12+
['name' => 'itopAPI#getAvatar', 'url' => '/avatar', 'verb' => 'GET'],
13+
['name' => 'itopAPI#getCIs', 'url' => '/cis', 'verb' => 'GET'],
14+
15+
// Search routes
16+
['name' => 'itopAPI#search', 'url' => '/search', 'verb' => 'GET'],
17+
]
18+
];

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "nextcloud/integration_itop",
3+
"description": "iTop integration for Nextcloud",
4+
"type": "project",
5+
"license": "AGPL-3.0+",
6+
"authors": [
7+
{
8+
"name": "Integration Bot"
9+
}
10+
],
11+
"require": {
12+
"php": "^8.0"
13+
},
14+
"autoload": {
15+
"psr-4": {
16+
"OCA\\Itop\\": "lib/"
17+
}
18+
}
19+
}

img/app-dark.svg

Lines changed: 26 additions & 0 deletions
Loading

img/app.svg

Lines changed: 26 additions & 0 deletions
Loading

img/ticket.svg

Lines changed: 7 additions & 0 deletions
Loading

lib/AppInfo/Application.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
/**
4+
* Nextcloud - iTop
5+
*
6+
*
7+
* @author Integration Bot
8+
* @copyright Integration Bot 2025
9+
*/
10+
11+
namespace OCA\Itop\AppInfo;
12+
13+
use Closure;
14+
use OCA\Itop\Dashboard\ItopWidget;
15+
use OCA\Itop\Listener\ItopReferenceListener;
16+
use OCA\Itop\Notification\Notifier;
17+
use OCA\Itop\Reference\ItopReferenceProvider;
18+
use OCA\Itop\Search\ItopSearchProvider;
19+
use OCP\AppFramework\App;
20+
use OCP\AppFramework\Bootstrap\IBootContext;
21+
use OCP\AppFramework\Bootstrap\IBootstrap;
22+
23+
use OCP\AppFramework\Bootstrap\IRegistrationContext;
24+
use OCP\Collaboration\Reference\RenderReferenceEvent;
25+
use OCP\IConfig;
26+
use OCP\IL10N;
27+
use OCP\INavigationManager;
28+
29+
use OCP\IURLGenerator;
30+
use OCP\IUserSession;
31+
use OCP\Notification\IManager as INotificationManager;
32+
33+
class Application extends App implements IBootstrap {
34+
35+
public const APP_ID = 'integration_itop';
36+
private IConfig $config;
37+
38+
public function __construct(array $urlParams = []) {
39+
parent::__construct(self::APP_ID, $urlParams);
40+
41+
$container = $this->getContainer();
42+
$this->config = $container->get(IConfig::class);
43+
44+
$manager = $container->get(INotificationManager::class);
45+
$manager->registerNotifierService(Notifier::class);
46+
}
47+
48+
public function register(IRegistrationContext $context): void {
49+
$context->registerDashboardWidget(ItopWidget::class);
50+
$context->registerSearchProvider(ItopSearchProvider::class);
51+
52+
$context->registerReferenceProvider(ItopReferenceProvider::class);
53+
$context->registerEventListener(RenderReferenceEvent::class, ItopReferenceListener::class);
54+
}
55+
56+
public function boot(IBootContext $context): void {
57+
$context->injectFn(Closure::fromCallable([$this, 'registerNavigation']));
58+
}
59+
60+
public function registerNavigation(IUserSession $userSession): void {
61+
$user = $userSession->getUser();
62+
if ($user !== null) {
63+
$userId = $user->getUID();
64+
$container = $this->getContainer();
65+
66+
if ($this->config->getUserValue($userId, self::APP_ID, 'navigation_enabled', '0') === '1') {
67+
$itopUrl = $this->config->getUserValue($userId, self::APP_ID, 'url', '');
68+
if ($itopUrl !== '') {
69+
$container->get(INavigationManager::class)->add(function () use ($container, $itopUrl) {
70+
$urlGenerator = $container->get(IURLGenerator::class);
71+
$l10n = $container->get(IL10N::class);
72+
return [
73+
'id' => self::APP_ID,
74+
75+
'order' => 10,
76+
77+
// the route that will be shown on startup
78+
'href' => $itopUrl,
79+
80+
// the icon that will be shown in the navigation
81+
// this file needs to exist in img/
82+
'icon' => $urlGenerator->imagePath(self::APP_ID, 'app.svg'),
83+
84+
// the title of your application. This will be used in the
85+
// navigation or on the settings page of your app
86+
'name' => $l10n->t('iTop'),
87+
];
88+
});
89+
}
90+
}
91+
}
92+
}
93+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/**
4+
* Nextcloud - iTop
5+
*
6+
* This file is licensed under the Affero General Public License version 3 or
7+
* later. See the COPYING file.
8+
*
9+
* @author Integration Bot
10+
* @copyright Integration Bot 2025
11+
*/
12+
13+
namespace OCA\Itop\BackgroundJob;
14+
15+
use OCA\Itop\Service\ItopAPIService;
16+
use OCP\BackgroundJob\TimedJob;
17+
use OCP\AppFramework\Utility\ITimeFactory;
18+
19+
use Psr\Log\LoggerInterface;
20+
21+
class CheckOpenTickets extends TimedJob {
22+
23+
public function __construct(
24+
ITimeFactory $time,
25+
private ItopAPIService $itopAPIService,
26+
private LoggerInterface $logger,
27+
) {
28+
parent::__construct($time);
29+
// Check every 15 minutes
30+
$this->setInterval(15 * 60);
31+
}
32+
33+
/**
34+
* @param mixed $argument
35+
*/
36+
protected function run($argument): void {
37+
$this->itopAPIService->checkOpenTickets();
38+
$this->logger->info('iTop open tickets check completed');
39+
}
40+
}

0 commit comments

Comments
 (0)