2023-10-10 19:38:59 +01:00
|
|
|
import Controller, { inject as controller } from "@ember/controller";
|
2023-03-15 09:42:12 +00:00
|
|
|
import { action } from "@ember/object";
|
2019-10-30 15:28:29 -05:00
|
|
|
import { alias, equal } from "@ember/object/computed";
|
2024-03-06 18:05:11 +01:00
|
|
|
import { service } from "@ember/service";
|
2016-06-30 13:55:44 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2024-08-20 09:59:43 +10:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2023-10-10 19:38:59 +01:00
|
|
|
import { i18n, setting } from "discourse/lib/computed";
|
2024-08-21 13:23:24 +10:00
|
|
|
import getURL from "discourse-common/lib/get-url";
|
2020-01-16 18:56:53 +01:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2023-10-18 03:07:09 -07:00
|
|
|
import I18n from "discourse-i18n";
|
2016-10-20 13:26:41 -04:00
|
|
|
|
2023-03-15 09:42:12 +00:00
|
|
|
export default class AdminBackupsIndexController extends Controller {
|
|
|
|
@service dialog;
|
|
|
|
@controller adminBackups;
|
|
|
|
|
|
|
|
@alias("adminBackups.model") status;
|
|
|
|
@i18n("admin.backups.upload.label") uploadLabel;
|
|
|
|
@setting("backup_location") backupLocation;
|
|
|
|
@equal("backupLocation", "local") localBackupStorage;
|
2014-02-12 20:35:46 -08:00
|
|
|
|
2024-08-21 13:23:24 +10:00
|
|
|
get restoreSettingsUrl() {
|
|
|
|
return getURL("/admin/backups/settings?filter=allow_restore");
|
|
|
|
}
|
|
|
|
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("status.allowRestore", "status.isOperationRunning")
|
2019-01-23 17:40:24 +01:00
|
|
|
restoreTitle(allowRestore, isOperationRunning) {
|
|
|
|
if (!allowRestore) {
|
2015-03-26 18:05:27 +01:00
|
|
|
return "admin.backups.operations.restore.is_disabled";
|
2019-01-23 17:40:24 +01:00
|
|
|
} else if (isOperationRunning) {
|
2015-03-26 18:05:27 +01:00
|
|
|
return "admin.backups.operations.is_running";
|
2014-02-12 20:35:46 -08:00
|
|
|
} else {
|
2015-03-26 18:05:27 +01:00
|
|
|
return "admin.backups.operations.restore.title";
|
2014-02-12 20:35:46 -08:00
|
|
|
}
|
2023-03-15 09:42:12 +00:00
|
|
|
}
|
2014-02-12 20:35:46 -08:00
|
|
|
|
2023-03-15 09:42:12 +00:00
|
|
|
@action
|
2024-08-20 09:59:43 +10:00
|
|
|
async download(backup) {
|
|
|
|
try {
|
|
|
|
await ajax(`/admin/backups/${backup.filename}`, { type: "PUT" });
|
|
|
|
this.dialog.alert(I18n.t("admin.backups.operations.download.alert"));
|
|
|
|
} catch (err) {
|
|
|
|
popupAjaxError(err);
|
2023-03-15 09:42:12 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-12 20:35:46 -08:00
|
|
|
|
2024-08-20 09:59:43 +10:00
|
|
|
@discourseComputed("status.isOperationRunning")
|
|
|
|
deleteTitle() {
|
|
|
|
if (this.status.isOperationRunning) {
|
|
|
|
return "admin.backups.operations.is_running";
|
|
|
|
}
|
2014-02-12 20:35:46 -08:00
|
|
|
|
2024-08-20 09:59:43 +10:00
|
|
|
return "admin.backups.operations.destroy.title";
|
2023-03-15 09:42:12 +00:00
|
|
|
}
|
|
|
|
}
|