mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
storage page refactoring
This commit is contained in:
51
resources/js/helpers/functionHelpers.js
vendored
51
resources/js/helpers/functionHelpers.js
vendored
@@ -1,6 +1,6 @@
|
||||
import i18n from '/resources/js/i18n/index'
|
||||
import store from '../store/index'
|
||||
import {debounce, isArray} from "lodash";
|
||||
import {debounce, isArray, orderBy} from "lodash";
|
||||
import {events} from '../bus'
|
||||
import axios from 'axios'
|
||||
|
||||
@@ -69,6 +69,55 @@ const FunctionHelpers = {
|
||||
})
|
||||
}
|
||||
|
||||
Vue.prototype.$mapStorageUsage = function (storage) {
|
||||
|
||||
let distribution = [
|
||||
{
|
||||
progress: storage.data.meta.images.percentage,
|
||||
color: 'success',
|
||||
value: storage.data.meta.images.used,
|
||||
title: 'Images'
|
||||
},
|
||||
{
|
||||
progress: storage.data.meta.videos.percentage,
|
||||
color: 'danger',
|
||||
value: storage.data.meta.videos.used,
|
||||
title: 'Videos'
|
||||
},
|
||||
{
|
||||
progress: storage.data.meta.audios.percentage,
|
||||
color: 'warning',
|
||||
value: storage.data.meta.audios.used,
|
||||
title: 'Audios'
|
||||
},
|
||||
{
|
||||
progress: storage.data.meta.documents.percentage,
|
||||
color: 'info',
|
||||
value: storage.data.meta.documents.used,
|
||||
title: 'Documents'
|
||||
},
|
||||
{
|
||||
progress: storage.data.meta.others.percentage,
|
||||
color: 'purple',
|
||||
value: storage.data.meta.others.used,
|
||||
title: 'Others'
|
||||
},
|
||||
]
|
||||
|
||||
// Order distribution by it's size
|
||||
distribution = orderBy(distribution, ['progress'], ['desc'])
|
||||
|
||||
// Push at the end empty space data
|
||||
distribution.push({
|
||||
progress: 100 - storage.data.attributes.percentage,
|
||||
color: 'secondary',
|
||||
value: storage.data.meta.others.used,
|
||||
title: 'Empty'
|
||||
})
|
||||
|
||||
return distribution
|
||||
}
|
||||
|
||||
Vue.prototype.$getImage = function (source) {
|
||||
return source ? this.$store.getters.config.host + '/' + source : ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user