From 97d80f67d6bd10781b6e92646a1d8e99fe38d29b Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Sat, 13 Jan 2024 14:10:19 -0700 Subject: [PATCH] Initial framework --- .../controllers/microservices_controller.rb | 17 +++++- openc3-cosmos-cmd-tlm-api/config/routes.rb | 2 + .../src/tools/admin/tabs/MicroservicesTab.vue | 54 ++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/openc3-cosmos-cmd-tlm-api/app/controllers/microservices_controller.rb b/openc3-cosmos-cmd-tlm-api/app/controllers/microservices_controller.rb index 63b5a83ca..0e8e4f7e6 100644 --- a/openc3-cosmos-cmd-tlm-api/app/controllers/microservices_controller.rb +++ b/openc3-cosmos-cmd-tlm-api/app/controllers/microservices_controller.rb @@ -14,7 +14,7 @@ # GNU Affero General Public License for more details. # Modified by OpenC3, Inc. -# All changes Copyright 2022, OpenC3, Inc. +# All changes Copyright 2024, OpenC3, Inc. # All Rights Reserved # # This file may also be used under the terms of a commercial license @@ -24,9 +24,24 @@ class MicroservicesController < ModelController def initialize + super() @model_class = OpenC3::MicroserviceModel end + def start + return unless authorization('system') + microservice = @model_class.get_model(name: params[:id], scope: params[:scope]) + OpenC3::Logger.info("#{params[:id]} started", scope: params[:scope], user: username()) + # TODO: How to access operator and start microservice? + end + + def stop + return unless authorization('system') + microservice = @model_class.get_model(name: params[:id], scope: params[:scope]) + OpenC3::Logger.info("#{params[:id]} stopped", scope: params[:scope], user: username()) + # TODO: How to access operator and stop microservice? + end + def traefik result = {} result['http'] = {} diff --git a/openc3-cosmos-cmd-tlm-api/config/routes.rb b/openc3-cosmos-cmd-tlm-api/config/routes.rb index e4ef1d76e..9983fcfd2 100644 --- a/openc3-cosmos-cmd-tlm-api/config/routes.rb +++ b/openc3-cosmos-cmd-tlm-api/config/routes.rb @@ -51,6 +51,8 @@ get '/microservices/:id', to: 'microservices#show', id: /[^\/]+/ match '/microservices/:id', to: 'microservices#update', id: /[^\/]+/, via: [:patch, :put] delete '/microservices/:id', to: 'microservices#destroy', id: /[^\/]+/ + post '/microservices/:id/start', to: 'microservices#start', id: /[^\/]+/ + post '/microservices/:id/stop', to: 'microservices#stop', id: /[^\/]+/ resources :process_status, only: [:index] get '/process_status/:id', to: 'process_status#show', id: /[^\/]+/ diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/tools/admin/tabs/MicroservicesTab.vue b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/tools/admin/tabs/MicroservicesTab.vue index bcbe471fa..fd7b3ff52 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/tools/admin/tabs/MicroservicesTab.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/tools/admin/tabs/MicroservicesTab.vue @@ -13,7 +13,7 @@ # GNU Affero General Public License for more details. # Modified by OpenC3, Inc. -# All changes Copyright 2023, OpenC3, Inc. +# All changes Copyright 2024, OpenC3, Inc. # All Rights Reserved # # This file may also be used under the terms of a commercial license @@ -22,6 +22,13 @@