Skip to content

Commit

Permalink
The most simple cli history there is
Browse files Browse the repository at this point in the history
  • Loading branch information
olle committed Mar 24, 2023
1 parent 8b51b89 commit 2d370a1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ui-frontend/src/components/PageCli.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<article>
<h1>Query Command Line Interface</h1>
<form v-on:submit.prevent="publish">
<form v-on:submit.prevent="publish" v-on:keyup="peek">
<div class="input-wrapper">
<label>&gt;</label>
<input
Expand All @@ -24,6 +24,7 @@ import { publishQuery } from "../api";
import IconSpinner from "./IconSpinner.vue";
const history = ref([]);
const query = ref("");
const response = ref(`# ${new Date()}`);
const spinner = ref(false);
Expand All @@ -39,8 +40,22 @@ function reset(value) {
document.querySelector("input").focus();
}
function peek(ev) {
var code = ev.keyCode;
if (code === 38) {
var lastQ = history.value.shift();
query.value = lastQ;
history.value.push(lastQ);
} else if (code === 40) {
query.value = "";
}
}
function publish() {
let q = query.value;
if (q !== "") {
history.value.unshift(q);
}
setTimeout(() => {
spinner.value = true;
response.value = "...";
Expand Down

0 comments on commit 2d370a1

Please sign in to comment.