Show space used in storage location page.
This commit is contained in:
parent
cbb35d55a1
commit
b0e23a87d0
|
@ -34,6 +34,18 @@
|
|||
<h5 class="m-0">{{ getAdapterName(row.item.adapter) }}</h5>
|
||||
<p class="card-text">{{ row.item.uri }}</p>
|
||||
</template>
|
||||
<template #cell(space)="row">
|
||||
<template v-if="row.item.storageAvailable">
|
||||
<b-progress :value="row.item.storageUsedPercent" show-progress height="15px" class="mb-1"
|
||||
:variant="getProgressVariant(row.item.storageUsedPercent)">
|
||||
</b-progress>
|
||||
|
||||
{{ getSpaceUsed(row.item) }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ getSpaceUsed(row.item) }}
|
||||
</template>
|
||||
</template>
|
||||
<template #cell(stations)="row">
|
||||
{{ row.item.stations.join(', ') }}
|
||||
</template>
|
||||
|
@ -59,9 +71,10 @@ export default {
|
|||
return {
|
||||
activeType: 'station_media',
|
||||
fields: [
|
||||
{ key: 'actions', label: this.$gettext('Actions'), sortable: false },
|
||||
{ key: 'adapter', label: this.$gettext('Adapter'), sortable: false },
|
||||
{ key: 'stations', label: this.$gettext('Station(s)'), sortable: false }
|
||||
{key: 'actions', label: this.$gettext('Actions'), sortable: false},
|
||||
{key: 'adapter', label: this.$gettext('Adapter'), sortable: false},
|
||||
{key: 'space', label: this.$gettext('Space Used'), class: 'text-nowrap', sortable: false},
|
||||
{key: 'stations', label: this.$gettext('Station(s)'), sortable: false}
|
||||
]
|
||||
};
|
||||
},
|
||||
|
@ -99,16 +112,30 @@ export default {
|
|||
return this.$gettext('Remote: Dropbox');
|
||||
}
|
||||
},
|
||||
relist () {
|
||||
getSpaceUsed(item) {
|
||||
return (item.storageAvailable)
|
||||
? item.storageUsed + ' / ' + item.storageAvailable
|
||||
: item.storageUsed;
|
||||
},
|
||||
getProgressVariant(percent) {
|
||||
if (percent > 85) {
|
||||
return 'danger';
|
||||
} else if (percent > 65) {
|
||||
return 'warning';
|
||||
} else {
|
||||
return 'default';
|
||||
}
|
||||
},
|
||||
relist() {
|
||||
this.$refs.datatable.refresh();
|
||||
},
|
||||
doCreate () {
|
||||
doCreate() {
|
||||
this.$refs.editModal.create();
|
||||
},
|
||||
doEdit (url) {
|
||||
doEdit(url) {
|
||||
this.$refs.editModal.edit(url);
|
||||
},
|
||||
doModify (url) {
|
||||
doModify(url) {
|
||||
this.$notify(this.$gettext('Applying changes...'), {
|
||||
variant: 'warning'
|
||||
});
|
||||
|
|
|
@ -132,11 +132,19 @@ class StorageLocationsController extends AbstractAdminApiCrudController
|
|||
/** @inheritDoc */
|
||||
protected function viewRecord(object $record, ServerRequest $request): object
|
||||
{
|
||||
/** @var Entity\StorageLocation $record */
|
||||
$original = parent::viewRecord($record, $request);
|
||||
|
||||
$return = new Entity\Api\Admin\StorageLocation();
|
||||
$return->fromParentObject($original);
|
||||
|
||||
$return->storageQuotaBytes = (string)($record->getStorageQuotaBytes() ?? '');
|
||||
$return->storageUsedBytes = (string)$record->getStorageUsedBytes();
|
||||
$return->storageUsedPercent = $record->getStorageUsePercentage();
|
||||
$return->storageAvailable = $record->getStorageAvailable();
|
||||
$return->storageAvailableBytes = (string)($record->getStorageAvailableBytes() ?? '');
|
||||
$return->isFull = $record->isStorageFull();
|
||||
|
||||
$return->uri = $record->getUri();
|
||||
|
||||
$stationsRaw = $this->storageLocationRepo->getStationsUsingLocation($record);
|
||||
|
|
|
@ -82,12 +82,48 @@ class StorageLocation
|
|||
*/
|
||||
public ?string $storageQuota = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="120000")
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $storageQuotaBytes = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="1 GB")
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $storageUsed = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="60000")
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $storageUsedBytes = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="1 GB")
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $storageAvailable = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="120000")
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $storageAvailableBytes = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="75")
|
||||
* @var int|null
|
||||
*/
|
||||
public ?int $storageUsedPercent = null;
|
||||
|
||||
/**
|
||||
* @OA\Property(example="true")
|
||||
* @var bool
|
||||
*/
|
||||
public bool $isFull = true;
|
||||
|
||||
/**
|
||||
* The URI associated with the storage location.
|
||||
*
|
||||
|
|
|
@ -92,16 +92,10 @@ class StorageLocation implements Stringable, IdentifiableEntityInterface
|
|||
#[ORM\Column(name: 'storage_quota', type: 'bigint', nullable: true)]
|
||||
protected ?string $storageQuota = null;
|
||||
|
||||
// Used for API generation.
|
||||
protected ?string $storageQuotaBytes = null;
|
||||
|
||||
#[ORM\Column(name: 'storage_used', type: 'bigint', nullable: true)]
|
||||
#[Attributes\AuditIgnore]
|
||||
protected ?string $storageUsed = null;
|
||||
|
||||
// Used for API generation.
|
||||
protected ?string $storageUsedBytes = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'storage_location', targetEntity: StationMedia::class)]
|
||||
protected Collection $media;
|
||||
|
||||
|
|
Loading…
Reference in New Issue