Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for dynamic asset group creation #51

Merged
merged 2 commits into from
Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nexpose/ajax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def delete(nsc, uri, content_type = 'text/xml')
# @return [Hash] The parametrized URI.

def parametrize_uri(uri, parameters)
uri = uri.concat(('?').concat(parameters.map { |k, v| "#{k}=#{CGI.escape(v[0].to_s)}" }.join('&'))) if parameters
uri = uri.concat(('?').concat(parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&'))) if parameters
end

###
Expand Down
18 changes: 5 additions & 13 deletions lib/nexpose/dag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def save(nsc)
# load includes admin users, but save will fail if they are included.
admins = nsc.users.select { |u| u.is_admin }.map { |u| u.id }
@users.reject! { |id| admins.member? id }
data = JSON.parse(AJAX.form_post(nsc,
'/data/assetGroup/saveAssetGroup',
to_map))
params = @id ? { 'entityid' => @id, 'mode' => 'edit' } : { 'entityid' => false, 'mode' => false }
uri = AJAX.parametrize_uri('/data/assetGroup/saveAssetGroup', params)
data = JSON.parse(AJAX.post(nsc, uri, _to_entity_details, 'application/json; charset-utf-8'))
data['response'] == 'success.'
end

Expand All @@ -53,21 +53,13 @@ def self.load(nsc, id)
dag
end

def to_map
def _to_entity_details
obj = { 'searchCriteria' => @criteria.to_map,
'name' => @name,
'tag' => @description.nil? ? '' : @description,
'dynamic' => true,
'users' => @users }
map = { 'entityDetails' => JSON.generate(obj) }
if @id
map['entityid'] = @id
map['mode'] = 'edit'
else
map['entityid'] = false
map['mode'] = false
end
map
JSON.generate(obj)
end
end
end