added remove and copy button
This commit is contained in:
@@ -207,11 +207,14 @@ def restart_ac_server() -> tuple[bool, str]:
|
||||
sysbus = dbus.SystemBus()
|
||||
systemd1 = sysbus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1')
|
||||
manager = dbus.Interface(systemd1, 'org.freedesktop.systemd1.Manager')
|
||||
job = manager.RestartUnit('assetto-corsa-server.service', 'replace')
|
||||
if job:
|
||||
return True, "Successfully restarted assetto-corsa-server.service"
|
||||
else:
|
||||
return False, "Failed to restart assetto-corsa-server.service"
|
||||
try:
|
||||
job = manager.RestartUnit('assetto-corsa-server.service', 'replace')
|
||||
if job:
|
||||
return True, "Successfully restarted assetto-corsa-server.service"
|
||||
else:
|
||||
return False, "Failed to restart assetto-corsa-server.service"
|
||||
except dbus.DBusException as e:
|
||||
return False, f"Could not restart server: {str(e)}"
|
||||
|
||||
server = HTTPServer(("0.0.0.0", 10303), Handler)
|
||||
print("Server running on port 10303")
|
||||
|
||||
@@ -2,10 +2,10 @@ import os
|
||||
|
||||
CONFIG_FILE = "server_cfg.ini"
|
||||
ENTRY_LIST_FILE = "entry_list.ini"
|
||||
CONTENT_FOLDER = "/home/sem/assetto-corsa/content"
|
||||
CONFIG_PATH = "/home/sem/assetto-corsa/cfg"
|
||||
# CONTENT_FOLDER = "./content"
|
||||
# CONFIG_PATH = "./cfg"
|
||||
# CONTENT_FOLDER = "/home/sem/assetto-corsa/content"
|
||||
# CONFIG_PATH = "/home/sem/assetto-corsa/cfg"
|
||||
CONTENT_FOLDER = "./content"
|
||||
CONFIG_PATH = "./cfg"
|
||||
|
||||
CARS_FOLDER = os.path.join(CONTENT_FOLDER, "cars")
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import os
|
||||
|
||||
CONFIG_FILE = "server_cfg.ini"
|
||||
CONTENT_FOLDER = "/home/sem/assetto-corsa/content"
|
||||
CONFIG_PATH = "/home/sem/assetto-corsa/cfg"
|
||||
# CONTENT_FOLDER = "./content"
|
||||
# CONFIG_PATH = "./cfg"
|
||||
# CONTENT_FOLDER = "/home/sem/assetto-corsa/content"
|
||||
# CONFIG_PATH = "/home/sem/assetto-corsa/cfg"
|
||||
CONTENT_FOLDER = "./content"
|
||||
CONFIG_PATH = "./cfg"
|
||||
|
||||
TRACKS_FOLDER = os.path.join(CONTENT_FOLDER, "tracks")
|
||||
|
||||
|
||||
30
index.html
30
index.html
@@ -135,7 +135,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function addCar() {
|
||||
async function addCar(preselectedCar = null, preselectedSkin = null) {
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.style.marginTop = "12px";
|
||||
wrapper.className = "car-block";
|
||||
@@ -147,6 +147,18 @@
|
||||
skinSelect.className = "skin-select";
|
||||
skinSelect.style.marginLeft = "10px";
|
||||
|
||||
const delBtn = document.createElement("button");
|
||||
delBtn.textContent = "Remove";
|
||||
delBtn.style.marginLeft = "10px";
|
||||
delBtn.onclick = () => wrapper.remove();
|
||||
|
||||
const copyBtn = document.createElement("button");
|
||||
copyBtn.textContent = "Copy";
|
||||
copyBtn.style.marginLeft = "10px";
|
||||
copyBtn.onclick = () => {
|
||||
addCar(carSelect.value, skinSelect.value);
|
||||
};
|
||||
|
||||
const img = document.createElement("img");
|
||||
img.className = "skin-preview";
|
||||
img.style.display = "block";
|
||||
@@ -155,6 +167,8 @@
|
||||
|
||||
wrapper.appendChild(carSelect);
|
||||
wrapper.appendChild(skinSelect);
|
||||
wrapper.appendChild(copyBtn);
|
||||
wrapper.appendChild(delBtn);
|
||||
wrapper.appendChild(img);
|
||||
carList.appendChild(wrapper);
|
||||
|
||||
@@ -215,8 +229,18 @@
|
||||
}
|
||||
});
|
||||
|
||||
// immediately load skins for first car
|
||||
loadSkins(cars[0].name);
|
||||
if (preselectedCar) {
|
||||
carSelect.value = preselectedCar;
|
||||
loadSkins(preselectedCar);
|
||||
if (preselectedSkin) {
|
||||
skinSelect.value = preselectedSkin;
|
||||
const car = cars.find(c => c.name === preselectedCar);
|
||||
const cfg = car.skins.find(x => x.name === preselectedSkin);
|
||||
updateImage(cfg ? cfg.image : "");
|
||||
}
|
||||
} else {
|
||||
loadSkins(cars[0].name);
|
||||
}
|
||||
}
|
||||
|
||||
addCarBtn.addEventListener("click", addCar);
|
||||
|
||||
Reference in New Issue
Block a user