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

76 lines
2.3 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"),
2014-02-22 08:41:01 +08:00
uploadText: function() { return I18n.t("admin.backups.upload.text"); }.property(),
2014-02-13 12:35:46 +08:00
2014-02-22 08:41:01 +08:00
readOnlyModeDisabled: Em.computed.alias("status.isOperationRunning"),
2014-02-13 12:35:46 +08:00
2014-02-22 08:41:01 +08:00
restoreDisabled: Em.computed.alias("status.restoreDisabled"),
2014-02-13 12:35:46 +08:00
restoreTitle: function() {
2014-02-14 01:19:04 +08:00
if (!Discourse.SiteSettings.allow_restore) {
2014-02-13 12:35:46 +08:00
return I18n.t("admin.backups.operations.restore.is_disabled");
} else if (this.get("status.isOperationRunning")) {
return I18n.t("admin.backups.operation_already_running");
} else {
return I18n.t("admin.backups.operations.restore.title");
}
}.property("status.isOperationRunning"),
2014-02-22 08:41:01 +08:00
destroyDisabled: Em.computed.alias("status.isOperationRunning"),
2014-02-13 12:35:46 +08:00
destroyTitle: function() {
if (this.get("status.isOperationRunning")) {
return I18n.t("admin.backups.operation_already_running");
} else {
return I18n.t("admin.backups.operations.destroy.title");
}
}.property("status.isOperationRunning"),
readOnlyModeTitle: function() { return this._readOnlyModeI18n("title"); }.property("Discourse.isReadOnly"),
readOnlyModeText: function() { return this._readOnlyModeI18n("text"); }.property("Discourse.isReadOnly"),
_readOnlyModeI18n: function(value) {
var action = Discourse.get("isReadOnly") ? "disable" : "enable";
return I18n.t("admin.backups.read_only." + action + "." + value);
},
actions: {
/**
Toggle read-only mode
@method toggleReadOnlyMode
**/
toggleReadOnlyMode: function() {
var self = this;
if (!Discourse.get("isReadOnly")) {
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
},
_toggleReadOnlyMode: function(enable) {
Discourse.ajax("/admin/backups/readonly", {
type: "PUT",
data: { enable: enable }
}).then(function() {
Discourse.set("isReadOnly", enable);
});
}
2014-02-13 12:35:46 +08:00
});