@@ -175,11 +177,11 @@ export default {
)
const { status, data } = await Axios.get(url)
if (status === 200) {
- this.orderCount = data.count
+ this.orderCount = data.order_count
if (this.orderCount) {
this.ordersDescription = this.ordersDescription.replace('%d', this.orderCount).replace('%s', data.my_orders_url)
}
- this.subscriptionCount = data.subscriptions
+ this.subscriptionCount = data.subscription_count
if (this.subscriptionCount) {
this.subscriptionDescription = this.subscriptionDescription.replace('%d', this.subscriptionCount).replace('%s', data.my_orders_url)
}
--
GitLab
From b3c26d3bf155100f9d5a59d5d9529486cbb09476 Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Thu, 9 Feb 2023 16:59:26 +0530
Subject: [PATCH 22/58] loading
---
src/PersonalSettings.vue | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/PersonalSettings.vue b/src/PersonalSettings.vue
index 19d263f2..a1a270d0 100644
--- a/src/PersonalSettings.vue
+++ b/src/PersonalSettings.vue
@@ -1,11 +1,11 @@
-
+
{{
t('ecloud-accounts', 'Loading...')
}}
-
+
{{
t('ecloud-accounts', 'We are going to proceed with your cloud account suppression.')
@@ -102,7 +102,7 @@ export default {
subscriptionCount: 0,
ordersDescription: this.t('ecloud-accounts', "For your information you have %d order(s) in your account."),
subscriptionDescription: this.t('ecloud-accounts', 'A subscription is active in this account. Please cancel it or let it expire before deleting your account.'),
- loader: true,
+ loading: true,
}
},
created() {
@@ -186,9 +186,9 @@ export default {
this.subscriptionDescription = this.subscriptionDescription.replace('%d', this.subscriptionCount).replace('%s', data.my_orders_url)
}
}
- this.loader = false
+ this.loading = false
} catch (e) {
- this.loader = false
+ this.loading = false
}
},
async updateDeleteShopPreference() {
--
GitLab
From 96371fce0389ed1bc8128c304d7805f3b2ad3b3f Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Thu, 9 Feb 2023 17:12:10 +0530
Subject: [PATCH 23/58] changes
---
lib/Controller/ShopAccountController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/Controller/ShopAccountController.php b/lib/Controller/ShopAccountController.php
index b8142807..d8627635 100644
--- a/lib/Controller/ShopAccountController.php
+++ b/lib/Controller/ShopAccountController.php
@@ -87,7 +87,7 @@ class ShopAccountController extends Controller {
}
$total_subscriptions = 0;
- foreach (SUBSCRIPTION_STATUS_LIST as $status) {
+ foreach (self::SUBSCRIPTION_STATUS_LIST as $status) {
$subscriptions = $this->shopAccountService->getSubscriptions($userId, $status);
if ($subscriptions) {
$total_subscriptions += count($subscriptions);
--
GitLab
From fc8d72f20a7a013f6e627111cfd9778791c1c579 Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Fri, 10 Feb 2023 01:05:23 +0530
Subject: [PATCH 24/58] removed more api calls
---
lib/Controller/ShopAccountController.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/Controller/ShopAccountController.php b/lib/Controller/ShopAccountController.php
index d8627635..0731a6ff 100644
--- a/lib/Controller/ShopAccountController.php
+++ b/lib/Controller/ShopAccountController.php
@@ -87,10 +87,12 @@ class ShopAccountController extends Controller {
}
$total_subscriptions = 0;
- foreach (self::SUBSCRIPTION_STATUS_LIST as $status) {
- $subscriptions = $this->shopAccountService->getSubscriptions($userId, $status);
- if ($subscriptions) {
- $total_subscriptions += count($subscriptions);
+ $subscriptions = $this->shopAccountService->getSubscriptions($userId, 'any');
+ if ($subscriptions) {
+ foreach ($subscriptions as $subscription) {
+ if (in_array($subscription['status'], self::SUBSCRIPTION_STATUS_LIST)) {
+ $total_subscriptions += count($subscriptions);
+ }
}
}
$data['subscription_count'] = $total_subscriptions;
--
GitLab
From b0d1a2d1b657fc7545ba59d1e5386de842bf17ea Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Fri, 10 Feb 2023 01:08:16 +0530
Subject: [PATCH 25/58] removed more api calls #2
---
lib/Controller/ShopAccountController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/Controller/ShopAccountController.php b/lib/Controller/ShopAccountController.php
index 0731a6ff..99c690f9 100644
--- a/lib/Controller/ShopAccountController.php
+++ b/lib/Controller/ShopAccountController.php
@@ -91,7 +91,7 @@ class ShopAccountController extends Controller {
if ($subscriptions) {
foreach ($subscriptions as $subscription) {
if (in_array($subscription['status'], self::SUBSCRIPTION_STATUS_LIST)) {
- $total_subscriptions += count($subscriptions);
+ $total_subscriptions++;
}
}
}
--
GitLab
From c83fa9ec6d183af716e4293f3adc9a4f882fff79 Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Fri, 10 Feb 2023 13:49:48 +0530
Subject: [PATCH 26/58] removed if
---
lib/Controller/ShopAccountController.php | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/Controller/ShopAccountController.php b/lib/Controller/ShopAccountController.php
index 99c690f9..0b7a8713 100644
--- a/lib/Controller/ShopAccountController.php
+++ b/lib/Controller/ShopAccountController.php
@@ -88,11 +88,9 @@ class ShopAccountController extends Controller {
$total_subscriptions = 0;
$subscriptions = $this->shopAccountService->getSubscriptions($userId, 'any');
- if ($subscriptions) {
- foreach ($subscriptions as $subscription) {
- if (in_array($subscription['status'], self::SUBSCRIPTION_STATUS_LIST)) {
- $total_subscriptions++;
- }
+ foreach ($subscriptions as $subscription) {
+ if (in_array($subscription['status'], self::SUBSCRIPTION_STATUS_LIST)) {
+ $total_subscriptions++;
}
}
$data['subscription_count'] = $total_subscriptions;
--
GitLab
From f34baec93a1c202abc5ad5cda15e09407206ea4c Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Wed, 15 Feb 2023 13:28:01 +0530
Subject: [PATCH 27/58] remove unneccessary code
---
src/PersonalSettings.vue | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/PersonalSettings.vue b/src/PersonalSettings.vue
index a1a270d0..851d4088 100644
--- a/src/PersonalSettings.vue
+++ b/src/PersonalSettings.vue
@@ -182,9 +182,6 @@ export default {
this.ordersDescription = this.ordersDescription.replace('%d', this.orderCount).replace('%s', data.my_orders_url)
}
this.subscriptionCount = data.subscription_count
- if (this.subscriptionCount) {
- this.subscriptionDescription = this.subscriptionDescription.replace('%d', this.subscriptionCount).replace('%s', data.my_orders_url)
- }
}
this.loading = false
} catch (e) {
--
GitLab
From 8f121786198cc8ece4bf9fefcf053c1ba21be513 Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Wed, 15 Feb 2023 18:05:02 +0530
Subject: [PATCH 28/58] changes for exception added
---
appinfo/routes.php | 1 +
lib/Controller/ShopAccountController.php | 33 +++++++++++++++-----
src/PersonalSettings.vue | 38 ++++++++++++++++++++++--
src/delete-account-listeners.js | 3 ++
4 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/appinfo/routes.php b/appinfo/routes.php
index db6f2a5a..b4eb6822 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -7,6 +7,7 @@ return ['routes' => [
['name' => 'shop_account#set_shop_email_post_delete', 'url' => '/shop-accounts/set_shop_email_post_delete', 'verb' => 'POST' ],
['name' => 'shop_account#set_shop_delete_preference', 'url' => '/shop-accounts/set_shop_delete_preference', 'verb' => 'POST' ],
['name' => 'shop_account#get_order_info', 'url' => '/shop-accounts/order_info', 'verb' => 'GET'],
+ ['name' => 'shop_account#get_subscription_info', 'url' => '/shop-accounts/subscription_info', 'verb' => 'GET'],
['name' => 'shop_account#get_shop_user', 'url' => '/shop-accounts/user', 'verb' => 'GET'],
['name' => 'shop_account#check_shop_email_post_delete', 'url' => '/shop-accounts/check_shop_email_post_delete', 'verb' => 'GET'],
[
diff --git a/lib/Controller/ShopAccountController.php b/lib/Controller/ShopAccountController.php
index 0b7a8713..5abb8000 100644
--- a/lib/Controller/ShopAccountController.php
+++ b/lib/Controller/ShopAccountController.php
@@ -10,6 +10,7 @@ use OCP\IUserSession;
use OCP\IRequest;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http;
class ShopAccountController extends Controller {
private $shopAccountService;
@@ -78,22 +79,40 @@ class ShopAccountController extends Controller {
* @NoAdminRequired
*/
public function getOrderInfo(int $userId) {
- $response = new DataResponse();
- $data = ['order_count' => 0,'subscription_count' => 0, 'my_orders_url' => $this->shopAccountService->getShopUrl() . '/my-account/orders'];
-
+ if (!$userId) {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+ $data = ['order_count' => 0, 'my_orders_url' => $this->shopAccountService->getShopUrl() . '/my-account/orders'];
$orders = $this->shopAccountService->getOrders($userId);
- if ($orders) {
- $data['order_count'] = count($orders);
+ if ($orders === null) {
+ return new DataResponse([''], Http::STATUS_BAD_REQUEST);
}
- $total_subscriptions = 0;
-
+ $data['order_count'] = count($orders);
+ $response = new DataResponse();
+ $response->setData($data);
+ return $response;
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function getSubscriptionInfo(int $userId) {
+ if (!$userId) {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+ $data = ['subscription_count' => 0];
$subscriptions = $this->shopAccountService->getSubscriptions($userId, 'any');
+ if ($subscriptions === null) {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+ $total_subscriptions = 0;
foreach ($subscriptions as $subscription) {
if (in_array($subscription['status'], self::SUBSCRIPTION_STATUS_LIST)) {
$total_subscriptions++;
}
}
$data['subscription_count'] = $total_subscriptions;
+ $response = new DataResponse();
$response->setData($data);
return $response;
}
diff --git a/src/PersonalSettings.vue b/src/PersonalSettings.vue
index 851d4088..35e17aa6 100644
--- a/src/PersonalSettings.vue
+++ b/src/PersonalSettings.vue
@@ -103,6 +103,7 @@ export default {
ordersDescription: this.t('ecloud-accounts', "For your information you have %d order(s) in your account."),
subscriptionDescription: this.t('ecloud-accounts', 'A subscription is active in this account. Please cancel it or let it expire before deleting your account.'),
loading: true,
+ showError: false,
}
},
created() {
@@ -116,6 +117,7 @@ export default {
this.getShopUser().then(() => {
if (this.shopUserExists) {
this.getOrdersInfo()
+ this.getSubscriptionInfo()
}
this.disableOrEnableDeleteAccount()
})
@@ -163,9 +165,10 @@ export default {
if (status === 200) {
this.shopUserExists = true
this.shopUser = data
- }
- if (status === 400) {
- this.enableDeleteAccountEvent()
+ } else {
+ showError(
+ t('ecloud-accounts', 'Error while fetching the records')
+ )
}
} catch (e) {
}
@@ -181,10 +184,39 @@ export default {
if (this.orderCount) {
this.ordersDescription = this.ordersDescription.replace('%d', this.orderCount).replace('%s', data.my_orders_url)
}
+ } else {
+ showError(
+ t('ecloud-accounts', 'Error while fetching the records')
+ )
+ }
+ this.loading = false
+ } catch (e) {
+ showError(
+ t('ecloud-accounts', 'Error while fetching the records')
+ )
+ this.loading = false
+ }
+ },
+ async getSubscriptionInfo() {
+ try {
+ const url = generateUrl(
+ `/apps/${this.appName}/shop-accounts/subscription_info?userId=${this.shopUser.id}`
+ )
+ const { status, data } = await Axios.get(url)
+ if (status === 200) {
this.subscriptionCount = data.subscription_count
+ } else {
+ this.disableDeleteAccountEvent()
+ showError(
+ t('ecloud-accounts', 'Error while fetching the records')
+ )
}
this.loading = false
} catch (e) {
+ this.disableDeleteAccountEvent()
+ showError(
+ t('ecloud-accounts', 'Error while fetching the records')
+ )
this.loading = false
}
},
diff --git a/src/delete-account-listeners.js b/src/delete-account-listeners.js
index 42046a3c..6677c105 100644
--- a/src/delete-account-listeners.js
+++ b/src/delete-account-listeners.js
@@ -8,6 +8,9 @@ $(document).ready(function() {
elem.addEventListener('disable-delete-account', function() {
$('#deleteaccount').prop('disabled', true)
$('#drop_account_confirm').prop('disabled', true)
+ $('#drop_account_confirm').prop('disabled', true)
+ $('#shop-accounts_confirm').prop('disabled', true)
+ $('#shop-alternate-email').prop('disabled', true)
})
elem.addEventListener('enable-delete-account', function() {
--
GitLab
From 16766453a8bbf7fd4f0625c547f5942243e15cdc Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Wed, 15 Feb 2023 18:07:09 +0530
Subject: [PATCH 29/58] else
---
src/PersonalSettings.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PersonalSettings.vue b/src/PersonalSettings.vue
index 35e17aa6..ff07a064 100644
--- a/src/PersonalSettings.vue
+++ b/src/PersonalSettings.vue
@@ -5,7 +5,7 @@
t('ecloud-accounts', 'Loading...')
}}
-
+
{{
t('ecloud-accounts', 'We are going to proceed with your cloud account suppression.')
--
GitLab
From 7f52099e03888ff6eb98fe6f1787963c56b0d1f2 Mon Sep 17 00:00:00 2001
From: Ronak Patel
Date: Wed, 15 Feb 2023 18:08:21 +0530
Subject: [PATCH 30/58] condition changes
---
src/PersonalSettings.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PersonalSettings.vue b/src/PersonalSettings.vue
index ff07a064..362d16ab 100644
--- a/src/PersonalSettings.vue
+++ b/src/PersonalSettings.vue
@@ -16,8 +16,8 @@
}}
-
-
+
+