Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@
<provider>OCA\Deck\Activity\DeckProvider</provider>
</providers>
</activity>

<fulltextsearch>
<provider min-version="16">OCA\Deck\Provider\DeckProvider</provider>
</fulltextsearch>

<navigations>
<navigation>
<name>Deck</name>
Expand All @@ -77,5 +75,9 @@
<order>10</order>
</navigation>
</navigations>

<sabre>
<calendar-plugins>
<plugin>OCA\Deck\DAV\CalendarPlugin</plugin>
</calendar-plugins>
</sabre>
</info>
9 changes: 3 additions & 6 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],

['name' => 'Config#get', 'url' => '/config', 'verb' => 'GET'],
['name' => 'Config#setValue', 'url' => '/config/{key}', 'verb' => 'POST'],

// boards
['name' => 'board#index', 'url' => '/boards', 'verb' => 'GET'],
['name' => 'board#create', 'url' => '/boards', 'verb' => 'POST'],
Expand Down Expand Up @@ -125,17 +122,17 @@
['name' => 'attachment_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'DELETE'],
['name' => 'attachment_api#restore', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}/restore', 'verb' => 'PUT'],



['name' => 'board_api#preflighted_cors', 'url' => '/api/v1.0/{path}','verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
],
'ocs' => [
['name' => 'Config#get', 'url' => '/api/v1.0/config', 'verb' => 'GET'],
['name' => 'Config#setValue', 'url' => '/api/v1.0/config/{key}', 'verb' => 'POST'],

['name' => 'comments_api#list', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'GET'],
['name' => 'comments_api#create', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'POST'],
['name' => 'comments_api#update', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'],
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],

// dashboard
['name' => 'overview_api#upcomingCards', 'url' => '/api/v1.0/overview/upcoming', 'verb' => 'GET'],
]
];
72 changes: 12 additions & 60 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,90 +23,42 @@

namespace OCA\Deck\Controller;

use OCA\Deck\Service\ConfigService;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\AppFramework\Controller;

class ConfigController extends Controller {
private $config;
private $userId;
private $groupManager;
class ConfigController extends OCSController {
private $configService;

public function __construct(
$AppName,
IRequest $request,
IConfig $config,
IGroupManager $groupManager,
$userId
ConfigService $configService
) {
parent::__construct($AppName, $request);

$this->userId = $userId;
$this->groupManager = $groupManager;
$this->config = $config;
$this->configService = $configService;
}

/**
* @NoCSRFRequired
* @NoAdminRequired
*/
public function get() {
$data = [
'groupLimit' => $this->getGroupLimit(),
];
return new DataResponse($data);
public function get(): DataResponse {
return new DataResponse($this->configService->getAll());
}

/**
* @NoCSRFRequired
* @NoAdminRequired
*/
public function setValue($key, $value) {
switch ($key) {
case 'groupLimit':
$result = $this->setGroupLimit($value);
break;
}
public function setValue(string $key, $value) {
$result = $this->configService->set($key, $value);
if ($result === null) {
return new NotFoundResponse();
}
return new DataResponse($result);
}

private function setGroupLimit($value) {
$groups = [];
foreach ($value as $group) {
$groups[] = $group['id'];
}
$data = implode(',', $groups);
$this->config->setAppValue($this->appName, 'groupLimit', $data);
return $groups;
}

private function getGroupLimitList() {
$value = $this->config->getAppValue($this->appName, 'groupLimit', '');
$groups = explode(',', $value);
if ($value === '') {
return [];
}
return $groups;
}

private function getGroupLimit() {
$groups = $this->getGroupLimitList();
$groups = array_map(function ($groupId) {
/** @var IGroup $groups */
$group = $this->groupManager->get($groupId);
if ($group === null) {
return null;
}
return [
'id' => $group->getGID(),
'displayname' => $group->getDisplayName(),
];
}, $groups);
return array_filter($groups);
}
}
10 changes: 5 additions & 5 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,33 @@
namespace OCA\Deck\Controller;

use OCA\Deck\AppInfo\Application;
use OCA\Deck\Service\ConfigService;
use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\IInitialStateService;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Controller;
use OCP\IL10N;

class PageController extends Controller {
private $permissionService;
private $userId;
private $l10n;
private $initialState;
private $configService;

public function __construct(
$AppName,
IRequest $request,
PermissionService $permissionService,
IInitialStateService $initialStateService,
IL10N $l10n,
$userId
ConfigService $configService
) {
parent::__construct($AppName, $request);

$this->userId = $userId;
$this->permissionService = $permissionService;
$this->initialState = $initialStateService;
$this->l10n = $l10n;
$this->configService = $configService;
}

/**
Expand All @@ -64,6 +63,7 @@ public function __construct(
public function index() {
$this->initialState->provideInitialState(Application::APP_ID, 'maxUploadSize', (int)\OCP\Util::uploadLimit());
$this->initialState->provideInitialState(Application::APP_ID, 'canCreate', $this->permissionService->canCreate());
$this->initialState->provideInitialState(Application::APP_ID, 'config', $this->configService->getAll());

$response = new TemplateResponse('deck', 'main');

Expand Down
Loading