2023-02-23 10:32:53 -05:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
|
|
|
import { alias } from "@ember/object/computed";
|
2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
2019-10-23 12:30:52 -04:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2018-12-14 17:14:46 -05:00
|
|
|
import { setting } from "discourse/lib/computed";
|
|
|
|
|
2023-02-23 10:32:53 -05:00
|
|
|
@classNames("admin-report-storage-stats")
|
|
|
|
export default class AdminReportStorageStats extends Component {
|
|
|
|
@setting("backup_location") backupLocation;
|
|
|
|
|
|
|
|
@alias("model.data.backups") backupStats;
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2023-02-23 10:32:53 -05:00
|
|
|
@alias("model.data.uploads") uploadStats;
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("backupStats")
|
2018-12-14 17:14:46 -05:00
|
|
|
showBackupStats(stats) {
|
|
|
|
return stats && this.currentUser.admin;
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("backupLocation")
|
2018-12-14 17:14:46 -05:00
|
|
|
backupLocationName(backupLocation) {
|
|
|
|
return I18n.t(`admin.backups.location.${backupLocation}`);
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("backupStats.used_bytes")
|
2018-12-14 17:14:46 -05:00
|
|
|
usedBackupSpace(bytes) {
|
|
|
|
return I18n.toHumanSize(bytes);
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("backupStats.free_bytes")
|
2018-12-14 17:14:46 -05:00
|
|
|
freeBackupSpace(bytes) {
|
|
|
|
return I18n.toHumanSize(bytes);
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("uploadStats.used_bytes")
|
2018-12-14 17:14:46 -05:00
|
|
|
usedUploadSpace(bytes) {
|
|
|
|
return I18n.toHumanSize(bytes);
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
2018-12-14 17:14:46 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("uploadStats.free_bytes")
|
2018-12-14 17:14:46 -05:00
|
|
|
freeUploadSpace(bytes) {
|
|
|
|
return I18n.toHumanSize(bytes);
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
|
|
|
}
|