2018-06-15 23:03:24 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2016-10-21 01:26:41 +08:00
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
|
|
|
adminBackups: Ember.inject.controller(),
|
2018-06-15 23:03:24 +08:00
|
|
|
status: Ember.computed.alias("adminBackups.model"),
|
2014-02-13 12:35:46 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
uploadLabel: function() {
|
|
|
|
return I18n.t("admin.backups.upload.label");
|
|
|
|
}.property(),
|
2015-03-27 01:05:27 +08:00
|
|
|
|
2014-02-13 12:35:46 +08:00
|
|
|
restoreTitle: function() {
|
2018-06-15 23:03:24 +08:00
|
|
|
if (!this.get("status.allowRestore")) {
|
2015-03-27 01:05:27 +08:00
|
|
|
return "admin.backups.operations.restore.is_disabled";
|
2016-10-21 01:26:41 +08:00
|
|
|
} else if (this.get("status.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
|
|
|
}
|
2016-10-21 01:26:41 +08:00
|
|
|
}.property("status.{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;
|
2014-09-12 03:25:30 +08:00
|
|
|
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) {
|
2014-02-13 23:56:23 +08:00
|
|
|
if (confirmed) {
|
|
|
|
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
|
|
|
self._toggleReadOnlyMode(true);
|
|
|
|
}
|
2014-02-13 12:35:46 +08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this._toggleReadOnlyMode(false);
|
|
|
|
}
|
2016-11-12 05:31:08 +08:00
|
|
|
},
|
2014-02-13 12:35:46 +08:00
|
|
|
|
2016-11-12 05:31:08 +08:00
|
|
|
download(backup) {
|
2018-06-15 23:03:24 +08:00
|
|
|
let link = backup.get("filename");
|
|
|
|
ajax("/admin/backups/" + link, { type: "PUT" }).then(() => {
|
2017-03-01 23:26:18 +08:00
|
|
|
bootbox.alert(I18n.t("admin.backups.operations.download.alert"));
|
|
|
|
});
|
2016-11-12 05:31:08 +08:00
|
|
|
}
|
2014-02-13 12:35:46 +08:00
|
|
|
},
|
|
|
|
|
2015-03-27 01:05:27 +08:00
|
|
|
_toggleReadOnlyMode(enable) {
|
2014-09-12 03:25:30 +08:00
|
|
|
var site = this.site;
|
2016-07-01 01:55:44 +08:00
|
|
|
ajax("/admin/backups/readonly", {
|
2014-02-13 12:35:46 +08:00
|
|
|
type: "PUT",
|
|
|
|
data: { enable: enable }
|
2017-03-01 23:26:18 +08:00
|
|
|
}).then(() => {
|
2014-09-12 03:25:30 +08:00
|
|
|
site.set("isReadOnly", enable);
|
2014-02-13 12:35:46 +08:00
|
|
|
});
|
2014-03-19 09:21:10 +08:00
|
|
|
}
|
2014-02-13 12:35:46 +08:00
|
|
|
});
|