diff --git a/cosmos-init/plugins/packages/cosmosc2-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue b/cosmos-init/plugins/packages/cosmosc2-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue index 364540135..580ed5703 100644 --- a/cosmos-init/plugins/packages/cosmosc2-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue +++ b/cosmos-init/plugins/packages/cosmosc2-tool-scriptrunner/src/tools/ScriptRunner/ScriptRunner.vue @@ -1029,19 +1029,20 @@ export default { this.startOrGoButton = GO this.scriptId = id this.editor.setReadOnly(true) - this.cable.createSubscription( - 'RunningScriptChannel', - localStorage.scope, - { - received: (data) => this.received(data) - }, - { - id: this.scriptId, - } - ) - .then((subscription) => { - this.subscription = subscription - }) + this.cable + .createSubscription( + 'RunningScriptChannel', + localStorage.scope, + { + received: (data) => this.received(data), + }, + { + id: this.scriptId, + } + ) + .then((subscription) => { + this.subscription = subscription + }) }, scriptComplete() { this.disableSuiteButtons = false diff --git a/cosmos-script-runner-api/app/controllers/scripts_controller.rb b/cosmos-script-runner-api/app/controllers/scripts_controller.rb index 41db1379c..b1ad3ca07 100644 --- a/cosmos-script-runner-api/app/controllers/scripts_controller.rb +++ b/cosmos-script-runner-api/app/controllers/scripts_controller.rb @@ -17,6 +17,8 @@ # enterprise edition license of COSMOS if purchased from the # copyright holder +require 'json' + class ScriptsController < ApplicationController def index begin @@ -49,9 +51,9 @@ def body end breakpoints = Script.get_breakpoints(params[:scope], params[:name]) results = { - "contents" => file, - "breakpoints" => breakpoints, - "locked" => locked + contents: file, + breakpoints: breakpoints, + locked: locked } if params[:name].include?('suite') results_suites, results_error, success = Script.process_suite(params[:name], file, scope: params[:scope]) @@ -59,7 +61,9 @@ def body results['error'] = results_error results['success'] = success end - render :json => results + # Using 'render :json => results' results in a raw json string like: + # {"contents":"{\"json_class\":\"String\",\"raw\":[35,226,128...]}","breakpoints":[],"locked":false} + render plain: JSON.generate(results) else head :not_found end diff --git a/cosmos-script-runner-api/config/cable.yml b/cosmos-script-runner-api/config/cable.yml index 5a8d52e56..41414fe04 100644 --- a/cosmos-script-runner-api/config/cable.yml +++ b/cosmos-script-runner-api/config/cable.yml @@ -13,4 +13,4 @@ production: url: <%= "redis://#{ENV['COSMOS_REDIS_USERNAME']}:#{ENV['COSMOS_REDIS_PASSWORD']}@#{ENV['COSMOS_REDIS_HOSTNAME']}:#{ENV['COSMOS_REDIS_PORT']}" %> # The channel_prefix is used in scripts/run_script.rb to subscribe to the channel # and app/models/running_script.rb to publish to the channel - channel_prefix: script-api \ No newline at end of file + channel_prefix: script-api