diff --git a/appinfo/app.php b/appinfo/app.php
index 15aef135..2abbec0a 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -23,36 +23,4 @@
use OCP\AppFramework\App;
-$app = new App('serverinfo');
-$container = $app->getContainer();
-
-$groupManager = \OC::$server->getGroupManager();
-$user = \OC::$server->getUserSession()->getUser();
-$isAdmin = $user !== null && $groupManager->isAdmin($user->getUID());
-
-
-if ($isAdmin) {
- $container->query('OCP\INavigationManager')->add(function () use ($container) {
- $urlGenerator = $container->query('OCP\IURLGenerator');
- $l10n = $container->query('OCP\IL10N');
- return [
- // the string under which your app will be referenced in owncloud
- 'id' => 'serverinfo',
-
- // sorting weight for the navigation. The higher the number, the higher
- // will it be listed in the navigation
- 'order' => 10,
-
- // the route that will be shown on startup
- 'href' => $urlGenerator->linkToRoute('serverinfo.page.index'),
-
- // the icon that will be shown in the navigation
- // this file needs to exist in img/
- 'icon' => $urlGenerator->imagePath('serverinfo', 'app.svg'),
-
- // the title of your application. This will be used in the
- // navigation or on the settings page of your app
- 'name' => $l10n->t('Server Info'),
- ];
- });
-}
+new App('serverinfo');
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 7c085dc8..93f5735a 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -4,12 +4,16 @@
Server info
Provider useful server information
AGPL
- Bjoern Schiessle
- 1.1.0
+ Bjoern Schiessle, Ivan Sein Santiago
+ 1.1.1
ServerInfo
other
+
+ \OCA\ServerInfo\Settings\AdminSettings
+ \OCA\ServerInfo\Settings\AdminSection
+
diff --git a/appinfo/routes.php b/appinfo/routes.php
index a6db72e8..e1da3185 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -30,7 +30,6 @@
return [
'routes' => [
- ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#update', 'url' => '/update', 'verb' => 'GET'],
],
'ocs' => [
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 439baeaa..336ddf62 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -54,9 +54,6 @@ class PageController extends Controller {
/** @var SessionStatistics */
private $sessionStatistics;
- /** @var IURLGenerator */
- private $urlGenerator;
-
/**
* ApiController constructor.
*
@@ -68,7 +65,6 @@ class PageController extends Controller {
* @param DatabaseStatistics $databaseStatistics
* @param ShareStatistics $shareStatistics
* @param SessionStatistics $sessionStatistics
- * @param IURLGenerator $urlGenerator
*/
public function __construct($appName,
IRequest $request,
@@ -77,8 +73,7 @@ public function __construct($appName,
PhpStatistics $phpStatistics,
DatabaseStatistics $databaseStatistics,
ShareStatistics $shareStatistics,
- SessionStatistics $sessionStatistics,
- IURLGenerator $urlGenerator
+ SessionStatistics $sessionStatistics
) {
parent::__construct($appName, $request);
@@ -88,18 +83,6 @@ public function __construct($appName,
$this->databaseStatistics = $databaseStatistics;
$this->shareStatistics = $shareStatistics;
$this->sessionStatistics = $sessionStatistics;
- $this->urlGenerator = $urlGenerator;
- }
-
- /**
- * Show app page with the server statistics
- * @NoCSRFRequired
- *
- * @return TemplateResponse
- */
- public function index() {
- $params = ['ocs' => $this->urlGenerator->getAbsoluteURL('ocs/v2.php/apps/serverinfo/api/v1/info')];
- return new TemplateResponse('serverinfo', 'main', $params);
}
/**
diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php
new file mode 100644
index 00000000..d7a765e8
--- /dev/null
+++ b/lib/Settings/AdminSection.php
@@ -0,0 +1,68 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+
+namespace OCA\ServerInfo\Settings;
+
+
+use OCP\IL10N;
+use OCP\Settings\ISection;
+
+class AdminSection implements ISection {
+
+ /** @var IL10N */
+ private $l;
+
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ /**
+ * returns the ID of the section. It is supposed to be a lower case string
+ *
+ * @returns string
+ */
+ public function getID() {
+ return 'serverinfo';
+ }
+
+ /**
+ * returns the translated name as it should be displayed, e.g. 'LDAP / AD
+ * integration'. Use the L10N service to translate it.
+ *
+ * @return string
+ */
+ public function getName() {
+ return $this->l->t('Server Info');
+ }
+
+ /**
+ * @return int whether the form should be rather on the top or bottom of
+ * the settings navigation. The sections are arranged in ascending order of
+ * the priority values. It is required to return a value between 0 and 99.
+ *
+ * keep the server setting at the top, right after "server settings"
+ */
+ public function getPriority() {
+ return 0;
+ }
+
+}
diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php
new file mode 100644
index 00000000..3a774a6b
--- /dev/null
+++ b/lib/Settings/AdminSettings.php
@@ -0,0 +1,79 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+
+namespace OCA\ServerInfo\Settings;
+
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\Settings\ISettings;
+
+class AdminSettings implements ISettings {
+
+
+ /** @var IL10N */
+ private $l;
+
+ /** @var IURLGenerator */
+ private $urlGenerator;
+
+ /**
+ * Admin constructor.
+ *
+ * @param IL10N $l
+ * @param IURLGenerator $urlGenerator
+ */
+ public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
+ $this->l = $l;
+ $this->urlGenerator = $urlGenerator;
+ }
+
+ /**
+ * @return TemplateResponse
+ */
+ public function getForm() {
+ $monitoringEndPoint = $this->urlGenerator->getAbsoluteURL('ocs/v2.php/apps/serverinfo/api/v1/info');
+ $params = ['ocs' => $monitoringEndPoint];
+
+ return new TemplateResponse('serverinfo', 'settings-admin', $params);
+ }
+
+ /**
+ * @return string the section ID, e.g. 'sharing'
+ */
+ public function getSection() {
+ return 'serverinfo';
+ }
+
+ /**
+ * @return int whether the form should be rather on the top or bottom of
+ * the admin section. The forms are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
+ *
+ * keep the server setting at the top, right after "server settings"
+ */
+ public function getPriority() {
+ return 0;
+ }
+
+}
diff --git a/templates/main.php b/templates/main.php
deleted file mode 100644
index 3b1d7e54..00000000
--- a/templates/main.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-script('serverinfo', 'script');
-script('serverinfo', 'smoothie');
-script('serverinfo', 'Chart.min');
-
-style('serverinfo', 'style');
-
-?>
-
-
-
- inc('part.navigation')); ?>
-
-
-
-
- inc('part.content')); ?>
-
-
-
diff --git a/templates/part.navigation.php b/templates/part.navigation.php
deleted file mode 100644
index 6b23550d..00000000
--- a/templates/part.navigation.php
+++ /dev/null
@@ -1,9 +0,0 @@
-
\ No newline at end of file
diff --git a/templates/part.content.php b/templates/settings-admin.php
similarity index 65%
rename from templates/part.content.php
rename to templates/settings-admin.php
index d7ce4ad5..1ccb29ba 100644
--- a/templates/part.content.php
+++ b/templates/settings-admin.php
@@ -1,3 +1,32 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+
+script('serverinfo', 'script');
+script('serverinfo', 'smoothie');
+script('serverinfo', 'Chart.min');
+
+style('serverinfo', 'style');
+?>
+
t('CPU load'));?>
@@ -41,6 +70,4 @@
t('External monitoring tool'));?>
t('You can connect a external monitoring tool by using this end point: ') . $_['ocs']);?>
-
-