manage_config_groups_view.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.MainServiceManageConfigGroupView = Em.View.extend({
  20. templateName: require('templates/main/service/manage_configuration_groups_popup'),
  21. selectedConfigGroup: null,
  22. isRemoveButtonDisabled: true,
  23. isRenameButtonDisabled: true,
  24. //Disable actions remove and rename for Default config group
  25. buttonObserver: function () {
  26. var selectedConfigGroup = this.get('controller.selectedConfigGroup');
  27. if(selectedConfigGroup.isDefault){
  28. this.set('isRemoveButtonDisabled', true);
  29. this.set('isRenameButtonDisabled', true);
  30. }else{
  31. this.set('isRemoveButtonDisabled', false);
  32. this.set('isRenameButtonDisabled', false);
  33. }
  34. }.observes('controller.selectedConfigGroup', 'controller.isHostsModified'),
  35. onGroupSelect: function () {
  36. var selectedConfigGroup = this.get('selectedConfigGroup');
  37. // to unable user select more than one config group at a time
  38. if (selectedConfigGroup.length) {
  39. this.set('controller.selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
  40. }
  41. if (selectedConfigGroup.length > 1) {
  42. this.set('selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
  43. }
  44. this.set('controller.selectedHosts', []);
  45. }.observes('selectedConfigGroup'),
  46. onLoad: function () {
  47. if (this.get('controller.isLoaded')) {
  48. this.set('selectedConfigGroup', this.get('controller.configGroups')[0])
  49. }
  50. }.observes('controller.isLoaded', 'controller.configGroups'),
  51. didInsertElement: function () {
  52. this.get('controller').loadConfigGroups(this.get('serviceName'));
  53. $('.properties-link').tooltip();
  54. $("[rel='button-info']").tooltip();
  55. },
  56. addButtonTooltip: function () {
  57. return Em.I18n.t('services.service.config_groups_popup.addButton');
  58. }.property(),
  59. removeButtonTooltip: function () {
  60. return Em.I18n.t('services.service.config_groups_popup.removeButton');
  61. }.property(),
  62. renameButtonTooltip: function () {
  63. return Em.I18n.t('services.service.config_groups_popup.renameButton');
  64. }.property(),
  65. duplicateButtonTooltip: function () {
  66. return Em.I18n.t('services.service.config_groups_popup.duplicateButton');
  67. }.property(),
  68. addHostTooltip: function () {
  69. return Em.I18n.t('services.service.config_groups_popup.addHost');
  70. }.property(),
  71. removeHostTooltip: function () {
  72. return Em.I18n.t('services.service.config_groups_popup.removeHost');
  73. }.property()
  74. });