diff --git a/README.md b/README.md index 728d561ccde37145a14a66b5ac4b9eb330b2313e..c375d0d28ddcb1bfdb86b095159a6fd224d1d077 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,7 @@ -# :key: Aliases - -The aliases center shows you where your data is stored and who can access it, either because you shared with them or because they are administrators. - -## Installation - -This app is shipped and enabled by default in every Nextcloud instance starting with Nextcloud 16. If you wish to disable this app, go to `Apps`, `Active Apps`, scroll down to find `Aliases` and click `Disable`. - -## Building the app - -The app can be built by using the provided Makefile by running: - - make - -This requires the following things to be present: -* make -* which -* tar: for building the archive -* curl: used if phpunit and composer are not installed to fetch them from the web -* npm: for building and testing everything JS, only required if a package.json is placed inside the **js/** folder - -The make command will install or update Composer dependencies if a composer.json is present and also **npm run build** if a package.json is present in the **js/** folder. The npm **build** script should use local paths for build systems and package managers, so people that simply want to build the app won't need to install npm libraries globally, e.g.: - -**package.json**: -```json -"scripts": { - "test": "node node_modules/gulp-cli/bin/gulp.js karma", - "prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update", - "build": "node node_modules/gulp-cli/bin/gulp.js" -} -``` - - -## Publish to App Store - -First get an account for the [App Store](http://apps.nextcloud.com/) then run: - - make && make appstore - -The archive is located in build/artifacts/appstore and can then be uploaded to the App Store. - -## Running tests -You can use the provided Makefile to run all tests by using: - - make test - -This will run the PHP unit and integration tests and if a package.json is present in the **js/** folder will execute **npm run test** - -Of course you can also install [PHPUnit](http://phpunit.de/getting-started.html) and use the configurations directly: - - phpunit -c phpunit.xml - -or: - - phpunit -c phpunit.integration.xml - -for integration tests - ## Make ecloud-dashboard app as default dashboard - To make default dashboard, add `'defaultapp' => 'ecloud-dashboard'` changes in `/config/config.php`. +## Config options + +- Set `shop_referral_program_url` to your referral program url in config.php to activate referral program section diff --git a/appinfo/info.xml b/appinfo/info.xml index b6f508b2459a823f77624ef99e4c58a608822127..64b103334ad414ffa2518f7ef7ffdcd67511b0ad 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Murena dashboard Murena Cloud Dashboard - 1.3.0 + 1.4.0 agpl Murena EcloudDashboard diff --git a/appinfo/routes.php b/appinfo/routes.php index fa7b77c423540f20285e2f55d21ba24afbf20abc..d82b09dd10e7d2023d679b8a8b35739e1b42cfa5 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -9,9 +9,6 @@ */ return [ 'routes' => [ - ['name' => 'apps#index', 'url' => '/get-apps', 'verb' => 'GET'], ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], - ['name' => 'apps#getStorageInfo', 'url' => '/apps/get-storageinfo', 'verb' => 'GET'], - ['name' => 'apps#getRedirections', 'url' => '/apps/get-redirections', 'verb' => 'GET'] ] ]; diff --git a/lib/Controller/AppsController.php b/lib/Controller/AppsController.php deleted file mode 100755 index ba0aea3b0b1e4ed95776bcb9f50bb307683f7f85..0000000000000000000000000000000000000000 --- a/lib/Controller/AppsController.php +++ /dev/null @@ -1,102 +0,0 @@ -util = $util; - $this->appName = $AppName; - $this->request = $request; - $this->config = $config; - $this->userSession = $userSession; - $this->localization = $localization; - } - /** - * @NoAdminRequired - * @return JSONResponse - */ - public function index() { - $response = new JSONResponse(); - $entries = $this->util->getAppEntries(); - $response->setData($entries); - return $response; - } - /** - * @NoAdminRequired - * @return JSONResponse - */ - public function getRedirections() { - $response = new JSONResponse(); - - //getting Group data - $groupData = $this->util->getGroups(); - - //getting redirection links - $redirectData = $this->getRedirectLink(); - - $redirectURL = 'https://doc.e.foundation/support-topics/referral-program'; //default - - if (in_array("Premium", $groupData) || in_array("premium", $groupData)) { - $redirectURL = str_replace('/ecloud-subscriptions', '', $redirectData['link']) . '/my-account/referral_coupons/'; - } - - $entries = array( 'redirectURL' => $redirectURL ); - - return $response->setData(array_merge($redirectData, $entries)); - ; - } - public function getRedirectLink() { - $link = $this->config->getAppValue( - 'increasestoragebutton', - 'link' - ); - - if ($link != '' && !filter_var($link, FILTER_VALIDATE_URL)) { - throw new LinkNotURLException( - $this->localization->t( - 'The given link is not a URL' - ) - ); - } - $userQuota = $this->userSession->getUser()->getQuota(); - $userQuota = str_replace(' ', '', $userQuota); - - if (empty($this->request->getCookie($this->cookieUsername)) || empty($this->request->getCookie($this->cookieToken))) { - $storageLink = $link; - } else { - $storageLink = $link . ((strpos($link, '?') !== false) ? '&' : '?') . - 'username=' . urlencode($this->request->getCookie($this->cookieUsername)) . - '&token=' . urlencode($this->request->getCookie($this->cookieToken)) . - '¤t-quota=' . $userQuota . - '&from=nextcloud'; - } - - - - return array('storageLink' => $storageLink , 'link' => $link); - } -} diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 48e0f4603f404830660af2819f072ab58a78dcc2..e5156dfc1df68468c77d5334417e53ba8514ea69 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -5,25 +5,43 @@ namespace OCA\EcloudDashboard\Controller; use OCP\IRequest; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Controller; +use OCP\AppFramework\Services\IInitialState; +use OCP\IConfig; +use OCP\IUserSession; +use OCA\EcloudDashboard\Util; class PageController extends Controller { - private $userId; + /** @var IInitialState */ + private $initialState; - public function __construct($AppName, IRequest $request, $UserId) { - parent::__construct($AppName, $request); - $this->userId = $UserId; + /** @var IConfig */ + private $config; + + /** @var IUserSession */ + private $userSession; + + public function __construct($appName, IRequest $request, IInitialState $initialState, IConfig $config, IUserSession $userSession, Util $util) { + $this->initialState = $initialState; + $this->config = $config; + $this->util = $util; + $this->userSession = $userSession; + parent::__construct($appName, $request); } + /** - * CAUTION: the @Stuff turns off security checks; for this page no admin is - * required and no CSRF check. If you don't know what CSRF is, read - * it up in the docs or you might create a security hole. This is - * basically the only required method to add this exemption, don't - * add it to any other method if you don't exactly know what it does - * - * @NoAdminRequired * @NoCSRFRequired + * @NoAdminRequired */ public function index() { - return new TemplateResponse('ecloud-dashboard', 'dashboard'); // templates/dashboard.php + $referralUrl = $this->config->getSystemValue('shop_referral_program_url', ''); + $storageUrl = $this->config->getAppValue('increasestoragebutton', 'link', ''); + $entries = $this->util->getAppEntries(); + $displayName = $this->userSession->getUser()->getDisplayName(); + + $this->initialState->provideInitialState('shopReferralProgramUrl', $referralUrl); + $this->initialState->provideInitialState('increaseStorageUrl', $storageUrl); + $this->initialState->provideInitialState('entries', $entries); + $this->initialState->provideInitialState('displayName', $displayName); + return new TemplateResponse('ecloud-dashboard', 'dashboard'); } } diff --git a/lib/Util.php b/lib/Util.php index f65a83ff0ffa04c27ee4ae606f4b90d46dd6209d..13839c088656ae95a831a656fc2abc39964d3e27 100755 --- a/lib/Util.php +++ b/lib/Util.php @@ -149,7 +149,7 @@ class Util { unset($entriesByHref['']); $entries = array_values($entriesByHref); - return array( 'apps' => $entries ); + return $entries; } /** diff --git a/package-lock.json b/package-lock.json index 9fa5b8d8a58483677eebb27e7aa68a9b65e31952..96dbac272e2c3e5d1c2f6a148e83549cca18b651 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@nextcloud/babel-config": "^1.0.0", "@nextcloud/browserslist-config": "^2.2.0", "@nextcloud/eslint-config": "^8.0.0", + "@nextcloud/initial-state": "^2.0.0", "@nextcloud/stylelint-config": "^2.1.2", "@nextcloud/webpack-vue-config": "^5.2.1" }, @@ -2156,6 +2157,12 @@ "core-js": "^3.6.4" } }, + "node_modules/@nextcloud/initial-state": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@nextcloud/initial-state/-/initial-state-2.0.0.tgz", + "integrity": "sha512-xmNP30v/RnkJ2z1HcuEo7YfcLJJa+FdWTwgNldXHOlMeMbl/ESpsGkWL2sULrhYurz64L0JpfwEdi/cHcmyuZQ==", + "dev": true + }, "node_modules/@nextcloud/l10n": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.6.0.tgz", @@ -13168,6 +13175,12 @@ "core-js": "^3.6.4" } }, + "@nextcloud/initial-state": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@nextcloud/initial-state/-/initial-state-2.0.0.tgz", + "integrity": "sha512-xmNP30v/RnkJ2z1HcuEo7YfcLJJa+FdWTwgNldXHOlMeMbl/ESpsGkWL2sULrhYurz64L0JpfwEdi/cHcmyuZQ==", + "dev": true + }, "@nextcloud/l10n": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.6.0.tgz", diff --git a/package.json b/package.json index 4b9afce40f3ae392fae12ff7d696414988153a79..411b66582686599c2dcb6ad064577da091378378 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@nextcloud/browserslist-config": "^2.2.0", "@nextcloud/eslint-config": "^8.0.0", "@nextcloud/stylelint-config": "^2.1.2", - "@nextcloud/webpack-vue-config": "^5.2.1" + "@nextcloud/webpack-vue-config": "^5.2.1", + "@nextcloud/initial-state": "^2.0.0" } } diff --git a/src/components/AllApps.vue b/src/components/AllApps.vue index 924ec88f7cf1daf6f5a1aef72fd82ed4e8eeed14..ad93f70b17e87f0bf9d05bc232ac734d1b2e6b62 100755 --- a/src/components/AllApps.vue +++ b/src/components/AllApps.vue @@ -26,21 +26,16 @@
-

{{ WelcomeBack }} {{ userInfo.ownerDisplayName }}

+

{{ t('ecloud-dashboard', 'Welcome back') }} {{ displayName }}

-
- {{ - showAllApps - }} - {{ - showLessApps - }} +
+ {{ t('ecloud-dashboard', 'Show All Apps') }} + {{ t('ecloud-dashboard', 'Show Less Apps') }}
-
- + @@ -65,47 +59,19 @@