Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow button widget vars and fix radio groups #1652

Merged
2 commits merged into from
May 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix button vars and radio groups
  • Loading branch information
jmthomas committed May 23, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 285178b6140ed397c480e8f3d0be0148a442ae4d
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@ VERTICAL
LABEL " Duration: "
NAMED_WIDGET DURATION TEXTFIELD 12 "10.0"
END
BUTTON 'Start Collect' "api.cmd('<%= target_name %> COLLECT with TYPE '+screen.get_named_widget('COLLECT_TYPE').text()+', DURATION '+screen.get_named_widget('DURATION').text())"
# This is an example of using a varible named 'type'. You can operate on variables with Javascript code.
# All COSMOS commands (api.cmd) must be separated by newlines '\n'. All code separated by semicolons is evaluated together.
BUTTON 'Start Collect' "var type=screen.get_named_widget('COLLECT_TYPE').text(); api.cmd('<%= target_name %> COLLECT with TYPE '+type+', DURATION '+screen.get_named_widget('DURATION').text())"
END
SETTING BACKCOLOR 163 185 163

Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ export default {
},
methods: {
onClick() {
const lines = this.eval.split(';')
const lines = this.eval.split('\n')
// Create local references to variables so users don't need to use 'this'
const self = this // needed for $emit
const screen = this.screen
@@ -77,8 +77,9 @@ export default {
result
.then((success) => {})
.catch((err) => {
if (err.message.includes('HazardousError')) {
this.lastCmd = err.message.split('\n')[2]
// This text is in top_level.rb HazardousError.to_s
if (err.message.includes('is Hazardous')) {
this.lastCmd = err.message.split('\n').pop()
this.displaySendHazardous = true
}
})
Original file line number Diff line number Diff line change
@@ -18,13 +18,24 @@
-->

<template>
<v-radio hide-details dense :label="label" :style="computedStyle" />
<v-radio
hide-details
dense
:label="label"
:style="computedStyle"
:value="value"
/>
</template>

<script>
import Widget from './Widget'

export default {
props: {
value: {
type: Number,
},
},
mixins: [Widget],
data() {
return {
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
<component
v-for="(widget, index) in widgets"
v-on="$listeners"
:value="index"
:key="index"
:is="widget.type"
:target="widget.target"
1 change: 0 additions & 1 deletion cosmos/lib/cosmos/microservices/interface_microservice.rb
Original file line number Diff line number Diff line change
@@ -143,7 +143,6 @@ def run
hazardous, hazardous_description = System.commands.cmd_pkt_hazardous?(command)
# Return back the error, description, and the formatted command
# This allows the error handler to simply re-send the command
# TODO: Should we set target_name, cmd_name, and cmd_params instead?
next "HazardousError\n#{hazardous_description}\n#{System.commands.format(command)}" if hazardous
end

6 changes: 5 additions & 1 deletion cosmos/lib/cosmos/top_level.rb
Original file line number Diff line number Diff line change
@@ -37,9 +37,13 @@ class HazardousError < StandardError
attr_accessor :cmd_name
attr_accessor :cmd_params
attr_accessor :hazardous_description
attr_accessor :formatted # formatted command for use in resending original

def to_s
"#{target_name} #{cmd_name} with #{cmd_params} is Hazardous due to #{hazardous_description}"
string = "#{target_name} #{cmd_name} with #{cmd_params} is Hazardous"
string << "due to '#{hazardous_description}'" if hazardous_description
# Pass along the original formatted command so it can be resent
string << ".\n#{formatted}"
end
end

4 changes: 3 additions & 1 deletion cosmos/lib/cosmos/topics/command_topic.rb
Original file line number Diff line number Diff line change
@@ -66,14 +66,16 @@ def self.send_command(command, scope:)
###########################################################################

def self.raise_hazardous_error(msg_hash, target_name, cmd_name, cmd_params)
_, description, _ = msg_hash["result"].split("\n")
_, description, formatted = msg_hash["result"].split("\n")
# Create and populate a new HazardousError and raise it up
# The _cmd method in script/commands.rb rescues this and calls prompt_for_hazardous
error = HazardousError.new
error.target_name = target_name
error.cmd_name = cmd_name
error.cmd_params = cmd_params
error.hazardous_description = description
error.formatted = formatted

# No Logger.info because the error is already logged by the Logger.info "Ack Received ...
raise error
end
20 changes: 10 additions & 10 deletions scripts/linux/cosmos_util.sh
Original file line number Diff line number Diff line change
@@ -19,28 +19,28 @@ saveTar() {
tag='latest'
else
tag=$1
docker pull ballaerospace/cosmosc2-minio-init:$tag
docker pull ballaerospace/cosmosc2-redis:$tag
docker pull ballaerospace/cosmosc2-traefik:$tag
docker pull ballaerospace/cosmosc2-ruby:$tag
docker pull ballaerospace/cosmosc2-node:$tag
docker pull ballaerospace/cosmosc2-base:$tag
docker pull ballaerospace/cosmosc2-cmd-tlm-api:$tag
docker pull ballaerospace/cosmosc2-script-runner-api:$tag
docker pull ballaerospace/cosmosc2-operator:$tag
docker pull ballaerospace/cosmosc2-init:$tag
fi
docker pull minio/minio
docker save minio/minio -o tmp/minio_minio.tar
docker pull ballaerospace/cosmosc2-minio-init:$tag
docker save ballaerospace/cosmosc2-minio-init:$tag -o tmp/cosmosc2-minio-init-$tag.tar
docker pull ballaerospace/cosmosc2-redis:$tag
docker save ballaerospace/cosmosc2-redis:$tag -o tmp/cosmosc2-redis-$tag.tar
docker pull ballaerospace/cosmosc2-traefik:$tag
docker save ballaerospace/cosmosc2-traefik:$tag -o tmp/cosmosc2-traefik-$tag.tar
docker pull ballaerospace/cosmosc2-ruby:$tag
docker save ballaerospace/cosmosc2-ruby:$tag -o tmp/cosmosc2-ruby-$tag.tar
docker pull ballaerospace/cosmosc2-node:$tag
docker save ballaerospace/cosmosc2-node:$tag -o tmp/cosmosc2-node-$tag.tar
docker pull ballaerospace/cosmosc2-base:$tag
docker save ballaerospace/cosmosc2-base:$tag -o tmp/cosmosc2-base-$tag.tar
docker pull ballaerospace/cosmosc2-cmd-tlm-api:$tag
docker save ballaerospace/cosmosc2-cmd-tlm-api:$tag -o tmp/cosmosc2-cmd-tlm-api-$tag.tar
docker pull ballaerospace/cosmosc2-script-runner-api:$tag
docker save ballaerospace/cosmosc2-script-runner-api:$tag -o tmp/cosmosc2-script-runner-api-$tag.tar
docker pull ballaerospace/cosmosc2-operator:$tag
docker save ballaerospace/cosmosc2-operator:$tag -o tmp/cosmosc2-operator-$tag.tar
docker pull ballaerospace/cosmosc2-init:$tag
docker save ballaerospace/cosmosc2-init:$tag -o tmp/cosmosc2-init-$tag.tar
}

22 changes: 12 additions & 10 deletions scripts/windows/cosmos_util.bat
Original file line number Diff line number Diff line change
@@ -38,32 +38,34 @@ GOTO :EOF
:save
if not exist tmp md tmp
if "%2" == "" (
REM If tag is not given don't pull and use locally built latest
set tag=latest
) else (
set tag=%2
REM Explictly pull the tag when given
docker pull ballaerospace/cosmosc2-traefik:%tag% || exit /b
docker pull ballaerospace/cosmosc2-redis:%tag% || exit /b
docker pull ballaerospace/cosmosc2-minio-init:%tag% || exit /b
docker pull ballaerospace/cosmosc2-ruby:%tag% || exit /b
docker pull ballaerospace/cosmosc2-node:%tag% || exit /b
docker pull ballaerospace/cosmosc2-base:%tag% || exit /b
docker pull ballaerospace/cosmosc2-cmd-tlm-api:%tag% || exit /b
docker pull ballaerospace/cosmosc2-script-runner-api:%tag% || exit /b
docker pull ballaerospace/cosmosc2-operator:%tag% || exit /b
docker pull ballaerospace/cosmosc2-init:%tag% || exit /b
)
echo on
docker pull minio/minio || exit /b
docker save minio/minio -o tmp/minio_minio.tar || exit /b
docker pull ballaerospace/cosmosc2-redis:%tag% || exit /b
docker save ballaerospace/cosmosc2-redis:%tag% -o tmp/cosmosc2-redis-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-minio-init:%tag% || exit /b
docker save ballaerospace/cosmosc2-minio-init:%tag% -o tmp/cosmosc2-minio-init-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-traefik:%tag% || exit /b
docker save ballaerospace/cosmosc2-traefik:%tag% -o tmp/cosmosc2-traefik-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-ruby:%tag% || exit /b
docker save ballaerospace/cosmosc2-ruby:%tag% -o tmp/cosmosc2-ruby-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-node:%tag% || exit /b
docker save ballaerospace/cosmosc2-node:%tag% -o tmp/cosmosc2-node-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-base:%tag% || exit /b
docker save ballaerospace/cosmosc2-base:%tag% -o tmp/cosmosc2-base-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-cmd-tlm-api:%tag% || exit /b
docker save ballaerospace/cosmosc2-cmd-tlm-api:%tag% -o tmp/cosmosc2-cmd-tlm-api-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-script-runner-api:%tag% || exit /b
docker save ballaerospace/cosmosc2-script-runner-api:%tag% -o tmp/cosmosc2-script-runner-api-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-operator:%tag% || exit /b
docker save ballaerospace/cosmosc2-operator:%tag% -o tmp/cosmosc2-operator-%tag%.tar || exit /b
docker pull ballaerospace/cosmosc2-init:%tag% || exit /b
docker save ballaerospace/cosmosc2-init:%tag% -o tmp/cosmosc2-init-%tag%.tar || exit /b
echo off
GOTO :EOF