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

52 lines
1.5 KiB
Plaintext
Raw Normal View History

export default Ember.ArrayController.extend({
2014-02-13 12:35:46 +08:00
needs: ["adminBackups"],
status: Em.computed.alias("controllers.adminBackups"),
isOperationRunning: Ember.computed.alias("status.model.isOperationRunning"),
restoreDisabled: Ember.computed.alias("status.model.restoreDisabled"),
2014-02-13 12:35:46 +08:00
2015-03-27 01:05:27 +08:00
uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(),
2014-02-13 12:35:46 +08:00
restoreTitle: function() {
if (!this.get('status.model.allowRestore')) {
2015-03-27 01:05:27 +08:00
return "admin.backups.operations.restore.is_disabled";
} else if (this.get("status.model.isOperationRunning")) {
2015-03-27 01:05:27 +08:00
return "admin.backups.operations.is_running";
2014-02-13 12:35:46 +08:00
} else {
2015-03-27 01:05:27 +08:00
return "admin.backups.operations.restore.title";
2014-02-13 12:35:46 +08:00
}
}.property("status.model.{allowRestore,isOperationRunning}"),
2014-02-13 12:35:46 +08:00
actions: {
2015-03-27 01:05:27 +08:00
toggleReadOnlyMode() {
2014-02-13 12:35:46 +08:00
var self = this;
if (!this.site.get("isReadOnly")) {
2014-02-13 12:35:46 +08:00
bootbox.confirm(
I18n.t("admin.backups.read_only.enable.confirm"),
I18n.t("no_value"),
I18n.t("yes_value"),
function(confirmed) {
if (confirmed) {
Discourse.User.currentProp("hideReadOnlyAlert", true);
self._toggleReadOnlyMode(true);
}
2014-02-13 12:35:46 +08:00
}
);
} else {
this._toggleReadOnlyMode(false);
}
2014-02-22 08:41:01 +08:00
}
2014-02-13 12:35:46 +08:00
},
2015-03-27 01:05:27 +08:00
_toggleReadOnlyMode(enable) {
var site = this.site;
2014-02-13 12:35:46 +08:00
Discourse.ajax("/admin/backups/readonly", {
type: "PUT",
data: { enable: enable }
}).then(function() {
site.set("isReadOnly", enable);
2014-02-13 12:35:46 +08:00
});
}
2014-02-13 12:35:46 +08:00
});