Commit aec8cf1c by John Doe

adjusted API to match frontend

parent de5f3b52
......@@ -2,8 +2,14 @@ class JouleModule < ApplicationRecord
belongs_to :nilm
has_many :joule_pipes, dependent: :destroy
def self.json_keys
# attributes accepted from the Joule json response
def self.joule_keys
[:name, :description, :web_interface, :exec_cmd,
:status, :pid]
end
# attributes sent to the client
def self.json_keys
[:id, :name, :description, :web_interface, :exec_cmd,
:status, :pid]
end
end
......@@ -28,7 +28,7 @@ class UpdateJouleModules
def _build_module(info)
# create JouleModule and associated pipes from
# hash returned by the JouleAdapter.module_info
params = info.extract!(*JouleModule.json_keys)
params = info.extract!(*JouleModule.joule_keys)
m = JouleModule.new(params)
# link inputs to database streams
info[:input_paths].each do |name, path|
......
......@@ -2,6 +2,7 @@ json.data do
json.array! @joule_modules do |m|
json.extract! m, *JouleModule.json_keys
json.url @url_template % [m.id]
json.nilm_id @nilm.id
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment