2014-07-22 23:20:45 -04:00
|
|
|
export default Ember.ArrayController.extend({
|
2014-02-12 23:35:46 -05:00
|
|
|
needs: ["adminBackups"],
|
2015-08-17 10:21:23 -04:00
|
|
|
status: Ember.computed.alias("controllers.adminBackups"),
|
2014-02-12 23:35:46 -05:00
|
|
|
|
2015-03-26 13:05:27 -04:00
|
|
|
uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(),
|
|
|
|
|
2014-02-12 23:35:46 -05:00
|
|
|
restoreTitle: function() {
|
2015-08-07 11:34:58 -04:00
|
|
|
if (!this.get('status.model.allowRestore')) {
|
2015-03-26 13:05:27 -04:00
|
|
|
return "admin.backups.operations.restore.is_disabled";
|
2015-08-07 11:34:58 -04:00
|
|
|
} else if (this.get("status.model.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
|
|
|
}
|
2015-08-07 11:34:58 -04:00
|
|
|
}.property("status.model.{allowRestore,isOperationRunning}"),
|
2014-02-12 23:35:46 -05:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
|
2015-03-26 13:05:27 -04:00
|
|
|
toggleReadOnlyMode() {
|
2014-02-12 23:35:46 -05:00
|
|
|
var self = this;
|
2014-09-11 15:25:30 -04:00
|
|
|
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"),
|
|
|
|
function(confirmed) {
|
2014-02-13 10:56:23 -05:00
|
|
|
if (confirmed) {
|
|
|
|
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
|
|
|
self._toggleReadOnlyMode(true);
|
|
|
|
}
|
2014-02-12 23:35:46 -05:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this._toggleReadOnlyMode(false);
|
|
|
|
}
|
2014-02-21 19:41:01 -05:00
|
|
|
}
|
2014-02-12 23:35:46 -05:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2015-03-26 13:05:27 -04:00
|
|
|
_toggleReadOnlyMode(enable) {
|
2014-09-11 15:25:30 -04:00
|
|
|
var site = this.site;
|
2014-02-12 23:35:46 -05:00
|
|
|
Discourse.ajax("/admin/backups/readonly", {
|
|
|
|
type: "PUT",
|
|
|
|
data: { enable: enable }
|
|
|
|
}).then(function() {
|
2014-09-11 15:25:30 -04:00
|
|
|
site.set("isReadOnly", enable);
|
2014-02-12 23:35:46 -05:00
|
|
|
});
|
2014-03-18 21:21:10 -04:00
|
|
|
}
|
2014-02-12 23:35:46 -05:00
|
|
|
});
|