Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
lumen-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
48195675
authored
Jan 13, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added shallow folder rendering
parent
f651e230
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
4 deletions
app/controllers/db_folders_controller.rb
app/models/db.rb
app/models/db_folder.rb
app/models/nilm.rb
app/controllers/db_folders_controller.rb
View file @
48195675
...
...
@@ -2,4 +2,9 @@
# Controller for DbFolders
class
DbFoldersController
<
ApplicationController
def
show
folder
=
DbFolder
.
find
(
params
[
:id
])
render
json:
folder
,
shallow:
false
end
end
app/models/db.rb
View file @
48195675
...
...
@@ -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
app/models/db_folder.rb
View file @
48195675
...
...
@@ -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
app/models/nilm.rb
View file @
48195675
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment