Импорт пресета не терял моды: полный набор и активный профиль
В пакете сборки рядом с комплектом сервера лежит пресет песочницы одиночной игры. Наборы сортировались по имени, и пресет песочницы часто оказывался первым — панель предлагала его по умолчанию, а модов и карт в нём нет. Теперь первым идёт набор с конфигом сервера, а в списке выбора видно, что внутри каждого. Вкладки показывают активный профиль, поэтому импорт в новый выглядел так, будто ничего не подтянулось. Появилась галочка «Сделать этот профиль активным»; если её снять, панель говорит, где искать импортированное. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+22
-3
@@ -1664,7 +1664,14 @@ function renderPresetSets() {
|
||||
|
||||
const picker = $("#preset-set");
|
||||
picker.innerHTML = presetSets
|
||||
.map((set) => `<option value="${escapeHTML(set.name)}">${escapeHTML(set.name)}</option>`)
|
||||
.map((set) => {
|
||||
// Подпись сразу говорит, что в наборе: пресет песочницы без конфига
|
||||
// сервера не принесёт ни модов, ни карт.
|
||||
const note = set.has_ini
|
||||
? t("import.setServer", { mods: set.mods })
|
||||
: t("import.setSandbox");
|
||||
return `<option value="${escapeHTML(set.name)}">${escapeHTML(`${set.name} — ${note}`)}</option>`;
|
||||
})
|
||||
.join("");
|
||||
// Выбор нужен, только когда в архиве несколько наборов.
|
||||
$("#preset-pick").hidden = presetSets.length < 2;
|
||||
@@ -1736,7 +1743,11 @@ $("#btn-preset-import").addEventListener("click", async () => {
|
||||
|
||||
const existing = $("#preset-target").value === "existing";
|
||||
const profile = existing ? $("#preset-profile").value : $("#preset-id").value.trim();
|
||||
if (!confirm(t("import.confirm", { name: set.name, profile }))) return;
|
||||
const activate = $("#preset-activate").checked;
|
||||
// Смена активного профиля — заметное действие: о нём предупреждаем заранее.
|
||||
const question = t("import.confirm", { name: set.name, profile })
|
||||
+ (activate && profile !== profiles.active ? "\n\n" + t("import.confirmActivate", { profile }) : "");
|
||||
if (!confirm(question)) return;
|
||||
|
||||
const form = new FormData();
|
||||
form.append("file", file);
|
||||
@@ -1748,6 +1759,7 @@ $("#btn-preset-import").addEventListener("click", async () => {
|
||||
.filter((box) => box.checked)
|
||||
.map((box) => box.dataset.keep)
|
||||
.join(","));
|
||||
form.append("activate", activate ? "1" : "");
|
||||
|
||||
const button = $("#btn-preset-import");
|
||||
button.disabled = true;
|
||||
@@ -1760,10 +1772,17 @@ $("#btn-preset-import").addEventListener("click", async () => {
|
||||
if (result.applied !== undefined) {
|
||||
toast(t("import.applied", { applied: result.applied, skipped: result.skipped }));
|
||||
}
|
||||
if (result.switched) {
|
||||
toast(t("import.switched", { profile: result.profile }));
|
||||
} else if (result.profile !== profiles.active) {
|
||||
// Вкладки показывают активный профиль: без этого импорт выглядит так,
|
||||
// будто моды и настройки никуда не попали.
|
||||
toast(t("import.notActive", { profile: result.profile }));
|
||||
}
|
||||
$("#preset-file").value = "";
|
||||
$("#preset-details").hidden = true;
|
||||
await loadProfiles();
|
||||
// Импортированный профиль мог оказаться активным — вкладки показывают
|
||||
// Импортированный профиль мог стать активным — вкладки показывают
|
||||
// именно его конфиг.
|
||||
loadTab(currentTab);
|
||||
} catch (error) {
|
||||
|
||||
@@ -303,6 +303,8 @@ const STRINGS = {
|
||||
"import.fileHint": "ZIP-пакет сборки или пресет песочницы .cfg. Из архива панель возьмёт серверный .ini, настройки песочницы и точки появления, остальное пропустит.",
|
||||
"import.reading": "Читаю архив…",
|
||||
"import.set": "Набор из архива",
|
||||
"import.setServer": "конфиг сервера, модов: {mods}",
|
||||
"import.setSandbox": "только пресет песочницы, без модов",
|
||||
"import.server": "Сервер: {name}",
|
||||
"import.mods": "Моды: {mods} · пакеты мастерской: {workshop}",
|
||||
"import.maps": "Карты: {maps}",
|
||||
@@ -320,6 +322,11 @@ const STRINGS = {
|
||||
"import.keepPorts": "Порты и RCON",
|
||||
"import.keepAccess": "Пароль сервера и объявляемый IP",
|
||||
"import.keepIdentity": "Имя и описание сервера",
|
||||
"import.activate": "Сделать этот профиль активным",
|
||||
"import.confirmActivate": "Профиль {profile} станет активным — панель и запуск переключатся на него.",
|
||||
"import.activateHint": "Вкладки «Моды» и «Настройки» показывают активный профиль. Без переключения импортированные моды там не появятся.",
|
||||
"import.switched": "Активный профиль: {profile}",
|
||||
"import.notActive": "Профиль {profile} не активен — импортированные моды и настройки видны только под ним. Переключиться можно на вкладке «Профили».",
|
||||
"import.apply": "Импортировать",
|
||||
"import.noFile": "Выберите ZIP-пакет сборки",
|
||||
"import.confirm": "Импортировать набор «{name}» в профиль {profile}?\n\nКонфиги профиля будут заменены, прежние останутся рядом с расширением .bak.",
|
||||
@@ -638,6 +645,8 @@ const STRINGS = {
|
||||
"import.fileHint": "A collection ZIP package or a .cfg sandbox preset. From the archive the panel takes the server .ini, the sandbox settings and the spawn regions, and skips the rest.",
|
||||
"import.reading": "Reading the archive…",
|
||||
"import.set": "Preset from the archive",
|
||||
"import.setServer": "server config, mods: {mods}",
|
||||
"import.setSandbox": "sandbox preset only, no mods",
|
||||
"import.server": "Server: {name}",
|
||||
"import.mods": "Mods: {mods} · Workshop items: {workshop}",
|
||||
"import.maps": "Maps: {maps}",
|
||||
@@ -655,6 +664,11 @@ const STRINGS = {
|
||||
"import.keepPorts": "Ports and RCON",
|
||||
"import.keepAccess": "Server password and announced IP",
|
||||
"import.keepIdentity": "Server name and description",
|
||||
"import.activate": "Make this profile active",
|
||||
"import.confirmActivate": "The profile {profile} will become active — the panel and the server start will switch to it.",
|
||||
"import.activateHint": "The Mods and Settings tabs show the active profile. Without switching, the imported mods will not appear there.",
|
||||
"import.switched": "Active profile: {profile}",
|
||||
"import.notActive": "The profile {profile} is not active — the imported mods and settings are only visible under it. You can switch on the Profiles tab.",
|
||||
"import.apply": "Import",
|
||||
"import.noFile": "Choose a collection ZIP package",
|
||||
"import.confirm": "Import the preset \"{name}\" into the profile {profile}?\n\nThe profile configs will be replaced, the previous ones stay next to them with a .bak extension.",
|
||||
|
||||
@@ -306,6 +306,10 @@
|
||||
<span data-i18n="import.keepIdentity"></span></label>
|
||||
</div>
|
||||
|
||||
<label class="checkbox"><input type="checkbox" id="preset-activate" checked>
|
||||
<span data-i18n="import.activate"></span></label>
|
||||
<div class="hint" data-i18n="import.activateHint"></div>
|
||||
|
||||
<button class="btn btn-primary" id="btn-preset-import" data-i18n="import.apply"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user