FIX: improves durability display check

This commit is contained in:
Joffrey JAFFEUX 2018-06-20 23:15:11 +02:00 committed by GitHub
parent 95d99de7b4
commit 50d11fd582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -15,8 +15,12 @@ export default Ember.Controller.extend({
exceptionController: Ember.inject.controller("exception"), exceptionController: Ember.inject.controller("exception"),
showVersionChecks: setting("version_checks"), showVersionChecks: setting("version_checks"),
diskSpace: Ember.computed.alias("model.attributes.disk_space"), diskSpace: Ember.computed.alias("model.attributes.disk_space"),
lastBackupTakenAt: Ember.computed.alias(
"model.attributes.last_backup_taken_at"
),
logSearchQueriesEnabled: setting("log_search_queries"), logSearchQueriesEnabled: setting("log_search_queries"),
availablePeriods: ["yearly", "quarterly", "monthly", "weekly"], availablePeriods: ["yearly", "quarterly", "monthly", "weekly"],
shouldDisplayDurability: Ember.computed.and("lastBackupTakenAt", "diskSpace"),
@computed("problems.length") @computed("problems.length")
foundProblems(problemsLength) { foundProblems(problemsLength) {
@ -137,7 +141,7 @@ export default Ember.Controller.extend({
return moment(updatedAt).format("LLL"); return moment(updatedAt).format("LLL");
}, },
@computed("model.attributes.last_backup_taken_at") @computed("lastBackupTakenAt")
backupTimestamp(lastBackupTakenAt) { backupTimestamp(lastBackupTakenAt) {
return moment(lastBackupTakenAt).format("LLL"); return moment(lastBackupTakenAt).format("LLL");
}, },

View File

@ -90,7 +90,7 @@
</div> </div>
{{#conditional-loading-section isLoading=isLoading title=(i18n "admin.dashboard.backups")}} {{#conditional-loading-section isLoading=isLoading title=(i18n "admin.dashboard.backups")}}
<div class="misc"> <div class="misc">
{{#if diskSpace}} {{#if shouldDisplayDurability}}
<div class="durability"> <div class="durability">
{{#if currentUser.admin}} {{#if currentUser.admin}}
<div class="backups"> <div class="backups">

View File

@ -23,11 +23,20 @@ class AdminDashboardNextData
end end
def as_json(_options = nil) def as_json(_options = nil)
@json ||= { @json ||= get_json
end
def get_json
json = {
reports: AdminDashboardNextData.reports(REPORTS), reports: AdminDashboardNextData.reports(REPORTS),
last_backup_taken_at: last_backup_taken_at,
updated_at: Time.zone.now.as_json updated_at: Time.zone.now.as_json
} }
if SiteSetting.enable_backups
json[:last_backup_taken_at] = last_backup_taken_at
end
json
end end
def last_backup_taken_at def last_backup_taken_at