manage_alert_notifications_controller.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.ManageAlertNotificationsController = Em.Controller.extend({
  20. name: 'manageAlertNotificationsController',
  21. isLoaded: false,
  22. /**
  23. * List of all Alert Notifications
  24. * @type {App.AlertNotification[]}
  25. */
  26. alertNotifications: function () {
  27. if (this.get('isLoaded')) {
  28. return App.AlertNotification.find().toArray();
  29. }
  30. return [];
  31. }.property('isLoaded'),
  32. /**
  33. * Selected Alert Notification
  34. * @type {App.AlertNotification}
  35. */
  36. selectedAlertNotification: null,
  37. /**
  38. * Load all Alert Notifications from server
  39. * Don't do anything if controller not isLoaded
  40. * @returns {$.ajax|null}
  41. */
  42. loadAlertNotifications: function () {
  43. if (this.get('isLoaded')) {
  44. return null;
  45. }
  46. return App.ajax.send({
  47. name: 'alerts.notifications',
  48. sender: this,
  49. data: {},
  50. success: 'getAlertNotificationsSuccessCallback',
  51. error: 'getAlertNotificationsErrorCallback'
  52. });
  53. },
  54. /**
  55. * Success-callback for load alert notifications request
  56. * @param {object} json
  57. * @method getAlertNotificationsSuccessCallback
  58. */
  59. getAlertNotificationsSuccessCallback: function (json) {
  60. App.alertNotificationMapper.map(json);
  61. this.set('isLoaded', true);
  62. },
  63. /**
  64. * Error-callback for load alert notifications request
  65. * @method getAlertNotificationsErrorCallback
  66. */
  67. getAlertNotificationsErrorCallback: function () {
  68. this.set('isLoaded', true);
  69. },
  70. addAlertNotification: Em.K,
  71. deleteAlertNotification: Em.K,
  72. editAlertNotification: Em.K,
  73. duplicateAlertNotification: Em.K
  74. });