Skip to content

Commit

Permalink
lestarch: command raw text input and fixed client validation
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Jul 23, 2021
1 parent 0392617 commit f292d45
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bytearray
calibri
callergraph
callgraph
cargs
cata
cbl
CCB
Expand Down Expand Up @@ -376,6 +377,7 @@ noapp
noqa
nosort
Noto
novalidate
nowait
nowrap
NSPACES
Expand Down Expand Up @@ -556,6 +558,7 @@ telem
testcase
TESTLIST
textarea
textbox
tgz
thead
thtcp
Expand Down
7 changes: 5 additions & 2 deletions src/fprime_gds/flask/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# a restful interface here. It is done this way to be in-tandem with the events and telemetry
# APIs for maintainability.
####
import json
import flask_restful
import flask_restful.reqparse

Expand Down Expand Up @@ -121,8 +122,10 @@ def put(self, command):
self.sender.send_command(command, arg_list)
except fprime.common.models.serialize.type_exceptions.NotInitializedException:
flask_restful.abort(403, message="Did not supply all required arguments.")
except fprime_gds.common.data_types.cmd_data.CommandArgumentException as exc:
flask_restful.abort(403, message=str(exc))
except fprime_gds.common.data_types.cmd_data.CommandArgumentsException as exc:
flask_restful.abort(403, message={"errors": exc.errors})
except KeyError as kerr:
flask_restful.abort(403, message="{} is not a valid command".format(kerr))
# except fprime_gds.common.data_types.cmd_data.CommandArgumentsException as exc:
# flask_restful.abort(403, message="Argument errors occurred", errors=exc.errors)
return {"message": "success"}
2 changes: 2 additions & 0 deletions src/fprime_gds/flask/static/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/fprime_gds/flask/static/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/fprime_gds/flask/static/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/fprime_gds/flask/static/.idea/static.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/fprime_gds/flask/static/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 42 additions & 22 deletions src/fprime_gds/flask/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,45 @@
<div class="fp-flex-repeater">
<div class="fp-flex-header">
<h2>Sending Command: {{ selected.full_name }}</h2>
<div class="form-row">
<div class="form-group col-4">
<label for="mnemonic">Mnemonic</label>
<v-select id="mnemonic" style="flex: 1 1 auto;"
:clearable="false" :searchable="true"
:filterable="true" label="full_name" :options="commandList" v-model="selected">
</v-select>
<form v-on:submit.prevent="sendCommand" class="command-input-form" novalidate>
<div class="form-row">
<div class="form-group col-4">
<label for="mnemonic">Mnemonic</label>
<v-select id="mnemonic" style="flex: 1 1 auto;"
:clearable="false" :searchable="true" @input="validate"
:filterable="true" label="full_name" :options="commandList" v-model="selected"
:class="this.error == '' ? '' : 'is-invalid'" required>
</v-select>
<div class="invalid-feedback">{{ (this.error != '')? this.error : "Supply valid command"}}</div>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col" v-for="argument in selected.args">
<command-argument :argument="argument"></command-argument>
<div class="form-row">
<div class="form-group col" v-for="argument in selected.args">
<command-argument :argument="argument"></command-argument>
</div>
</div>
</div>
<div class="row no-gutters">
<button type="button" class="col-2 btn btn-outline-secondary" v-on:click="clearArguments">Clear Arguments</button>
<button type="button" :disabled="active" class="col-2 btn btn-primary" v-on:click="sendCommand">
Send Command
</button>
<div class="form-row no-gutters">
<button type="button" class="col-2 btn btn-outline-secondary" v-on:click="clearArguments">Clear Arguments</button>
<button type="submit" :disabled="active" class="col-2 btn btn-primary">
Send Command
</button>
</div>
</form>
</div>
<command-text :selected="selected"></command-text>
</div>
</template>
<!-- Command Text:
Input textbox for entering in a command
-->
<template id="command-text-template">
<div class="fp-flex-repeater">
<div class="form-row">
<div class="form-group col-12">
<h5>Command String</h5>
<input type="text" name="command-text" id="command-text" class="form-control" v-model.lazy="text"
placeholder="Command input string">
</div>
</div>
</div>
Expand Down Expand Up @@ -223,14 +243,14 @@ <h5 class="mb-1">{{calculateCommandTime + " " + command.template.mnemonic }}</h5
<div>
<label :for="argument.name">{{ argument.name }}</label>
<input v-if="argument.type != 'Enum'" :type="inputType[0]" :id="argument.name" class="form-control"
:placeholder="argument.name" :pattern="inputType[1]"
v-model="argument.value">
:placeholder="argument.name" :pattern="inputType[1]" :step="inputType[2]" v-on:input="validate"
v-model="argument.value" :class="argument.error == '' ? '' : 'is-invalid'" required>
<v-select v-if="argument.type == 'Enum'" :id="argument.name" style="flex: 1 1 auto;"
:clearable="false" :searchable="true"
:clearable="false" :searchable="true" @input="validate"
:filterable="true" label="full_name" :options="argument.possible"
v-model="argument.value">
v-model="argument.value" :class="argument.error == '' ? '' : 'is-invalid'" required>
</v-select>
<div>{{ argument.error }}</div>
<div class="invalid-feedback">{{ (argument.error != '')? argument.error : inputType[3] }}</div>
</div>
</template>

Expand Down
Loading

0 comments on commit f292d45

Please sign in to comment.