-
Notifications
You must be signed in to change notification settings - Fork 357
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
Security group: Fix Display #2543
Conversation
@dclarizio, @martinpovolny, @himdel, could you please review as this one high priority because Security Groups Rules CRUD is a new feature to the new release. This was working before some change impacted it (see description). This is now working fine, besides some cosmetic effect on the table row (font), well I've no idea where Thanks |
@gildub (Also, you may need to rebase, looks like Travis is failing more than it should :).) |
@himdel, yeah I saw Travis issues last week, BTW thanks for tackling it. Rebased. Thanks for the details about |
Do you have a screenshot please? (Or, is the breakage visual or..?) |
@himdel, the symptoms are that neither the data model are showing up and the select options are not available in the drop downs. This is the actual broken situation: And this is what it should look like with current patch, which actually fix other things as well but the |
BZ has |
miqService.sparkleOn(); | ||
API.get("/api/security_groups/" + securityGroupFormId + "?attributes=name,ext_management_system.name,description,cloud_tenant.name,firewall_rules").then(function(data) { | ||
Object.assign(vm.securityGroupModel, data); | ||
vm.securityGroupModel.firewall_rules_delete = false; vm.securityGroupModel.name = data.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why that vm.securityGroupModel.name = data.name;
? Isn't that handled by the assign too? (But if not, formatting..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a residual cut mistake, removed, thanks!
OK, tested in the UI, this is definitely better than before :). I think loading the security group data should not have to wait for the security group list query, but if this fixes a bug.. :). Also, the table is too wide now, if you have security groups with long names - previously, the select was limited to a specific width, now it grows so wide I can't see the right side. I do agree that you don't want the old approach with But, I don't see why you can't use that From what I can tell, it actually makes the table a bit better: current state (plain
|
miqService.sparkleOn(); | ||
API.get("/api/security_groups/" + securityGroupFormId + "?attributes=name,ext_management_system.name,description,cloud_tenant.name,firewall_rules").then(function(data) { | ||
vm.securityGroupModel.name = data.name; | ||
vm.securityGroupModel.ems_name = data.ext_management_system.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're removing ems_name
completely - is that intentional?
The same goes for cloud_tenant_name
.
(Though it looks like it's OK, here.. you're saving via the UI, and I don't see any params[:ems_name]
or params[:cloud_tenant_name]
in the controller.)
EDIT: verified only name
, description
, ems_id
, cloud_tenant_id
and firewall_rules
seem to be used by ruby side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is only for the display.
Ok, this is the diff for the style part.. diff --git a/app/views/security_group/_fw_rules.haml b/app/views/security_group/_fw_rules.haml
index 51bca0bd1..e9667cc93 100644
--- a/app/views/security_group/_fw_rules.haml
+++ b/app/views/security_group/_fw_rules.haml
@@ -23,32 +23,32 @@
%tr{"ng-repeat" => "fw_rule in vm.securityGroupModel.firewall_rules",
"ng-form" => "rowForm",
"ng-if" => "!fw_rule.deleted"}
- %td.table-view-pf-select
+ %td
%select{"name" => "direction",
- "data-width" => "auto",
- "ng-model" => "vm.securityGroupModel.firewall_rules[$index].direction",
- "ng-options" => "direction for direction in vm.directions",
- "required" => ""}
- %td.table-view-pf-select
+ "ng-model" => "vm.securityGroupModel.firewall_rules[$index].direction",
+ "ng-options" => "direction for direction in vm.directions",
+ "required" => "",
+ 'pf-select' => true}
+ %td
%select{"name" => "network_protocol",
- "data-width" => "auto",
- "ng-model" => "vm.securityGroupModel.firewall_rules[$index].network_protocol",
- "ng-options" => "network_protocol for network_protocol in vm.networkProtocols"}
+ "ng-model" => "vm.securityGroupModel.firewall_rules[$index].network_protocol",
+ "ng-options" => "network_protocol for network_protocol in vm.networkProtocols",
+ 'pf-select' => true}
%option{"value" => ""}
= "<#{_('Choose')}>"
- %td.table-view-pf-select
+ %td
%select{"name" => "host_protocol",
- "data-width" => "auto",
- "ng-model" => "vm.securityGroupModel.firewall_rules[$index].host_protocol",
- "ng-options" => "host_protocol for host_protocol in vm.hostProtocols"}
+ "ng-model" => "vm.securityGroupModel.firewall_rules[$index].host_protocol",
+ "ng-options" => "host_protocol for host_protocol in vm.hostProtocols",
+ 'pf-select' => true}
%option{"value" => ""}
= "<#{_('Choose')}>"
- %td.table-view-pf-select
+ %td
%select{"name" => "source_security_group_id",
- "data-width" => "auto",
- "ng-model" => "vm.securityGroupModel.firewall_rules[$index].source_security_group_id",
- "ng-options" => "sg.id as sg.name + ' - ' + sg.ems_ref for sg in vm.security_groups_list",
- "ng-change" => "vm.securityGroupModel.firewall_rules[$index].source_ip_range = null"}
+ "ng-model" => "vm.securityGroupModel.firewall_rules[$index].source_security_group_id",
+ "ng-options" => "sg.id as sg.name + ' - ' + sg.ems_ref for sg in vm.security_groups_list",
+ "ng-change" => "vm.securityGroupModel.firewall_rules[$index].source_ip_range = null",
+ 'pf-select' => true}
%option{"value" => ""}
= "<#{_('Choose')}>"
%td Does that work for you? :) (It also removes the |
OK, from the BZ, I can't tell what the bug really was, but if having the requests go one by one is not part of the fix, I'd rather you made them run in parallel.. Does this work for you..? diff --git a/app/assets/javascripts/controllers/security_group/security_group_form_controller.js b/app/assets/javascripts/controllers/security_group/security_group_form_controller.js
index c0b498731..290b6665d 100644
--- a/app/assets/javascripts/controllers/security_group/security_group_form_controller.js
+++ b/app/assets/javascripts/controllers/security_group/security_group_form_controller.js
@@ -1,4 +1,4 @@
-ManageIQ.angular.app.controller('securityGroupFormController', ['securityGroupFormId', 'miqService', 'API', function(securityGroupFormId, miqService, API) {
+ManageIQ.angular.app.controller('securityGroupFormController', ['securityGroupFormId', 'miqService', 'API', '$q', function(securityGroupFormId, miqService, API, $q) {
var vm = this;
var init = function() {
@@ -18,23 +18,38 @@ ManageIQ.angular.app.controller('securityGroupFormController', ['securityGroupFo
vm.newRecord = securityGroupFormId === "new";
vm.saveable = miqService.saveable;
- API.get("/api/security_groups/?expand=resources&attributes=ems_ref,id,name").then(function(data) {
- vm.security_groups_list = data.resources;
- }).then(function() {
- if (vm.newRecord) {
- vm.afterGet = true;
- vm.modelCopy = angular.copy( vm.securityGroupModel );
- } else {
- miqService.sparkleOn();
- API.get("/api/security_groups/" + securityGroupFormId + "?attributes=name,ext_management_system.name,description,cloud_tenant.name,firewall_rules").then(function(data) {
+ if (vm.newRecord) {
+ vm.afterGet = true;
+ vm.modelCopy = angular.copy( vm.securityGroupModel );
+ getSecurityGroups()
+ .catch(miqService.handleFailure);
+ } else {
+ miqService.sparkleOn();
+
+ $q.all([getSecurityGroup(securityGroupFormId), getSecurityGroups()])
+ .then(function(array) {
+ var data = array[0];
+
Object.assign(vm.securityGroupModel, data);
- vm.securityGroupModel.firewall_rules_delete = false; vm.securityGroupModel.name = data.name;
+ vm.securityGroupModel.firewall_rules_delete = false;
vm.afterGet = true;
vm.modelCopy = _.cloneDeep(vm.securityGroupModel);
+
miqService.sparkleOff();
- }).catch(miqService.handleFailure);
- }
- }).catch(miqService.handleFailure);
+ })
+ .catch(miqService.handleFailure);
+ }
+ };
+
+ var getSecurityGroup = function(id) {
+ return API.get("/api/security_groups/" + id + "?attributes=name,ext_management_system.name,description,cloud_tenant.name,firewall_rules");
+ };
+
+ var getSecurityGroups = function() {
+ return API.get("/api/security_groups/?expand=resources&attributes=ems_ref,id,name")
+ .then(function(data) {
+ vm.security_groups_list = data.resources;
+ });
};
vm.addClicked = function() { |
.. alternately with this, if the idea was to wait for securityGroups with afterGet, in the diff --git a/app/assets/javascripts/controllers/security_group/security_group_form_controller.js b/app/assets/javascripts/controllers/security_group/security_group_form_controller.js
index 290b6665d..96a9cc8f0 100644
--- a/app/assets/javascripts/controllers/security_group/security_group_form_controller.js
+++ b/app/assets/javascripts/controllers/security_group/security_group_form_controller.js
@@ -19,9 +19,11 @@ ManageIQ.angular.app.controller('securityGroupFormController', ['securityGroupFo
vm.saveable = miqService.saveable;
if (vm.newRecord) {
- vm.afterGet = true;
- vm.modelCopy = angular.copy( vm.securityGroupModel );
getSecurityGroups()
+ .then(function() {
+ vm.afterGet = true;
+ vm.modelCopy = angular.copy( vm.securityGroupModel );
+ })
.catch(miqService.handleFailure);
} else {
miqService.sparkleOn(); |
Checked commits https://github.com/gildub/manageiq-ui-classic/compare/c204cd0922e1f44cf49bfc3c6a6ade65871f27bf~...108543cec2042f04e88846604d8e1bb60d2c418f with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@himdel, thanks for the investigation. The initial display regression issue is addressed by the first commit: 99aac08. Sorry I didn't make that obvious enough. I've restored the I'm not sure why I shared the security-groups-list (getSecurityGroups) for both, it's only needed for edit, fixed that too. |
OK, ignoring the parallel request issue and merging. (created #2771) |
Security group: Fix Display (cherry picked from commit 87eee0f)
Gaprindashvili backport details:
|
The security group rules are not displayed properly any more, this seems to be related with "selectpicker-for-select-tag" => "", removing them restores normal behaviour of ng-repeat and ng-options
Also
ng-selected
which is not needed and not recommended alongng-repeat
which takes care of it.security_groups_list
retrieval to proper synchronous flow.cloneDeep
and cleanup for firewall_rules.https://bugzilla.redhat.com/show_bug.cgi?id=1507915