mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 10:21:37 +00:00
add stop button
This commit is contained in:
parent
33594f2dba
commit
165212fed2
@ -1,5 +1,5 @@
|
|||||||
<div
|
<div
|
||||||
{{ $attributes->merge(["class" => "h-[500px] w-full overflow-auto whitespace-pre-line rounded-md border border-gray-200 bg-black p-5 text-gray-50 dark:border-gray-700"]) }}
|
{{ $attributes->merge(["class" => "relative h-[500px] w-full overflow-auto whitespace-pre-line rounded-md border border-gray-200 bg-black p-5 text-gray-50 dark:border-gray-700"]) }}
|
||||||
>
|
>
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
<div
|
<div
|
||||||
x-data="{
|
x-data="{
|
||||||
user: '{{ $server->ssh_user }}',
|
user: '{{ $server->ssh_user }}',
|
||||||
|
running: false,
|
||||||
command: '',
|
command: '',
|
||||||
output: '',
|
output: '',
|
||||||
runUrl: '{{ route("servers.console.run", ["server" => $server]) }}',
|
runUrl: '{{ route("servers.console.run", ["server" => $server]) }}',
|
||||||
async run() {
|
async run() {
|
||||||
|
this.running = true
|
||||||
this.output = 'Running...\n'
|
this.output = 'Running...\n'
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -26,6 +28,11 @@
|
|||||||
const decoder = new TextDecoder('utf-8')
|
const decoder = new TextDecoder('utf-8')
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
if (! this.running) {
|
||||||
|
reader.cancel()
|
||||||
|
this.output += '\nStopped!'
|
||||||
|
break
|
||||||
|
}
|
||||||
const { value, done } = await reader.read()
|
const { value, done } = await reader.read()
|
||||||
if (done) break
|
if (done) break
|
||||||
|
|
||||||
@ -37,6 +44,10 @@
|
|||||||
document.getElementById('console-output').scrollHeight
|
document.getElementById('console-output').scrollHeight
|
||||||
}
|
}
|
||||||
this.output += '\nDone!'
|
this.output += '\nDone!'
|
||||||
|
this.running = false
|
||||||
|
},
|
||||||
|
stop() {
|
||||||
|
this.running = false
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
@ -69,7 +80,24 @@
|
|||||||
class="mx-1 flex-grow"
|
class="mx-1 flex-grow"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
/>
|
/>
|
||||||
<x-primary-button id="btn-run" x-on:click="run" class="h-[40px]">Run</x-primary-button>
|
<x-secondary-button
|
||||||
|
type="button"
|
||||||
|
id="btn-stop"
|
||||||
|
x-on:click="stop"
|
||||||
|
class="mr-1 h-[40px]"
|
||||||
|
x-bind:disabled="!running"
|
||||||
|
>
|
||||||
|
Stop
|
||||||
|
</x-secondary-button>
|
||||||
|
<x-primary-button
|
||||||
|
type="submit"
|
||||||
|
id="btn-run"
|
||||||
|
x-on:click="run"
|
||||||
|
class="h-[40px]"
|
||||||
|
x-bind:disabled="running || command === ''"
|
||||||
|
>
|
||||||
|
Run
|
||||||
|
</x-primary-button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user