From dd0d9b014fcf6ff0a10f7a7073462a4b9cc8057b Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:11:00 +0530 Subject: [PATCH 1/9] Refactor and move referral url to config --- appinfo/routes.php | 3 - lib/Controller/AppsController.php | 102 ------------------------------ lib/Controller/PageController.php | 43 +++++++++---- package.json | 3 +- src/components/AllApps.vue | 62 ++++-------------- src/components/StorageLayout.vue | 42 ++++-------- 6 files changed, 60 insertions(+), 195 deletions(-) delete mode 100755 lib/Controller/AppsController.php diff --git a/appinfo/routes.php b/appinfo/routes.php index fa7b77c..d82b09d 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 ba0aea3..0000000 --- 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 48e0f46..ec83e60 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -5,25 +5,44 @@ 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; - public function __construct($AppName, IRequest $request, $UserId) { - parent::__construct($AppName, $request); - $this->userId = $UserId; + /** @var IInitialState */ + private $initialState; + + /** @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 */ 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->provideIntialState('displayName',$displayName); + return new TemplateResponse('ecloud-dashboard', 'dashboard'); } + } diff --git a/package.json b/package.json index 4b9afce..411b665 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 924ec88..374fc1a 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 @@ -- GitLab From 158026d82eb278e879735af6116509daac7c255e Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:14:12 +0530 Subject: [PATCH 2/9] Update package-lock --- package-lock.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/package-lock.json b/package-lock.json index 9fa5b8d..96dbac2 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", -- GitLab From 6125e1b36c8a5f5c845d6b5217a6bbfb302f9ff2 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:17:07 +0530 Subject: [PATCH 3/9] Update README --- README.md | 61 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 728d561..c375d0d 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 -- GitLab From 2f686333ccfb513ea9601a200ab6653d63b23c31 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:18:03 +0530 Subject: [PATCH 4/9] PHP lint --- lib/Controller/PageController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index ec83e60..abbf6ed 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -11,7 +11,6 @@ use OCP\IUserSession; use OCA\EcloudDashboard\Util; class PageController extends Controller { - /** @var IInitialState */ private $initialState; @@ -34,15 +33,14 @@ class PageController extends Controller { */ public function index() { $referralUrl = $this->config->getSystemValue('shop_referral_program_url', ''); - $storageUrl = $this->config->getAppValue('increasestoragebutton', 'link' ,''); + $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->provideIntialState('displayName',$displayName); - return new TemplateResponse('ecloud-dashboard', 'dashboard'); + $this->initialState->provideIntialState('displayName', $displayName); + return new TemplateResponse('ecloud-dashboard', 'dashboard'); } - } -- GitLab From 9837a4b51c01c96e7a1acf2c11f1fe43e97eed30 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:23:35 +0530 Subject: [PATCH 5/9] Add NoCSRFRequired again --- lib/Controller/PageController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index abbf6ed..bf4b8c2 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -29,6 +29,7 @@ class PageController extends Controller { } /** + * @NoCSRFRequired * @NoAdminRequired */ public function index() { -- GitLab From e2c07400e1e6c3f74f87b951a8b0ad3c30315ad0 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:31:28 +0530 Subject: [PATCH 6/9] Fix typo --- lib/Controller/PageController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index bf4b8c2..e5156df 100755 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -41,7 +41,7 @@ class PageController extends Controller { $this->initialState->provideInitialState('shopReferralProgramUrl', $referralUrl); $this->initialState->provideInitialState('increaseStorageUrl', $storageUrl); $this->initialState->provideInitialState('entries', $entries); - $this->initialState->provideIntialState('displayName', $displayName); + $this->initialState->provideInitialState('displayName', $displayName); return new TemplateResponse('ecloud-dashboard', 'dashboard'); } } -- GitLab From 388cc2aae3220809c5a995a9aef5549983abd066 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:40:08 +0530 Subject: [PATCH 7/9] Fix loadState --- src/components/AllApps.vue | 4 ++-- src/components/StorageLayout.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AllApps.vue b/src/components/AllApps.vue index 374fc1a..ad93f70 100755 --- a/src/components/AllApps.vue +++ b/src/components/AllApps.vue @@ -67,8 +67,8 @@ export default { data() { return { showAllApps: false, - entries: loadState('entries'), - displayName: loadState('displayName'), + entries: loadState('ecloud-dashboard', 'entries'), + displayName: loadState('ecloud-dashboard', 'displayName'), } }, methods: { diff --git a/src/components/StorageLayout.vue b/src/components/StorageLayout.vue index 8ee2f3a..82fbe1b 100755 --- a/src/components/StorageLayout.vue +++ b/src/components/StorageLayout.vue @@ -79,8 +79,8 @@ export default { return { storageInfo: [], storageFetchStatus: false, - shopReferralProgramUrl: loadState('shopReferralProgramUrl'), - increaseStorageUrl: loadState('increaseStorageUrl'), + shopReferralProgramUrl: loadState('ecloud-dashboard', 'shopReferralProgramUrl'), + increaseStorageUrl: loadState('ecloud-dashboard', 'increaseStorageUrl'), } }, computed: { -- GitLab From c1bcffb1a4fe3cd00cb63dc95eaea345dc1b6482 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 11 Jan 2023 23:47:36 +0530 Subject: [PATCH 8/9] fix getAppEntries --- lib/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Util.php b/lib/Util.php index f65a83f..13839c0 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; } /** -- GitLab From 969b231486f05d17b6fe7097ebbe08952f2e315e Mon Sep 17 00:00:00 2001 From: Akhil Date: Thu, 12 Jan 2023 00:13:09 +0530 Subject: [PATCH 9/9] Version 1.4.0 --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index b6f508b..64b1033 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 -- GitLab