jingrow.pages["backups"].on_page_load = function (wrapper) {
	var page = jingrow.ui.make_app_page({
		parent: wrapper,
		title: __("Download Backups"),
		single_column: true,
	});

	page.add_inner_button(__("Set Number of Backups"), function () {
		jingrow.set_route("Form", "System Settings").then(() => {
			cur_frm.scroll_to_field("backup_limit");
		});
	});

	page.add_inner_button(__("Download Files Backup"), function () {
		jingrow.call({
			method: "jingrow.desk.page.backups.backups.schedule_files_backup",
			args: { user_email: jingrow.session.user_email },
		});
	});

	page.add_inner_button(__("Get Backup Encryption Key"), function () {
		if (jingrow.user.has_role("System Manager")) {
			jingrow.verify_password(function () {
				jingrow.call({
					method: "jingrow.utils.backups.get_backup_encryption_key",
					callback: function (r) {
						jingrow.msgprint({
							title: __("Backup Encryption Key"),
							message: __(r.message),
							indicator: "blue",
						});
					},
				});
			});
		} else {
			jingrow.msgprint({
				title: __("Error"),
				message: __("System Manager privileges required."),
				indicator: "red",
			});
		}
	});

	jingrow.breadcrumbs.add("Setup");

	$(jingrow.render_template("backups")).appendTo(page.body.addClass("no-border"));
};
