Commit 48195675 by John Doe

added shallow folder rendering

parent f651e230
......@@ -2,4 +2,9 @@
# Controller for DbFolders
class DbFoldersController < ApplicationController
def show
folder = DbFolder.find(params[:id])
render json: folder, shallow: false
end
end
......@@ -19,7 +19,7 @@ class Db < ActiveRecord::Base
def as_json(options = {})
db = super(except: [:created_at, :updated_at])
db[:contents] = root_folder.as_json(options)
db[:contents] = root_folder.as_json({shallow: false})
db
end
end
......@@ -24,10 +24,12 @@ class DbFolder < ActiveRecord::Base
true
end
def as_json(_options = {})
def as_json(options = {shallow: true})
folder = super(except: [:created_at, :updated_at])
folder[:subfolders] = subfolders.map(&:as_json)
folder[:streams] = db_streams.map(&:as_json)
if(options[:shallow]== false)
folder[:subfolders] = subfolders.map(&:as_json)
folder[:streams] = db_streams.map(&:as_json)
end
folder
end
end
......@@ -6,6 +6,7 @@ class Nilm < ActiveRecord::Base
def as_json(_options = {})
nilm = super(except: [:created_at, :updated_at])
nilm[:db] = db.as_json()
nilm
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