manage_config_groups_view.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. isDuplicateButtonDisabled: true,
  25. //Disable actions remove and rename for Default config group
  26. buttonObserver: function () {
  27. var selectedConfigGroup = this.get('controller.selectedConfigGroup');
  28. if(selectedConfigGroup.isDefault){
  29. this.set('isRemoveButtonDisabled', true);
  30. this.set('isRenameButtonDisabled', true);
  31. this.set('isDuplicateButtonDisabled', true);
  32. }else{
  33. this.set('isRemoveButtonDisabled', false);
  34. this.set('isRenameButtonDisabled', false);
  35. this.set('isDuplicateButtonDisabled', false);
  36. }
  37. }.observes('controller.selectedConfigGroup', 'controller.isHostsModified'),
  38. onGroupSelect: function () {
  39. var selectedConfigGroup = this.get('selectedConfigGroup');
  40. // to unable user select more than one config group at a time
  41. if (selectedConfigGroup.length) {
  42. this.set('controller.selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
  43. }
  44. if (selectedConfigGroup.length > 1) {
  45. this.set('selectedConfigGroup', selectedConfigGroup[selectedConfigGroup.length - 1]);
  46. }
  47. this.set('controller.selectedHosts', []);
  48. }.observes('selectedConfigGroup'),
  49. onLoad: function () {
  50. if (this.get('controller.isLoaded')) {
  51. this.set('selectedConfigGroup', this.get('controller.configGroups')[0])
  52. }
  53. }.observes('controller.isLoaded', 'controller.configGroups'),
  54. didInsertElement: function () {
  55. this.get('controller').loadConfigGroups(this.get('serviceName'), this.get('usedConfigGroupNames'));
  56. App.tooltip($('.properties-link'));
  57. App.tooltip($("[rel='button-info']"));
  58. App.tooltip($("[rel='button-info-dropdown']"), {placement: 'left'});
  59. },
  60. addButtonTooltip: function () {
  61. return Em.I18n.t('services.service.config_groups_popup.addButton');
  62. }.property(),
  63. removeButtonTooltip: function () {
  64. return Em.I18n.t('services.service.config_groups_popup.removeButton');
  65. }.property(),
  66. renameButtonTooltip: function () {
  67. return Em.I18n.t('services.service.config_groups_popup.renameButton');
  68. }.property(),
  69. duplicateButtonTooltip: function () {
  70. return Em.I18n.t('services.service.config_groups_popup.duplicateButton');
  71. }.property(),
  72. addHostTooltip: function () {
  73. if (!this.get('controller.selectedConfigGroup.isDefault') && this.get('controller.selectedConfigGroup.isAddHostsDisabled')) {
  74. return Em.I18n.t('services.service.config_groups_popup.addHostDisabled');
  75. } else {
  76. return Em.I18n.t('services.service.config_groups_popup.addHost');
  77. }
  78. }.property('controller.selectedConfigGroup.isDefault', 'controller.selectedConfigGroup.isAddHostsDisabled'),
  79. removeHostTooltip: function () {
  80. return Em.I18n.t('services.service.config_groups_popup.removeHost');
  81. }.property()
  82. });