-
Notifications
You must be signed in to change notification settings - Fork 157
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 (#11287)
* Create quota information component, add to account page
- Loading branch information
1 parent
0fed190
commit cfb122f
Showing
7 changed files
with
137 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 | ||
|
79 changes: 79 additions & 0 deletions
79
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,79 @@ | ||
<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/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, | ||
default: () => undefined as Quota // FIXME: hack because vue doesn't detect type | ||
} | ||
}, | ||
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
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