-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create quota information component, add to account page
- Loading branch information
1 parent
c99001f
commit 8c4a081
Showing
7 changed files
with
136 additions
and
81 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
changelog/unreleased/enhancement-add-quota-information-to-account-page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Add quota information to account page | ||
|
||
We've added a new section to the account page that displays the users current quota usage. | ||
|
||
https://github.com/owncloud/web/pull/11287 | ||
|
78 changes: 78 additions & 0 deletions
78
packages/web-runtime/src/components/Account/QuotaInformation.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<template> | ||
<div class="quota-information oc-flex oc-flex-bottom"> | ||
<oc-icon name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs" /> | ||
<div> | ||
<p class="oc-my-rm"> | ||
<span class="quota-information-text" v-text="personalStorageDetailsLabel" /> | ||
</p> | ||
<oc-progress | ||
v-if="limitedPersonalStorage" | ||
class="quota-information-progress-bar" | ||
:value="quotaUsagePercent" | ||
:max="100" | ||
size="small" | ||
:variation="quotaProgressVariant" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent, PropType, unref } from 'vue' | ||
import { Quota } from '@ownclouders/web-client/src/graph/generated' | ||
import { filesize } from 'filesize' | ||
import { useGettext } from 'vue3-gettext' | ||
export default defineComponent({ | ||
name: 'QuotaInformation', | ||
props: { | ||
quota: { | ||
type: Object as PropType<Quota>, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const { $gettext } = useGettext() | ||
const limitedPersonalStorage = computed(() => { | ||
return props.quota.total !== 0 | ||
}) | ||
const quotaUsagePercent = computed(() => { | ||
return parseFloat(((props.quota.used / props.quota.total) * 100).toFixed(2)) | ||
}) | ||
const personalStorageDetailsLabel = computed(() => { | ||
const total = props.quota.total || 0 | ||
const used = props.quota.used || 0 | ||
return total | ||
? $gettext('%{used} of %{total} used (%{percentage}%)', { | ||
used: filesize(used), | ||
total: filesize(total), | ||
percentage: (unref(quotaUsagePercent) || 0).toString() | ||
}) | ||
: $gettext('%{used} used', { | ||
used: filesize(used), | ||
total: filesize(total) | ||
}) | ||
}) | ||
const quotaProgressVariant = computed(() => { | ||
if ((unref(quotaUsagePercent) || 0) < 80) { | ||
return 'primary' | ||
} | ||
if ((unref(quotaUsagePercent) || 0) < 90) { | ||
return 'warning' | ||
} | ||
return 'danger' | ||
}) | ||
return { | ||
quotaUsagePercent, | ||
personalStorageDetailsLabel, | ||
limitedPersonalStorage, | ||
quotaProgressVariant | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,11 +65,11 @@ exports[`User Menu component > when quota and no email is set > renders a naviga | |
<li data-v-08f1b1e7="" class="profile-info-wrapper oc-pl-s"> | ||
<avatar-image-stub data-v-08f1b1e7="" width="32" userid="einstein" user-name="Albert Einstein"></avatar-image-stub> <span data-v-08f1b1e7="" class="profile-info-wrapper oc-py-xs"><span data-v-08f1b1e7="" class="oc-display-block">Albert Einstein</span> | ||
<!--v-if--> | ||
<div data-v-08f1b1e7="" class="storage-wrapper oc-flex oc-flex-bottom oc-mt-xs"> | ||
<oc-icon-stub data-v-08f1b1e7="" name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div data-v-08f1b1e7=""> | ||
<p data-v-08f1b1e7="" class="oc-my-rm"><span data-v-08f1b1e7="" class="storage-wrapper-quota oc-text-small">300 B of 1 kB used (30%)</span></p> | ||
<oc-progress-stub data-v-08f1b1e7="" max="100" size="small" variation="primary" value="30"></oc-progress-stub> | ||
<div data-v-08f1b1e7="" class="quota-information oc-flex oc-flex-bottom oc-text-small oc-mt-xs"> | ||
<oc-icon-stub name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div> | ||
<p class="oc-my-rm"><span class="quota-information-text">300 B of 1 kB used (30%)</span></p> | ||
<oc-progress-stub class="quota-information-progress-bar" max="100" size="small" variation="primary" value="30"></oc-progress-stub> | ||
</div> | ||
</div></span> | ||
</li> | ||
|
@@ -98,11 +98,11 @@ exports[`User Menu component > when quota is above 80% and below 90% > renders a | |
<oc-list-stub data-v-08f1b1e7="" class="user-menu-list"> | ||
<li data-v-08f1b1e7="" class="profile-info-wrapper oc-pl-s"> | ||
<avatar-image-stub data-v-08f1b1e7="" width="32" userid="einstein" user-name="Albert Einstein"></avatar-image-stub> <span data-v-08f1b1e7="" class="profile-info-wrapper"><span data-v-08f1b1e7="" class="oc-display-block">Albert Einstein</span> <span data-v-08f1b1e7="" class="oc-text-small">[email protected]</span> | ||
<div data-v-08f1b1e7="" class="storage-wrapper oc-flex oc-flex-bottom oc-mt-xs"> | ||
<oc-icon-stub data-v-08f1b1e7="" name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div data-v-08f1b1e7=""> | ||
<p data-v-08f1b1e7="" class="oc-my-rm"><span data-v-08f1b1e7="" class="storage-wrapper-quota oc-text-small">810 B of 1 kB used (81%)</span></p> | ||
<oc-progress-stub data-v-08f1b1e7="" max="100" size="small" variation="warning" value="81"></oc-progress-stub> | ||
<div data-v-08f1b1e7="" class="quota-information oc-flex oc-flex-bottom oc-text-small oc-mt-xs"> | ||
<oc-icon-stub name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div> | ||
<p class="oc-my-rm"><span class="quota-information-text">810 B of 1 kB used (81%)</span></p> | ||
<oc-progress-stub class="quota-information-progress-bar" max="100" size="small" variation="warning" value="81"></oc-progress-stub> | ||
</div> | ||
</div></span> | ||
</li> | ||
|
@@ -131,11 +131,11 @@ exports[`User Menu component > when quota is above 90% > renders a danger quota | |
<oc-list-stub data-v-08f1b1e7="" class="user-menu-list"> | ||
<li data-v-08f1b1e7="" class="profile-info-wrapper oc-pl-s"> | ||
<avatar-image-stub data-v-08f1b1e7="" width="32" userid="einstein" user-name="Albert Einstein"></avatar-image-stub> <span data-v-08f1b1e7="" class="profile-info-wrapper"><span data-v-08f1b1e7="" class="oc-display-block">Albert Einstein</span> <span data-v-08f1b1e7="" class="oc-text-small">[email protected]</span> | ||
<div data-v-08f1b1e7="" class="storage-wrapper oc-flex oc-flex-bottom oc-mt-xs"> | ||
<oc-icon-stub data-v-08f1b1e7="" name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div data-v-08f1b1e7=""> | ||
<p data-v-08f1b1e7="" class="oc-my-rm"><span data-v-08f1b1e7="" class="storage-wrapper-quota oc-text-small">910 B of 1 kB used (91%)</span></p> | ||
<oc-progress-stub data-v-08f1b1e7="" max="100" size="small" variation="danger" value="91"></oc-progress-stub> | ||
<div data-v-08f1b1e7="" class="quota-information oc-flex oc-flex-bottom oc-text-small oc-mt-xs"> | ||
<oc-icon-stub name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div> | ||
<p class="oc-my-rm"><span class="quota-information-text">910 B of 1 kB used (91%)</span></p> | ||
<oc-progress-stub class="quota-information-progress-bar" max="100" size="small" variation="danger" value="91"></oc-progress-stub> | ||
</div> | ||
</div></span> | ||
</li> | ||
|
@@ -164,11 +164,11 @@ exports[`User Menu component > when quota is below 80% > renders a primary quota | |
<oc-list-stub data-v-08f1b1e7="" class="user-menu-list"> | ||
<li data-v-08f1b1e7="" class="profile-info-wrapper oc-pl-s"> | ||
<avatar-image-stub data-v-08f1b1e7="" width="32" userid="einstein" user-name="Albert Einstein"></avatar-image-stub> <span data-v-08f1b1e7="" class="profile-info-wrapper"><span data-v-08f1b1e7="" class="oc-display-block">Albert Einstein</span> <span data-v-08f1b1e7="" class="oc-text-small">[email protected]</span> | ||
<div data-v-08f1b1e7="" class="storage-wrapper oc-flex oc-flex-bottom oc-mt-xs"> | ||
<oc-icon-stub data-v-08f1b1e7="" name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div data-v-08f1b1e7=""> | ||
<p data-v-08f1b1e7="" class="oc-my-rm"><span data-v-08f1b1e7="" class="storage-wrapper-quota oc-text-small">300 B of 1 kB used (30%)</span></p> | ||
<oc-progress-stub data-v-08f1b1e7="" max="100" size="small" variation="primary" value="30"></oc-progress-stub> | ||
<div data-v-08f1b1e7="" class="quota-information oc-flex oc-flex-bottom oc-text-small oc-mt-xs"> | ||
<oc-icon-stub name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div> | ||
<p class="oc-my-rm"><span class="quota-information-text">300 B of 1 kB used (30%)</span></p> | ||
<oc-progress-stub class="quota-information-progress-bar" max="100" size="small" variation="primary" value="30"></oc-progress-stub> | ||
</div> | ||
</div></span> | ||
</li> | ||
|
@@ -197,10 +197,10 @@ exports[`User Menu component > when quota is not defined > renders no percentag | |
<oc-list-stub data-v-08f1b1e7="" class="user-menu-list"> | ||
<li data-v-08f1b1e7="" class="profile-info-wrapper oc-pl-s"> | ||
<avatar-image-stub data-v-08f1b1e7="" width="32" userid="einstein" user-name="Albert Einstein"></avatar-image-stub> <span data-v-08f1b1e7="" class="profile-info-wrapper"><span data-v-08f1b1e7="" class="oc-display-block">Albert Einstein</span> <span data-v-08f1b1e7="" class="oc-text-small">[email protected]</span> | ||
<div data-v-08f1b1e7="" class="storage-wrapper oc-flex oc-flex-bottom oc-mt-xs"> | ||
<oc-icon-stub data-v-08f1b1e7="" name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div data-v-08f1b1e7=""> | ||
<p data-v-08f1b1e7="" class="oc-my-rm"><span data-v-08f1b1e7="" class="storage-wrapper-quota oc-text-small">910 B used</span></p> | ||
<div data-v-08f1b1e7="" class="quota-information oc-flex oc-flex-bottom oc-text-small oc-mt-xs"> | ||
<oc-icon-stub name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div> | ||
<p class="oc-my-rm"><span class="quota-information-text">910 B used</span></p> | ||
<!--v-if--> | ||
</div> | ||
</div></span> | ||
|
@@ -230,10 +230,10 @@ exports[`User Menu component > when quota is unlimited > renders no percentag of | |
<oc-list-stub data-v-08f1b1e7="" class="user-menu-list"> | ||
<li data-v-08f1b1e7="" class="profile-info-wrapper oc-pl-s"> | ||
<avatar-image-stub data-v-08f1b1e7="" width="32" userid="einstein" user-name="Albert Einstein"></avatar-image-stub> <span data-v-08f1b1e7="" class="profile-info-wrapper"><span data-v-08f1b1e7="" class="oc-display-block">Albert Einstein</span> <span data-v-08f1b1e7="" class="oc-text-small">[email protected]</span> | ||
<div data-v-08f1b1e7="" class="storage-wrapper oc-flex oc-flex-bottom oc-mt-xs"> | ||
<oc-icon-stub data-v-08f1b1e7="" name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div data-v-08f1b1e7=""> | ||
<p data-v-08f1b1e7="" class="oc-my-rm"><span data-v-08f1b1e7="" class="storage-wrapper-quota oc-text-small">300 B used</span></p> | ||
<div data-v-08f1b1e7="" class="quota-information oc-flex oc-flex-bottom oc-text-small oc-mt-xs"> | ||
<oc-icon-stub name="hard-drive-2" size="small" fill-type="line" class="oc-mr-xs"></oc-icon-stub> | ||
<div> | ||
<p class="oc-my-rm"><span class="quota-information-text">300 B used</span></p> | ||
<!--v-if--> | ||
</div> | ||
</div></span> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters