alert_group.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /**
  20. * Represents an alert-group on the cluster.
  21. * A alert group is a collection of alert definitions
  22. *
  23. * Alert group hierarchy is at 2 levels. For
  24. * each service there is a 'Default' alert group
  25. * containing all definitions , this group is read-only
  26. *
  27. * User can create new alert group containing alert definitions from
  28. * any service.
  29. */
  30. App.AlertGroup = DS.Model.extend({
  31. name: DS.attr('string'),
  32. description: DS.attr('string'),
  33. /**
  34. * Is this group default for some service
  35. * @type {boolean}
  36. */
  37. default: DS.attr('boolean'),
  38. /**
  39. * @type {App.AlertDefinition[]}
  40. */
  41. definitions: DS.hasMany('App.AlertDefinition'),
  42. /**
  43. * @type {App.AlertNotification[]}
  44. */
  45. targets: DS.hasMany('App.AlertNotification'),
  46. /**
  47. * @type {string}
  48. */
  49. displayName: function () {
  50. var name = App.config.truncateGroupName(this.get('name'));
  51. return this.get('default') ? (name + ' Default') : name;
  52. }.property('name', 'default'),
  53. /**
  54. * @type {string}
  55. */
  56. displayNameDefinitions: Em.computed.format('{0} ({1})', 'displayName', 'definitions.length'),
  57. isAddDefinitionsDisabled: Em.computed.alias('default')
  58. });
  59. App.AlertGroup.FIXTURES = [];