Added storage stats to the account page
This commit is contained in:
@@ -1,33 +1,19 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div>
|
<div>
|
||||||
{{ creatureCount }} /
|
<creature-storage-stats />
|
||||||
<v-icon v-if="characterSlots === -1">
|
|
||||||
mdi-infinity
|
|
||||||
</v-icon>
|
|
||||||
<template v-else>
|
|
||||||
{{ characterSlots }}
|
|
||||||
</template>
|
|
||||||
<archive-button />
|
<archive-button />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js">
|
<script lang="js">
|
||||||
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
import CreatureStorageStats from '/imports/ui/creature/creatureList/CreatureStorageStats.vue';
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
|
||||||
import ArchiveButton from '/imports/ui/creature/creatureList/ArchiveButton.vue';
|
import ArchiveButton from '/imports/ui/creature/creatureList/ArchiveButton.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
CreatureStorageStats,
|
||||||
ArchiveButton,
|
ArchiveButton,
|
||||||
},
|
},
|
||||||
meteor: {
|
|
||||||
creatureCount(){
|
|
||||||
return Creatures.find({owner: Meteor.userId()}).count();
|
|
||||||
},
|
|
||||||
characterSlots(){
|
|
||||||
return getUserTier(Meteor.userId()).characterSlots;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="creature-storage-stats"
|
||||||
|
style="display: inline-block;"
|
||||||
|
>
|
||||||
|
{{ creatureCount }} /
|
||||||
|
<v-icon v-if="characterSlots === -1">
|
||||||
|
mdi-infinity
|
||||||
|
</v-icon>
|
||||||
|
<template v-else>
|
||||||
|
{{ characterSlots }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
meteor: {
|
||||||
|
creatureCount(){
|
||||||
|
return Creatures.find({owner: Meteor.userId()}).count();
|
||||||
|
},
|
||||||
|
characterSlots(){
|
||||||
|
return getUserTier(Meteor.userId()).characterSlots;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
</v-toolbar-title>
|
</v-toolbar-title>
|
||||||
<div>
|
<div>
|
||||||
<v-alert type="warning" outlined>
|
<v-alert type="warning" outlined>
|
||||||
This cannot be undone
|
This can't be undone
|
||||||
</v-alert>
|
</v-alert>
|
||||||
<p v-if="name">
|
<p v-if="name">
|
||||||
Type "{{ name }}" to permanenetly delete.
|
Type "{{ name }}" to permanenetly delete.
|
||||||
|
|||||||
66
app/imports/ui/files/FileStorageStats.vue
Normal file
66
app/imports/ui/files/FileStorageStats.vue
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<template>
|
||||||
|
<v-col
|
||||||
|
cols="12"
|
||||||
|
md="4"
|
||||||
|
lg="3"
|
||||||
|
class="layout column justify-center align-center"
|
||||||
|
>
|
||||||
|
<v-progress-circular
|
||||||
|
:rotate="-90"
|
||||||
|
:size="100"
|
||||||
|
:width="15"
|
||||||
|
:value="percentFileStorageUsed"
|
||||||
|
:buffer-value="50"
|
||||||
|
color="accent"
|
||||||
|
>
|
||||||
|
{{ percentFileStorageUsed }}%
|
||||||
|
</v-progress-circular>
|
||||||
|
<div class="ma-2 mt-4">
|
||||||
|
{{ prettyBytes(storageUsed) }} / {{ prettyBytes(storageAllowed) }}
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
@click="updateStorageUsed"
|
||||||
|
>
|
||||||
|
<v-icon>mdi-refresh</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
import { snackbar } from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
||||||
|
import updateFileStorageUsed from '/imports/api/users/methods/updateFileStorageUsed.js';
|
||||||
|
import prettyBytes from 'pretty-bytes';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
meteor: {
|
||||||
|
storageUsed(){
|
||||||
|
return Meteor.user().fileStorageUsed || 0;
|
||||||
|
},
|
||||||
|
storageAllowed(){
|
||||||
|
return getUserTier(Meteor.userId()).fileStorage * 1000000;
|
||||||
|
},
|
||||||
|
percentFileStorageUsed(){
|
||||||
|
return Math.round((this.storageUsed / this.storageAllowed) * 100);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
prettyBytes(input){
|
||||||
|
return prettyBytes(input)
|
||||||
|
},
|
||||||
|
updateStorageUsed(){
|
||||||
|
this.updateStorageUsedLoading = true;
|
||||||
|
updateFileStorageUsed.call(error => {
|
||||||
|
this.updateStorageUsedLoading = false;
|
||||||
|
if (!error) return;
|
||||||
|
snackbar({text: error.reason});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -8,6 +8,18 @@
|
|||||||
style="flex-basis: 900px"
|
style="flex-basis: 900px"
|
||||||
>
|
>
|
||||||
<v-list>
|
<v-list>
|
||||||
|
<v-subheader>
|
||||||
|
File storage used
|
||||||
|
</v-subheader>
|
||||||
|
<file-storage-stats />
|
||||||
|
<v-subheader>
|
||||||
|
Character storage used
|
||||||
|
</v-subheader>
|
||||||
|
<v-list-item>
|
||||||
|
<v-list-item-title>
|
||||||
|
<creature-storage-stats />
|
||||||
|
</v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
<v-subheader>
|
<v-subheader>
|
||||||
Preferences
|
Preferences
|
||||||
</v-subheader>
|
</v-subheader>
|
||||||
@@ -221,8 +233,14 @@
|
|||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
import addEmail from '/imports/api/users/methods/addEmail.js';
|
import addEmail from '/imports/api/users/methods/addEmail.js';
|
||||||
import removeEmail from '/imports/api/users/methods/removeEmail.js';
|
import removeEmail from '/imports/api/users/methods/removeEmail.js';
|
||||||
|
import CreatureStorageStats from '/imports/ui/creature/creatureList/CreatureStorageStats.vue';
|
||||||
|
import FileStorageStats from '/imports/ui/files/FileStorageStats.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CreatureStorageStats,
|
||||||
|
FileStorageStats,
|
||||||
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
$subscribe: {
|
$subscribe: {
|
||||||
'userPublicProfiles'(){
|
'userPublicProfiles'(){
|
||||||
|
|||||||
@@ -1,32 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row justify="center">
|
<v-row justify="center">
|
||||||
<v-col
|
<file-storage-stats />
|
||||||
cols="12"
|
|
||||||
md="4"
|
|
||||||
lg="3"
|
|
||||||
class="layout column justify-center align-center"
|
|
||||||
>
|
|
||||||
<v-progress-circular
|
|
||||||
:rotate="-90"
|
|
||||||
:size="100"
|
|
||||||
:width="15"
|
|
||||||
:value="percentFileStorageUsed"
|
|
||||||
:buffer-value="50"
|
|
||||||
color="accent"
|
|
||||||
>
|
|
||||||
{{ percentFileStorageUsed }}%
|
|
||||||
</v-progress-circular>
|
|
||||||
<div class="ma-2 mt-4">
|
|
||||||
{{ prettyBytes(storageUsed) }} / {{ prettyBytes(storageAllowed) }}
|
|
||||||
<v-btn
|
|
||||||
icon
|
|
||||||
@click="updateStorageUsed"
|
|
||||||
>
|
|
||||||
<v-icon>mdi-refresh</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row dense>
|
<v-row dense>
|
||||||
<template v-if="archiveFiles && archiveFiles.length">
|
<template v-if="archiveFiles && archiveFiles.length">
|
||||||
@@ -51,13 +26,12 @@
|
|||||||
import ArchiveCreatureFiles from '/imports/api/creature/archive/ArchiveCreatureFiles.js';
|
import ArchiveCreatureFiles from '/imports/api/creature/archive/ArchiveCreatureFiles.js';
|
||||||
import prettyBytes from 'pretty-bytes';
|
import prettyBytes from 'pretty-bytes';
|
||||||
import ArchiveFileCard from '/imports/ui/files/ArchiveFileCard.vue';
|
import ArchiveFileCard from '/imports/ui/files/ArchiveFileCard.vue';
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
import FileStorageStats from '/imports/ui/files/FileStorageStats.vue';
|
||||||
import { snackbar } from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
|
||||||
import updateFileStorageUsed from '/imports/api/users/methods/updateFileStorageUsed.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ArchiveFileCard,
|
ArchiveFileCard,
|
||||||
|
FileStorageStats,
|
||||||
},
|
},
|
||||||
data(){ return {
|
data(){ return {
|
||||||
updateStorageUsedLoading: false,
|
updateStorageUsedLoading: false,
|
||||||
@@ -67,15 +41,6 @@ export default {
|
|||||||
'archiveCreatureFiles': [],
|
'archiveCreatureFiles': [],
|
||||||
'characterList': [],
|
'characterList': [],
|
||||||
},
|
},
|
||||||
storageUsed(){
|
|
||||||
return Meteor.user().fileStorageUsed || 0;
|
|
||||||
},
|
|
||||||
storageAllowed(){
|
|
||||||
return getUserTier(Meteor.userId()).fileStorage * 1000000;
|
|
||||||
},
|
|
||||||
percentFileStorageUsed(){
|
|
||||||
return Math.round((this.storageUsed / this.storageAllowed) * 100);
|
|
||||||
},
|
|
||||||
archiveFiles() {
|
archiveFiles() {
|
||||||
var userId = Meteor.userId();
|
var userId = Meteor.userId();
|
||||||
return ArchiveCreatureFiles.find(
|
return ArchiveCreatureFiles.find(
|
||||||
@@ -91,18 +56,5 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
prettyBytes(input){
|
|
||||||
return prettyBytes(input)
|
|
||||||
},
|
|
||||||
updateStorageUsed(){
|
|
||||||
this.updateStorageUsedLoading = true;
|
|
||||||
updateFileStorageUsed.call(error => {
|
|
||||||
this.updateStorageUsedLoading = false;
|
|
||||||
if (!error) return;
|
|
||||||
snackbar({text: error.reason});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user