alert_config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.AlertConfigProperty = Ember.Object.extend({
  20. /**
  21. * label to be shown for config property
  22. * @type {String}
  23. */
  24. label: '',
  25. /**
  26. * config property value
  27. * @type {*}
  28. */
  29. value: null,
  30. /**
  31. * property value cache to realise undo function
  32. * @type {*}
  33. */
  34. previousValue: null,
  35. /**
  36. * define either input is disabled or enabled
  37. * @type {Boolean}
  38. */
  39. isDisabled: false,
  40. /**
  41. * options that Select list will have
  42. * @type {Array}
  43. */
  44. options: [],
  45. /**
  46. * input displayType
  47. * one of 'textFields', 'textArea', 'select' or 'threshold'
  48. * @type {String}
  49. */
  50. displayType: '',
  51. /**
  52. * unit to be shown with value
  53. * @type {String}
  54. */
  55. unit: null,
  56. /**
  57. * space separated list of css class names to use
  58. * @type {String}
  59. */
  60. classNames: '',
  61. /**
  62. * view class according to <code>displayType</code>
  63. * @type {Em.View}
  64. */
  65. viewClass: function () {
  66. var displayType = this.get('displayType');
  67. switch (displayType) {
  68. case 'textField':
  69. return App.AlertConfigTextFieldView;
  70. case 'textArea':
  71. return App.AlertConfigTextAreaView;
  72. case 'select':
  73. return App.AlertConfigSelectView;
  74. case 'threshold':
  75. return App.AlertConfigThresholdView;
  76. default:
  77. console.error('Unable to find viewClass for displayType ', displayType);
  78. }
  79. }.property('displayType')
  80. });
  81. App.AlertConfigProperties = {
  82. AlertName: App.AlertConfigProperty.extend({
  83. label: 'Alert Name',
  84. displayType: 'textField',
  85. classNames: 'alert-text-input'
  86. }),
  87. AlertNameSelected: App.AlertConfigProperty.extend({
  88. label: 'Alert Name',
  89. displayType: 'select'
  90. }),
  91. Service: App.AlertConfigProperty.extend({
  92. label: 'Service',
  93. displayType: 'select'
  94. }),
  95. Component: App.AlertConfigProperty.extend({
  96. label: 'Component',
  97. displayType: 'select'
  98. }),
  99. Scope: App.AlertConfigProperty.extend({
  100. label: 'Scope',
  101. options: ['Any', 'Host', 'Service'],
  102. displayType: 'select'
  103. }),
  104. Description: App.AlertConfigProperty.extend({
  105. label: 'Description',
  106. displayType: 'textArea',
  107. classNames: 'alert-config-text-area'
  108. }),
  109. Interval: App.AlertConfigProperty.extend({
  110. label: 'Interval',
  111. displayType: 'textField',
  112. unit: 'Second',
  113. classNames: 'alert-interval-input'
  114. }),
  115. Thresholds: App.AlertConfigProperty.extend({
  116. label: 'Thresholds',
  117. displayType: 'threshold',
  118. classNames: 'alert-thresholds-input',
  119. from: '',
  120. to: '',
  121. value: '',
  122. setFromTo: function () {
  123. this.set('doNotChangeValue', true);
  124. this.set('from', this.get('value').split('-')[0]);
  125. this.set('to', this.get('value').split('-')[1]);
  126. this.set('doNotChangeValue', false);
  127. }.observes('value'),
  128. setValue: function () {
  129. if (!this.get('doNotChangeValue')) {
  130. this.set('value', this.get('from') + '-' + this.get('to'));
  131. }
  132. }.observes('from', 'to'),
  133. // flag for providing correct from, to and value recomputing
  134. doNotChangeValue: false
  135. }),
  136. URI: App.AlertConfigProperty.extend({
  137. label: 'URI',
  138. displayType: 'textField',
  139. classNames: 'alert-text-input'
  140. }),
  141. URIExtended: App.AlertConfigProperty.extend({
  142. label: 'URI',
  143. displayType: 'textArea',
  144. classNames: 'alert-config-text-area'
  145. }),
  146. DefaultPort: App.AlertConfigProperty.extend({
  147. label: 'Default Port',
  148. displayType: 'textField',
  149. classNames: 'alert-port-input'
  150. }),
  151. Path: App.AlertConfigProperty.extend({
  152. label: 'Path',
  153. displayType: 'textField',
  154. classNames: 'alert-text-input'
  155. }),
  156. Metrics: App.AlertConfigProperty.extend({
  157. label: 'JMX/Ganglia Metrics',
  158. displayType: 'textArea',
  159. classNames: 'alert-config-text-area'
  160. }),
  161. FormatString: App.AlertConfigProperty.extend({
  162. label: 'Format String',
  163. displayType: 'textArea',
  164. classNames: 'alert-config-text-area'
  165. })
  166. };