Add legacy ordering support toggle for each client

This commit is contained in:
Yukino Song
2025-05-28 22:47:51 +08:00
parent 251ae915a6
commit 2f89d85fca
7 changed files with 94 additions and 17 deletions

View File

@@ -105,6 +105,15 @@
</div>
</div>
<!-- Enable legacy ordering -->
<Checkbox class="mb-3"
id="enable_legacy_ordering"
label="pin.enable_legacy_ordering"
desc="pin.enable_legacy_ordering_desc"
v-model="client.editEnableLegacyOrdering"
default="true"
></Checkbox>
<!-- Display Mode Override -->
<div class="mb-3 mt-2">
<label for="display_mode_override" class="form-label">{{ $t('pin.display_mode_override') }}</label>
@@ -119,8 +128,17 @@
<div class="form-text">{{ $t('pin.display_mode_override_desc') }} <a href="https://github.com/ClassicOldSong/Apollo/wiki/Display-Mode-Override" target="_blank">{{ $t('_common.learn_more') }}</a></div>
</div>
<!-- Allow client commands -->
<Checkbox class="mb-3"
id="allow_client_commands"
label="pin.allow_client_commands"
desc="pin.allow_client_commands_desc"
v-model="client.editAllowClientCommands"
default="true"
></Checkbox>
<!-- connect/disconnect commands -->
<div class="mb-3 mt-2 d-flex flex-column" v-for="cmdType in ['do', 'undo']">
<div class="mb-3 mt-2 d-flex flex-column" v-for="cmdType in ['do', 'undo']" v-if="client.editAllowClientCommands">
<label class="mb-0 orm-label">{{ $t(`pin.client_${cmdType}_cmd`) }}</label>
<div class="form-text">{{ $t(`pin.client_${cmdType}_cmd_desc`) }} <a href="https://github.com/ClassicOldSong/Apollo/wiki/Client-Commands" target="_blank">{{ $t('_common.learn_more') }}</a></div>
<table class="mt-2 table" v-if="client[`edit_${cmdType}`].length > 0">
@@ -185,6 +203,7 @@
import { createApp } from 'vue'
import { initApp } from './init'
import Navbar from './Navbar.vue'
import Checkbox from './Checkbox.vue'
let resetOTPTimeout = null;
const qrContainer = document.createElement('div');
@@ -353,7 +372,8 @@
let app = createApp({
components: {
Navbar
Navbar,
Checkbox
},
inject: ['i18n'],
data,
@@ -497,22 +517,26 @@
if (currentEditingClient) {
this.cancelEdit(currentEditingClient);
}
currentEditingClient = client;
client.editing = true;
client.editPerm = client.perm;
client.editName = client.name;
client.editAllowClientCommands = client.allow_client_commands;
client.editEnableLegacyOrdering = client.enable_legacy_ordering;
client.editDisplayMode = client.display_mode;
client.edit_do = JSON.parse(JSON.stringify(client.do || []));
client.edit_undo = JSON.parse(JSON.stringify(client.undo || []));
currentEditingClient = client;
console.log(client.do, client.undo)
},
cancelEdit(client) {
currentEditingClient = null;
client.editing = false;
client.editPerm = client.perm;
client.editName = client.name;
client.editDisplayMode = client.display_mode;
currentEditingClient = null;
client.editAllowClientCommands = client.allow_client_commands;
client.editEnableLegacyOrdering = client.enable_legacy_ordering;
},
saveClient(client) {
client.editing = false;
@@ -521,6 +545,8 @@
uuid: client.uuid,
name: client.editName,
display_mode: client.editDisplayMode.trim(),
allow_client_commands: client.editAllowClientCommands,
enable_legacy_ordering: client.editEnableLegacyOrdering,
perm: client.editPerm & permissionMapping._all,
do: client.edit_do.reduce((filtered, {cmd: _cmd, elevated}) => {
const cmd = _cmd.trim()
@@ -643,7 +669,17 @@
.then((response) => {
if (response.status && response.named_certs && response.named_certs.length) {
this.platform = response.platform
this.clients = response.named_certs.map(({name, uuid, display_mode, perm, connected, do: _do, undo}) => {
this.clients = response.named_certs.map(({
name,
uuid,
display_mode,
perm,
connected,
do: _do,
undo,
allow_client_commands,
enable_legacy_ordering
}) => {
const permInt = parseInt(perm, 10);
return {
name,
@@ -653,7 +689,9 @@
connected,
editing: false,
do: _do,
undo
undo,
allow_client_commands,
enable_legacy_ordering
}
})
currentEditingClient = null;