Implement pause/resume commands w/ APOLLO_APP_STATUS envvar

This commit is contained in:
Yukino Song
2025-06-05 01:57:41 +08:00
parent 2795e34e16
commit 3e0cbaf2c2
13 changed files with 312 additions and 119 deletions

View File

@@ -68,6 +68,10 @@
vertical-align: top;
}
.pre-wrap {
white-space: pre-wrap;
}
.dragover {
border-top: 2px solid #ffc400;
}
@@ -87,7 +91,7 @@
<thead>
<tr>
<th scope="col">{{ $t('apps.name') }}</th>
<th scope="col">{{ $t('apps.actions') }}</th>
<th scope="col" class="text-end">{{ $t('apps.actions') }}</th>
</tr>
</thead>
<tbody>
@@ -104,18 +108,18 @@
@drop="onDrop($event, app, i)"
>
<td>{{app.name || ' '}}</td>
<td v-if="app.uuid">
<td v-if="app.uuid" class="text-end">
<button class="btn btn-primary me-2" :disabled="actionDisabled" @click="editApp(app)">
<i class="fas fa-edit"></i> {{ $t('apps.edit') }}
<i class="fas fa-edit"></i>
</button>
<button class="btn btn-danger me-2" :disabled="actionDisabled" @click="showDeleteForm(app)">
<i class="fas fa-trash"></i> {{ $t('apps.delete') }}
<i class="fas fa-trash"></i>
</button>
<button class="btn btn-warning" :disabled="actionDisabled" @click="closeApp()" v-if="currentApp === app.uuid">
<i class="fas fa-stop"></i> {{ $t('apps.close') }}
<i class="fas fa-stop"></i>
</button>
<button class="btn btn-success" :disabled="actionDisabled" @click="launchApp(app)" v-else>
<i class="fas fa-play"></i> {{ $t('apps.launch') }}
<i class="fas fa-play"></i>
</button>
</td>
<td v-else></td>
@@ -193,76 +197,35 @@
</select>
<div class="form-text">{{ $t('config.gamepad_desc') }}</div>
</div>
<!-- allow client commands -->
<Checkbox class="mb-3"
id="clientCommands"
label="apps.allow_client_commands"
desc="apps.allow_client_commands_desc"
v-model="editForm['allow-client-commands']"
default="true"
></Checkbox>
<!-- prep-cmd -->
<Checkbox class="mb-3"
id="excludeGlobalPrep"
label="apps.global_prep_name"
desc="apps.global_prep_desc"
v-model="editForm['exclude-global-prep-cmd']"
default="true"
inverse-values
></Checkbox>
<!-- command -->
<div class="mb-3">
<label for="appName" class="form-label">{{ $t('apps.cmd_prep_name') }}</label>
<div class="form-text">{{ $t('apps.cmd_prep_desc') }}</div>
<div class="d-flex justify-content-start mb-3 mt-3" v-if="editForm['prep-cmd'].length === 0">
<button class="btn btn-success" @click="addPrepCmd(-1)">
<i class="fas fa-plus mr-1"></i> {{ $t('apps.add_cmds') }}
</button>
<label for="appCmd" class="form-label">{{ $t('apps.cmd') }}</label>
<input type="text" class="form-control monospace" id="appCmd" aria-describedby="appCmdHelp"
v-model="editForm.cmd" />
<div id="appCmdHelp" class="form-text">
{{ $t('apps.cmd_desc') }}<br>
<b>{{ $t('_common.note') }}</b> {{ $t('apps.cmd_note') }}
</div>
<table class="table" v-if="editForm['prep-cmd'].length > 0">
<thead>
<tr>
<th scope="col"><i class="fas fa-play"></i> {{ $t('_common.do_cmd') }}</th>
<th scope="col"><i class="fas fa-undo"></i> {{ $t('_common.undo_cmd') }}</th>
<th scope="col" v-if="platform === 'windows'">
<i class="fas fa-shield-alt"></i> {{ $t('_common.run_as') }}
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr v-for="(c, i) in editForm['prep-cmd']">
<td>
<input type="text" class="form-control monospace" v-model="c.do" />
</td>
<td>
<input type="text" class="form-control monospace" v-model="c.undo" />
</td>
<td v-if="platform === 'windows'" class="align-middle">
<Checkbox :id="'prep-cmd-admin-' + i"
label="_common.elevated"
desc=""
v-model="c.elevated"
></Checkbox>
</td>
<td>
<button class="btn btn-danger" @click="editForm['prep-cmd'].splice(i,1)">
<i class="fas fa-trash"></i>
</button>
<button class="btn btn-success" @click="addPrepCmd(i)">
<i class="fas fa-plus"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
<!-- elevation -->
<Checkbox v-if="platform === 'windows'"
class="mb-3"
id="appElevation"
label="_common.run_as"
desc="apps.run_as_desc"
v-model="editForm.elevated"
default="false"
></Checkbox>
<!-- detached -->
<div class="mb-3">
<label for="appName" class="form-label">{{ $t('apps.detached_cmds') }}</label>
<label class="form-label">{{ $t('apps.detached_cmds') }}</label>
<div v-for="(c,i) in editForm.detached" class="d-flex justify-content-between my-2">
<input type="text" v-model="editForm.detached[i]" class="form-control monospace">
<button class="btn btn-danger mx-2" @click="editForm.detached.splice(i,1)">
&times;
<i class="fas fa-trash"></i>
</button>
<button class="btn btn-success" @click="editForm.detached.splice(i, 0, '')">
<i class="fas fa-plus"></i>
</button>
</div>
<div class="d-flex justify-content-between">
@@ -275,16 +238,71 @@
<b>{{ $t('_common.note') }}</b> {{ $t('apps.detached_cmds_note') }}
</div>
</div>
<!-- command -->
<div class="mb-3">
<label for="appCmd" class="form-label">{{ $t('apps.cmd') }}</label>
<input type="text" class="form-control monospace" id="appCmd" aria-describedby="appCmdHelp"
v-model="editForm.cmd" />
<div id="appCmdHelp" class="form-text">
{{ $t('apps.cmd_desc') }}<br>
<b>{{ $t('_common.note') }}</b> {{ $t('apps.cmd_note') }}
<!-- allow client commands -->
<Checkbox class="mb-3"
id="clientCommands"
label="apps.allow_client_commands"
desc="apps.allow_client_commands_desc"
v-model="editForm['allow-client-commands']"
default="true"
></Checkbox>
<!-- prep and state-cmd -->
<template v-for="type in ['prep', 'state']">
<Checkbox class="mb-3"
:id="'excludeGlobal_' + type"
:label="'apps.global_' + type + '_name'"
:desc="'apps.global_' + type + '_desc'"
v-model="editForm['exclude-global-' + type + '-cmd']"
default="true"
inverse-values
></Checkbox>
<div class="mb-3">
<label class="form-label">{{ $t('apps.cmd_' + type + '_name') }}</label>
<div class="form-text pre-wrap">{{ $t('apps.cmd_' + type + '_desc') }}</div>
<table class="table" v-if="editForm[type + '-cmd'].length > 0">
<thead>
<tr>
<th scope="col"><i class="fas fa-play"></i> {{ $t('_common.do_cmd') }}</th>
<th scope="col"><i class="fas fa-undo"></i> {{ $t('_common.undo_cmd') }}</th>
<th scope="col" v-if="platform === 'windows'">
<i class="fas fa-shield-alt"></i> {{ $t('_common.run_as') }}
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr v-for="(c, i) in editForm[type + '-cmd']">
<td>
<input type="text" class="form-control monospace" v-model="c.do" />
</td>
<td>
<input type="text" class="form-control monospace" v-model="c.undo" />
</td>
<td v-if="platform === 'windows'" class="align-middle">
<Checkbox :id="type + '-cmd-admin-' + i"
label="_common.elevated"
desc=""
v-model="c.elevated"
></Checkbox>
</td>
<td class="text-end">
<button class="btn btn-danger mx-2" @click="editForm[type + '-cmd'].splice(i,1)">
<i class="fas fa-trash"></i>
</button>
<button class="btn btn-success" @click="addCmd(editForm[type + '-cmd'], i)">
<i class="fas fa-plus"></i>
</button>
</td>
</tr>
</tbody>
</table>
<div class="d-flex justify-content-start mb-3 mt-3">
<button class="btn btn-success" @click="addCmd(editForm[type + '-cmd'], -1)">
<i class="fas fa-plus mr-1"></i> {{ $t('apps.add_cmds') }}
</button>
</div>
</div>
</div>
</template>
<!-- working dir -->
<div class="mb-3">
<label for="appWorkingDir" class="form-label">{{ $t('apps.working_dir') }}</label>
@@ -299,15 +317,6 @@
v-model="editForm.output" />
<div id="appOutputHelp" class="form-text">{{ $t('apps.output_desc') }}</div>
</div>
<!-- elevation -->
<Checkbox v-if="platform === 'windows'"
class="mb-3"
id="appElevation"
label="_common.run_as"
desc="apps.run_as_desc"
v-model="editForm.elevated"
default="false"
></Checkbox>
<!-- auto-detach -->
<Checkbox class="mb-3"
id="autoDetach"
@@ -392,6 +401,10 @@
<td style="font-family: monospace">APOLLO_APP_UUID</td>
<td>{{ $t('apps.env_app_uuid') }}</td>
</tr>
<tr>
<td style="font-family: monospace">APOLLO_APP_STATUS</td>
<td>{{ $t('apps.env_app_status') }}</td>
</tr>
<tr>
<td style="font-family: monospace">APOLLO_CLIENT_UUID</td>
<td>{{ $t('apps.env_client_uuid') }}</td>
@@ -499,11 +512,13 @@
"output": "",
"cmd": "",
"exclude-global-prep-cmd": false,
"exclude-global-state-cmd": false,
"elevated": false,
"auto-detach": true,
"wait-all": true,
"exit-timeout": 5,
"prep-cmd": [],
"state-cmd": [],
"detached": [],
"image-path": "",
"scale-factor": 100,
@@ -729,7 +744,7 @@
});
}
},
addPrepCmd(idx) {
addCmd(cmdArr, idx) {
const template = {
do: "",
undo: ""
@@ -739,7 +754,11 @@
template.elevated = false;
}
this.editForm["prep-cmd"].splice(idx + 1, 0, template);
if (idx < 0) {
cmdArr.push(template);
} else {
cmdArr.splice(idx, 0, template);
}
},
showCoverFinder($event) {
this.coverCandidates = [];