Skip to content

Commit

Permalink
Improved UI Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ksainc committed Oct 8, 2023
1 parent 319c9b5 commit 70b25f0
Show file tree
Hide file tree
Showing 9 changed files with 647 additions and 59 deletions.
36 changes: 26 additions & 10 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: Sebastian Krupinski <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

/**
* Create your routes in here. The name is the lowercase name of the controller
* without the controller part, the stuff after the hash is the method.
* e.g. page#index -> OCA\Data\Controller\PageController->index()
*
* The controller class has to be registered in the application.php file since
* it's instantiated in there
*/
* @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/>.
*
*/

return [
'routes' => [
[
Expand Down Expand Up @@ -38,6 +49,11 @@
'url' => '/phone/{id}/',
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#listTypes',
'url' => '/list-types',
'verb' => 'GET'
],
[
'name' => 'UserConfiguration#listCollections',
'url' => '/list-collections',
Expand Down
55 changes: 29 additions & 26 deletions js/data-userSettings.js

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

2 changes: 1 addition & 1 deletion js/data-userSettings.js.map

Large diffs are not rendered by default.

47 changes: 45 additions & 2 deletions lib/Controller/UserConfigurationController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: Sebastian Krupinski <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

/**
* @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\Controller;

Expand All @@ -24,6 +44,29 @@ public function __construct(IRequest $request,
$this->DataService = $DataService;
$this->userId = $userId;
}
/**
* handels types list requests
*
* @NoAdminRequired
*
* @return DataResponse
*/
public function listTypes(): DataResponse {

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

}
/**
* handels collections list requests
*
Expand Down
14 changes: 6 additions & 8 deletions lib/Db/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ public function listByUserId(string $uid) : array {

// construct data store command
$cmd = $this->DataStore->getQueryBuilder();
if (empty($uid)) {
$cmd->select('*')
->from($this->DataStoreTable);
}
else {
$cmd->select('*')
->from($this->DataStoreTable)
->where($cmd->expr()->eq('uid', $cmd->createNamedParameter($uid)));
$cmd->select('DS.*', 'CC.displayname AS data_collection_name')
->from($this->DataStoreTable, 'DS')
->leftJoin('DS', 'addressbooks', 'CC', 'DS.data_type = "CC" AND DS.data_collection = CC.id');
// evaluate, if id is present
if (!empty($uid)) {
$cmd->where($cmd->expr()->eq('uid', $cmd->createNamedParameter($uid)));
}
// execute command
$rs = $cmd->executeQuery()->fetchAll();
Expand Down
Loading

0 comments on commit 70b25f0

Please sign in to comment.