From 3e6ad7a0e782bb553b4a224831cc20145fa7a1d2 Mon Sep 17 00:00:00 2001 From: MasterOfDeath Date: Sat, 27 Oct 2018 17:11:53 +0500 Subject: [PATCH] Indicate users default quota Indicate users default quota Signed-off-by: Rinat Gumirov --- apps/provisioning_api/lib/Controller/AUserData.php | 6 +++++- settings/src/components/userList.vue | 12 ++++++++---- settings/src/components/userList/userRow.vue | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 25e5ab5c86d1a..5c90d6d839210 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -159,6 +159,8 @@ protected function getUserSubAdminGroupsData(string $userId): array { */ protected function fillStorageInfo(string $userId): array { try { + $quotaConfig = \OC::$server->getConfig()->getUserValue($userId, 'files', 'quota', 'default'); + $isQuotaDefault = $quotaConfig === 'default'; \OC_Util::tearDownFS(); \OC_Util::setupFS($userId); $storage = OC_Helper::getStorageInfo('/'); @@ -168,6 +170,7 @@ protected function fillStorageInfo(string $userId): array { 'total' => $storage['total'], 'relative' => $storage['relative'], 'quota' => $storage['quota'], + 'isQuotaDefault' => $isQuotaDefault, ]; } catch (NotFoundException $ex) { // User fs is not setup yet @@ -181,7 +184,8 @@ protected function fillStorageInfo(string $userId): array { } $data = [ 'quota' => $quota !== false ? $quota : 'none', - 'used' => 0 + 'used' => 0, + 'isQuotaDefault' => $isQuotaDefault, ]; } return $data; diff --git a/settings/src/components/userList.vue b/settings/src/components/userList.vue index 521ad7cc39270..69c63506818a8 100644 --- a/settings/src/components/userList.vue +++ b/settings/src/components/userList.vue @@ -150,11 +150,9 @@ export default { InfiniteLoading }, data() { - let unlimitedQuota = {id:'none', label:t('settings', 'Unlimited')}, - defaultQuota = {id:'default', label:t('settings', 'Default quota')}; + let unlimitedQuota = {id:'none', label:t('settings', 'Unlimited')}; return { unlimitedQuota: unlimitedQuota, - defaultQuota: defaultQuota, loading: { all: false, groups: false @@ -168,7 +166,7 @@ export default { mailAddress:'', groups: [], subAdminsGroups: [], - quota: defaultQuota, + quota: this.defaultQuota, language: {code: 'en', name: t('settings', 'Default language')} } }; @@ -197,6 +195,12 @@ export default { this.userSearch = new OCA.Search(this.search, this.resetSearch); }, computed: { + defaultQuota() { + return { + id: 'default', + label: `${this.settings.defaultQuota} (${t('settings', 'Default quota')})` + }; + }, settings() { return this.$store.getters.getServerData; }, diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue index 138f855eaf06d..72a0d41e4a1b7 100644 --- a/settings/src/components/userList/userRow.vue +++ b/settings/src/components/userList/userRow.vue @@ -234,12 +234,12 @@ export default { }, // Mapping saved values to objects userQuota() { - if (this.user.quota.quota >= 0) { + if (this.user.quota.quota >= 0 && !this.user.quota.isQuotaDefault) { // if value is valid, let's map the quotaOptions or return custom quota let humanQuota = OC.Util.humanFileSize(this.user.quota.quota); let userQuota = this.quotaOptions.find(quota => quota.id === humanQuota); return userQuota ? userQuota : {id:humanQuota, label:humanQuota}; - } else if (this.user.quota.quota === 'default') { + } else if (this.user.quota.quota === 'default' || this.user.quota.isQuotaDefault) { // default quota is replaced by the proper value on load return this.quotaOptions[0]; }