Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Improve backup stats on admin dashboard
* Dashboard doesn't timeout anymore when Amazon S3 is used for backups * Storage stats are now a proper report with the same caching rules * Changing the backup_location, s3_backup_bucket or creating and deleting backups removes the report from the cache * It shows the number of backups and the backup location * It shows the used space for the correct backup location instead of always showing used space on local storage * It shows the date of the last backup as relative date
- Loading branch information
Showing
20 changed files
with
224 additions
and
174 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/assets/javascripts/admin/components/admin-report-storage-stats.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { setting } from "discourse/lib/computed"; | ||
import computed from "ember-addons/ember-computed-decorators"; | ||
|
||
export default Ember.Component.extend({ | ||
classNames: ["admin-report-storage-stats"], | ||
|
||
backupLocation: setting("backup_location"), | ||
backupStats: Ember.computed.alias("model.data.backups"), | ||
uploadStats: Ember.computed.alias("model.data.uploads"), | ||
|
||
@computed("backupStats") | ||
showBackupStats(stats) { | ||
return stats && this.currentUser.admin; | ||
}, | ||
|
||
@computed("backupLocation") | ||
backupLocationName(backupLocation) { | ||
return I18n.t(`admin.backups.location.${backupLocation}`); | ||
}, | ||
|
||
@computed("backupStats.used_bytes") | ||
usedBackupSpace(bytes) { | ||
return I18n.toHumanSize(bytes); | ||
}, | ||
|
||
@computed("backupStats.free_bytes") | ||
freeBackupSpace(bytes) { | ||
return I18n.toHumanSize(bytes); | ||
}, | ||
|
||
@computed("uploadStats.used_bytes") | ||
usedUploadSpace(bytes) { | ||
return I18n.toHumanSize(bytes); | ||
}, | ||
|
||
@computed("uploadStats.free_bytes") | ||
freeUploadSpace(bytes) { | ||
return I18n.toHumanSize(bytes); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/admin/models/admin-dashboard-next.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/assets/javascripts/admin/templates/components/admin-report-storage-stats.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{#if showBackupStats}} | ||
<div class="backups"> | ||
<h3 class="storage-stats-title"> | ||
<a href="{{get-url '/admin/backups'}}">{{d-icon "archive"}} {{i18n "admin.dashboard.backups"}}</a> | ||
</h3> | ||
<p> | ||
{{#if backupStats.free_bytes}} | ||
{{i18n "admin.dashboard.space_used_and_free" usedSize=usedBackupSpace freeSize=freeBackupSpace}} | ||
{{else}} | ||
{{i18n "admin.dashboard.space_used" usedSize=usedBackupSpace}} | ||
{{/if}} | ||
|
||
<br> | ||
{{i18n "admin.dashboard.backup_count" count=backupStats.count location=backupLocationName}} | ||
|
||
{{#if backupStats.last_backup_taken_at}} | ||
<br> | ||
{{{i18n "admin.dashboard.lastest_backup" date=(format-date backupStats.last_backup_taken_at leaveAgo="true")}}} | ||
{{/if}} | ||
</p> | ||
</div> | ||
{{/if}} | ||
|
||
<div class="uploads"> | ||
<h3 class="storage-stats-title">{{d-icon "upload"}} {{i18n "admin.dashboard.uploads"}}</h3> | ||
<p> | ||
{{#if uploadStats.free_bytes}} | ||
{{i18n "admin.dashboard.space_used_and_free" usedSize=usedUploadSpace freeSize=freeUploadSpace}} | ||
{{else}} | ||
{{i18n "admin.dashboard.space_used" usedSize=usedUploadSpace}} | ||
{{/if}} | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1a8ca68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/dashboard-fails-due-to-s3-timeout/103687/9
1a8ca68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️