discourse/app/assets/javascripts/admin/addon/components/admin-report-storage-stats.gjs
dependabot[bot] e7d3c344d1
Build(deps-dev): Bump the lint group across 1 directory with 4 updates (#33881)
Bumps the lint group with 4 updates in the / directory:
[@discourse/lint-configs](https://github.com/discourse/lint-configs),
[ember-template-lint](https://github.com/ember-template-lint/ember-template-lint),
[eslint](https://github.com/eslint/eslint) and
[stylelint](https://github.com/stylelint/stylelint).


Updates `@discourse/lint-configs` from 2.22.0 to 2.28.0
- [Commits](https://github.com/discourse/lint-configs/commits)

Updates `ember-template-lint` from 7.7.0 to 7.9.1
- [Release
notes](https://github.com/ember-template-lint/ember-template-lint/releases)
-
[Changelog](https://github.com/ember-template-lint/ember-template-lint/blob/master/CHANGELOG.md)
-
[Commits](https://github.com/ember-template-lint/ember-template-lint/commits)

Updates `eslint` from 9.27.0 to 9.32.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.27.0...v9.32.0)

Updates `stylelint` from 16.19.1 to 16.22.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
-
[Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
-
[Commits](https://github.com/stylelint/stylelint/compare/16.19.1...16.22.0)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Discourse CI <ci@ci.invalid>
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-07-28 18:02:41 +02:00

106 lines
3 KiB
Text
Vendored

import Component from "@ember/component";
import { alias } from "@ember/object/computed";
import { htmlSafe } from "@ember/template";
import { classNames } from "@ember-decorators/component";
import icon from "discourse/helpers/d-icon";
import formatDate from "discourse/helpers/format-date";
import { setting } from "discourse/lib/computed";
import discourseComputed from "discourse/lib/decorators";
import getUrl from "discourse/lib/get-url";
import I18n, { i18n } from "discourse-i18n";
@classNames("admin-report-storage-stats")
export default class AdminReportStorageStats extends Component {
@setting("backup_location") backupLocation;
@alias("model.data.backups") backupStats;
@alias("model.data.uploads") uploadStats;
@discourseComputed("backupStats")
showBackupStats(stats) {
return stats && this.currentUser.admin;
}
@discourseComputed("backupLocation")
backupLocationName(backupLocation) {
return i18n(`admin.backups.location.${backupLocation}`);
}
@discourseComputed("backupStats.used_bytes")
usedBackupSpace(bytes) {
return I18n.toHumanSize(bytes);
}
@discourseComputed("backupStats.free_bytes")
freeBackupSpace(bytes) {
return I18n.toHumanSize(bytes);
}
@discourseComputed("uploadStats.used_bytes")
usedUploadSpace(bytes) {
return I18n.toHumanSize(bytes);
}
@discourseComputed("uploadStats.free_bytes")
freeUploadSpace(bytes) {
return I18n.toHumanSize(bytes);
}
<template>
{{#if this.showBackupStats}}
<div class="backups">
<h3 class="storage-stats-title">
<a href={{getUrl "/admin/backups"}}>{{icon "box-archive"}}
{{i18n "admin.dashboard.backups"}}</a>
</h3>
<p>
{{#if this.backupStats.free_bytes}}
{{i18n
"admin.dashboard.space_used_and_free"
usedSize=this.usedBackupSpace
freeSize=this.freeBackupSpace
}}
{{else}}
{{i18n "admin.dashboard.space_used" usedSize=this.usedBackupSpace}}
{{/if}}
<br />
{{i18n
"admin.dashboard.backup_count"
count=this.backupStats.count
location=this.backupLocationName
}}
{{#if this.backupStats.last_backup_taken_at}}
<br />
{{htmlSafe
(i18n
"admin.dashboard.lastest_backup"
date=(formatDate
this.backupStats.last_backup_taken_at leaveAgo="true"
)
)
}}
{{/if}}
</p>
</div>
{{/if}}
<div class="uploads">
<h3 class="storage-stats-title">{{icon "upload"}}
{{i18n "admin.dashboard.uploads"}}</h3>
<p>
{{#if this.uploadStats.free_bytes}}
{{i18n
"admin.dashboard.space_used_and_free"
usedSize=this.usedUploadSpace
freeSize=this.freeUploadSpace
}}
{{else}}
{{i18n "admin.dashboard.space_used" usedSize=this.usedUploadSpace}}
{{/if}}
</p>
</div>
</template>
}