Allow exporting and import form disabled backends if user request by using -s flag, and disable warning about it.

This commit is contained in:
abdulmohsen
2024-07-09 20:46:05 +03:00
parent d9c3c8b527
commit ec8c1c1a65
3 changed files with 44 additions and 18 deletions

View File

@@ -34,8 +34,9 @@
<div class="field-body">
<div class="field is-grouped-tablet">
<p class="control is-expanded has-icons-left">
<input type="text" class="input" v-model="command"
<input type="text" class="input is-fullwidth" v-model="command"
:placeholder="`system:view ${allEnabled ? 'or $ ls' : ''}`"
list="recent_commands"
autocomplete="off" ref="command_input" @keydown.enter="RunCommand" :disabled="isLoading">
<span class="icon is-left"><i class="fas fa-terminal" :class="{'fa-spin':isLoading}"></i></span>
</p>
@@ -98,6 +99,9 @@
</ul>
</Message>
</div>
<datalist id="recent_commands">
<option v-for="item in executedCommands" :key="item" :value="item"/>
</datalist>
</div>
</template>
@@ -124,6 +128,8 @@ const command = ref(fromCommand)
const isLoading = ref(false)
const outputConsole = ref()
const command_input = ref()
const executedCommands = useStorage('executedCommands', [])
const hasPrefix = computed(() => command.value.startsWith('console') || command.value.startsWith('docker'))
const hasPlaceholder = computed(() => command.value && command.value.match(/\[.*\]/))
const show_page_tips = useStorage('show_page_tips', true)
@@ -157,6 +163,12 @@ const RunCommand = async () => {
return
}
if (userCommand === 'clear_ac') {
executedCommands.value = []
command.value = ''
return
}
const searchParams = new URLSearchParams()
searchParams.append('apikey', api_token.value)
searchParams.append('json', btoa(JSON.stringify({command: userCommand})))
@@ -177,8 +189,9 @@ const RunCommand = async () => {
sse = new EventSource(`${api_url.value}${api_path.value}/system/command/?${searchParams.toString()}`)
terminal.value.writeln(`~ ${userCommand}`)
if ('' !== command.value) {
terminal.value.writeln(`~ ${userCommand}`)
}
sse.addEventListener('data', async e => terminal.value.write(atob(e.data)))
sse.addEventListener('close', async () => finished())
sse.onclose = async () => finished()
@@ -200,6 +213,10 @@ const finished = async () => {
await useRouter().push({path: '/console'})
}
if (!executedCommands.value.includes(command.value)) {
executedCommands.value.push(command.value)
}
command.value = ''
await nextTick()

View File

@@ -175,11 +175,17 @@ class ExportCommand extends Command
continue;
}
if (true !== ag($backend, 'export.enabled')) {
$this->logger->info("SYSTEM: Ignoring '{backend}' as the backend has export disabled.", [
'backend' => $backendName
]);
continue;
if (true !== (bool)ag($backend, 'export.enabled')) {
if ($isCustom) {
$this->logger->warning("SYSTEM: Exporting to a export disabled backend '{backend}' as requested.", [
'backend' => $backendName
]);
} else {
$this->logger->info("SYSTEM: Ignoring '{backend}' as the backend has export disabled.", [
'backend' => $backendName
]);
continue;
}
}
if (!isset($supported[$type])) {
@@ -251,7 +257,7 @@ class ExportCommand extends Command
'backend' => ag($backend, 'name'),
]);
$export[ag($backends, 'name')] = $backend;
$export[ag($backend, 'name')] = $backend;
continue;
}
@@ -263,7 +269,7 @@ class ExportCommand extends Command
]
);
$export[ag($backends, 'name')] = $backend;
$export[ag($backend, 'name')] = $backend;
continue;
}
@@ -452,10 +458,7 @@ class ExportCommand extends Command
}
}
$this->logger->notice("SYSTEM: Sent '{total}' change play state requests.", [
'total' => $total
]);
$this->logger->notice("SYSTEM: Sent '{total}' change play state requests.", ['total' => $total]);
$this->logger->notice("Using WatchState version - '{version}'.", ['version' => getAppVersion()]);
} else {
$this->logger->notice('SYSTEM: No play state changes detected.');

View File

@@ -313,10 +313,16 @@ class ImportCommand extends Command
}
if (true !== $metadata && true !== (bool)ag($backend, 'import.enabled')) {
$this->logger->info("SYSTEM: Ignoring '{backend}' as the backend has import disabled.", [
'backend' => $backendName
]);
continue;
if ($isCustom) {
$this->logger->warning("SYSTEM: Importing from import disabled backend '{backend}' as requested.", [
'backend' => $backendName
]);
} else {
$this->logger->info("SYSTEM: Ignoring '{backend}' as the backend has import disabled.", [
'backend' => $backendName
]);
continue;
}
}
if (!isset($supported[$type])) {