Skip to content

Commit

Permalink
Implemented Basic Admin UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ksainc committed Oct 9, 2023
1 parent 70b25f0 commit 061c47c
Show file tree
Hide file tree
Showing 22 changed files with 62,812 additions and 133 deletions.
2 changes: 2 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<nextcloud min-version="26" max-version="28"/>
</dependencies>
<settings>
<admin>OCA\Data\Settings\AdminSettings</admin>
<admin-section>OCA\Data\Settings\AdminSection</admin-section>
<personal>OCA\Data\Settings\UserSettings</personal>
<personal-section>OCA\Data\Settings\UserSection</personal-section>
</settings>
Expand Down
19 changes: 12 additions & 7 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,42 @@
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#listTypes',
'name' => 'Settings#listUsers',
'url' => '/list-users',
'verb' => 'GET'
],
[
'name' => 'Settings#listTypes',
'url' => '/list-types',
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#listCollections',
'name' => 'Settings#listCollections',
'url' => '/list-collections',
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#listFormats',
'name' => 'Settings#listFormats',
'url' => '/list-formats',
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#listServices',
'name' => 'Settings#listServices',
'url' => '/list-services',
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#createService',
'name' => 'Settings#createService',
'url' => '/create-service',
'verb' => 'PUT'
],
[
'name' => 'UserConfiguration#modifyService',
'name' => 'Settings#modifyService',
'url' => '/modify-service',
'verb' => 'PUT'
],
[
'name' => 'UserConfiguration#deleteService',
'name' => 'Settings#deleteService',
'url' => '/delete-service',
'verb' => 'PUT'
],
Expand Down
61,874 changes: 61,874 additions & 0 deletions js/data-AdminSettings.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/data-AdminSettings.js.map

Large diffs are not rendered by default.

18 changes: 7 additions & 11 deletions js/data-userSettings.js → js/data-UserSettings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/data-UserSettings.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion js/data-userSettings.js.map

This file was deleted.

80 changes: 0 additions & 80 deletions lib/Controller/DataApiController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use OCA\Data\AppInfo\Application;
use OCA\Data\Service\DataService;

class UserConfigurationController extends Controller {
class SettingsController extends Controller {
private DataService $DataService;

use Errors;
Expand All @@ -44,6 +44,27 @@ public function __construct(IRequest $request,
$this->DataService = $DataService;
$this->userId = $userId;
}
/**
* handels user list requests
*
* @return DataResponse
*/
public function listUsers(): DataResponse {

// evaluate if user id is present
if ($this->userId === null) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
// retrieve formats
$rs = $this->DataService->listUsers();
// return response
if (isset($rs)) {
return new DataResponse($rs);
} else {
return new DataResponse($rs['error'], 401);
}

}
/**
* handels types list requests
*
Expand Down
67 changes: 67 additions & 0 deletions lib/Db/UsersUtile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
//declare(strict_types=1);

/**
* @copyright Copyright (c) 2023 Sebastian Krupinski <[email protected]>
*
* @author Sebastian Krupinski <[email protected]>
*
* @license AGPL-3.0-or-later
*
* 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 <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Data\Db;

use OCP\AppFramework\Db\DoesNotExistException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;

class UsersUtile {

private IDBConnection $DataStore;
private string $DataStoreTable = 'users';

public function __construct(IDBConnection $db) {
$this->DataStore = $db;
}

/**
* retrieve all users from data store
*
* @since Release 1.0.0
*
* @return array of data fields
*/
public function listUsers(): array {

// construct database command
$dc = $this->DataStore->getQueryBuilder();
$dc->select('uid AS id', 'displayname AS label')
->from($this->DataStoreTable);
// execute command
$rs = $dc->executeQuery()->fetchAll();
$dc->executeQuery()->closeCursor();
// return result or null
if (is_array($rs) && count($rs) > 0) {
return $rs;
}
else {
return [];
}

}

}
18 changes: 18 additions & 0 deletions lib/Service/DataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ public function __construct(ConfigurationService $ConfigurationService, Services
$this->ContactsService = $ContactsService;
}

/**
* retrieve users
*
* @since Release 1.0.0
*
* @return array of users
*/
public function listUsers(): array {

// load helper
$UserUtile = \OC::$server->get(\OCA\Data\Db\UsersUtile::class);
// retrieve users
$users = $UserUtile->listUsers();
// return data
return $users;

}

/**
* retrieve types for specific user
*
Expand Down
Loading

0 comments on commit 061c47c

Please sign in to comment.