Commit aec8cf1c by John Doe

adjusted API to match frontend

parent de5f3b52
...@@ -2,8 +2,14 @@ class JouleModule < ApplicationRecord ...@@ -2,8 +2,14 @@ class JouleModule < ApplicationRecord
belongs_to :nilm belongs_to :nilm
has_many :joule_pipes, dependent: :destroy 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, [:name, :description, :web_interface, :exec_cmd,
:status, :pid] :status, :pid]
end end
# attributes sent to the client
def self.json_keys
[:id, :name, :description, :web_interface, :exec_cmd,
:status, :pid]
end
end end
...@@ -28,7 +28,7 @@ class UpdateJouleModules ...@@ -28,7 +28,7 @@ class UpdateJouleModules
def _build_module(info) def _build_module(info)
# create JouleModule and associated pipes from # create JouleModule and associated pipes from
# hash returned by the JouleAdapter.module_info # hash returned by the JouleAdapter.module_info
params = info.extract!(*JouleModule.json_keys) params = info.extract!(*JouleModule.joule_keys)
m = JouleModule.new(params) m = JouleModule.new(params)
# link inputs to database streams # link inputs to database streams
info[:input_paths].each do |name, path| info[:input_paths].each do |name, path|
......
...@@ -2,6 +2,7 @@ json.data do ...@@ -2,6 +2,7 @@ json.data do
json.array! @joule_modules do |m| json.array! @joule_modules do |m|
json.extract! m, *JouleModule.json_keys json.extract! m, *JouleModule.json_keys
json.url @url_template % [m.id] json.url @url_template % [m.id]
json.nilm_id @nilm.id
end end
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