Stop All: include named servers

This commit is contained in:
Simon Li
2024-10-27 22:15:42 +00:00
parent 95a7c97052
commit e9002bfec9
2 changed files with 15 additions and 4 deletions

View File

@@ -508,7 +508,7 @@ const ServerDashboard = (props) => {
variant="primary" variant="primary"
className="start-all" className="start-all"
data-testid="start-all" data-testid="start-all"
title="start all servers on the current page" title="Start all default servers on the current page"
onClick={() => { onClick={() => {
Promise.all(startAll(user_data.map((e) => e.name))) Promise.all(startAll(user_data.map((e) => e.name)))
.then((res) => { .then((res) => {
@@ -539,11 +539,12 @@ const ServerDashboard = (props) => {
variant="danger" variant="danger"
className="stop-all" className="stop-all"
data-testid="stop-all" data-testid="stop-all"
title="stop all servers on the current page" title="Stop all servers including named servers on the current page"
onClick={() => { onClick={() => {
Promise.all(stopAll(user_data.map((e) => e.name))) Promise.all(stopAll(user_data.map((e) => e.name)))
.then((res) => { .then((res) => {
let failedServers = res.filter((e) => !e.ok); // Array of arrays of servers for each user
let failedServers = res.flat().filter((e) => !e.ok);
if (failedServers.length > 0) { if (failedServers.length > 0) {
setErrorAlert( setErrorAlert(
`Failed to stop ${failedServers.length} ${ `Failed to stop ${failedServers.length} ${

View File

@@ -30,7 +30,17 @@ const withAPI = withProps(() => ({
startAll: (names) => startAll: (names) =>
names.map((e) => jhapiRequest("/users/" + e + "/server", "POST")), names.map((e) => jhapiRequest("/users/" + e + "/server", "POST")),
stopAll: (names) => stopAll: (names) =>
names.map((e) => jhapiRequest("/users/" + e + "/server", "DELETE")), names.map((name) =>
jhapiRequest("/users/" + name, "GET")
.then((data) => data.json())
.then((data) =>
Promise.all(
Object.keys(data.servers).map((server) =>
jhapiRequest("/users/" + name + "/servers/" + server, "DELETE"),
),
),
),
),
addToGroup: (users, groupname) => addToGroup: (users, groupname) =>
jhapiRequest("/groups/" + groupname + "/users", "POST", { users }), jhapiRequest("/groups/" + groupname + "/users", "POST", { users }),
updateProp: (propobject, groupname) => updateProp: (propobject, groupname) =>