step1_controller.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.AddAlertDefinitionStep1Controller = Em.Controller.extend({
  20. name: 'addAlertDefinitionStep1',
  21. /**
  22. * List of available alert definition types
  23. * @type {{value: string, isActive: boolean}[]}
  24. */
  25. alertDefinitionsTypes: [
  26. Em.Object.create({value: 'PORT', isActive: false, icon: 'icon-signal'}),
  27. Em.Object.create({value: 'METRIC', isActive: false, icon: 'icon-bolt'}),
  28. Em.Object.create({value: 'WEB', isActive: false, icon: 'icon-globe'}),
  29. Em.Object.create({value: 'AGGREGATE', isActive: false, icon: 'icon-plus-sign-alt'}),
  30. Em.Object.create({value: 'SCRIPT', isActive: false, icon: 'icon-code'})
  31. ],
  32. /**
  33. * "Next"-button is disabled if user doesn't select any alert definition type
  34. * @type {boolean}
  35. */
  36. isSubmitDisabled: function() {
  37. return this.get('alertDefinitionsTypes').everyProperty('isActive', false);
  38. }.property('alertDefinitionsTypes.@each.isActive'),
  39. /**
  40. * Set selectedType if it exists in the wizard controller
  41. * @method loadStep
  42. */
  43. loadStep: function() {
  44. this.get('alertDefinitionsTypes').setEach('isActive', false);
  45. var selectedType = this.get('content.selectedType');
  46. if(selectedType) {
  47. this.selectType({context: {value: selectedType}});
  48. }
  49. },
  50. /**
  51. * Handler for select alert definition type selection
  52. * @param {object} e
  53. * @method selectType
  54. */
  55. selectType: function(e) {
  56. var type = e.context,
  57. types = this.get('alertDefinitionsTypes');
  58. types.setEach('isActive', false);
  59. types.findProperty('value', type.value).set('isActive', true);
  60. this.set('content.selectedType', type.value);
  61. }
  62. });