Skip to content

Commit

Permalink
Merge pull request #39 from OpenC3/modified_plugins
Browse files Browse the repository at this point in the history
Show modified targets and D/L modifications
  • Loading branch information
jmthomas authored Aug 2, 2022
2 parents 29f73b7 + a72392a commit 3443dbf
Show file tree
Hide file tree
Showing 12 changed files with 495 additions and 75 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ jobs:
- name: Sleep for 2min
run: sleep 120s
shell: bash
# Build a test plugin for playwright
- name: Build plugin
shell: 'script -q -e -c "bash {0}"'
run: |
./openc3.sh cliroot generate plugin PW_TEST
cd openc3-pw-test
../openc3.sh cliroot rake build VERSION=1.0.0
sudo mv openc3-pw-test*.gem openc3-pw-test-1.0.0.gem
# Ensure we're connected and running
- name: Wait for build
run: yarn playwright test --project=chromium tests/wait-for-build.spec.ts
Expand Down
22 changes: 22 additions & 0 deletions openc3-cmd-tlm-api/app/controllers/targets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,26 @@ class TargetsController < ModelController
def initialize
@model_class = OpenC3::TargetModel
end

# All targets with indication of modified targets
def all_modified
return unless authorization('system')
render :json => @model_class.all_modified(scope: params[:scope])
end

def download
return unless authorization('system')
begin
file = @model_class.download(params[:id], scope: params[:scope])
if file
results = { 'filename' => file.filename, 'contents' => Base64.encode64(file.contents) }
render json: results
else
head :not_found
end
rescue Exception => e
render(json: { status: 'error', message: e.message }, status: 500) and
return
end
end
end
2 changes: 2 additions & 0 deletions openc3-cmd-tlm-api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
get '/targets/:id', to: 'targets#show', id: /[^\/]+/
match '/targets/:id', to: 'targets#update', id: /[^\/]+/, via: [:patch, :put]
delete '/targets/:id', to: 'targets#destroy', id: /[^\/]+/
post '/targets/:id/download', to: 'targets#download', id: /[^\/]+/
get '/targets_modified', to: 'targets#all_modified'

resources :gems, only: [:index, :create]
get '/gems/:id', to: 'gems#show', id: /[^\/]+/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@
<v-card-text>
<div class="pa-3">
<div v-if="!readonly">
<v-row class="mt-3"> Upload a file. </v-row>
<v-row no-gutters align="center">
<v-col cols="3">
<v-btn
block
color="success"
@click="loadFile"
:disabled="!file || loadingFile || readonly"
:loading="loadingFile"
data-test="editScreenLoadBtn"
>
Load
<template v-slot:loader>
<span>Loading...</span>
</template>
</v-btn>
</v-col>
<v-col cols="9">
<v-file-input
v-model="file"
accept=".json"
label="Click to select .json file."
:disabled="readonly"
/>
</v-col>
</v-row>
<v-row class="mt-3"> Upload a file. </v-row>
<v-row no-gutters align="center">
<v-col cols="3">
<v-btn
block
color="success"
@click="loadFile"
:disabled="!file || loadingFile || readonly"
:loading="loadingFile"
data-test="editScreenLoadBtn"
>
Load
<template v-slot:loader>
<span>Loading...</span>
</template>
</v-btn>
</v-col>
<v-col cols="9">
<v-file-input
v-model="file"
accept=".json"
label="Click to select .json file."
:disabled="readonly"
/>
</v-col>
</v-row>
</div>
<v-row no-gutters>
<v-textarea
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
<v-textarea
v-model="localPluginTxt"
rows="15"
data-test="editPluginTxt"
data-test="edit-plugin-txt"
/>
</v-tab-item>
<v-tab-item v-if="existing_plugin_txt !== null" :key="2">
<v-textarea
v-model="localExistingPluginTxt"
rows="15"
data-test="editExistingPluginTxt"
data-test="edit-existing-plugin-txt"
/>
</v-tab-item>
</v-tabs-items>
Expand All @@ -84,15 +84,15 @@
@click.prevent="close"
outlined
class="mx-2"
data-test="editCancelBtn"
data-test="edit-cancel"
>
Cancel
</v-btn>
<v-btn
class="mx-2"
color="primary"
type="submit"
data-test="variables-dialog-ok"
data-test="edit-submit"
>
Install
</v-btn>
Expand Down
Loading

0 comments on commit 3443dbf

Please sign in to comment.