discourse/app/assets/javascripts/admin/addon/controllers/admin-backups-index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.8 KiB
JavaScript
Raw Normal View History

import I18n from "I18n";
import { alias, equal } from "@ember/object/computed";
import Controller, { inject as controller } from "@ember/controller";
2016-06-30 13:55:44 -04:00
import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators";
import { setting, i18n } from "discourse/lib/computed";
import bootbox from "bootbox";
export default Controller.extend({
adminBackups: controller(),
status: alias("adminBackups.model"),
uploadLabel: i18n("admin.backups.upload.label"),
backupLocation: setting("backup_location"),
localBackupStorage: equal("backupLocation", "local"),
2014-02-12 23:35:46 -05:00
@discourseComputed("status.allowRestore", "status.isOperationRunning")
restoreTitle(allowRestore, isOperationRunning) {
if (!allowRestore) {
2015-03-26 13:05:27 -04:00
return "admin.backups.operations.restore.is_disabled";
} else if (isOperationRunning) {
2015-03-26 13:05:27 -04:00
return "admin.backups.operations.is_running";
2014-02-12 23:35:46 -05:00
} else {
2015-03-26 13:05:27 -04:00
return "admin.backups.operations.restore.title";
2014-02-12 23:35:46 -05:00
}
},
2014-02-12 23:35:46 -05:00
actions: {
2015-03-26 13:05:27 -04:00
toggleReadOnlyMode() {
if (!this.site.get("isReadOnly")) {
2014-02-12 23:35:46 -05:00
bootbox.confirm(
I18n.t("admin.backups.read_only.enable.confirm"),
I18n.t("no_value"),
I18n.t("yes_value"),
(confirmed) => {
if (confirmed) {
this.set("currentUser.hideReadOnlyAlert", true);
this._toggleReadOnlyMode(true);
}
2014-02-12 23:35:46 -05:00
}
);
} else {
this._toggleReadOnlyMode(false);
}
},
2014-02-12 23:35:46 -05:00
download(backup) {
const link = backup.get("filename");
ajax(`/admin/backups/${link}`, { type: "PUT" }).then(() =>
bootbox.alert(I18n.t("admin.backups.operations.download.alert"))
);
},
2014-02-12 23:35:46 -05:00
},
2015-03-26 13:05:27 -04:00
_toggleReadOnlyMode(enable) {
2016-06-30 13:55:44 -04:00
ajax("/admin/backups/readonly", {
2014-02-12 23:35:46 -05:00
type: "PUT",
data: { enable },
}).then(() => this.site.set("isReadOnly", enable));
},
2014-02-12 23:35:46 -05:00
});