diff --git a/Makefile.release b/Makefile.release index 3d261e9775e..8c46083ebf5 100644 --- a/Makefile.release +++ b/Makefile.release @@ -68,6 +68,7 @@ endif .PHONY: ocx-app-config ocx-app-config: cp -R packages/web-integration-oc10/appinfo $(dist_dir) + cp -R packages/web-integration-oc10/js $(dist_dir) cp -R packages/web-integration-oc10/lib $(dist_dir) .PHONY: ocx-app-bundle diff --git a/packages/web-integration-oc10/appinfo/app.php b/packages/web-integration-oc10/appinfo/app.php index 621ca0cb365..84805914f20 100644 --- a/packages/web-integration-oc10/appinfo/app.php +++ b/packages/web-integration-oc10/appinfo/app.php @@ -20,3 +20,4 @@ */ $app = new OCA\Web\Application(); +$app->boot(); diff --git a/packages/web-integration-oc10/appinfo/routes.php b/packages/web-integration-oc10/appinfo/routes.php index b64b62ae9f0..ab73a0eb59b 100644 --- a/packages/web-integration-oc10/appinfo/routes.php +++ b/packages/web-integration-oc10/appinfo/routes.php @@ -28,6 +28,7 @@ 'routes' => [ ['name' => 'Index#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'Config#getConfig', 'url' => '/config.json', 'verb' => 'GET'], + ['name' => 'Settings#setWebDefaultConfig', 'url' => '/settings/default', 'verb' => 'POST'], [ 'name' => 'Files#getFile', 'url' => '/{path}', diff --git a/packages/web-integration-oc10/js/app.js b/packages/web-integration-oc10/js/app.js new file mode 100644 index 00000000000..88c1168f994 --- /dev/null +++ b/packages/web-integration-oc10/js/app.js @@ -0,0 +1,7 @@ +$(document).ready(function () { + $('#apps') + .find('li[data-id=web]') + .click(function () { + $.post(OC.generateUrl('/apps/web/settings/default'), { isDefault: true }) + }) +}) diff --git a/packages/web-integration-oc10/lib/Application.php b/packages/web-integration-oc10/lib/Application.php index cbbb7197a71..ee0e95080ee 100644 --- a/packages/web-integration-oc10/lib/Application.php +++ b/packages/web-integration-oc10/lib/Application.php @@ -22,6 +22,7 @@ namespace OCA\Web; use OCP\AppFramework\App; +use OCP\Util; class Application extends App { @@ -33,4 +34,8 @@ class Application extends App { public function __construct(array $urlParams = []) { parent::__construct(Application::APPID, $urlParams); } + + public function boot(): void { + Util::addscript(Application::APPID, 'app'); + } } diff --git a/packages/web-integration-oc10/lib/Controller/SettingsController.php b/packages/web-integration-oc10/lib/Controller/SettingsController.php new file mode 100644 index 00000000000..3fa53a18954 --- /dev/null +++ b/packages/web-integration-oc10/lib/Controller/SettingsController.php @@ -0,0 +1,84 @@ + + * @author Jan Ackermann + * + * @copyright Copyright (c) 2021, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\Web\Controller; + +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; +use OCP\IConfig; +use OCP\IRequest; +use OCP\IUserSession; + +/** + * Class SettingsController + * + * @package OCA\Web\Controller + */ +class SettingsController extends Controller { + + /** + * @var IConfig + */ + private $config; + + /** + * @var IUserSession + */ + private $userSession; + + /** + * @param string $appName + * @param IRequest $request an instance of the request + * @param IUserSession $userSession + * @param IConfig $config + */ + public function __construct( + $appName, + IRequest $request, + IUserSession $userSession, + IConfig $config + ) { + parent::__construct($appName, $request); + $this->config = $config; + $this->userSession = $userSession; + } + + /** + * Set the web default config. + * + * @NoAdminRequired + * + * @return JSONResponse + */ + public function setWebDefaultConfig() { + $value = \filter_var($this->request->getParam('isDefault'), FILTER_VALIDATE_BOOLEAN); + $user = $this->userSession->getUser(); + $configToSet = $value === true ? 'web' : null; + if (!$configToSet) { + $this->config->deleteUserValue($user->getUID(), 'core', 'defaultapp'); + } else { + $this->config->setUserValue($user->getUID(), 'core', 'defaultapp', $configToSet); + } + + return new JSONResponse([]); + } +} diff --git a/packages/web-runtime/src/components/ApplicationsMenu.vue b/packages/web-runtime/src/components/ApplicationsMenu.vue index 3bbdf3e03c4..da24a7f0087 100644 --- a/packages/web-runtime/src/components/ApplicationsMenu.vue +++ b/packages/web-runtime/src/components/ApplicationsMenu.vue @@ -22,7 +22,13 @@ >