forked from sodabrew/puppet-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sodabrew#198 from fhrbek/rails3_class_parameters
Class Parameters
- Loading branch information
Showing
57 changed files
with
1,478 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function form_submit_success(jsonResponse, error_messages_element_id) { | ||
|
||
if(jsonResponse.status == "error") { | ||
errorMessagesElement = document.getElementById(error_messages_element_id); | ||
errorMessagesElement.style.display = "block"; | ||
errorMessagesElement.innerHTML = jsonResponse.error_html; | ||
} | ||
else { | ||
if(jsonResponse.valid == "true") { | ||
window.location = jsonResponse.redirect_to; | ||
} | ||
else { | ||
confirmElement = document.createElement('div'); | ||
confirmElement.style.position = 'absolute'; | ||
confirmElement.style.top = '0px'; | ||
confirmElement.style.right = '0px'; | ||
confirmElement.style.bottom = '0px'; | ||
confirmElement.style.left = '0px'; | ||
document.getElementsByTagName('body')[0].appendChild(confirmElement); | ||
confirmElement.innerHTML = jsonResponse.confirm_html; | ||
} | ||
} | ||
} | ||
|
||
function register_ajax_submit(form_id) { | ||
jQuery(form_id).submit(function() { | ||
var param_form = this; | ||
// delay sending the data so that placeholders could be removed in non-html5 browsers before the form is serialized | ||
// TODO - detect native HTML5 support and if it's the case then call following code directly | ||
setTimeout(function() { | ||
jQuery.post(param_form.action, jQuery(param_form).serialize(), "json"). | ||
success(function(data) {form_submit_success(data, 'error_messages');}). | ||
error(function() {alert('Oops, something went wrong!');}); | ||
}, 0); | ||
return false; | ||
}); | ||
} | ||
|
||
function bind_response_events(xhr_element_id, error_element_id) { | ||
jQuery(xhr_element_id) | ||
.bind("ajax:success", function(event, data, status, xhr) { | ||
form_submit_success(data, error_element_id); | ||
}) | ||
.bind("ajax:failure", function() { alert('Oops!! An error occurred.') }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function form_submit_success(jsonResponse, error_messages_element_id) { | ||
if(jsonResponse.status == "error") { | ||
errorMessagesElement = document.getElementById(error_messages_element_id); | ||
errorMessagesElement.style.display = "block"; | ||
errorMessagesElement.innerHTML = jsonResponse.error_html; | ||
} | ||
else { | ||
if(jsonResponse.valid == "true") { | ||
window.location = jsonResponse.redirect_to; | ||
} | ||
else { | ||
confirmElement = document.createElement('div'); | ||
confirmElement.style.position = 'absolute'; | ||
confirmElement.style.top = '0px'; | ||
confirmElement.style.right = '0px'; | ||
confirmElement.style.bottom = '0px'; | ||
confirmElement.style.left = '0px'; | ||
document.getElementsByTagName('body')[0].appendChild(confirmElement); | ||
confirmElement.innerHTML = jsonResponse.confirm_html; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,5 @@ | |
*= require colorbox | ||
*= require help | ||
*= require jquery.jqplot | ||
*= require popups | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#popupWindowGlass, #popupWindowLayoutHelperTable { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
} | ||
|
||
#popupWindowGlass { | ||
background-color: black; | ||
opacity: 0.4; | ||
} | ||
|
||
#popupWindowLayoutHelperTable { | ||
display: table; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#popupWindowLayoutHelperTableCell { | ||
display: table-cell; | ||
text-align: center; | ||
vertical-align: middle; | ||
} | ||
|
||
#popupWindow { | ||
background-color: white; | ||
display: inline-block; | ||
padding: 20px; | ||
border: 1px solid #aaa; | ||
border-radius: 4px; | ||
text-align: left; | ||
} | ||
|
||
#popupWindowButtons { | ||
margin-top: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,10 @@ h3 { | |
margin: 0; | ||
} | ||
|
||
h3.conflicts { | ||
color:#c33; | ||
} | ||
|
||
h4 { | ||
font-size: 1em; | ||
line-height: 1.28em; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class NodeClassMembershipsController < InheritedResources::Base | ||
respond_to :html, :json | ||
before_filter :raise_unless_using_external_node_classification | ||
before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :create, :update, :destroy] | ||
|
||
include SearchableIndex | ||
include ConflictAnalyzer | ||
include ConflictHtml | ||
|
||
def update | ||
update_helper :class => NodeClassMembership, | ||
:conflict_attribute => :node | ||
end | ||
|
||
def destroy | ||
destroy_helper :class => NodeClassMembership, | ||
:owner_class => Node, | ||
:conflict_attribute => :node | ||
end | ||
|
||
end |
21 changes: 21 additions & 0 deletions
21
app/controllers/node_group_class_memberships_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class NodeGroupClassMembershipsController < InheritedResources::Base | ||
respond_to :html, :json | ||
before_filter :raise_unless_using_external_node_classification | ||
before_filter :raise_if_enable_read_only_mode, :only => [:new, :edit, :create, :update, :destroy] | ||
|
||
include SearchableIndex | ||
include ConflictAnalyzer | ||
include ConflictHtml | ||
|
||
def update | ||
update_helper :class => NodeGroupClassMembership, | ||
:conflict_attribute => :node_group | ||
end | ||
|
||
def destroy | ||
destroy_helper :class => NodeGroupClassMembership, | ||
:owner_class => NodeGroup, | ||
:conflict_attribute => :node_group | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.